X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fshader%2Fprog_statevars.c;h=d37d7fb9bf4d2f45a28eed84c76ff24afef11119;hb=b41ef5506153fc2cd471341b4ad1eda2338f2438;hp=21d518a8100e58ccedd2ac9580b221f834c88f78;hpb=ef0cc9db547017309988c848376569174cfb90e8;p=mesa.git diff --git a/src/mesa/shader/prog_statevars.c b/src/mesa/shader/prog_statevars.c index 21d518a8100..d37d7fb9bf4 100644 --- a/src/mesa/shader/prog_statevars.c +++ b/src/mesa/shader/prog_statevars.c @@ -1,6 +1,6 @@ /* * Mesa 3-D graphics library - * Version: 6.5.3 + * Version: 7.0 * * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * @@ -121,17 +121,17 @@ _mesa_fetch_state(GLcontext *ctx, const gl_state_index state[], return; case STATE_HALF_VECTOR: { - GLfloat eye_z[] = {0, 0, 1}; - + static const GLfloat eye_z[] = {0, 0, 1}; + GLfloat p[3]; /* Compute infinite half angle vector: - * half-vector = light_position + (0, 0, 1) - * and then normalize. w = 0 - * + * halfVector = normalize(normalize(lightPos) + (0, 0, 1)) * light.EyePosition.w should be 0 for infinite lights. */ - ADD_3V(value, eye_z, ctx->Light.Light[ln].EyePosition); + COPY_3V(p, ctx->Light.Light[ln].EyePosition); + NORMALIZE_3FV(p); + ADD_3V(value, p, eye_z); NORMALIZE_3FV(value); - value[3] = 0; + value[3] = 1.0; } return; case STATE_POSITION_NORMALIZED: @@ -278,14 +278,12 @@ _mesa_fetch_state(GLcontext *ctx, const gl_state_index state[], case STATE_MVP_MATRIX: case STATE_TEXTURE_MATRIX: case STATE_PROGRAM_MATRIX: - /*case STATE_MATRIX:*/ { - /* state[1] = modelview, projection, texture, etc. */ - /* state[2] = which texture matrix or program matrix */ - /* state[3] = first row to fetch */ - /* state[4] = last row to fetch */ - /* state[5] = transpose, inverse or invtrans */ - + /* state[0] = modelview, projection, texture, etc. */ + /* state[1] = which texture matrix or program matrix */ + /* state[2] = first row to fetch */ + /* state[3] = last row to fetch */ + /* state[4] = transpose, inverse or invtrans */ const GLmatrix *matrix; const gl_state_index mat = state[0]; const GLuint index = (GLuint) state[1]; @@ -396,23 +394,51 @@ _mesa_fetch_state(GLcontext *ctx, const gl_state_index state[], return; case STATE_INTERNAL: - { - switch (state[1]) { - case STATE_TEXRECT_SCALE: { - const int unit = (int) state[2]; - const struct gl_texture_object *texObj = ctx->Texture.Unit[unit]._Current; - if (texObj) { - struct gl_texture_image *texImage = texObj->Image[0][0]; - ASSIGN_4V(value, 1.0 / texImage->Width, 1.0 / texImage->Height, 0, 1); - } - break; - } - default: - /* unknown state indexes are silently ignored - * should be handled by the driver. - */ - return; + switch (state[1]) { + case STATE_NORMAL_SCALE: + ASSIGN_4V(value, ctx->_ModelViewInvScale, 0, 0, 1); + return; + case STATE_TEXRECT_SCALE: + { + const int unit = (int) state[2]; + const struct gl_texture_object *texObj + = ctx->Texture.Unit[unit]._Current; + if (texObj) { + struct gl_texture_image *texImage = texObj->Image[0][0]; + ASSIGN_4V(value, 1.0 / texImage->Width, + 1.0 / texImage->Height, + 0.0, 1.0); + } } + return; + case STATE_FOG_PARAMS_OPTIMIZED: + /* for simpler per-vertex/pixel fog calcs. POW (for EXP/EXP2 fog) + * might be more expensive than EX2 on some hw, plus it needs + * another constant (e) anyway. Linear fog can now be done with a + * single MAD. + * linear: fogcoord * -1/(end-start) + end/(end-start) + * exp: 2^-(density/ln(2) * fogcoord) + * exp2: 2^-((density/(ln(2)^2) * fogcoord)^2) + */ + value[0] = -1.0F / (ctx->Fog.End - ctx->Fog.Start); + value[1] = ctx->Fog.End / (ctx->Fog.End - ctx->Fog.Start); + value[2] = ctx->Fog.Density * ONE_DIV_LN2; + value[3] = ctx->Fog.Density * ONE_DIV_SQRT_LN2; + return; + case STATE_SPOT_DIR_NORMALIZED: { + /* here, state[2] is the light number */ + /* pre-normalize spot dir */ + const GLuint ln = (GLuint) state[2]; + COPY_3V(value, ctx->Light.Light[ln].EyeDirection); + NORMALIZE_3FV(value); + value[3] = ctx->Light.Light[ln]._CosCutoff; + return; + } + default: + /* unknown state indexes are silently ignored + * should be handled by the driver. + */ + return; } return; @@ -481,6 +507,8 @@ _mesa_program_state_flags(const gl_state_index state[STATE_LENGTH]) switch (state[1]) { case STATE_TEXRECT_SCALE: return _NEW_TEXTURE; + case STATE_FOG_PARAMS_OPTIMIZED: + return _NEW_FOG; default: /* unknown state indexes are silently ignored and * no flag set, since it is handled by the driver. @@ -744,6 +772,14 @@ _mesa_program_state_string(const gl_state_index state[STATE_LENGTH]) append(str, tmp); } break; + case STATE_POINT_SIZE: + break; + case STATE_POINT_ATTENUATION: + break; + case STATE_FOG_PARAMS: + break; + case STATE_FOG_COLOR: + break; case STATE_DEPTH_RANGE: break; case STATE_FRAGMENT_PROGRAM: