Skip to content

Allow 3D textures to be renderable#6004

Closed
matthew-wong1 wants to merge 4 commits intogfx-rs:trunkfrom
matthew-wong1:trunk
Closed

Allow 3D textures to be renderable#6004
matthew-wong1 wants to merge 4 commits intogfx-rs:trunkfrom
matthew-wong1:trunk

Conversation

@matthew-wong1
Copy link
Copy Markdown
Contributor

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 test on an M2 Mac. All tests passed except 3 (the same 3 also failed on the trunk branch of wgpu).

Checklist

  • Run cargo fmt.
  • Run cargo clippy. If applicable, add:
    • --target wasm32-unknown-unknown
    • --target wasm32-unknown-emscripten
  • Run cargo xtask test to run tests.
  • Add change to CHANGELOG.md. See simple instructions inside file.

@matthew-wong1 matthew-wong1 requested a review from a team as a code owner July 20, 2024 23:26
Copy link
Copy Markdown
Member

@Wumpf Wumpf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

@matthew-wong1
Copy link
Copy Markdown
Contributor Author

matthew-wong1 commented Jul 21, 2024

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.

@cwfitzgerald
Copy link
Copy Markdown
Member

Sorry for overlooking the changelog.

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.

@matthew-wong1
Copy link
Copy Markdown
Contributor Author

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 colorAttachment.depthSlice to be included in the renderPassDescriptor. For me, implementing that is a bit out of my depth but I'm happy to help with writing any unit tests along the way. Sorry!

@Wumpf
Copy link
Copy Markdown
Member

Wumpf commented Jul 24, 2024

Then it's probably best to shelve this for now.
Would you mind creating an issue detailing what needs to be done and what you've learned on the way so far?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants