X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fprogram%2Fprog_statevars.c;h=71c33132a0092f5e121b573784431013d544846f;hb=HEAD;hp=c310acb01d4fdc619c4b9c47ebabb63ae9a2991a;hpb=64244dfd39b6e63a62a91ea2fb2743bd88a22476;p=mesa.git diff --git a/src/mesa/program/prog_statevars.c b/src/mesa/program/prog_statevars.c index c310acb01d4..71c33132a00 100644 --- a/src/mesa/program/prog_statevars.c +++ b/src/mesa/program/prog_statevars.c @@ -1,6 +1,5 @@ /* * Mesa 3-D graphics library - * Version: 7.1 * * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * @@ -17,9 +16,10 @@ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. */ /** @@ -29,13 +29,21 @@ */ +#include #include "main/glheader.h" #include "main/context.h" -#include "main/imports.h" +#include "main/blend.h" + #include "main/macros.h" #include "main/mtypes.h" +#include "main/fbobject.h" #include "prog_statevars.h" #include "prog_parameter.h" +#include "main/samplerobj.h" +#include "main/framebuffer.h" + + +#define ONE_DIV_SQRT_LN2 (1.201122408786449815) /** @@ -46,18 +54,20 @@ * The program parser will produce the state[] values. */ static void -_mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[], - GLfloat *value) +fetch_state(struct gl_context *ctx, const gl_state_index16 state[], + gl_constant_value *val) { + GLfloat *value = &val->f; + switch (state[0]) { case STATE_MATERIAL: { /* state[1] is either 0=front or 1=back side */ const GLuint face = (GLuint) state[1]; const struct gl_material *mat = &ctx->Light.Material; - ASSERT(face == 0 || face == 1); + assert(face == 0 || face == 1); /* we rely on tokens numbered so that _BACK_ == _FRONT_+ 1 */ - ASSERT(MAT_ATTRIB_FRONT_AMBIENT + 1 == MAT_ATTRIB_BACK_AMBIENT); + assert(MAT_ATTRIB_FRONT_AMBIENT + 1 == MAT_ATTRIB_BACK_AMBIENT); /* XXX we could get rid of this switch entirely with a little * work in arbprogparse.c's parse_state_single_item(). */ @@ -167,7 +177,7 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[], const GLuint ln = (GLuint) state[1]; const GLuint face = (GLuint) state[2]; GLint i; - ASSERT(face == 0 || face == 1); + assert(face == 0 || face == 1); switch (state[3]) { case STATE_AMBIENT: for (i = 0; i < 3; i++) { @@ -205,28 +215,28 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[], /* state[2] is the texgen attribute */ switch (state[2]) { case STATE_TEXGEN_EYE_S: - COPY_4V(value, ctx->Texture.Unit[unit].GenS.EyePlane); + COPY_4V(value, ctx->Texture.FixedFuncUnit[unit].GenS.EyePlane); return; case STATE_TEXGEN_EYE_T: - COPY_4V(value, ctx->Texture.Unit[unit].GenT.EyePlane); + COPY_4V(value, ctx->Texture.FixedFuncUnit[unit].GenT.EyePlane); return; case STATE_TEXGEN_EYE_R: - COPY_4V(value, ctx->Texture.Unit[unit].GenR.EyePlane); + COPY_4V(value, ctx->Texture.FixedFuncUnit[unit].GenR.EyePlane); return; case STATE_TEXGEN_EYE_Q: - COPY_4V(value, ctx->Texture.Unit[unit].GenQ.EyePlane); + COPY_4V(value, ctx->Texture.FixedFuncUnit[unit].GenQ.EyePlane); return; case STATE_TEXGEN_OBJECT_S: - COPY_4V(value, ctx->Texture.Unit[unit].GenS.ObjectPlane); + COPY_4V(value, ctx->Texture.FixedFuncUnit[unit].GenS.ObjectPlane); return; case STATE_TEXGEN_OBJECT_T: - COPY_4V(value, ctx->Texture.Unit[unit].GenT.ObjectPlane); + COPY_4V(value, ctx->Texture.FixedFuncUnit[unit].GenT.ObjectPlane); return; case STATE_TEXGEN_OBJECT_R: - COPY_4V(value, ctx->Texture.Unit[unit].GenR.ObjectPlane); + COPY_4V(value, ctx->Texture.FixedFuncUnit[unit].GenR.ObjectPlane); return; case STATE_TEXGEN_OBJECT_Q: - COPY_4V(value, ctx->Texture.Unit[unit].GenQ.ObjectPlane); + COPY_4V(value, ctx->Texture.FixedFuncUnit[unit].GenQ.ObjectPlane); return; default: _mesa_problem(ctx, "Invalid texgen state in fetch_state"); @@ -237,18 +247,23 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[], { /* state[1] is the texture unit */ const GLuint unit = (GLuint) state[1]; - COPY_4V(value, ctx->Texture.Unit[unit].EnvColor); + if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer)) + COPY_4V(value, ctx->Texture.FixedFuncUnit[unit].EnvColor); + else + COPY_4V(value, ctx->Texture.FixedFuncUnit[unit].EnvColorUnclamped); } return; case STATE_FOG_COLOR: - COPY_4V(value, ctx->Fog.Color); + if (_mesa_get_clamp_fragment_color(ctx, ctx->DrawBuffer)) + COPY_4V(value, ctx->Fog.Color); + else + COPY_4V(value, ctx->Fog.ColorUnclamped); return; case STATE_FOG_PARAMS: value[0] = ctx->Fog.Density; value[1] = ctx->Fog.Start; value[2] = ctx->Fog.End; - value[3] = (ctx->Fog.End == ctx->Fog.Start) - ? 1.0f : (GLfloat)(1.0 / (ctx->Fog.End - ctx->Fog.Start)); + value[3] = 1.0f / (ctx->Fog.End - ctx->Fog.Start); return; case STATE_CLIPPLANE: { @@ -287,10 +302,8 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[], const gl_state_index modifier = state[4]; const GLfloat *m; GLuint row, i; - ASSERT(firstRow >= 0); - ASSERT(firstRow < 4); - ASSERT(lastRow >= 0); - ASSERT(lastRow < 4); + assert(firstRow < 4); + assert(lastRow < 4); if (mat == STATE_MODELVIEW_MATRIX) { matrix = ctx->ModelviewMatrixStack.Top; } @@ -301,22 +314,21 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[], matrix = &ctx->_ModelProjectMatrix; } else if (mat == STATE_TEXTURE_MATRIX) { - ASSERT(index < Elements(ctx->TextureMatrixStack)); + assert(index < ARRAY_SIZE(ctx->TextureMatrixStack)); matrix = ctx->TextureMatrixStack[index].Top; } else if (mat == STATE_PROGRAM_MATRIX) { - ASSERT(index < Elements(ctx->ProgramMatrixStack)); + assert(index < ARRAY_SIZE(ctx->ProgramMatrixStack)); matrix = ctx->ProgramMatrixStack[index].Top; } else { - _mesa_problem(ctx, "Bad matrix name in _mesa_fetch_state()"); + _mesa_problem(ctx, "Bad matrix name in fetch_state()"); return; } if (modifier == STATE_MATRIX_INVERSE || modifier == STATE_MATRIX_INVTRANS) { /* Be sure inverse is up to date: */ - _math_matrix_alloc_inv( (GLmatrix *) matrix ); _math_matrix_analyse( (GLmatrix*) matrix ); m = matrix->inv; } @@ -342,10 +354,13 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[], } } return; + case STATE_NUM_SAMPLES: + val[0].i = MAX2(1, _mesa_geometric_samples(ctx->DrawBuffer)); + return; case STATE_DEPTH_RANGE: - value[0] = ctx->Viewport.Near; /* near */ - value[1] = ctx->Viewport.Far; /* far */ - value[2] = ctx->Viewport.Far - ctx->Viewport.Near; /* far - near */ + value[0] = ctx->ViewportArray[0].Near; /* near */ + value[1] = ctx->ViewportArray[0].Far; /* far */ + value[2] = ctx->ViewportArray[0].Far - ctx->ViewportArray[0].Near; /* far - near */ value[3] = 1.0; return; case STATE_FRAGMENT_PROGRAM: @@ -358,10 +373,20 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[], COPY_4V(value, ctx->FragmentProgram.Parameters[idx]); return; case STATE_LOCAL: - COPY_4V(value, ctx->FragmentProgram.Current->Base.LocalParams[idx]); + if (!ctx->FragmentProgram.Current->arb.LocalParams) { + ctx->FragmentProgram.Current->arb.LocalParams = + rzalloc_array_size(ctx->FragmentProgram.Current, + sizeof(float[4]), + MAX_PROGRAM_LOCAL_PARAMS); + if (!ctx->FragmentProgram.Current->arb.LocalParams) + return; + } + + COPY_4V(value, + ctx->FragmentProgram.Current->arb.LocalParams[idx]); return; default: - _mesa_problem(ctx, "Bad state switch in _mesa_fetch_state()"); + _mesa_problem(ctx, "Bad state switch in fetch_state()"); return; } } @@ -377,17 +402,27 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[], COPY_4V(value, ctx->VertexProgram.Parameters[idx]); return; case STATE_LOCAL: - COPY_4V(value, ctx->VertexProgram.Current->Base.LocalParams[idx]); + if (!ctx->VertexProgram.Current->arb.LocalParams) { + ctx->VertexProgram.Current->arb.LocalParams = + rzalloc_array_size(ctx->VertexProgram.Current, + sizeof(float[4]), + MAX_PROGRAM_LOCAL_PARAMS); + if (!ctx->VertexProgram.Current->arb.LocalParams) + return; + } + + COPY_4V(value, + ctx->VertexProgram.Current->arb.LocalParams[idx]); return; default: - _mesa_problem(ctx, "Bad state switch in _mesa_fetch_state()"); + _mesa_problem(ctx, "Bad state switch in fetch_state()"); return; } } return; case STATE_NORMAL_SCALE: - ASSIGN_4V(value, ctx->_ModelViewInvScale, 0, 0, 1); + ASSIGN_4V(value, ctx->_ModelViewInvScaleEyespace, 0, 0, 1); return; case STATE_INTERNAL: @@ -399,32 +434,30 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[], } return; - case STATE_NORMAL_SCALE: - ASSIGN_4V(value, - ctx->_ModelViewInvScale, - ctx->_ModelViewInvScale, - ctx->_ModelViewInvScale, - 1); - return; - - case STATE_TEXRECT_SCALE: - /* Value = { 1/texWidth, 1/texHeight, 0, 1 }. - * Used to convert unnormalized texcoords to normalized texcoords. - */ + case STATE_CURRENT_ATTRIB_MAYBE_VP_CLAMPED: { - 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, - (GLfloat) (1.0 / texImage->Width), - (GLfloat) (1.0 / texImage->Height), - 0.0f, 1.0f); + const GLuint idx = (GLuint) state[2]; + if(ctx->Light._ClampVertexColor && + (idx == VERT_ATTRIB_COLOR0 || + idx == VERT_ATTRIB_COLOR1)) { + value[0] = SATURATE(ctx->Current.Attrib[idx][0]); + value[1] = SATURATE(ctx->Current.Attrib[idx][1]); + value[2] = SATURATE(ctx->Current.Attrib[idx][2]); + value[3] = SATURATE(ctx->Current.Attrib[idx][3]); } + else + COPY_4V(value, ctx->Current.Attrib[idx]); } return; + case STATE_NORMAL_SCALE: + ASSIGN_4V(value, + ctx->_ModelViewInvScale, + ctx->_ModelViewInvScale, + ctx->_ModelViewInvScale, + 1); + 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 @@ -432,12 +465,12 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[], * single MAD. * linear: fogcoord * -1/(end-start) + end/(end-start) * exp: 2^-(density/ln(2) * fogcoord) - * exp2: 2^-((density/(ln(2)^2) * fogcoord)^2) + * exp2: 2^-((density/(sqrt(ln(2))) * fogcoord)^2) */ value[0] = (ctx->Fog.End == ctx->Fog.Start) ? 1.0f : (GLfloat)(-1.0F / (ctx->Fog.End - ctx->Fog.Start)); value[1] = ctx->Fog.End * -value[0]; - value[2] = (GLfloat)(ctx->Fog.Density * ONE_DIV_LN2); + value[2] = (GLfloat)(ctx->Fog.Density * M_LOG2E); /* M_LOG2E == 1/ln(2) */ value[3] = (GLfloat)(ctx->Fog.Density * ONE_DIV_SQRT_LN2); return; @@ -459,7 +492,7 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[], minImplSize = ctx->Const.MinPointSizeAA; maxImplSize = ctx->Const.MaxPointSize; } - else if (ctx->Point.SmoothFlag || ctx->Multisample._Enabled) { + else if (ctx->Point.SmoothFlag || _mesa_is_multisample_enabled(ctx)) { minImplSize = ctx->Const.MinPointSizeAA; maxImplSize = ctx->Const.MaxPointSizeAA; } @@ -473,29 +506,6 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[], value[3] = ctx->Point.Threshold; } return; - case STATE_POINT_SIZE_IMPL_CLAMP: - { - /* for implementation clamp only in vs */ - GLfloat minImplSize; - GLfloat maxImplSize; - if (ctx->Point.PointSprite) { - minImplSize = ctx->Const.MinPointSizeAA; - maxImplSize = ctx->Const.MaxPointSize; - } - else if (ctx->Point.SmoothFlag || ctx->Multisample._Enabled) { - minImplSize = ctx->Const.MinPointSizeAA; - maxImplSize = ctx->Const.MaxPointSizeAA; - } - else { - minImplSize = ctx->Const.MinPointSize; - maxImplSize = ctx->Const.MaxPointSize; - } - value[0] = ctx->Point.Size; - value[1] = minImplSize; - value[2] = maxImplSize; - value[3] = ctx->Point.Threshold; - } - return; case STATE_LIGHT_SPOT_DIR_NORMALIZED: { /* here, state[2] is the light number */ @@ -551,20 +561,6 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[], value[3] = ctx->Pixel.AlphaBias; return; - case STATE_SHADOW_AMBIENT: - { - const int unit = (int) state[2]; - const struct gl_texture_object *texObj - = ctx->Texture.Unit[unit]._Current; - if (texObj) { - value[0] = - value[1] = - value[2] = - value[3] = texObj->CompareFailValue; - } - } - return; - case STATE_FB_SIZE: value[0] = (GLfloat) (ctx->DrawBuffer->Width - 1); value[1] = (GLfloat) (ctx->DrawBuffer->Height - 1); @@ -575,44 +571,49 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[], case STATE_FB_WPOS_Y_TRANSFORM: /* A driver may negate this conditional by using ZW swizzle * instead of XY (based on e.g. some other state). */ - if (ctx->DrawBuffer->Name != 0) { + if (!ctx->DrawBuffer->FlipY) { /* Identity (XY) followed by flipping Y upside down (ZW). */ value[0] = 1.0F; value[1] = 0.0F; value[2] = -1.0F; - value[3] = (GLfloat) (ctx->DrawBuffer->Height - 1); + value[3] = _mesa_geometric_height(ctx->DrawBuffer); } else { /* Flipping Y upside down (XY) followed by identity (ZW). */ value[0] = -1.0F; - value[1] = (GLfloat) (ctx->DrawBuffer->Height - 1); + value[1] = _mesa_geometric_height(ctx->DrawBuffer); value[2] = 1.0F; value[3] = 0.0F; } return; - case STATE_ROT_MATRIX_0: - { - const int unit = (int) state[2]; - GLfloat *rotMat22 = ctx->Texture.Unit[unit].RotMatrix; - value[0] = rotMat22[0]; - value[1] = rotMat22[2]; - value[2] = 0.0; - value[3] = 0.0; - } + case STATE_TCS_PATCH_VERTICES_IN: + val[0].i = ctx->TessCtrlProgram.patch_vertices; return; - case STATE_ROT_MATRIX_1: + case STATE_TES_PATCH_VERTICES_IN: + if (ctx->TessCtrlProgram._Current) + val[0].i = ctx->TessCtrlProgram._Current->info.tess.tcs_vertices_out; + else + val[0].i = ctx->TessCtrlProgram.patch_vertices; + return; + + case STATE_ADVANCED_BLENDING_MODE: + val[0].i = _mesa_get_advanced_blend_sh_constant( + ctx->Color.BlendEnabled, ctx->Color._AdvancedBlendMode); + return; + + case STATE_ALPHA_REF: + value[0] = ctx->Color.AlphaRefUnclamped; + return; + + case STATE_CLIP_INTERNAL: { - const int unit = (int) state[2]; - GLfloat *rotMat22 = ctx->Texture.Unit[unit].RotMatrix; - value[0] = rotMat22[1]; - value[1] = rotMat22[3]; - value[2] = 0.0; - value[3] = 0.0; + const GLuint plane = (GLuint) state[2]; + COPY_4V(value, ctx->Transform._ClipUserPlane[plane]); } return; - /* XXX: make sure new tokens added here are also handled in the + /* XXX: make sure new tokens added here are also handled in the * _mesa_program_state_flags() switch, below. */ default: @@ -629,6 +630,15 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[], } } +unsigned +_mesa_program_state_value_size(const gl_state_index16 state[STATE_LENGTH]) +{ + if (state[0] == STATE_LIGHT && state[2] == STATE_SPOT_CUTOFF) + return 1; + + /* Everything else is packed into vec4s */ + return 4; +} /** * Return a bitmask of the Mesa state flags (_NEW_* values) which would @@ -638,21 +648,26 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[], * some GL state has changed. */ GLbitfield -_mesa_program_state_flags(const gl_state_index state[STATE_LENGTH]) +_mesa_program_state_flags(const gl_state_index16 state[STATE_LENGTH]) { switch (state[0]) { case STATE_MATERIAL: + case STATE_LIGHTPROD: + case STATE_LIGHTMODEL_SCENECOLOR: + /* these can be effected by glColor when colormaterial mode is used */ + return _NEW_LIGHT | _NEW_CURRENT_ATTRIB; + case STATE_LIGHT: case STATE_LIGHTMODEL_AMBIENT: - case STATE_LIGHTMODEL_SCENECOLOR: - case STATE_LIGHTPROD: return _NEW_LIGHT; case STATE_TEXGEN: + return _NEW_TEXTURE_STATE; case STATE_TEXENV_COLOR: - return _NEW_TEXTURE; + return _NEW_TEXTURE_STATE | _NEW_BUFFERS | _NEW_FRAG_CLAMP; case STATE_FOG_COLOR: + return _NEW_FOG | _NEW_BUFFERS | _NEW_FRAG_CLAMP; case STATE_FOG_PARAMS: return _NEW_FOG; @@ -674,6 +689,9 @@ _mesa_program_state_flags(const gl_state_index state[STATE_LENGTH]) case STATE_PROGRAM_MATRIX: return _NEW_TRACK_MATRIX; + case STATE_NUM_SAMPLES: + return _NEW_BUFFERS; + case STATE_DEPTH_RANGE: return _NEW_VIEWPORT; @@ -688,19 +706,15 @@ _mesa_program_state_flags(const gl_state_index state[STATE_LENGTH]) switch (state[1]) { case STATE_CURRENT_ATTRIB: return _NEW_CURRENT_ATTRIB; + case STATE_CURRENT_ATTRIB_MAYBE_VP_CLAMPED: + return _NEW_CURRENT_ATTRIB | _NEW_LIGHT | _NEW_BUFFERS; case STATE_NORMAL_SCALE: return _NEW_MODELVIEW; - case STATE_TEXRECT_SCALE: - case STATE_SHADOW_AMBIENT: - case STATE_ROT_MATRIX_0: - case STATE_ROT_MATRIX_1: - return _NEW_TEXTURE; case STATE_FOG_PARAMS_OPTIMIZED: return _NEW_FOG; case STATE_POINT_SIZE_CLAMPED: - case STATE_POINT_SIZE_IMPL_CLAMP: return _NEW_POINT | _NEW_MULTISAMPLE; case STATE_LIGHT_SPOT_DIR_NORMALIZED: case STATE_LIGHT_POSITION: @@ -716,6 +730,15 @@ _mesa_program_state_flags(const gl_state_index state[STATE_LENGTH]) case STATE_FB_WPOS_Y_TRANSFORM: return _NEW_BUFFERS; + case STATE_ADVANCED_BLENDING_MODE: + return _NEW_COLOR; + + case STATE_ALPHA_REF: + return _NEW_COLOR; + + case STATE_CLIP_INTERNAL: + return _NEW_TRANSFORM | _NEW_PROJECTION; + default: /* unknown state indexes are silently ignored and * no flag set, since it is handled by the driver. @@ -861,6 +884,9 @@ append_token(char *dst, gl_state_index k) case STATE_TEXENV_COLOR: append(dst, "texenv"); break; + case STATE_NUM_SAMPLES: + append(dst, "numsamples"); + break; case STATE_DEPTH_RANGE: append(dst, "depth.range"); break; @@ -880,21 +906,18 @@ append_token(char *dst, gl_state_index k) case STATE_CURRENT_ATTRIB: append(dst, "current"); break; + case STATE_CURRENT_ATTRIB_MAYBE_VP_CLAMPED: + append(dst, "currentAttribMaybeVPClamped"); + break; case STATE_NORMAL_SCALE: append(dst, "normalScale"); break; - case STATE_TEXRECT_SCALE: - append(dst, "texrectScale"); - break; case STATE_FOG_PARAMS_OPTIMIZED: append(dst, "fogParamsOptimized"); break; case STATE_POINT_SIZE_CLAMPED: append(dst, "pointSizeClamped"); break; - case STATE_POINT_SIZE_IMPL_CLAMP: - append(dst, "pointSizeImplClamp"); - break; case STATE_LIGHT_SPOT_DIR_NORMALIZED: append(dst, "lightSpotDirNormalized"); break; @@ -913,20 +936,20 @@ append_token(char *dst, gl_state_index k) case STATE_PT_BIAS: append(dst, "PTbias"); break; - case STATE_SHADOW_AMBIENT: - append(dst, "CompareFailValue"); - break; case STATE_FB_SIZE: append(dst, "FbSize"); break; case STATE_FB_WPOS_Y_TRANSFORM: append(dst, "FbWposYTransform"); break; - case STATE_ROT_MATRIX_0: - append(dst, "rotMatrixRow0"); + case STATE_ADVANCED_BLENDING_MODE: + append(dst, "AdvancedBlendingMode"); break; - case STATE_ROT_MATRIX_1: - append(dst, "rotMatrixRow1"); + case STATE_ALPHA_REF: + append(dst, "alphaRef"); + break; + case STATE_CLIP_INTERNAL: + append(dst, "clipInternal"); break; default: /* probably STATE_INTERNAL_DRIVER+i (driver private state) */ @@ -957,7 +980,7 @@ append_index(char *dst, GLint index) * Use free() to deallocate the string. */ char * -_mesa_program_state_string(const gl_state_index state[STATE_LENGTH]) +_mesa_program_state_string(const gl_state_index16 state[STATE_LENGTH]) { char str[1000] = ""; char tmp[30]; @@ -1039,6 +1062,8 @@ _mesa_program_state_string(const gl_state_index state[STATE_LENGTH]) break; case STATE_FOG_COLOR: break; + case STATE_NUM_SAMPLES: + break; case STATE_DEPTH_RANGE: break; case STATE_FRAGMENT_PROGRAM: @@ -1060,7 +1085,7 @@ _mesa_program_state_string(const gl_state_index state[STATE_LENGTH]) break; } - return _mesa_strdup(str); + return strdup(str); } @@ -1083,100 +1108,9 @@ _mesa_load_state_parameters(struct gl_context *ctx, for (i = 0; i < paramList->NumParameters; i++) { if (paramList->Parameters[i].Type == PROGRAM_STATE_VAR) { - _mesa_fetch_state(ctx, - paramList->Parameters[i].StateIndexes, - paramList->ParameterValues[i]); - } - } -} - - -/** - * Copy the 16 elements of a matrix into four consecutive program - * registers starting at 'pos'. - */ -static void -load_matrix(GLfloat registers[][4], GLuint pos, const GLfloat mat[16]) -{ - GLuint i; - for (i = 0; i < 4; i++) { - registers[pos + i][0] = mat[0 + i]; - registers[pos + i][1] = mat[4 + i]; - registers[pos + i][2] = mat[8 + i]; - registers[pos + i][3] = mat[12 + i]; - } -} - - -/** - * As above, but transpose the matrix. - */ -static void -load_transpose_matrix(GLfloat registers[][4], GLuint pos, - const GLfloat mat[16]) -{ - memcpy(registers[pos], mat, 16 * sizeof(GLfloat)); -} - - -/** - * Load current vertex program's parameter registers with tracked - * matrices (if NV program). This only needs to be done per - * glBegin/glEnd, not per-vertex. - */ -void -_mesa_load_tracked_matrices(struct gl_context *ctx) -{ - GLuint i; - - for (i = 0; i < MAX_NV_VERTEX_PROGRAM_PARAMS / 4; i++) { - /* point 'mat' at source matrix */ - GLmatrix *mat; - if (ctx->VertexProgram.TrackMatrix[i] == GL_MODELVIEW) { - mat = ctx->ModelviewMatrixStack.Top; - } - else if (ctx->VertexProgram.TrackMatrix[i] == GL_PROJECTION) { - mat = ctx->ProjectionMatrixStack.Top; - } - else if (ctx->VertexProgram.TrackMatrix[i] == GL_TEXTURE) { - GLuint unit = MIN2(ctx->Texture.CurrentUnit, - Elements(ctx->TextureMatrixStack) - 1); - mat = ctx->TextureMatrixStack[unit].Top; - } - else if (ctx->VertexProgram.TrackMatrix[i]==GL_MODELVIEW_PROJECTION_NV) { - /* XXX verify the combined matrix is up to date */ - mat = &ctx->_ModelProjectMatrix; - } - else if (ctx->VertexProgram.TrackMatrix[i] >= GL_MATRIX0_NV && - ctx->VertexProgram.TrackMatrix[i] <= GL_MATRIX7_NV) { - GLuint n = ctx->VertexProgram.TrackMatrix[i] - GL_MATRIX0_NV; - ASSERT(n < Elements(ctx->ProgramMatrixStack)); - mat = ctx->ProgramMatrixStack[n].Top; - } - else { - /* no matrix is tracked, but we leave the register values as-is */ - assert(ctx->VertexProgram.TrackMatrix[i] == GL_NONE); - continue; - } - - /* load the matrix values into sequential registers */ - if (ctx->VertexProgram.TrackMatrixTransform[i] == GL_IDENTITY_NV) { - load_matrix(ctx->VertexProgram.Parameters, i*4, mat->m); - } - else if (ctx->VertexProgram.TrackMatrixTransform[i] == GL_INVERSE_NV) { - _math_matrix_analyse(mat); /* update the inverse */ - ASSERT(!_math_matrix_is_dirty(mat)); - load_matrix(ctx->VertexProgram.Parameters, i*4, mat->inv); - } - else if (ctx->VertexProgram.TrackMatrixTransform[i] == GL_TRANSPOSE_NV) { - load_transpose_matrix(ctx->VertexProgram.Parameters, i*4, mat->m); - } - else { - assert(ctx->VertexProgram.TrackMatrixTransform[i] - == GL_INVERSE_TRANSPOSE_NV); - _math_matrix_analyse(mat); /* update the inverse */ - ASSERT(!_math_matrix_is_dirty(mat)); - load_transpose_matrix(ctx->VertexProgram.Parameters, i*4, mat->inv); + unsigned pvo = paramList->ParameterValueOffset[i]; + fetch_state(ctx, paramList->Parameters[i].StateIndexes, + paramList->ParameterValues + pvo); } } }