Skip to content

[naga spv-in] Add support for memory barriers #7630

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

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

Conversation

PhenaOfMari
Copy link
Contributor

@PhenaOfMari PhenaOfMari commented Apr 25, 2025

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

  • Run cargo fmt.
  • Run taplo format.
  • Run cargo clippy --tests. If applicable, add:
    • --target wasm32-unknown-unknown
  • Run cargo xtask test to run tests.
  • If this contains user-facing changes, add a CHANGELOG.md entry.

@PhenaOfMari PhenaOfMari force-pushed the spv-memory-barriers branch 2 times, most recently from fb1082c to c867f55 Compare April 26, 2025 01:22
@PhenaOfMari PhenaOfMari force-pushed the spv-memory-barriers branch from c867f55 to cf1d916 Compare April 26, 2025 02:15
@PhenaOfMari PhenaOfMari marked this pull request as ready for review April 26, 2025 02:30
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