Image load/stores in primitive order

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

Not without extensions. Specifically, VK_EXT_fragment_shader_interlock. This is not a particularly widely provided extension. AMD doesn’t support it at all (note that their OpenGL implementations don’t support the GL equivalent extension either), and even Intel support is somewhat sketchy.

I’m OK with using extensions for it. However, if even AMD does not support it, it sounds a little sad.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.