Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 1 of 1

Thread: Coherent GLSL 420 imageBuffer access in single-stage, single-pass scenario

  1. #1
    Junior Member Regular Contributor
    Join Date
    Jul 2010
    Posts
    132

    Coherent GLSL 420 imageBuffer access in single-stage, single-pass scenario

    Sorry if this question has been asked before, but I find lots of confusing information in the forums. Sometimes this information is (I believe) contradicting the specification of OpenGL.

    When carefully reading the following paragraph in the ARB_shader_image_load_store spec:

    "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."
    I conclude that all imageStore()'s will be immediately visible to all fragment shader invocation in my situation: single pass, single shader. Also, image load/store operations are guaranteed to be executed in-order.

    My fragment shader looks like this:

    Code :
    coherent layout(1x32) uniform uimageBuffer data;
     
    void main()
    {
      ...
      various calls to imageLoad(data, ..., ...);
      ...
      various calls to imageStore(data, ..., ...);
      ...
    }

    Because in-order execution is guaranteed, if a given invocation performs the following:

    Code :
    imageStore(data, 0, 1234);
    imageStore(data, 1, 5678);

    the following is true, for any other invocation:

    Code :
    if (imageLoad(data, 0) == 1234)
    {
      int result = imageLoad(data, 1);
      // result here is GUARANTEED to be 5678
      // because 'data' is marked as 'coherent'
      // and I'm in a single shader instance
      // (matching the spec 'similarly-declared' variable)
    }

    Is that correct? (no need to call memoryBarrier() at all, for instance).

    NB: not interested in non-coherent or multi-stage or multi-pass processing scenarios. Only coherent imageBuffer declarations, single pass, just using the fragment shader.
    Last edited by fred_em; 05-17-2014 at 11:45 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •