[Mesa-dev] [PATCH 00/13] Fix gl_VertexID on i965

Ian Romanick idr at freedesktop.org
Mon Jun 23 10:57:28 PDT 2014

On 06/21/2014 08:36 AM, Roland Scheidegger wrote:
> Am 21.06.2014 03:00, schrieb Ian Romanick:
>> This patch series fixes bugs in the i965 w.r.t. several uses of
>> gl_VertexID.  OpenGL (desktop and ES) have the following expectations of
>> gl_VertexID:
>> 1. When used with BaseVertex drawing commands, gl_VertexID will include
>> the value of basevertex.  This differens from "the other API," but the
>> change in OpenGL was based on feedback from application developers.
>> This only affects OpenGL 3.2+.
> I don't question this, but note some binary drivers may not agree. There
> are unforunately lots of man pages around of
> glDrawElementsInstancedBaseVertexBaseInstance too which state:
> "The basevertex has no effect on the shader-visible value of
> gl_VertexID." There's a bug filed about this
> (https://www.khronos.org/bugzilla/show_bug.cgi?id=932) which is still
> open though maybe it has all been resolved...
> (I'll just mention that llvmpipe right now will do d3d10-style vertexID
> though I guess indeed at some point we need to make it either switchable
> or implement GL_ARB_shader_draw_parameters so it can be worked around
> easily in the state tracker.)

It doesn't matter what their documentation says... there are desktop
OpenGL conformance tests that expect this behavior. :(  See also the
overview of GL_ARB_shader_draw_parameters (emphasis mine):

        In unextended GL, vertex shaders have inputs named gl_VertexID and
    gl_InstanceID, which contain, respectively the index of the vertex and
    instance. The value of gl_VertexID is the implicitly passed index of the
    vertex being processed, which *includes the value of baseVertex*, for those
    commands that accept it. Meanwhile, gl_InstanceID is the integer index
    of the current instance being processed, but, even for commands that
    accept a baseInstance parameter, it does not include the value of this
    argument. Furthermore, the equivalents to these variables in other
    graphics APIs do not necessarily follow these conventions. The reason for
    this inconsistency is that there are legitimate use cases for both
    inclusion and exclusion of the baseVertex or baseInstance parameters
    in gl_VertexID and gl_InstanceID, respectively.

> Roland

More information about the mesa-dev mailing list