Allow 3D textures to be renderable#6004
Allow 3D textures to be renderable#6004matthew-wong1 wants to merge 4 commits intogfx-rs:trunkfrom matthew-wong1:trunk
Conversation
There was a problem hiding this comment.
the change itself is looking good but...
- I think this should be covered by a unit test since there's no way of being sure that our backends actually support this (if any doesn't, we have to emulate this feature by doing copies etc.). I had a quick browse just now and it unforunately doesn't look like there's anything checking on something like that yet.
- a test creating a renderpass to clear a specific layer of a small volume texture with a "marker color" and then reading back that only that layer has been cleared should be enough
- bonus points if that test also tests array textures :)
- changelog entry please!
|
Thanks for the feedback! Sorry for overlooking the changelog. I've been working on writing the test but I've been a bit slow as I'm still a bit new to Rust and using WebGPU through rust. My understanding is to create a texture view of a particular layer and then pass that into a render pass with a Clear operation, then copy the texture to a buffer and see if that layer is of the color that it was cleared to. Also realized I'll probably need to update a couple more places in the code as I've been running into unreachable errors related to 3D textures. |
We're pretty bad about it ourselves, so you're in good company 😅 Feel free to come on the matrix to ask any questions if you need help with implementing tbf tests. |
|
It seems like the current backend doesn't fully support rendering 3D textures just yet. I probably should've looked a bit closer initially, but based on the WebGPU spec (https://www.w3.org/TR/webgpu/#dom-gpucommandencoder-beginrenderpass) beginning a renderpass with a 3D texture requires a new attribute |
|
Then it's probably best to shelve this for now. |
Description
Hi! The WebGPU spec now allows textures with a 3D dimension to be renderable but the current wgpu implementation only allows for 2D textures to be renderable. I updated the checks to not throw an error if a 3D texture has GPUTextureUsage.RENDER_ATTACHMENT. I couldn't find any open issues or pull requests related to this. Sorry if it might be a work-in-progress or if it was a conscious decision not to enable 3D textures to be renderable yet!
I think the they updated the spec for 3D textures to be renderable around November 2023.
Testing
I ran
cargo xtask teston an M2 Mac. All tests passed except 3 (the same 3 also failed on the trunk branch of wgpu).Checklist
cargo fmt.cargo clippy. If applicable, add:--target wasm32-unknown-unknown--target wasm32-unknown-emscriptencargo xtask testto run tests.CHANGELOG.md. See simple instructions inside file.