KhronosGroup / GLSL

GLSL Shading Language Issue Tracker
328 stars 96 forks source link

Are atomic operations allowed on writeonly memory? #174

Open ianromanick opened 2 years ago

ianromanick commented 2 years ago

The spec is unclear whether memory decorated with writeonly can be passed to, for example, atomicAdd. The atomic operations are specifically described to read then write the memory in question, so it seem reasonable that either writeonly or readonly should be invalid. Section 8.11 (Atomic Memory Functions) goes to some effort to say that restrict, coherent, and volatile are valid, but it makes no mention of readonly or writeonly.

However, we have discovered that the GIANTS Editor does this in many of its shaders, and closed-source drivers from both AMD and NVIDIA accept the shaders.

See also https://gitlab.freedesktop.org/mesa/mesa/-/issues/5842.

pdaniell-nv commented 2 years ago

We discussed this in the 2022-01-19 meeting. The built in atomic functions should not be allowed on readonly or writeonly memory. We'll clarify the spec to explicitly forbid them, but being careful to not contradict the Vulkan memory model extension which has atomicRead and atomicWrite which would be allowed on readonly and writeonly respectively.