From 58fadc624281b3f0bbe084e3e8af28a61036ca94 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 22 May 2009 13:00:49 -0600 Subject: demos: fix multitex.c VertCoord attribute mapping If the multitex.vert shader uses the VertCoord generic vertex attribute instead of the pre-defined gl_Vertex attribute, we need to make sure that VertCoord gets bound to generic vertex attribute zero. That's because we need to call glVertexAttrib2fv(0, xy) after all the other vertex attributes have been set since setting generic attribute 0 triggers vertex submission. Before, we wound up issuing the vertex attributes in the order 0, 1, 2 which caused the first vertex to be submitted before all the attributes were set. Now, the attributes are set in 1, 2, 0 order. --- progs/glsl/multitex.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/progs/glsl/multitex.c b/progs/glsl/multitex.c index b4be463787..bbf58af055 100644 --- a/progs/glsl/multitex.c +++ b/progs/glsl/multitex.c @@ -271,9 +271,24 @@ CreateProgram(const char *vertProgFile, const char *fragProgFile, InitUniforms(program, uniforms); + VertCoord_attr = glGetAttribLocation_func(program, "VertCoord"); + if (VertCoord_attr > 0) { + /* We want the VertCoord attrib to have position zero so that + * the call to glVertexAttrib(0, xyz) triggers vertex processing. + * Otherwise, if TexCoord0 or TexCoord1 gets position 0 we'd have + * to set that attribute last (which is a PITA to manage). + */ + glBindAttribLocation_func(program, 0, "VertCoord"); + /* re-link */ + glLinkProgram_func(program); + /* VertCoord_attr should be zero now */ + VertCoord_attr = glGetAttribLocation_func(program, "VertCoord"); + assert(VertCoord_attr == 0); + } + TexCoord0_attr = glGetAttribLocation_func(program, "TexCoord0"); TexCoord1_attr = glGetAttribLocation_func(program, "TexCoord1"); - VertCoord_attr = glGetAttribLocation_func(program, "VertCoord"); + printf("TexCoord0_attr = %d\n", TexCoord0_attr); printf("TexCoord1_attr = %d\n", TexCoord1_attr); printf("VertCoord_attr = %d\n", VertCoord_attr); -- cgit v1.2.3 From c3538969e1ae3e626a618934aa8f35a7a22ddb39 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 22 May 2009 13:15:41 -0600 Subject: vbo: fix crash in vbo_exec_bind_arrays() When a vertex shader uses generic vertex attribute 0, but not gl_Vertex, we need to set attribute[16] to point to attribute[0]. We were setting the attribute size, but not the pointer. Fixes crash in glsl/multitex.c when using the VertCoord attribute instead of gl_Vertex. --- src/mesa/vbo/vbo_exec_draw.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/vbo/vbo_exec_draw.c b/src/mesa/vbo/vbo_exec_draw.c index 5381cc4d92..da2d849ded 100644 --- a/src/mesa/vbo/vbo_exec_draw.c +++ b/src/mesa/vbo/vbo_exec_draw.c @@ -185,6 +185,7 @@ static void vbo_exec_bind_arrays( GLcontext *ctx ) (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.attrptr[16] = exec->vtx.attrptr[0]; exec->vtx.attrsz[0] = 0; } break; -- cgit v1.2.3