I have posted this on the beginners forum in OpenGl but thought it might be better here
I have a problem I do not understand. The following code works in a simple test program on AMD - in a more complex program something is affecting glDrawArrays offset index.
The code works correctly in both programs on nVidia
glVertexAttribPointer(VERTEX_BINDINGS_POSITION, 3, GL_FLOAT, GL_FALSE, sizeof(C3D_VertexC), 0);
glVertexAttribPointer(VERTEX_BINDINGS_COLOUR, 4,GL_UNSIGNED_BYTE, GL_TRUE,sizeof(C3D_VertexC),(const void*)(sizeof(float)*3));
for (int i = 0; i < 5; i++)
float x = (float)i;
v.x = (x-10.0f)/10.0f;
v.y = 0;
v.z = 0;
v.rgba = 255;
glBufferData(GL_ARRAY_BUFFER, sizeof(C3D_VertexC)*20, NULL, GL_STATIC_DRAW);
// this draws the 5 points in the correct location on the screen
// glBufferSubData(GL_ARRAY_BUFFER, sizeof(C3D_VertexC)*12, // sizeof(C3D_VertexC)*5, v);
// all verices drawn at 0,0,0 in black
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(C3D_VertexC)*5, v);
glDrawArrays(GL_POINTS, 0, 5);
What can affect the first vertex used in glDrawArrays?
The problems seems to be caused by using this code prior to the above code
I changed this to
and the code now works
I'm not sure why this might be causing a problem. When you changed your glDrawElementsIndirect code to use the absolute address of the array rather than the indirect buffer, you caused the driver to fetch the draw parameters from client memory. This is not directly supported by the hardware and so the driver emulates this with independent draw calls and is therefore equivalent to a simple loop in the application (minus a small amount of driver overhead).
Off the top of my head, the only thing I can think of is that there's some state leak GPU side, but I would consider that very unlikely. To really debug this, we'll need a test case that reproduces the issue. Besides the code you've already posted, do you have anything you'd be willing to share?
I will see if I can produce it in a simpler program