[naga spv-in] Add support for memory barriers #7630
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.
Description
Naga's SpirV ingest currently has support for control barriers, but not memory-only barriers. This PR endeavors to add this support for SpirV in as well as any language out that may make proper use of them. Languages that don't support memory barriers without an execution barrier will follow the existing Control Barrier path.
Additionally, Control Barriers for SpirV in and out have no distinction between workgroup and subgroup memory scopes. Support for that has been added as a separate commit, which can easily be pulled out into a separate pull request if desired.
Testing
I've compiled a simple shader with rust-gpu that utilizes their memory_barrier function. These changes allow the compiled shader to be parsed and executed, where previously the validator would panic that OpMemoryBarrier was unsupported. I've also added a spvasm file to
naga/tests/in/spv
that compiles to all backends.Squash or Rebase
Both commits should be able to stand on their own if whoever does the merge prefers to rebase. Either way is fine.
Checklist
cargo fmt
.taplo format
.cargo clippy --tests
. If applicable, add:--target wasm32-unknown-unknown
cargo xtask test
to run tests.CHANGELOG.md
entry.