You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If an atomic comes from an storage buffer then it has a QueueFamily memory scope. Reading the synchronization section it says: All synchronization functions use the Workgroup [memory scope](https://www.w3.org/TR/WGSL/#memory-scope). Isn't that memory scope different from the one used for atomics in a storage buffer?
Yes, but atomics aren't synchronization functions.
A storage barrier provides the synchronization necessary to make memory operations on storage buffers available and visible to other invocations in the same workgroup instance.
An atomic operation on an atomic type in a storage buffer will become available/visible to all other invocations in the same draw/dispatch. It does not, however, provide necessary synchronization (because it uses relaxed memory ordering) for availability/visibility to be properly synchronized on other storage buffer memory.
Let me see if I understand that, you can have an atomic inside a storage buffer. Calling storageBarrier will synchronize access to the contents of the storage buffer except for the atomic.
The atomic access will all be visible to all the invocations, but there is no way to to synchronize them, you can just change the atomic value.
Not exactly. Atomics operations made through the same reference (e.g. variable) are mutually ordered. Additionally, there is a modification order, that is all invocations would witness modifications in the same order. Because WGSL only supports relaxed memory ordering for atomics they cannot be used for synchronization, but they are always coherent and synchronize with other atomic operations to the same location.
Barriers provide the only synchronization mechanism for non-atomic memory operations in WGSL. As such an author can only rely on a consistent view of non-atomic memory operations within a workgroup because that is the memory scope of barriers.
So,
The atomic access will all be visible to all the invocations, but there is no way to to synchronize them, you can just change the atomic value.
Atomics will never race on the same location given the constraints we have in the language (e.g. no aliased bindings). A barrier is unnecessary to synchronize atomics.
Activity
alan-baker commentedon May 31, 2022
Yes, but atomics aren't synchronization functions.
A storage barrier provides the synchronization necessary to make memory operations on storage buffers available and visible to other invocations in the same workgroup instance.
An atomic operation on an atomic type in a storage buffer will become available/visible to all other invocations in the same draw/dispatch. It does not, however, provide necessary synchronization (because it uses relaxed memory ordering) for availability/visibility to be properly synchronized on other storage buffer memory.
dj2 commentedon May 31, 2022
Let me see if I understand that, you can have an atomic inside a storage buffer. Calling
storageBarrierwill synchronize access to the contents of the storage buffer except for the atomic.The atomic access will all be visible to all the invocations, but there is no way to to synchronize them, you can just change the atomic value.
Is that right?
alan-baker commentedon May 31, 2022
Not exactly. Atomics operations made through the same reference (e.g. variable) are mutually ordered. Additionally, there is a modification order, that is all invocations would witness modifications in the same order. Because WGSL only supports relaxed memory ordering for atomics they cannot be used for synchronization, but they are always coherent and synchronize with other atomic operations to the same location.
Barriers provide the only synchronization mechanism for non-atomic memory operations in WGSL. As such an author can only rely on a consistent view of non-atomic memory operations within a workgroup because that is the memory scope of barriers.
So,
Atomics will never race on the same location given the constraints we have in the language (e.g. no aliased bindings). A barrier is unnecessary to synchronize atomics.
dj2 commentedon May 31, 2022
That makes sense, thanks. Clarifying this in the spec would be useful.