Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #86
The WebGPU spec defines part of the API on the canvas object. I can see how this makes sense in JS, where there is one type of canvas, under the control of the browser. But for us it makes the code a bit "entangled".
Therefore I moved these API functions to the device. One tricky part was how to do the presenting (aka swap the buffers). Then I realized that getting the texture view from the swap-chain, and presenting it, are two actions that always go in pairs. Python context managers are awesome for this, so this is what the swap-chain now uses.
So ...
WgpuCanvasInterafce
class with three methods.WgpuCanvaseBase
subclasses the interface and ads convenience stuff.configure_swap_chain
andget_swap_chain_preferred_format
are now methods of device instead of canvas.