0 Replies Latest reply on Oct 17, 2014 2:05 AM by fletcheb

    GL_ARB_shader_storage_buffer_object ".length()" for unsized arrays returns erroneous value

    fletcheb

      I am using OpenGL 4.3 core profile to do various things in OpenGL under Linux.  I am having trouble when using shader storage buffers where the last component of a shader storage block is an unsized array.  I do not have this problem when using the NVIDIA driver.  Is this a driver bug, or am I doing something wrong??

       

       

      Description of problem:

       

      It appears that the ".length()" function for unsized arrays at the end of shader storage blocks always returns 0. This is contrary to the specification for GL_ARB_shader_storage_buffer_object where "Issue (19)" describes ".length()" as returning the size of unsized arrays based on the size of the provided buffer object.

       

       

      Steps to reproduce:

      1. Include a shader with a shader storage block containing an unsized array as the last component

       

      ...

      layout(std430, binding=0) buffer Test

      {

        float test[];

      }

      ...

       

      2. Bind a shader storage buffer with a size equivalent to the desired shader storage block unsized array size in bytes

       

      ...

      GLuint testBuffer;

      glGenBuffers(1, &testBuffer);

      glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, testBuffer);

      glBufferData(GL_SHADER_STORAGE_BUFFER, sizeof(float)*4, NULL, GL_DYNAMIC_DRAW);

      ...

       

      3. In the shader, access the shader storage block unsized array ".length()" function and check that it contains the number of elements we allocated via

      glBufferData.

       

      ...

      int elements = test.length();

       

      if(elements!=4)

      {

        // the .length() function has returned a value outside the

        // GL_ARB_shader_storage_buffer_object specification

      }

      ...

       

       

      Actual result:

       

      elements = 0

       

      Expected result:

       

      elements = 4