Skip to content

[naga hlsl-out, glsl-out] Support atomicCompareExchangeWeak #7658

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 13 commits into
base: trunk
Choose a base branch
from

Conversation

cryvosh
Copy link

@cryvosh cryvosh commented May 2, 2025

Connections
Fixes #7578, related to #4364.

Description
Adds support for atomicCompareExchangeWeak translation to hlsl and glsl.

Note this does not implement the [allow_uav_condition] loop attribute mentioned here and here.
Not sure the best way to check if the loop termination is based off a UAV read.
Maybe can later borrow logic from the uniformity analyzer?
Dawn doesn't seem to do this either, though maybe it should?
There is a test with a while loop that depends on .exchanged which seems to pass hlsl validation.

Testing
Added / enabled some basic atomicCompareExchangeWeak tests to Naga.
My personal project using atomicCompareExchangeWeak runs fine now on Windows/Nvidia/DX12.
GL backend is untested outside the Naga tests / validation.

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.

@cryvosh cryvosh marked this pull request as draft May 2, 2025 04:46
@cryvosh cryvosh marked this pull request as ready for review May 2, 2025 05:43
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.

Internal error in writing type when atomicCompareExchangeWeak is used in compute shader, on GL backend
1 participant