From a887a44b2da48dfa50b5c19c2be9ebbef79ae2db Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 10 Jan 2005 12:30:08 +0000 Subject: [PATCH] Fix segfault in pipes by dealing with stride == 0 case in generic_interp_extras --- src/mesa/tnl/t_vertex.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/src/mesa/tnl/t_vertex.c b/src/mesa/tnl/t_vertex.c index e88df0707f1..2ed4c417590 100644 --- a/src/mesa/tnl/t_vertex.c +++ b/src/mesa/tnl/t_vertex.c @@ -1031,22 +1031,30 @@ static void generic_interp_extras( GLcontext *ctx, { struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - if (VB->ColorPtr[1]) { + /* If stride is zero, ColorPtr[1] is constant across the VB, so + * there is no point interpolating between two values as they will + * be identical. In all other cases, this value is generated by + * t_vb_lighttmp.h and has a stride of 4 dwords. + */ + if (VB->ColorPtr[1] && VB->ColorPtr[1]->stride) { assert(VB->ColorPtr[1]->stride == 4 * sizeof(GLfloat)); INTERP_4F( t, VB->ColorPtr[1]->data[dst], VB->ColorPtr[1]->data[out], VB->ColorPtr[1]->data[in] ); + } - if (VB->SecondaryColorPtr[1]) { - INTERP_3F( t, - VB->SecondaryColorPtr[1]->data[dst], - VB->SecondaryColorPtr[1]->data[out], - VB->SecondaryColorPtr[1]->data[in] ); - } + if (VB->SecondaryColorPtr[1]) { + assert(VB->SecondaryColorPtr[1]->stride == 4 * sizeof(GLfloat)); + + INTERP_3F( t, + VB->SecondaryColorPtr[1]->data[dst], + VB->SecondaryColorPtr[1]->data[out], + VB->SecondaryColorPtr[1]->data[in] ); } - else if (VB->IndexPtr[1]) { + + if (VB->IndexPtr[1]) { VB->IndexPtr[1]->data[dst][0] = LINTERP( t, VB->IndexPtr[1]->data[out][0], VB->IndexPtr[1]->data[in][0] ); @@ -1064,16 +1072,19 @@ static void generic_copy_pv_extras( GLcontext *ctx, { struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - if (VB->ColorPtr[1]) { + /* See above comment: + */ + if (VB->ColorPtr[1] && VB->ColorPtr[1]->stride) { COPY_4FV( VB->ColorPtr[1]->data[dst], VB->ColorPtr[1]->data[src] ); + } - if (VB->SecondaryColorPtr[1]) { - COPY_4FV( VB->SecondaryColorPtr[1]->data[dst], - VB->SecondaryColorPtr[1]->data[src] ); - } + if (VB->SecondaryColorPtr[1]) { + COPY_4FV( VB->SecondaryColorPtr[1]->data[dst], + VB->SecondaryColorPtr[1]->data[src] ); } - else if (VB->IndexPtr[1]) { + + if (VB->IndexPtr[1]) { VB->IndexPtr[1]->data[dst][0] = VB->IndexPtr[1]->data[src][0]; } -- 2.30.2