Assume I render a trianguted mesh. My fragment shader does an atomic exchange operation like this:
float prevDepth = atomicExchange(someImage, fragCoord, currDepth);
//doing something with prevDepth
The spec (https://vulkan.lunarg.com/doc/view/1.0.26.0/linux/vkspec.chunked/ch08s03.html) says:
The relative order of invocations of the same shader type are undefined. A store issued by a shader when working on primitive B might complete prior to a store for primitive A, even if primitive A is specified prior to primitive B. This applies even to fragment shaders; while fragment shader outputs are always written to the framebuffer in primitive order, stores executed by fragment shader invocations are not.
I, however, want to ensure that these exchanges are all done in primitive order. Every fragment only accesses a single pixel it’s rasterized on. Is there a way to guarantee such thing?