Skip to content
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

Mutable bind groups in DX12 and Vulkan within wgpu-hal #6842

Open
wants to merge 4 commits into
base: trunk
Choose a base branch
from

Conversation

lucas-miguel-antunes
Copy link

Connections
Link to the issues addressed by this PR, or dependent PRs in other repositories

Description
Describe what problem this is solving, and how it's solved.
Implements mutable bind groups in wgpu-hal. When you create a bind group with the ALLOW_UPDATES flag, you can call update_bind_group in the device, which has a similar API to create_bind_group and will update the existing descriptors in DX12 and Vulkan (not implemented in other backends). This allows you to have much more efficient bindless texturing, because you can use a single large bind group and change its descriptors at runtime, without having to recreate the large bind group.

In order to make this more usable in DX12, I also implemented partial resources, by storing the descriptor offsets of every value in entries for the different heap types, then doing a CopyDescriptors call that fills in every handle as a range with 1 value instead of doing them all as a single big range.

And finally I added array_element_offset to BindGroupEntry, which allows the user to write to a specific array element, useful when you have a bind group entry with a large count and you want to do bindless writing to it.

Testing
Explain how this change is tested.
Edited the halmark example in wgpu-hal to update the bind group every 100 frames when MUTABLE_BIND_GROUP is true, and ran the test in DX12 and Vulkan, as well as all the other tests using xtask test.

Checklist

  • Run cargo fmt.
  • Run taplo format.
  • 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.

@lucas-miguel-antunes lucas-miguel-antunes requested a review from a team as a code owner January 2, 2025 16:23
@lucas-miguel-antunes lucas-miguel-antunes changed the title Mutable bind group Mutable bind groups in DX12 and Vulkan within wgpu-hal Jan 2, 2025
@cwfitzgerald cwfitzgerald self-assigned this Jan 8, 2025
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