On Mon, 04 Oct 2004 12:09:09 +0100 Keith Whitwell <[EMAIL PROTECTED]> wrote:
> John, > > I'd say the problem is with these lines in savagetris.c: > > > if (index & (_TNL_BIT_COLOR1|_TNL_BIT_FOG)) { > EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR, SAVAGE_HW_NO_CS ); > EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F, SAVAGE_HW_NO_CS ); > } > > This is a cut and paste of old code from another driver. Have a look at how > other drivers handle this now to avoid trying to emit FOG when only COLOR1 is > enabled, and vice versa. Is there a simpler test case than RTCW? I can't reproduce a segfault with a simple program that draws triangles with diffuse lighting and Fog. John, can you try if the attached patch fixes it? > > Keith > Regards, Felix | Felix Kühling <[EMAIL PROTECTED]> http://fxk.de.vu | | PGP Fingerprint: 6A3C 9566 5B30 DDED 73C3 B152 151C 5CC1 D888 E595 |
Index: savagetris.c =================================================================== RCS file: /cvs/mesa/Mesa/src/mesa/drivers/dri/savage/savagetris.c,v retrieving revision 1.12 diff -u -r1.12 savagetris.c --- savagetris.c 1 Jul 2004 13:14:06 -0000 1.12 +++ savagetris.c 6 Oct 2004 11:46:34 -0000 @@ -715,6 +715,15 @@ drawCmd &= ~SKIP; \ } while (0) +#define EMIT_PAD( N ) \ +do { \ + imesa->vertex_attrs[imesa->vertex_attr_count].attrib = 0; \ + imesa->vertex_attrs[imesa->vertex_attr_count].format = EMIT_PAD; \ + imesa->vertex_attrs[imesa->vertex_attr_count].offset = (N); \ + imesa->vertex_attr_count++; \ +} while (0) + + static void savageRenderStart( GLcontext *ctx ) { savageContextPtr imesa = SAVAGE_CONTEXT(ctx); @@ -745,8 +754,14 @@ EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA, SAVAGE_HW_NO_CD ); if (index & (_TNL_BIT_COLOR1|_TNL_BIT_FOG)) { - EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR, SAVAGE_HW_NO_CS ); - EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F, SAVAGE_HW_NO_CS ); + if ((index & _TNL_BIT_COLOR1)) + EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR, SAVAGE_HW_NO_CS ); + else + EMIT_PAD( 3 ); + if ((index & _TNL_BIT_FOG)) + EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F, SAVAGE_HW_NO_CS ); + else + EMIT_PAD( 1 ); } if (index & _TNL_BIT_TEX(0)) {