From dd9666bc1def9e99a5050545ab71d24037cf5af0 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 5 Jan 2005 18:06:05 +0000 Subject: [PATCH] Give attributes with zero-stride a count of 1 to make it easier to avoid transforming the same attribute multiple times. Don't light a single normal multiple times in light_fast_rgba* --- src/mesa/tnl/t_array_import.c | 2 +- src/mesa/tnl/t_save_playback.c | 2 +- src/mesa/tnl/t_vb_lighttmp.h | 45 ++++++++++++++++++++++++---------- src/mesa/tnl/t_vb_normals.c | 13 +++------- src/mesa/tnl/t_vtx_exec.c | 2 +- 5 files changed, 39 insertions(+), 25 deletions(-) diff --git a/src/mesa/tnl/t_array_import.c b/src/mesa/tnl/t_array_import.c index dac64631558..93d2640b8e1 100644 --- a/src/mesa/tnl/t_array_import.c +++ b/src/mesa/tnl/t_array_import.c @@ -332,7 +332,7 @@ void _tnl_vb_bind_arrays( GLcontext *ctx, GLint start, GLint end) */ if (inputs & _TNL_BITS_MAT_ANY) { for (i = _TNL_ATTRIB_MAT_FRONT_AMBIENT; i < _TNL_ATTRIB_INDEX; i++) { - tmp->Attribs[i].count = VB->Count; + tmp->Attribs[i].count = 1; tmp->Attribs[i].data = (GLfloat (*)[4]) tnl->vtx.current[i]; tmp->Attribs[i].start = tnl->vtx.current[i]; tmp->Attribs[i].size = 4; diff --git a/src/mesa/tnl/t_save_playback.c b/src/mesa/tnl/t_save_playback.c index dc9ffa8db4b..26c77bd7d8e 100644 --- a/src/mesa/tnl/t_save_playback.c +++ b/src/mesa/tnl/t_save_playback.c @@ -77,7 +77,7 @@ static void _tnl_bind_vertex_list( GLcontext *ctx, data += node->attrsz[attr]; } else { - tmp->Attribs[attr].count = node->count; + tmp->Attribs[attr].count = 1; tmp->Attribs[attr].data = (GLfloat (*)[4]) tnl->vtx.current[attr]; tmp->Attribs[attr].start = tnl->vtx.current[attr]; tmp->Attribs[attr].size = get_size( tnl->vtx.current[attr] ); diff --git a/src/mesa/tnl/t_vb_lighttmp.h b/src/mesa/tnl/t_vb_lighttmp.h index d8094e29c36..2d33f71a8c0 100644 --- a/src/mesa/tnl/t_vb_lighttmp.h +++ b/src/mesa/tnl/t_vb_lighttmp.h @@ -68,9 +68,6 @@ static void TAG(light_rgba_spec)( GLcontext *ctx, const GLuint nr = VB->Count; - (void) nstride; - (void) vstride; - #ifdef TRACE fprintf(stderr, "%s\n", __FUNCTION__ ); #endif @@ -90,6 +87,9 @@ static void TAG(light_rgba_spec)( GLcontext *ctx, if (stage->changed_inputs == 0) return; + store->LitColor[0].stride = 16; + store->LitColor[1].stride = 16; + for (j = 0; j < nr; j++,STRIDE_F(vertex,vstride),STRIDE_F(normal,nstride)) { GLfloat sum[2][3], spec[2][3]; struct gl_light *light; @@ -263,9 +263,6 @@ static void TAG(light_rgba)( GLcontext *ctx, fprintf(stderr, "%s\n", __FUNCTION__ ); #endif - (void) nstride; - (void) vstride; - VB->ColorPtr[0] = &store->LitColor[0]; sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3]; @@ -277,6 +274,9 @@ static void TAG(light_rgba)( GLcontext *ctx, if (stage->changed_inputs == 0) return; + store->LitColor[0].stride = 16; + store->LitColor[1].stride = 16; + for (j = 0; j < nr; j++,STRIDE_F(vertex,vstride),STRIDE_F(normal,nstride)) { GLfloat sum[2][3]; struct gl_light *light; @@ -444,15 +444,17 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx, const struct gl_light *light = ctx->Light.EnabledList.next; GLuint j = 0; GLfloat base[2][4]; +#if IDX & LIGHT_MATERIAL const GLuint nr = VB->Count; +#else + const GLuint nr = VB->NormalPtr->count; +#endif #ifdef TRACE fprintf(stderr, "%s\n", __FUNCTION__ ); #endif (void) input; /* doesn't refer to Eye or Obj */ - (void) nr; - (void) nstride; VB->ColorPtr[0] = &store->LitColor[0]; #if IDX & LIGHT_TWOSIDE @@ -462,6 +464,15 @@ static void TAG(light_fast_rgba_single)( GLcontext *ctx, if (stage->changed_inputs == 0) return; + if (nr > 1) { + store->LitColor[0].stride = 16; + store->LitColor[1].stride = 16; + } + else { + store->LitColor[0].stride = 0; + store->LitColor[1].stride = 0; + } + for (j = 0; j < nr; j++, STRIDE_F(normal,nstride)) { GLfloat n_dot_VP; @@ -542,7 +553,11 @@ static void TAG(light_fast_rgba)( GLcontext *ctx, GLfloat (*Bcolor)[4] = (GLfloat (*)[4]) store->LitColor[1].data; #endif GLuint j = 0; +#if IDX & LIGHT_MATERIAL const GLuint nr = VB->Count; +#else + const GLuint nr = VB->NormalPtr->count; +#endif const struct gl_light *light; #ifdef TRACE @@ -550,8 +565,6 @@ static void TAG(light_fast_rgba)( GLcontext *ctx, #endif (void) input; - (void) nr; - (void) nstride; sumA[0] = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3]; sumA[1] = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_DIFFUSE][3]; @@ -564,6 +577,15 @@ static void TAG(light_fast_rgba)( GLcontext *ctx, if (stage->changed_inputs == 0) return; + if (nr > 1) { + store->LitColor[0].stride = 16; + store->LitColor[1].stride = 16; + } + else { + store->LitColor[0].stride = 0; + store->LitColor[1].stride = 0; + } + for (j = 0; j < nr; j++, STRIDE_F(normal,nstride)) { GLfloat sum[2][3]; @@ -656,9 +678,6 @@ static void TAG(light_ci)( GLcontext *ctx, fprintf(stderr, "%s\n", __FUNCTION__ ); #endif - (void) nstride; - (void) vstride; - VB->IndexPtr[0] = &store->LitIndex[0]; #if IDX & LIGHT_TWOSIDE VB->IndexPtr[1] = &store->LitIndex[1]; diff --git a/src/mesa/tnl/t_vb_normals.c b/src/mesa/tnl/t_vb_normals.c index d82008821f2..9d6a4ba5d2d 100644 --- a/src/mesa/tnl/t_vb_normals.c +++ b/src/mesa/tnl/t_vb_normals.c @@ -68,23 +68,18 @@ static GLboolean run_normal_stage( GLcontext *ctx, else lengths = VB->NormalLengthPtr; - /* If there is only one normal, don't transform it multiple times: - */ - if (VB->NormalPtr->stride == 0) - VB->NormalPtr->count = 1; - store->NormalTransform( ctx->ModelviewMatrixStack.Top, ctx->_ModelViewInvScale, VB->NormalPtr, /* input normals */ lengths, &store->normal ); /* resulting normals */ - if (VB->NormalPtr->stride == 0) { - VB->NormalPtr->count = VB->Count; + if (VB->NormalPtr->count > 1) { + store->normal.stride = 16; + } + else { store->normal.stride = 0; } - else - store->normal.stride = 16; } VB->NormalPtr = &store->normal; diff --git a/src/mesa/tnl/t_vtx_exec.c b/src/mesa/tnl/t_vtx_exec.c index 6925850f06a..e8700b934c4 100644 --- a/src/mesa/tnl/t_vtx_exec.c +++ b/src/mesa/tnl/t_vtx_exec.c @@ -139,7 +139,7 @@ static void _tnl_vb_bind_vtx( GLcontext *ctx ) /* VB->AttribPtr[attr] = &tnl->current.Attribs[attr]; */ - tmp->Attribs[attr].count = count; + tmp->Attribs[attr].count = 1; tmp->Attribs[attr].data = (GLfloat (*)[4]) tnl->vtx.current[attr]; tmp->Attribs[attr].start = tnl->vtx.current[attr]; tmp->Attribs[attr].size = get_size( tnl->vtx.current[attr] ); -- 2.30.2