Repository navigation
Add rgba8unorm support for swapchain format - #952
Conversation
|
@kainino0x @Kangz @austinEng PTAL |
e2a7b9c to
8ec807d
Compare
|
Previews, as seen when this build job started (8ec807d): |
|
Also please retain the PR template and fill out the checklist according to the docs (maybe you opened the PR with a tool which doesn't prefill the template?) I pasted in the checklist and reviewed the reviewer aspects. |
This extends the readbackFromWebGPUCanvas and canvas_clear tests to cover rgba8unorm.
8ec807d to
96162dd
Compare
|
Previews, as seen when this build job started (96162dd): |
Ah, I manually removed the template as I didn't know what it's for. Thanks for correcting me! |
|
@kainino0x Would you like to take a look again? Thanks! |
There was a problem hiding this comment.
Still LGTM
jchen10 force-pushed the swapchain_format branch from 8ec807d to 96162dd 19 hours ago
Please avoid force pushing after a review has started so it's easier to look at incremental changes. (If you need to update with the main branch, use a merge commit, which GitHub can render more nicely than a force-push rebase.)
(In this case the force-push was still easy to read, I think because it didn't contain a rebase.)
Good to know, thanks! |
|
Previews, as seen when this build job started (1f1ebf5): |
fc94ddd to
1f1ebf5
Compare
|
Previews, as seen when this build job started (1f1ebf5): |
|
@kainino0x Sorry for the inconvenience. I probably did another force-update accidentally for rebase. |
* Add rgba8unorm support for swapchain format This extends the readbackFromWebGPUCanvas and canvas_clear tests to cover rgba8unorm. * Cleanup kValidSwapchainFormats and use draw to initialize canvas
|
No worries! |
| passEncoder.setPipeline(pipeline); | ||
| passEncoder.draw(6, 1, 0, 0); | ||
| passEncoder.endPass(); | ||
| t.device.queue.submit([commandEncoder.finish()]); |
There was a problem hiding this comment.
I'm very sorry, I definitely didn't think this suggestion through. I was imagining using just the loadValue, no draw call. Of course this isn't possible because you want to draw different colors to each of the 4 pixels.
Using a draw call is obviously a lot more complex than using a copy even though the copy gets slightly complex with different formats. Simplicity would be nice here, but I suppose the draw call is still nicer since it will generalize to all formats.
An alternative would be to create a 1x1 temporary render target temp and do 4 empty render passes and 4 copyTextureToTexture commands:
- add local closure
const clearOnePixel = () => { ... }that does:- beginRenderPass (temp, clear to a color, store), end pass
- copyTextureToTexture(temp into one pixel of canvas)
- call
clearOnePixelonce for each of the 4 pixels
WDYT of this approach?
|
Previews, as seen when this build job started (2231b78): |
|
Previews, as seen when this build job started (8e0e07a): |
|
Previews, as seen when this build job started (9bf7de7): |
kainino0x
left a comment
There was a problem hiding this comment.
Sorry for all the rounds of comments. I have one last simplification but it's minor - just using one texture and one submit instead of many.
| const pixels = [ | ||
| { color: { r: 0.0, g: 0.0, b: 1.0, a: 1.0 }, pos: { x: 0, y: 0 } }, | ||
| { color: { r: 0.0, g: 1.0, b: 0.0, a: 1.0 }, pos: { x: 1, y: 0 } }, | ||
| { color: { r: 1.0, g: 0.0, b: 0.0, a: 1.0 }, pos: { x: 0, y: 1 } }, | ||
| { color: { r: 1.0, g: 1.0, b: 0.0, a: 1.0 }, pos: { x: 1, y: 1 } }, | ||
| ]; | ||
| pixels.forEach(pixel => { | ||
| clearOnePixel(pixel.color, pixel.pos.x, pixel.pos.y); | ||
| }); |
There was a problem hiding this comment.
nit: prefer for (const pixel of pixels) over pixels.forEach(pixel =>
In this case, however, I would just write this, as it's much simpler:
clearOnePixel([0, 0, 1, 1], 0, 0);
clearOnePixel([0, 1, 0, 1], 1, 0);
...see suggestion below
|
Previews, as seen when this build job started (3698722): |
Nice, thanks for reviewing! |
This extends the readbackFromWebGPUCanvas and canvas_clear tests to cover rgba8unorm.
Issue: #915
Requirements for PR author:
.unimplemented()./** documented */and new helper files are found inhelper_index.txt.Requirements for reviewer sign-off:
When landing this PR, be sure to make any necessary issue status updates.