-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add support for transient textures on Vulkan and Metal #8247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking this on! It just so happened we just talked about wanting this in the WebGPU face to face, so super happy to have this! There's a few things that need to be added, but I don't think it will end up being too much work:
- At the face to face, we've decided that transient textures wouldn't be a feature. It would be available everywhere, but a no-op on unsupported platforms. If we wanted to expose to the user if this is supported, we can do this in the AdapterInfo as a hint.
- We need two pieces of validation:
a. If you add the transient attachment usage, the usage must be exactly RENDER_ATTACHMENT | TRANSIENT
b. When writing a renderpass to these attachments, the StoreOp must be discard. - With point 1 implemented, we should stick these flags on as many of the examples as relevant as we really want to encourage its use.
- On VK, we need to add
VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT
to the memory so that it may be lazily allocated. I think you may be getting this already implicitly without explicitly asking for it, if you're seeing memory improvements. - We should add some tests
a. For all the validation I mentioned, these can be simple tests in wgpu-validation.
b. We should have at least one test in the wgpu-gpu tests which ensures we don't get validation errors from vk/metal.
Let me know if you have any questions or if any of this is unclear!
Thanks for your input @cwfitzgerald! For:
|
Re 3: |
Yeah this is unfortunately a mobile only feature really, but hopefully the validation layers can save us on desktop. Apple is the main one that really benefits from it on "desktop". |
I did make it so that a if a memory type with the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments and needs tests, but moving in the right direction!
Alright, I looked through it more carefully again, we should be able to apply |
Co-authored-by: Connor Fitzgerald <[email protected]>
Co-authored-by: Connor Fitzgerald <[email protected]>
Co-authored-by: Connor Fitzgerald <[email protected]>
What's the use case for this? One thing I do in Bevy is use a dummy render target for a render pass, since I use storage atomics for my output. I have wanted render passes with no render attachments for this reason, so that we don't need to waste memory on a dummy render target. Would this be a suitable replacement? |
Tilers where you need an attachment but never actually read from it from memory. You can avoid allocating that memory.
This is better than nothing, but not really. It would only actually reduce memory on tilers. |
…ENT` isn't present.
I checked and it appears the only usage of |
Sure, that works |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff!
Connections
Fixes #8239
Description
Exposes
MTLStorageMode.memoryless
for Metal andvk::MemoryPropertyFlags::LAZILY_ALLOCATED
for Vulkan by addingTextureUsages::TRANSIENT
.Testing
Added corresponding
TextureUsage
flag to relevant examples.Also added some render tests and validation testing.
Squash or Rebase?
Squash
Checklist
cargo fmt
.taplo format
.cargo clippy --tests
. If applicable, add:--target wasm32-unknown-unknown
cargo xtask test
to run tests.CHANGELOG.md
entry.