diff options
author | Brian Paul <[email protected]> | 2012-02-08 20:11:58 -0700 |
---|---|---|
committer | Brian Paul <[email protected]> | 2012-02-10 08:06:56 -0700 |
commit | ae509f88a54b9cc32f16099109330f2792593c83 (patch) | |
tree | 482cf3dde475b64fcc3c2d2e9dee17db6df3c23f /src/mesa/main/light.c | |
parent | 4dacf793c8bf5c18f66efeb04e9d8a7e037e7378 (diff) |
mesa: remove gl_light::_SpotExpTable field
Just use pow() instead. Spot lights aren't too common and fixed-function
lighting isn't as important as it used to me.
This saves 32KB per context. Each table was 4KB and there's 8 lights.
Diffstat (limited to 'src/mesa/main/light.c')
-rw-r--r-- | src/mesa/main/light.c | 52 |
1 files changed, 1 insertions, 51 deletions
diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c index bf4bee3d696..39a984b1f19 100644 --- a/src/mesa/main/light.c +++ b/src/mesa/main/light.c @@ -154,7 +154,6 @@ _mesa_light(struct gl_context *ctx, GLuint lnum, GLenum pname, const GLfloat *pa return; FLUSH_VERTICES(ctx, _NEW_LIGHT); light->SpotExponent = params[0]; - _mesa_invalidate_spot_exp_table(light); break; case GL_SPOT_CUTOFF: ASSERT(params[0] == 180.0 || (params[0] >= 0.0 && params[0] <= 90.0)); @@ -911,46 +910,6 @@ _mesa_GetMaterialiv( GLenum face, GLenum pname, GLint *params ) -/* - * Whenever the spotlight exponent for a light changes we must call - * this function to recompute the exponent lookup table. - */ -void -_mesa_invalidate_spot_exp_table( struct gl_light *l ) -{ - l->_SpotExpTable[0][0] = -1; -} - - -static void -validate_spot_exp_table( struct gl_light *l ) -{ - GLint i; - GLdouble exponent = l->SpotExponent; - GLdouble tmp = 0; - GLint clamp = 0; - - l->_SpotExpTable[0][0] = 0.0; - - for (i = EXP_TABLE_SIZE - 1; i > 0 ;i--) { - if (clamp == 0) { - tmp = pow(i / (GLdouble) (EXP_TABLE_SIZE - 1), exponent); - if (tmp < FLT_MIN * 100.0) { - tmp = 0.0; - clamp = 1; - } - } - l->_SpotExpTable[i][0] = (GLfloat) tmp; - } - for (i = 0; i < EXP_TABLE_SIZE - 1; i++) { - l->_SpotExpTable[i][1] = (l->_SpotExpTable[i+1][0] - - l->_SpotExpTable[i][0]); - } - l->_SpotExpTable[EXP_TABLE_SIZE-1][1] = 0.0; -} - - - /* Calculate a new shine table. Doing this here saves a branch in * lighting, and the cost of doing it early may be partially offset * by keeping a MRU cache of shine tables for various shine values. @@ -1020,7 +979,6 @@ validate_shine_table( struct gl_context *ctx, GLuint side, GLfloat shininess ) void _mesa_validate_all_lighting_tables( struct gl_context *ctx ) { - GLuint i; GLfloat shininess; shininess = ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_SHININESS][0]; @@ -1030,10 +988,6 @@ _mesa_validate_all_lighting_tables( struct gl_context *ctx ) shininess = ctx->Light.Material.Attrib[MAT_ATTRIB_BACK_SHININESS][0]; if (!ctx->_ShineTable[1] || ctx->_ShineTable[1]->shininess != shininess) validate_shine_table( ctx, 1, shininess ); - - for (i = 0; i < ctx->Const.MaxLights; i++) - if (ctx->Light.Light[i]._SpotExpTable[0][0] == -1) - validate_spot_exp_table( &ctx->Light.Light[i] ); } @@ -1180,11 +1134,8 @@ compute_light_positions( struct gl_context *ctx ) light->_NormSpotDirection); if (PV_dot_dir > light->_CosCutoff) { - double x = PV_dot_dir * (EXP_TABLE_SIZE-1); - int k = (int) x; light->_VP_inf_spot_attenuation = - (GLfloat) (light->_SpotExpTable[k][0] + - (x-k)*light->_SpotExpTable[k][1]); + powf(PV_dot_dir, light->SpotExponent); } else { light->_VP_inf_spot_attenuation = 0; @@ -1303,7 +1254,6 @@ init_light( struct gl_light *l, GLuint n ) ASSIGN_4V( l->EyePosition, 0.0, 0.0, 1.0, 0.0 ); ASSIGN_3V( l->SpotDirection, 0.0, 0.0, -1.0 ); l->SpotExponent = 0.0; - _mesa_invalidate_spot_exp_table( l ); l->SpotCutoff = 180.0; l->_CosCutoffNeg = -1.0f; l->_CosCutoff = 0.0; /* KW: -ve values not admitted */ |