From dea0d4d56326f148a42c766bdbaf1b5bb247cc59 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 2 Feb 2009 16:33:08 -0700 Subject: mesa: fix GLSL issue preventing use of all 16 generic vertex attributes Only 15 actually worked before since we always reserved generic[0] as an alias for vertex position. The case of vertex attribute 0 is tricky. The spec says that there is no aliasing between generic vertex attributes 0..MAX_VERTEX_ATTRIBS-1 and the conventional attributes. But it also says that calls to glVertexAttrib(0, v) are equivalent to glVertex(v). The distinction seems to be in glVertex-mode versus vertex array mode. So update the VBO code so that if the shader uses generic[0] but not gl_Vertex, route the attribute data set with glVertex() to go to shader input generic[0]. No change needed for the glDrawArrays/Elements() path. This is a potentially risky change so regressions are possible. All the usual tests seem OK though. --- src/mesa/vbo/vbo_exec_draw.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/mesa/vbo/vbo_exec_draw.c') diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index 5b2e3550ca..7204aec1dc 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -175,7 +175,20 @@ static void vbo_exec_bind_arrays( GLcontext *ctx ) exec->vtx.inputs[attr + 16] = &vbo->generic_currval[attr]; } map = vbo->map_vp_arb; + + /* check if VERT_ATTRIB_POS is not read but VERT_BIT_GENERIC0 is read. + * In that case we effectively need to route the data from + * glVertexAttrib(0, val) calls to feed into the GENERIC0 input. + */ + if ((ctx->VertexProgram._Current->Base.InputsRead & VERT_BIT_POS) == 0 && + (ctx->VertexProgram._Current->Base.InputsRead & VERT_BIT_GENERIC0)) { + exec->vtx.inputs[16] = exec->vtx.inputs[0]; + exec->vtx.attrsz[16] = exec->vtx.attrsz[0]; + exec->vtx.attrsz[0] = 0; + } break; + default: + assert(0); } /* Make all active attributes (including edgeflag) available as -- cgit v1.2.3