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

Thread: gl_PrimitiveID bug in AMD Cards?

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

    gl_PrimitiveID bug in AMD Cards?

    Hi,

    We are developing a CAD application where the meshes usually are very big. For improve the performance we are painting in a unique batch all the primitives using glDrawElements.
    We are using the follow shader to generate Picking info over a FBO. With small mesh (around 2 million of primitives), all works fine but with mesh greater than of 8 millions of primitives the gl_PrimitiveID became invalid. It looks like if in a previous state, the gl_PrimitiveID was reset to zero. Is gl_PrimitiveID limited to a max number of Primitives? or is just a bug?

    The shaders we are using are this:

    Code :
    // Vertex
    #version 330
    #define POSITION    0
     
    uniform mat4 MVP_Matrix;
     
    layout(location = POSITION) in vec4 VertexPosition;
     
    void main(void)
    {
       gl_Position = MVP_Matrix * VertexPosition;
    }
     
    // Fragment
    #version 330
    #extension GL_EXT_gpu_shader4 : enable
    uniform uint gEntyID; // Object Id 
    uniform uint gSubEntyID; // Element Id
    uvec3 outFragColor;
    void main()
    {
        outFragColor = uvec3 (gEntyID,gSubEntyID,gl_PrimitiveID);
    }

    Thanks,

    Carlos.

  2. #2
    Member Regular Contributor malexander's Avatar
    Join Date
    Aug 2009
    Location
    Ontario
    Posts
    320
    We avoided this situation by drawing large meshes in chunks (500K tris), though not specifically for this case (Windows likes to reset the driver if it's not responsive after 2s, which is easily accomplished by sending a large rendering batch to low-end hardware, which was the main issue). By passing a BasePrimID uniform to the shader and adding it to the gl_PrimitiveID, the original primitive ID can be determined. This might solve the problem for your large mesh case.

    However, this does seem to be a bug with the driver.

  3. #3
    Junior Member Newbie
    Join Date
    Oct 2012
    Posts
    15
    Hi Malexander,

    Thank you for your reply.
    I have resolved it using the same technique that you propose. In my coding I am using chunk of 1Million of primitives for a firepro 4900.

    Thanks,
    Carlos.

Posting Permissions

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