Hi,

I have a shader that pokes into a framebuffer-sized image (uimage2D) when rendering fragments.
Eg. everytime a fragment shader invocation is run, the following happens:

Code :
uniform uimage2D myimage;
 
uint val = compute some value;
imageAtomicMin(myimage, ivec2(gl_FragCoord.xy),                val);
imageAtomicMin(myimage, ivec2(gl_FragCoord.xy) + ivec2(-1, 0), val);
imageAtomicMin(myimage, ivec2(gl_FragCoord.xy) + ivec2( 1, 0), val);
imageAtomicMin(myimage, ivec2(gl_FragCoord.xy) + ivec2( 0, 1), val);
imageAtomicMin(myimage, ivec2(gl_FragCoord.xy) + ivec2( 0,-1), val);

Basically a value is written into myimage (well, a min() is performed) with regards to the current fragment location, as well as for the 4 neighbor locations (above, underneath, and on the left and right sides).

Note that another fragment of the same triangle primitive might write at a location currently being written to by the current fragment shader invocation. Concurrency may also happen between fragment shader invocations related to 2 different triangle primitives.

I have two questions regarding my logic:

- should I declare myimage as coherent?
- should I issue a memoryBarrier() prior to calling imageAtomicMin?

Thanks,
Fred