Calling glDrawArrays(mode,first,count) with non-zero first parameter behaves differently on ATI/Nvidia with respect to the gl_VertexID built-in variable. On Nvidia, the gl_VertexID contains the values from first to first+count, but on ATI the indices always start from zero.
I’m not sure what is the correct behavior. The specification says only that “gl_VertexID holds the integer index i implicitly passed by DrawArrays or one of the other drawing commands …”. As far as I can see it doesn’t explicitly say what the indices should be with respect to the value of first.
Can anyone tell what should be the correct interpretation?
PS: Tested with mode=GL_POINTS, Nvidia 196.21 driver and ATI 10.2 driver.
This is an unfortunate case where the 3.2 core spec is missing vital information provided by the 3.2 compatibility spec.
The value ‘i’ is the implicit value that is used for glArrayElement; all of the array commands are defined in terms of this function. Of course, since this function isn’t in 3.2 core, it is removed as well as explicit references to it. Implicit references to it, like referring to the index ‘i’, are not.
In any case, the NVIDIA behavior is (not unsurprisingly) correct in this case.
do you see the same behavior for both client side data and vertex side data (on either nvidia/amd) ?
We are only using it with GPU side VBOs, but I can test it with CPU-side buffers, if it can help.
(fyi, I think that you will see the same behavior on amd with vertexid starting from 0)
Yes, it’s the same behavior. So, is it a bug in amd driver?
A quick note: apparently when using the basevertex in glDrawElementsBaseVertex, gl_VertexID contains the values from the index buffer, without basevertex value being added to it (tested on Nvidia)
Is this the correct behavior in this case?
the behavior you describe is the expected one in our current implementation (i.e. no offset on either client/server). we will try to clarify the expected behavior and get back to you
Update on the status of the problem:
With recent AMD drivers, when using glDrawElementsBaseVertex the built-in shader variable gl_VertexID now contains the value of basevertex+index, which is I believe the correct behavior.
However, several releases ago Nvidia drivers started to exhibit the (wrong) behavior as well (gl_Vertex containing just the index), so the behavior is again different between the two