mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-28 01:40:08 +01:00
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*
This commit is contained in:
parent
30f6486276
commit
dd9666bc1d
5 changed files with 39 additions and 25 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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] );
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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] );
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue