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 8 of 8

Thread: Atomic access to Shader Storage Buffers fails linking

Hybrid View

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2012
    Posts
    7

    Question Atomic access to Shader Storage Buffers fails linking

    Hi there,

    I'm working with OpenGL 4.3 (GTX 680, driver version 306.63) and want to use the Shader Storage Buffers atomically.

    Using the following shaders, the linking fails but I do not have a clue, why that is and how to fix it:
    Vertex:
    Code :
    #version 430
    layout(location = 0) in vec3 vertexPos;
    void main()
    {
    	gl_Position.xyz = vertexPos;
    }

    Fragment:
    Code :
    #version 430
     
    in vec4 gl_FragCoord;
    out vec4 gl_FragColor;
    uniform unsigned int width;
     
    layout(binding = 1) buffer List
    {
    	unsigned int entry[];
    }list;
     
    void main(void)
    {
        uvec2 p = uvec2(gl_FragCoord.xy);
        uint index = p.x + p.y*width;
        unsigned int a = 5;
        atomicExchange(list.entry[index], a);
    }
    So, I have a shader storage buffer containing as many 'entry' values as the buffer can hold when bound.
    Every shader calculates the index of where to write into the buffer using linearizing the fragment position.
    Then, I want to replace the value in the buffer with 'a' atomically.
    When I write 'list.entry[index] = a', it links and works fine.
    But when I use the atomic operation, it compiles(!) but fails to link with no message.
    I need the atomic operation for an lock free list implementation.
    I have not tried this with compute shaders as I need the data generated by the rasterizer.
    The example above is the most minimalistic one producing the error.

    Can anyone help me with this? Is there something I did wrong or missed?
    Thanks in advance,
    daniel

  2. #2
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,948
    fails to link with no message
    Anytime that happens, it's the driver's fault. There should be nothing you can do with a shader that causes it to emit a link failure and not update the info-log.

  3. #3
    Advanced Member Frequent Contributor
    Join Date
    Apr 2009
    Posts
    600
    Admittedly not likely the source of your problem:

    Code :
     
    gl_Position.xyz = vertexPos;

    why is gl_Position.w not set?

  4. #4
    Junior Member Newbie
    Join Date
    Oct 2012
    Posts
    7
    Quote Originally Posted by Alfonse Reinheart View Post
    Anytime that happens, it's the driver's fault. There should be nothing you can do with a shader that causes it to emit a link failure and not update the info-log.
    Thanks, so I'll have to wait for NVIDIA...

    @kRogue:
    a) It's a pass-through-shader for full screen quads without any transformation.
    b) Because it works without .w

    Daniel

  5. #5
    Junior Member Newbie
    Join Date
    Oct 2012
    Posts
    7
    Quote Originally Posted by Alfonse Reinheart View Post
    Anytime that happens, it's the driver's fault. There should be nothing you can do with a shader that causes it to emit a link failure and not update the info-log.
    Thanks, so I'll have to wait for NVIDIA...

    @kRogue:
    a) It's a pass-through-shader for full screen quads without any transformation.
    b) Because it works without .w

    Daniel

  6. #6
    Junior Member Newbie
    Join Date
    Feb 2012
    Location
    Germany
    Posts
    13
    @Danielkr:
    make sure you try to read the info log straight after linking without an additional validate in between.
    Validate overwrites the info log message, which may be a reason why you get an empty log message.

  7. #7
    Junior Member Regular Contributor
    Join Date
    Mar 2009
    Posts
    153
    Try the latest driver which is 310.33

  8. #8
    Junior Member Newbie
    Join Date
    Oct 2012
    Posts
    7
    Unfortunately, driver 310.33 does not solve the problem.
    I discovered that the following works:
    Code :
    layout(binding = 1) buffer List
    {
    	unsigned int entry[];
    };
     
    void main(void)
    {
        uvec2 p = uvec2(gl_FragCoord.xy);
        uint index = p.x + p.y*width;
        unsigned int a = 5;
        atomicExchange(entry[index], a);
    }
    Note, that I simply removed 'list' in the buffer declaration and use 'entry' directly.

Posting Permissions

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