From: Keith Whitwell Date: Wed, 1 Aug 2001 05:10:42 +0000 (+0000) Subject: Fix copying problem (light spots) on evaluated surfaces. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c618005dcff0d4011a77cfebd109880eb784d581;p=mesa.git Fix copying problem (light spots) on evaluated surfaces. --- diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h index 7142f316165..afa7b3fe001 100644 --- a/src/mesa/tnl/t_context.h +++ b/src/mesa/tnl/t_context.h @@ -1,4 +1,4 @@ -/* $Id: t_context.h,v 1.30 2001/07/12 22:09:22 keithw Exp $ */ +/* $Id: t_context.h,v 1.31 2001/08/01 05:10:42 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -189,6 +189,7 @@ struct immediate GLuint CopyOrFlag; GLuint CopyAndFlag; GLuint CopyTexSize; + GLuint Evaluated; /* allocate storage for these on demand: diff --git a/src/mesa/tnl/t_imm_debug.c b/src/mesa/tnl/t_imm_debug.c index d641ee10493..78121f9e5a6 100644 --- a/src/mesa/tnl/t_imm_debug.c +++ b/src/mesa/tnl/t_imm_debug.c @@ -1,4 +1,4 @@ -/* $Id: t_imm_debug.c,v 1.3 2001/04/28 08:39:18 keithw Exp $ */ +/* $Id: t_imm_debug.c,v 1.4 2001/08/01 05:10:42 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -66,7 +66,7 @@ void _tnl_print_cassette( struct immediate *IM ) GLuint i; GLuint *flags = IM->Flag; GLuint andflag = IM->CopyAndFlag; - GLuint orflag = IM->CopyOrFlag; + GLuint orflag = (IM->CopyOrFlag|IM->Evaluated); GLuint state = IM->BeginState; GLuint req = ~0; diff --git a/src/mesa/tnl/t_imm_eval.c b/src/mesa/tnl/t_imm_eval.c index f6d33dfa1a4..1ae006666fd 100644 --- a/src/mesa/tnl/t_imm_eval.c +++ b/src/mesa/tnl/t_imm_eval.c @@ -1,4 +1,4 @@ -/* $Id: t_imm_eval.c,v 1.13 2001/05/14 09:00:51 keithw Exp $ */ +/* $Id: t_imm_eval.c,v 1.14 2001/08/01 05:10:42 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -343,7 +343,14 @@ static void copy_4f_stride( GLfloat to[][4], GLfloat *from, static void copy_3f( GLfloat to[][3], GLfloat from[][3], GLuint count ) { - MEMCPY( to, from, (count) * sizeof(to[0])); + int i; +/* MEMCPY( to, from, (count) * sizeof(to[0])); */ + for (i = 0 ; i < count ; i++) { +/* fprintf(stderr, "copy norm %d from %p: %f %f %f\n", i, */ +/* from[i], */ +/* from[i][0], from[i][1], from[i][2]); */ + COPY_3FV(to[i], from[i]); + } } @@ -442,8 +449,8 @@ void _tnl_eval_immediate( GLcontext *ctx, struct immediate *IM ) else copycount = IM->Count - IM->CopyStart; /* copy all vertices */ -/* fprintf(stderr, "%s copystart %d start %d count %d copycount %d\n", */ -/* __FUNCTION__, IM->CopyStart, IM->Start, IM->Count, copycount); */ +/* fprintf(stderr, "%s copystart %d start %d count %d copycount %d\n", */ +/* __FUNCTION__, IM->CopyStart, IM->Start, IM->Count, copycount); */ if (!store) store = tnl->eval.im = _tnl_alloc_immediate( ctx ); @@ -509,16 +516,6 @@ void _tnl_eval_immediate( GLcontext *ctx, struct immediate *IM ) eval2_1ui( &tmp->Index, coord, flags, &ctx->EvalMap.Map2Index ); generated |= VERT_EVAL_C2|VERT_EVAL_P2; } - - /* Propogate values to generate correct vertices when vertex - * maps are disabled. - */ - if (purge_flags & generated) - _tnl_fixup_1ui( tmp->Index.data, flags, 0, - VERT_INDEX| - VERT_OBJ| - generated| - (VERT_EVAL_ANY&~purge_flags) ); } if (req & VERT_RGBA) @@ -545,17 +542,6 @@ void _tnl_eval_immediate( GLcontext *ctx, struct immediate *IM ) eval2_4f_ca( &tmp->Color, coord, flags, 4, &ctx->EvalMap.Map2Color4 ); generated |= VERT_EVAL_C2|VERT_EVAL_P2; } - - /* Propogate values to generate correct vertices when vertex - * maps are disabled. - */ - if (purge_flags & generated) - _tnl_fixup_4f( store->Color + IM->CopyStart, - flags, 0, - VERT_RGBA| - VERT_OBJ| - generated| - (VERT_EVAL_ANY&~purge_flags) ); } @@ -617,16 +603,6 @@ void _tnl_eval_immediate( GLcontext *ctx, struct immediate *IM ) generated |= VERT_EVAL_C2|VERT_EVAL_P2; } } - - /* Propogate values to generate correct vertices when vertex - * maps are disabled. - */ - if (purge_flags & generated) - _tnl_fixup_4f( tmp->TexCoord[0].data, flags, 0, - VERT_TEX0| - VERT_OBJ| - generated| - (VERT_EVAL_ANY&~purge_flags) ); } @@ -635,7 +611,7 @@ void _tnl_eval_immediate( GLcontext *ctx, struct immediate *IM ) GLuint generated = 0; if (copycount) { -/* fprintf(stderr, "%s: Copy normals\n", __FUNCTION__); */ +/* fprintf(stderr, "%s: Copy normals\n", __FUNCTION__); */ copy_3f( store->Normal + IM->CopyStart, tmp->Normal.data, copycount ); } @@ -654,16 +630,6 @@ void _tnl_eval_immediate( GLcontext *ctx, struct immediate *IM ) &ctx->EvalMap.Map2Normal ); generated |= VERT_EVAL_C2|VERT_EVAL_P2; } - - /* Propogate values to generate correct vertices when vertex - * maps are disabled. - */ - if (purge_flags & generated) - _tnl_fixup_3f( tmp->Normal.data, flags, 0, - VERT_NORM| - VERT_OBJ| - generated| - (VERT_EVAL_ANY&~purge_flags) ); } @@ -723,8 +689,9 @@ void _tnl_eval_immediate( GLcontext *ctx, struct immediate *IM ) /* Calculate new IM->Elts, IM->Primitive, IM->PrimitiveLength for - * the case where vertex maps are not enabled for some received eval - * coordinates. + * the case where vertex maps are not enabled for some received + * eval coordinates. In this case those slots in the immediate + * must be ignored. */ if (purge_flags) { GLuint vertex = VERT_OBJ|(VERT_EVAL_ANY & ~purge_flags); @@ -763,6 +730,6 @@ void _tnl_eval_immediate( GLcontext *ctx, struct immediate *IM ) tnl->vb.Flag = store->Flag; for (i = 0 ; i < count ; i++) store->Flag[i] |= req; - IM->CopyOrFlag |= req; /* hack for copying. */ + IM->Evaluated = req; /* hack for copying. */ } } diff --git a/src/mesa/tnl/t_imm_exec.c b/src/mesa/tnl/t_imm_exec.c index 547af43a397..b99260bfbc5 100644 --- a/src/mesa/tnl/t_imm_exec.c +++ b/src/mesa/tnl/t_imm_exec.c @@ -1,4 +1,4 @@ -/* $Id: t_imm_exec.c,v 1.27 2001/06/28 17:34:14 keithw Exp $ */ +/* $Id: t_imm_exec.c,v 1.28 2001/08/01 05:10:42 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -199,6 +199,7 @@ void _tnl_compute_orflag( struct immediate *IM, GLuint start ) IM->Flag[IM->LastData+1] |= VERT_END_VB; IM->CopyAndFlag = IM->AndFlag = andflag; IM->CopyOrFlag = IM->OrFlag = orflag; + IM->Evaluated = 0; } diff --git a/src/mesa/tnl/t_imm_fixup.c b/src/mesa/tnl/t_imm_fixup.c index 607235d327b..b5f191e3a38 100644 --- a/src/mesa/tnl/t_imm_fixup.c +++ b/src/mesa/tnl/t_imm_fixup.c @@ -1,4 +1,4 @@ -/* $Id: t_imm_fixup.c,v 1.23 2001/07/17 21:44:37 keithw Exp $ */ +/* $Id: t_imm_fixup.c,v 1.24 2001/08/01 05:10:42 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -74,8 +74,14 @@ _tnl_fixup_3f( float data[][3], GLuint flag[], GLuint start, GLuint match ) { GLuint i = start; + for (;;) { if ((flag[++i] & match) == 0) { +/* fprintf(stderr, "_tnl_fixup_3f copy to %p values %f %f %f\n", */ +/* data[i], */ +/* data[i-1][0], */ +/* data[i-1][1], */ +/* data[i-1][2]); */ COPY_3V(data[i], data[i-1]); if (flag[i] & VERT_END_VB) break; } @@ -145,6 +151,8 @@ fixup_first_3f( GLfloat data[][3], GLuint flag[], GLuint match, GLuint i = start-1; match |= VERT_END_VB; +/* fprintf(stderr, "fixup_first_3f\n"); */ + while ((flag[++i]&match) == 0) COPY_3FV(data[i], dflt); } @@ -190,7 +198,7 @@ void _tnl_fixup_input( GLcontext *ctx, struct immediate *IM ) TNLcontext *tnl = TNL_CONTEXT(ctx); GLuint start = IM->CopyStart; GLuint andflag = IM->CopyAndFlag; - GLuint orflag = IM->CopyOrFlag; + GLuint orflag = IM->CopyOrFlag | IM->Evaluated; GLuint fixup; IM->CopyTexSize = IM->TexSize; @@ -421,23 +429,21 @@ void _tnl_copy_immediate_vertices( GLcontext *ctx, struct immediate *next ) next->CopyAndFlag &= VERT_ELT; } else { - /* prev->CopyOrFlag is hacked to include values generated by eval: - */ - GLuint copy = tnl->pipeline.inputs & prev->CopyOrFlag; + GLuint copy = tnl->pipeline.inputs & (prev->CopyOrFlag|prev->Evaluated); GLuint flag; if (is_fan_like[ctx->Driver.CurrentExecPrimitive]) { - next->TexSize |= tnl->ExecCopyTexSize; - next->CopyOrFlag |= (prev->CopyOrFlag & VERT_FIXUP); - next->CopyAndFlag &= (prev->CopyOrFlag & VERT_FIXUP); - flag = (prev->CopyOrFlag & VERT_FIXUP); + flag = ((prev->CopyOrFlag|prev->Evaluated) & VERT_FIXUP); + next->CopyOrFlag |= flag; } else { /* Don't let an early 'glColor', etc. poison the elt path. */ - next->CopyAndFlag &= (prev->OrFlag & VERT_FIXUP); - flag = (prev->OrFlag & VERT_FIXUP); + flag = ((prev->OrFlag|prev->Evaluated) & VERT_FIXUP); } + + next->TexSize |= tnl->ExecCopyTexSize; + next->CopyAndFlag &= flag; /* Copy whole vertices @@ -455,8 +461,15 @@ void _tnl_copy_immediate_vertices( GLcontext *ctx, struct immediate *next ) */ COPY_4FV( next->Obj[dst], inputs->Obj.data[isrc] ); - if (copy & VERT_NORM) + if (copy & VERT_NORM) { +/* fprintf(stderr, "copy vert norm %d to %d (%p): %f %f %f\n", */ +/* isrc, dst, */ +/* next->Normal[dst], */ +/* inputs->Normal.data[isrc][0], */ +/* inputs->Normal.data[isrc][1], */ +/* inputs->Normal.data[isrc][2]); */ COPY_3FV( next->Normal[dst], inputs->Normal.data[isrc] ); + } if (copy & VERT_RGBA) COPY_4FV( next->Color[dst], @@ -490,8 +503,7 @@ void _tnl_copy_immediate_vertices( GLcontext *ctx, struct immediate *next ) } next->Flag[dst] = flag; - next->OrFlag |= prev->Flag[src]; /* for non-fanlike prims, - otherwise redundant */ + next->CopyOrFlag |= prev->Flag[src]; } } @@ -514,6 +526,7 @@ void _tnl_fixup_compiled_cassette( GLcontext *ctx, struct immediate *IM ) GLuint fixup; GLuint start = IM->Start; + IM->Evaluated = 0; IM->CopyOrFlag = IM->OrFlag; IM->CopyAndFlag = IM->AndFlag; IM->CopyTexSize = IM->TexSize | tnl->ExecCopyTexSize; diff --git a/src/mesa/tnl/t_vb_lighttmp.h b/src/mesa/tnl/t_vb_lighttmp.h index ff3dead13ef..f26f1df68b6 100644 --- a/src/mesa/tnl/t_vb_lighttmp.h +++ b/src/mesa/tnl/t_vb_lighttmp.h @@ -1,4 +1,4 @@ -/* $Id: t_vb_lighttmp.h,v 1.14 2001/07/28 19:28:49 keithw Exp $ */ +/* $Id: t_vb_lighttmp.h,v 1.15 2001/08/01 05:10:42 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -117,7 +117,7 @@ static void TAG(light_rgba_spec)( GLcontext *ctx, -/* fprintf(stderr, "%s\n", __FUNCTION__ ); */ +/* fprintf(stderr, "%s\n", __FUNCTION__ ); */ spec[0] = Fspec; spec[1] = Bspec; @@ -588,7 +588,6 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx, do { GLfloat n_dot_VP = DOT3(normal, light->_VP_inf_norm); - if (n_dot_VP < 0.0F) { if (IDX & LIGHT_TWOSIDE) { GLfloat n_dot_h = -DOT3(normal, light->_h_inf_norm); @@ -699,6 +698,7 @@ static void TAG(light_fast_rgba)( GLcontext *ctx, ctx->Light.Material[1].Diffuse[3]); } + COPY_3V(sum[0], ctx->Light._BaseColor[0]); if (IDX & LIGHT_TWOSIDE) COPY_3V(sum[1], ctx->Light._BaseColor[1]);