Skip to content
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

atomicCompareExchangeWeak not working #1755

Closed
ria8651 opened this issue Feb 28, 2022 · 4 comments
Closed

atomicCompareExchangeWeak not working #1755

ria8651 opened this issue Feb 28, 2022 · 4 comments

Comments

@ria8651
Copy link

ria8651 commented Feb 28, 2022

Description
When using atomicCompareExchangeWeak I get a validation error: Result type for [33] doesn't match the statement

let exchange = atomicCompareExchangeWeak(&n.lock, 0u, 1u);

Expected vs observed behaviour
I'd expect the behaviour explained in the spec.

Platform

  • macOS
  • wgpu 0.12 or wgpu master
@kvark
Copy link
Member

kvark commented Feb 28, 2022

So this is the validation triggering, and while it can be fixed, the backends don't really implement any atomic comparison methods yet. Reason being that we need to return a proper type first - see #1161 (comment)
There isn't going to be a short-term fix here, we need to be able to return structures, and then we'll implement it in backends.

@ria8651
Copy link
Author

ria8651 commented Feb 28, 2022

Would it be possible to just return the bool for now? As far as I know, the only use of this function is for a lock and you don't need the original value for that.

@cwfitzgerald cwfitzgerald transferred this issue from gfx-rs/wgpu Feb 28, 2022
@kvark
Copy link
Member

kvark commented Mar 1, 2022

We could implement something in the backends, but it would be partially wasted work, since this isn't going to be the API of WGSL but rather something ad-hoc.

@teoxoy teoxoy added this to the WGSL Specification V1 milestone Apr 30, 2022
aweinstock314 added a commit to aweinstock314/naga that referenced this issue Dec 9, 2022
…_compare_exchange_result` struct, and add SPIR-V codegen for it.

Partially addresses #2113, gfx-rs#1755.
aweinstock314 added a commit to aweinstock314/naga that referenced this issue Dec 9, 2022
…_compare_exchange_result` struct, and add SPIR-V codegen for it.

Partially addresses gpuweb/gpuweb#2113, gfx-rs#1755.
teoxoy pushed a commit that referenced this issue Dec 13, 2022
…2165)

* Add support for WGSL's `atomicCompareExchangeWeak` with the `__atomic_compare_exchange_result` struct, and add SPIR-V codegen for it.

Partially addresses gpuweb/gpuweb#2113, #1755.

* Add tests for `atomicCompareExchangeWeak`, and support both u32 and i32 atomics with it.

* More thorough typechecking of the struct returned by `atomicCompareExchangeWeak`.
@teoxoy
Copy link
Member

teoxoy commented Sep 25, 2023

Validation was updated by #2165 which also added support for SPIR-V codegen.
Let's track remaining work (adding support for the builting to the other remaining backends) in gfx-rs/wgpu#4364.

@teoxoy teoxoy closed this as completed Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants