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+.

2. When used with DrawArrays drawing commands, gl_VertexID will count
from the 'start' value instead of zero.  This affects OpenGL 3.0+ and
OpenGL ES 3.0+.

The i965 driver botched both of these for slightly different reasons.
For #1, our hardware was designed with the "other API's" semantic in
mind, so gl_VertexID doesn't include the basevertex value.

For #2, we implement DrawArrays with a non-zero start index by
reprogramming the array base offset.  As a result, gl_VertexID always
counts from zero.

I suspect other hardware may suffer from one or both of these issues.  I
have sent tests to the piglit list to reproduce them.

To fix both of these issues, the shader needs to know the basevertex
value.  A later GL extension, GL_ARB_shader_draw_parameters, adds
gl_BaseVertex and gl_BaseInstance as built-in variables.  I believe some
hardware implements these as system values much like gl_VertexID.

I started this series with the assumption that we could have a
SYSTEM_VALUE_BASE_VERTEX that might come from a uniform.  In the end, I
couldn't make that work.  I left patch 7 in the series, but we may want
to remove it.

I added a STATE_BASE_VERTEX uniform instead.

There is now a lowering pass that converts gl_VertexID to
gl_VertexIDMESA + gl_BaseVertex (backed by a uniform).  Some of these
names should probably be changed.

I have also contemplated adding an extension that exposes the other
semantic for gl_VertexID for applications that actually want that.  This
is primarily things that are porting content (or "bridging" content)
from the other API.  That, however, can happen later.

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to