Validate binding ranges against buffer size#7911
Merged
jimblandy merged 6 commits intogfx-rs:trunkfrom Jul 10, 2025
Merged
Conversation
c560520 to
2502704
Compare
2502704 to
24ec47d
Compare
Member
|
@jimblandy fielded the review for the first iteration of this fix, so I'll tentatively pull him in for the second round. |
jimblandy
approved these changes
Jul 10, 2025
Member
jimblandy
left a comment
There was a problem hiding this comment.
Andy and I talked through this in a meeting, and it looks good to me.
This was referenced Jul 10, 2025
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reprise of #7875, which was reverted in #7905.
This tightens up the validation of binding sizes. I have added a helper on the wgpu_core Buffer type to resolve implicit remainder-of-buffer sizes and validate the binding offset and size against the size of the buffer. This helper is now the preferred way of constructing a hal::BufferBinding. Direct construction is no longer allowed in wgpu_core. There is an unsafe new_unchecked helper for cases where direct construction is necessary.
This fixes a small but critical typo in the previous change: 14a5abd
It also stays even closer to the original behavior for zero-size bindings than the previous change. When we validate a binding with implicit remainder-of-buffer size, we preserve the information that it is sized as such, and resolve it again in the backends.
I've divided the changes into meaningful independent commits. Since #7875 was reverted, the PR diff is against the state prior to those changes. The diff against the state after #7875 may also be informative: https://github.com/gfx-rs/wgpu/compare/e5b03ffa1defc0b760a8c0bd8c54aa9b98c78002...andyleiserson:wgpu:buffer-size-fixes?expand=1.
Testing
Enables some CTS tests that were broken by the previous change.
The following CTS tests are still failing, but are also relevant:
Squash or Rebase? Undecided
Checklist
cargo fmt.taplo format.cargo clippy --tests. If applicable, add:--target wasm32-unknown-unknowncargo xtask testto run tests.CHANGELOG.mdentry.