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".
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
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?
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).
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.