opengl 4 - GLSL coherent imageBuffer access in single-stage (fragment shader), single-pass scenario -
i have single fragment shader performs processing on imagebuffer using image load/store operations. exclusively concerned following scenario:
- i have single fragment shader (no multistage (eg. vertex fragment shaders) considerations, , no multipass rendering)
- imagebuffer variables declared coherent. exclusively interested in coherent imagebuffers.
to make things clear, scenario following:
// source code of sole , unique fragment shader: coherent layout(1x32) uniform uimagebuffer data; void main() { ... various calls imageload(data, ..., ...); ... various calls imagestore(data, ..., ...); ... }
i have largely looked @ spec
especially paragraph:
"using variables declared "coherent" guarantees results of stores visible shader invocations using similarly-declared variables; calling memorybarrier required ensure stores visible other operations."
note: "coherent uniform imagebuffer data;" declaration precisely "similarly-declared" variable. scenario single-pass, single-stage (fragment shader).
now, have looked @ various web sites , stumbled (like people think) upon thread on stackoverflow.com:
how glsl's "coherent" memory qualifier interpreted gpu drivers multi-pass rendering?
and more specifically, paragraph:
"your shaders cannot make assumption issuing load right after store memory stored in shader (yes really. have put memorybarrier in pull 1 off)."
my question following:
with coherent qualifier specified, in single-shader, single-pass processing scenario, can yes or no sure imagestore()'s visible invocations of fragment shader (eg. current invocation other concurrent invocations)?
by reading arb_shader_image_load_store spec, seems me that:
- the answer question yes,
- i don't need kind of memorybarrier(),
- the quoted sentence in above referenced thread in stackoverflow may indeed misleading , wrong.
thanks insight.
use memory barrier.
for 1 thing gpu may optimize , fetch whole blocks of memeory read from, , have separate memory write to.
in other words if shader modify single location once ok, if relay on neighbors values after computation applied, need memory barrier.
Comments
Post a Comment