I have a fragment shader (GLSL 4.5), which is supposed to write non-transparent pixels to the framebuffer (by writing to the declared output variables) and transparent pixels into a shader storage buffer for later composition. To make that work I planned to write transparent pixels to the shader storage buffer and then call discard
to prevent the write to the framebuffer.
Now I stumbled upon this section of the khronos.org's OpenGL Wiki (emphasis mine):
The discard command will also prevent any image store and atomic operations and Shader Storage Buffer Object writes (issued before the discard) from working.
I was very surprised to see this, because if you consider that different shader invocations are able to exchange information by writing and reading shader storage buffers, and therefor could have already behaved differently based on such a wirte before the discard statement is even reached.
I looked into the the GLSL 4.5 Specification, but I could not find anything, which supports the statement form the Wiki.
Also: If this is true, are maybe later writes to a shared storage buffer not discarded?