Defined behaviour of image load after store in a different shader stage?

Started by
-1 comments, last by obfuscator 9 years, 9 months ago
Hi,
imagine following scenario:
- I want to draw indexed triangle strips with a primitive restart after every fourth index (restart index: 0xffffffff) which results in quads.
- Then I want to store a computed value for every quad into an image via vertex shader. The store should only be executed for the first vertex of a quad.
Pseudo code for vertex shader:


void main()
{
  ...
 
  if (gl_VertexID % 4 == 0)
  {
    imageStore(image, coordinate, value); // req.: coherent qualifier
    memoryBarrier();
  }
 
  ...
}
 
Now the question: Is it safe to assume (defined behaviour) that this stored value is visible for all fragments of the triangle strip / quad or can it happen that it is only visible for one triangle of the strip and the other uses an obsolete or undefined value? Is the fragment shader dependent on the primitive type of the draw call (here: triangle strip) or only on one triangle of the primitive type?
Two important cites from the OpenGL - Memory Model wiki article my question is based on:


Second, if a shader invocation is being executed, then the shader invocations necessary to cause that invocation must have taken place. For example, in a fragment shader, you can assume that the vertex shaders to compute the vertices for the primitive being rasterized have completed. This is called a dependent invocation. They get to have special privileges in terms of ordering.



Invocations of the same shader stage may be executed in any order. Even within the same draw call. This includes fragment shaders; writes to the framebuffer are ordered, but the actual fragment shader execution is not.

What is a primitive here? Triangle or triangle strip?
Btw every quad has its own store coordinate (independent from the others).

This topic is closed to new replies.

Advertisement