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: glDrawArraysIndirect and gl_VertexID

Threaded View

  1. #1
    Newbie Newbie
    Join Date
    May 2013
    Posts
    3

    AMD 13.4 Beta: glDrawArraysIndirect and gl_VertexID bug

    I'm not 100% positive what the correct behavior is here, but on NVIDIA hardware, gl_VertexID = first + [vertex index]. So if I specify first=2, count = 6, then the values for gl_VertexID in each instance of the shader are: 2, 3, 4, 5, 6, 7. However on AMD hardware, gl_VertexID always starts at 0. When calling glDrawArrays with no bound attributes, the behavior between NVIDIA and AMD is the same and correct. Has anybody else experienced this issue on AMD hardware?

    Code :
    typedef struct
    {
        GLuint count;
        GLuint instanceCount;
        GLuint first;
        GLuint baseInstance;
    } DrawArraysIndirectCommand;
     
    DrawArraysIndirectCommand command;
    command.count = 6;
    command.instanceCount = 1;
    command.first = 4;
    command.baseInstance = 0;
     
    glGenBuffers(1, &indirectBuffer);
    glBindBuffer(GL_DRAW_INDIRECT_BUFFER, indirectBuffer);
    glBufferData(GL_DRAW_INDIRECT_BUFFER, sizeof(DrawArraysIndirectCommand), &command, GL_STATIC_DRAW);
    glBindBuffer(GL_DRAW_INDIRECT_BUFFER, 0);

    Code :
    glBindVertexArray(dummyVao);
    glBindBuffer(GL_DRAW_INDIRECT_BUFFER, indirectBuffer);
    glDrawArraysIndirect(GL_POINTS, 0);
    glBindBuffer(GL_DRAW_INDIRECT_BUFFER, 0);
    glBindVertexArray(0);

    Code :
    #version 430 core
     
    layout (std430, binding = 0) buffer BufferObject
    {
        int data[];  
    };
     
    uniform mat4 ModelViewProjectionMatrix;
     
    void main()
    {
        data[gl_VertexID] = gl_VertexID;
        gl_Position = ModelViewProjectionMatrix * vec4(gl_VertexID, 0.0, 0.0, 1.0);
    }
    Last edited by soconnell; 07-26-2013 at 09:41 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
  •