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 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?