I have a single fragment shader that performs processing on an imageBuffer using image load/store operations. I am exclusively concerned about the following scenario:
- I have a single fragment shader (no multistage (eg. vertex then fragment shaders) considerations, and no multipass rendering)
- imageBuffer variables are declared as coherent. Exclusively interested in coherent imageBuffers.
To make things perfectly clear, my scenario is the following:
// Source code of my sole and unique fragment shader:
coherent layout(1x32) uniform uimageBuffer data;
void main()
{
...
various calls to imageLoad(data, ..., ...);
...
various calls to imageStore(data, ..., ...);
...
}
I have largely looked at the spec
especially this very paragraph:
"Using variables declared as "coherent" guarantees that the results of stores will be immediately visible to shader invocations using similarly-declared variables; calling MemoryBarrier is required to ensure that the stores are visible to other operations."
Note: my "coherent uniform imageBuffer data;" declaration precisely is a "similarly-declared" variable. My scenario is single-pass, single-stage (fragment shader).
Now, I have looked at various web sites and stumbled (like most people I think) upon this thread on stackoverflow.com:
and more specifically, this paragraph:
"Your shaders cannot even make the assumption that issuing a load right after a store will get the memory that was just stored in this very shader (yes really. You have to put a memoryBarrier in to pull that one off)."
My question is the following:
With the coherent qualifier specified, in my single-shader, single-pass processing scenario, can I yes or no be sure that imageStore()'s will be immediately visible to ALL invocations of my fragment shader (eg. the current invocation as well as other concurrent invocations)?
By reading the ARB_shader_image_load_store spec, it seems to me that:
- the answer to this question is yes,
- I don't need any kind of memoryBarrier(),
- the quoted sentence in the above referenced thread in stackoverflow may indeed be misleading and wrong.
Thanks for your insight.