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

Add a function to clear bindgroups from passes and bundles, with stub backend implementations. #5778

Closed
wants to merge 1 commit into from

Conversation

bradwerth
Copy link
Contributor

@bradwerth bradwerth commented Jun 5, 2024

Since the spec allows null BindGroups to be passed to setBindGroup, we need a way to clear the BindGroup associated with an index. This patch implements that through a clear_bind_group function defined in various necessary places, and implements as much of it as possible, without getting into the wgpu-hal backend implementations, which are left as TODOs.

Connections
N/A

Testing
This code is not exercised, since all of our set_bind_group entry points require a BindGroup. The CTS contains tests that set null BindGroups.

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.

… backend implementations.

Since the spec allows null BindGroups to be passed to setBindGroup, we
need a way to clear the bindGroup associated with an index. This patch
implements that through a clear_bind_group function defined in various
necessary places, and implements as much of it as possible, without
getting into the wgpu-hal backend implementations, which are left as
TODOs.
@ErichDonGubler
Copy link
Member

I have several questions before I'm willing to dive into a full review of the implementation:

  1. Is this actually shippable without having hal implementations?
  2. Is there a reason that we shouldn't adhere more to the design of the JS API, specifically WRT GPUDevice.setBindGroup expressing this use case as an optional bindGroup argument, rather than a separate method?

@bradwerth
Copy link
Contributor Author

I have several questions before I'm willing to dive into a full review of the implementation:

1. Is this actually shippable without having `hal` implementations?

Probably not. Undoing the effects of a setBindGroup are subtle and require expertise per-backend; expertise I don't have.

2. Is there a reason that we shouldn't adhere more to the design of the JS API, specifically WRT `GPUDevice.setBindGroup` expressing this use case as an optional `bindGroup` argument, rather than a separate method?

Modifying the top-level entry point would be superior I think, but it would break all usage with the change, since every caller of setBindGroup would need to be modified. I also wasn't sure which of the many implementations of setBindGroup is the topmost, external-facing one. For those reasons, I offered the implementation up in this form.

@bradwerth bradwerth closed this Jun 17, 2024
@bradwerth
Copy link
Contributor Author

I'll create a new PR that changes the external-facing signature of setBindGroup to take an Option<bindGroupId>.

@bradwerth
Copy link
Contributor Author

The new PR is #6216.

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.

2 participants