X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Ftnl%2Ft_vb_light.c;h=8d13712e218b3a71cc96094dc1a11daf33048bbb;hb=6c61c31dc2fe52ad8a56ebe0b3aa10c223b635ba;hp=f6884a464eaf2da1e678d4e1bbc69f756600cf1f;hpb=8ab6759cef6dc5101be3badce10a52d1d046f2ea;p=mesa.git diff --git a/src/mesa/tnl/t_vb_light.c b/src/mesa/tnl/t_vb_light.c index f6884a464ea..8d13712e218 100644 --- a/src/mesa/tnl/t_vb_light.c +++ b/src/mesa/tnl/t_vb_light.c @@ -23,9 +23,8 @@ */ - +#include "c99_math.h" #include "main/glheader.h" -#include "main/colormac.h" #include "main/light.h" #include "main/macros.h" #include "main/imports.h" @@ -34,6 +33,8 @@ #include "math/m_translate.h" +#include "util/bitscan.h" + #include "t_context.h" #include "t_pipeline.h" #include "tnl.h" @@ -123,7 +124,7 @@ validate_shine_table( struct gl_context *ctx, GLuint side, GLfloat shininess ) struct tnl_shine_tab *list = tnl->_ShineTabList; struct tnl_shine_tab *s; - ASSERT(side < 2); + assert(side < 2); foreach(s, list) if ( s->shininess == shininess ) @@ -138,23 +139,23 @@ validate_shine_table( struct gl_context *ctx, GLuint side, GLfloat shininess ) break; m = s->tab; - m[0] = 0.0; - if (shininess == 0.0) { + m[0] = 0.0F; + if (shininess == 0.0F) { for (j = 1 ; j <= SHINE_TABLE_SIZE ; j++) - m[j] = 1.0; + m[j] = 1.0F; } else { for (j = 1 ; j < SHINE_TABLE_SIZE ; j++) { - GLdouble t, x = j / (GLfloat) (SHINE_TABLE_SIZE - 1); - if (x < 0.005) /* underflow check */ - x = 0.005; - t = pow(x, shininess); - if (t > 1e-20) - m[j] = (GLfloat) t; + GLfloat t, x = j / (GLfloat) (SHINE_TABLE_SIZE - 1); + if (x < 0.005F) /* underflow check */ + x = 0.005F; + t = powf(x, shininess); + if (t > 1e-20F) + m[j] = t; else - m[j] = 0.0; + m[j] = 0.0F; } - m[SHINE_TABLE_SIZE] = 1.0; + m[SHINE_TABLE_SIZE] = 1.0F; } s->shininess = shininess; @@ -232,10 +233,12 @@ prepare_materials(struct gl_context *ctx, * with the color pointer for each one. */ if (ctx->Light.ColorMaterialEnabled) { - const GLuint bitmask = ctx->Light._ColorMaterialBitmask; - for (i = 0 ; i < MAT_ATTRIB_MAX ; i++) - if (bitmask & (1<AttribPtr[_TNL_ATTRIB_MAT_FRONT_AMBIENT + i] = VB->AttribPtr[_TNL_ATTRIB_COLOR0]; + GLbitfield bitmask = ctx->Light._ColorMaterialBitmask; + while (bitmask) { + const int i = u_bit_scan(&bitmask); + VB->AttribPtr[_TNL_ATTRIB_MAT_FRONT_AMBIENT + i] = + VB->AttribPtr[_TNL_ATTRIB_COLOR0]; + } } /* Now, for each material attribute that's tracking vertex color, save @@ -395,7 +398,8 @@ static void validate_lighting( struct gl_context *ctx, tab = _tnl_light_tab; } else { - if (ctx->Light.EnabledList.next == ctx->Light.EnabledList.prev) + /* Power of two means only a single active light. */ + if (_mesa_is_pow_two(ctx->Light._EnabledLights)) tab = _tnl_light_fast_single_tab; else tab = _tnl_light_fast_tab;