Skip to content

Add coherent and volatile memory decorations for storage buffers.#9168

Merged
cwfitzgerald merged 2 commits intogfx-rs:trunkfrom
atlv24:ad/memory-decorations
Mar 11, 2026
Merged

Add coherent and volatile memory decorations for storage buffers.#9168
cwfitzgerald merged 2 commits intogfx-rs:trunkfrom
atlv24:ad/memory-decorations

Conversation

@atlv24
Copy link
Copy Markdown
Collaborator

@atlv24 atlv24 commented Mar 7, 2026

Connections
#4444 (related)

Description
Adds support for coherent and volatile memory decorations where supported, via custom attributes on wgsl @coherent and @volatile.

Testing
Naga snapshots and validation tests

Squash or Rebase?

Squash

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.

@cwfitzgerald cwfitzgerald self-assigned this Mar 7, 2026
Copy link
Copy Markdown
Member

@cwfitzgerald cwfitzgerald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great stuff, thank you for all the testing!

My one question is about metal - do you have a cite for all buffers being coherent already? My impression is that you'd need to make atomics use memory_order_seq_cst on those buffers to get full coherence.

@atlv24
Copy link
Copy Markdown
Collaborator Author

atlv24 commented Mar 11, 2026

So it turns out I misread and got confused. Looking at MSL 3.2 coherent qualifier for buffers: Metal Shading Language Specification v4, section on address space qualifiers https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf shows that there actually is a decorator. Looking at the SPIRV-Cross implementation backs this up KhronosGroup/SPIRV-Cross#2473 showing they use coherent device KhronosGroup/SPIRV-Cross#2487

@atlv24 atlv24 force-pushed the ad/memory-decorations branch 3 times, most recently from 9897728 to 03d7d94 Compare March 11, 2026 02:51
@atlv24 atlv24 force-pushed the ad/memory-decorations branch from 03d7d94 to f520aa3 Compare March 11, 2026 21:57
@cwfitzgerald cwfitzgerald merged commit 9ed7737 into gfx-rs:trunk Mar 11, 2026
59 checks passed
@atlv24 atlv24 mentioned this pull request Mar 14, 2026
6 tasks
mockersf pushed a commit to bevyengine/naga_oil that referenced this pull request Mar 19, 2026
wgpu 29 is close to releasing, so this is a preview of the naga-29
changes for naga-oil.

Changes are currently relative to: 

updating from [this
commit](gfx-rs/wgpu@0ab6edd)
to [the two fixes
below](gfx-rs/wgpu@e80dc8d)
causes two test failures

```
test compose::test::test::test_atomics ... FAILED
test compose::test::test::use_shared_global ... FAILED
```

- [coherent and volatile memory
decorations](gfx-rs/wgpu#9168)
- [InstanceDescriptor::default no longer
exists](gfx-rs/wgpu#8782)
@atlv24 atlv24 deleted the ad/memory-decorations branch April 2, 2026 19:55
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