Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: glDrawElementsInstanced + glVertexAttribDivisor + glPrimitiveRestartIndex crash

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2010

    glDrawElementsInstanced + glVertexAttribDivisor + glPrimitiveRestartIndex crash


    I am rendering 3 identical grids, 65*65 size, computing the Z ( my vertical axis ) value in a vertex shader. To offset each grid, I am creating an array with 3 vec2 elements, sent in the vertex shader as an attribute that shifts an entire grid, thereby expecting 3 identical grids at different positions on the screen. For this, I am using glVertexAttribDivisor to specify the offsetting attribute of each grid as "per instance" instead of "per vertex".

    glVertexAttribDivisor(m_nglA_offset, 1);

    Both renderings use glDrawElementsInstanced.

    First, I am creating a single triangle strips, with degenerate strips at line ends, then call glDrawElementsInstanced and the 3 grids are rendered just fine.

    Second, I am creating a new array of indices, with 64 primitive restarts ( using restart index (~0)) and call the same code. The code crash in glDrawElementsInstanced, after setting

    glEnable(GL_PRIMITIVE_RESTART); glPrimitiveRestartIndex(~0).

    The vertex buffer is a VBO object and the 3-elements offset array is in main memory.

    I tried to specify a big advancement for glVertexAttribDivisor, but the crash remains.

    Is this normal functionality or a bug in the driver?

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jan 2007
    What format are you using for your indices - 16-bit or 32-bit? If 16-bit, then ~0 will never actually get you a primitive restart as you're specifying to restart on 0xffffffff (and when the draw command hits 0xffff in the index buffer, it's going to overflow your vertex buffers).

  3. #3
    Junior Member Newbie
    Join Date
    Dec 2010

    I think I found the problem, there was an GL_INDEX_ARRAY left enabled. I am still debugging the problem as restarting primitives seem to run much slower when running big chunks of primitives ( 32 k indices, with triangles fan restarting at each 4 indexes ). Card is an old Nvidia 9400 GT with support to opengl 2.1.

Posting Permissions

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