[Mesa-dev] [PATCH] mesa/vbo: Treat attribute 0 and vertex as the same

Ian Romanick idr at freedesktop.org
Thu Oct 13 16:34:10 PDT 2011


From: Ian Romanick <ian.d.romanick at intel.com>

This is supported by the pseudo-code on pages 27 and 28 (pages 41 and
42 of the PDF) of the OpenGL 2.1 spec.  The last part of the
implementation of ArrayElement is:

    if (generic attribute array 0 enabled) {
      if (generic vertex attribute 0 array normalization flag is set, and
	  type is not FLOAT or DOUBLE)
	VertexAttrib[size]N[type]v(0, generic vertex attribute 0 array element i);
      else
	VertexAttrib[size][type]v(0, generic vertex attribute 0 array element i);
    } else if (vertex array enabled) {
      Vertex[size][type]v(vertex array element i);
    }

Page 23 (page 37 of the PDF) of the same spec says:

    "Setting generic vertex attribute zero specifies a vertex; the
    four vertex coordinates are taken from the values of attribute
    zero. A Vertex2, Vertex3, or Vertex4 command is completely
    equivalent to the corresponding VertexAttrib* command with an
    index of zero."

Fixes piglit test attribute0.

NOTE: This is a candidate for stable branches.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 src/mesa/vbo/vbo_exec_array.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c
index 18719d5..ceb6a64 100644
--- a/src/mesa/vbo/vbo_exec_array.c
+++ b/src/mesa/vbo/vbo_exec_array.c
@@ -538,7 +538,7 @@ recalculate_input_bindings(struct gl_context *ctx)
          }
       }
 
-      for (i = 0; i < MAX_VERTEX_GENERIC_ATTRIBS; i++) {
+      for (i = 1; i < MAX_VERTEX_GENERIC_ATTRIBS; i++) {
 	 if (exec->array.generic_array[i]->Enabled)
 	    inputs[VERT_ATTRIB_GENERIC0 + i] = exec->array.generic_array[i];
 	 else {
@@ -547,6 +547,7 @@ recalculate_input_bindings(struct gl_context *ctx)
          }
       }
 
+      inputs[VERT_ATTRIB_GENERIC0] = inputs[0];
       ctx->NewState |= _NEW_ARRAY;
       break;
    }
-- 
1.7.6.4



More information about the mesa-dev mailing list