Results 1 to 7 of 7

Thread: Shader storage buffer bug in Catalyst 13.4

  1. #1
    Member Contributor
    Join Date
    Jul 2003
    Location
    Faro, Portugal
    Posts
    90

    Shader storage buffer bug in Catalyst 13.4

    Hello guys,

    AMD added support for OpenGL 4.3 in their latest 13.4 driver but it seems they have a bug on their implementation of Shader Buffer Objects. I have a shader that increments an atomic counter and uses it as an index to write to a Shader Buffer Object buffer that hold points data. The buffer is big enough to old 100.000 points but the shader is only writting the first 1696 points.

    I can see this because after running the shader I map the atomic counter and the point buffer to look at their contents. The point buffer is only filled to the first 1696 positions although the atomic counter was incremented beyond that value. It seems the shader is assuming that the array has only 1696 elements, this is confirmed by the bokehPoints.length() that I'm writting into the buffer which returns precisely 1696. The extension specification says that we can query the size of the attached shader buffer object with glGetInteger64i_v(GL_SHADER_STORAGE_BUFFER_SIZE, 1, &value) which in my case it returns the expected value of 3.200.000 which represents sizeof(Point) * 100000 and not sizeof(Point) * 1696.

    So to sum up, the shader is assuming that the array is smaller than it actually is. Note that I have no problems running this stuff on NVidia cards so I'd like to know if anyone is experienced the same problems with AMD or if it's me who is doing something wrong.

    This is how the buffer is created:

    Code :
    glGenBuffers(1, &bokehPointsBufferID);
    glBindBuffer(GL_SHADER_STORAGE_BUFFER, bokehPointsBufferID);
    glBufferData(GL_SHADER_STORAGE_BUFFER, sizeof(Point) * 100000, NULL, GL_DYNAMIC_DRAW);
    glBindBuffer(GL_SHADER_STORAGE_BUFFER, 0);

    These are the rendering commands:

    Code :
    //Reset the value of the atomic counter and bind it.
    GLuint resetValue = 0;
    glNamedBufferSubDataEXT(depthOfField.getBokehPointsAtomicCounter(), 0, sizeof(GLuint), &resetValue);
    glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, 0, 0);
     
    //Bind the points buffer.
    glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, bokehPointsBufferID);
     
    //Draw full screen quad.
    //NOTE: I know glBegin/glEnd is evil.
    glBegin(GL_QUADS);
    glVertex3f(0, 0, 0);
    glVertex3f(1, 0, 0);
    glVertex3f(1, 1, 0);
    glVertex3f(0, 1, 0);
    glEnd();
     
    glMemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT | GL_ATOMIC_COUNTER_BARRIER_BIT);

    Declaration of the atomic counter and shader buffer object in the shader:

    Code :
    struct BokehPoint
    {
        vec4    position;
        vec4    colorAndRadius;
    };
     
    layout (binding = 0, offset = 0) uniform atomic_uint bokehPointCounter;
     
    layout (packed, binding = 1) buffer BokehPointBuffer
    {
        writeonly BokehPoint bokehPoints[];
    };

    And this is how I write to the buffer in the shader:

    Code :
    uint index = atomicCounterIncrement(bokehPointCounter);
    bokehPoints[index].position = vec4(texCoord, 0.0, float(bokehPoints.length()));
    bokehPoints[index].colorAndRadius = vec4(color * scale, radius);

  2. #2
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,674
    What happens if you use binding 0 rather than binding 1 for your storage buffer?

  3. #3
    Member Contributor
    Join Date
    Jul 2003
    Location
    Faro, Portugal
    Posts
    90
    Quote Originally Posted by Alfonse Reinheart View Post
    What happens if you use binding 0 rather than binding 1 for your storage buffer?
    The problem remains.

  4. #4
    Member Contributor
    Join Date
    Jul 2003
    Location
    Faro, Portugal
    Posts
    90
    So, anybody got any more ideas? I'm really stuck on this.

  5. #5
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,674
    Wait for AMD to fix their drivers. Or rewrite your code to not use SSBOs.

  6. #6
    Member Contributor
    Join Date
    Jul 2003
    Location
    Faro, Portugal
    Posts
    90
    Oh well, it doesn't seem like I have a choice.
    I've tested their new Beta driver version 13.6 and it still has the same issue so there's no hope for the near future. Let's hope they fix it on later releases.

    Thanks for the help.

  7. #7
    Senior Member OpenGL Lord
    Join Date
    Mar 2015
    Posts
    6,674
    That's no surprise. When GL 3.3 came out, it took them about 6 months to implement sampler objects. And then 9 months on top of that to implement them correctly.

Similar Threads

  1. shader storage buffer mat4x3[] array
    By Christoph.LGDV in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 04-06-2017, 06:47 AM
  2. Get Shader Storage Buffer Object to work
    By FonzTech in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 09-09-2016, 02:35 PM
  3. shader storage buffer objects within geometry shader
    By minidrive in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 07-14-2014, 08:43 AM
  4. how to read atomic counter value using shader storage buffer
    By neha.bhende in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 10-04-2013, 01:55 AM
  5. Replies: 3
    Last Post: 04-16-2013, 01:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean