diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index 7c8b93b6ed4..eb84c3d5c44 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -903,8 +903,8 @@ _mesa_PopAttrib(void) if (mask & GL_CURRENT_BIT) { memcpy(&ctx->Current, &attr->Current, sizeof(struct gl_current_attrib)); - /* Set _NEW_LIGHT because current attribs may reference materials. */ - ctx->NewState |= _NEW_CURRENT_ATTRIB | _NEW_LIGHT; + /* Set _NEW_LIGHT_CONSTANTS because current attribs may reference materials. */ + ctx->NewState |= _NEW_CURRENT_ATTRIB | _NEW_LIGHT_CONSTANTS; } if (mask & GL_DEPTH_BUFFER_BIT) { @@ -1003,7 +1003,7 @@ _mesa_PopAttrib(void) (GLfloat) attr->Light.Model.ColorControl); } else { /* Fast path for other drivers. */ - ctx->NewState |= _NEW_LIGHT; + ctx->NewState |= _NEW_LIGHT_CONSTANTS | _NEW_LIGHT_FF_PROGRAM; memcpy(ctx->Light.LightSource, attr->Light.LightSource, sizeof(attr->Light.LightSource)); @@ -1020,7 +1020,8 @@ _mesa_PopAttrib(void) TEST_AND_UPDATE(ctx->Light.ColorMaterialEnabled, attr->Light.ColorMaterialEnabled, GL_COLOR_MATERIAL); /* Materials - they might be used by current attribs. */ - ctx->NewState |= _NEW_CURRENT_ATTRIB; + /* Shininess material is used by the fixed-func vertex program. */ + ctx->NewState |= _NEW_CURRENT_ATTRIB | _NEW_LIGHT_FF_PROGRAM; memcpy(&ctx->Light.Material, &attr->Light.Material, sizeof(struct gl_material)); if (ctx->Extensions.ARB_color_buffer_float) { diff --git a/src/mesa/main/blend.c b/src/mesa/main/blend.c index c622ea00b91..fa01fa49097 100644 --- a/src/mesa/main/blend.c +++ b/src/mesa/main/blend.c @@ -1091,7 +1091,7 @@ _mesa_ClampColor(GLenum target, GLenum clamp) case GL_CLAMP_VERTEX_COLOR_ARB: if (ctx->API == API_OPENGL_CORE) goto invalid_enum; - FLUSH_VERTICES(ctx, _NEW_LIGHT, GL_LIGHTING_BIT | GL_ENABLE_BIT); + FLUSH_VERTICES(ctx, _NEW_LIGHT_STATE, GL_LIGHTING_BIT | GL_ENABLE_BIT); ctx->Light.ClampVertexColor = clamp; _mesa_update_clamp_vertex_color(ctx, ctx->DrawBuffer); break; diff --git a/src/mesa/main/debug.c b/src/mesa/main/debug.c index 355fa88ef72..08cf3282eb7 100644 --- a/src/mesa/main/debug.c +++ b/src/mesa/main/debug.c @@ -73,7 +73,7 @@ void _mesa_print_state( const char *msg, GLuint state ) { _mesa_debug(NULL, - "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", + "%s: (0x%x) %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", msg, state, (state & _NEW_MODELVIEW) ? "ctx->ModelView, " : "", @@ -83,7 +83,9 @@ _mesa_print_state( const char *msg, GLuint state ) (state & _NEW_DEPTH) ? "ctx->Depth, " : "", (state & _NEW_FOG) ? "ctx->Fog, " : "", (state & _NEW_HINT) ? "ctx->Hint, " : "", - (state & _NEW_LIGHT) ? "ctx->Light, " : "", + (state & _NEW_LIGHT_FF_PROGRAM)? "ctx->Light(FFProgram), " : "", + (state & _NEW_LIGHT_CONSTANTS) ? "ctx->Light(Constants), " : "", + (state & _NEW_LIGHT_STATE) ? "ctx->Light(State), " : "", (state & _NEW_LINE) ? "ctx->Line, " : "", (state & _NEW_PIXEL) ? "ctx->Pixel, " : "", (state & _NEW_POINT) ? "ctx->Point, " : "", diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c index 2d4800ac4c1..7551a6ccab8 100644 --- a/src/mesa/main/enable.c +++ b/src/mesa/main/enable.c @@ -494,7 +494,8 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) goto invalid_enum_error; if (ctx->Light.ColorMaterialEnabled == state) return; - FLUSH_VERTICES(ctx, _NEW_LIGHT, GL_LIGHTING_BIT | GL_ENABLE_BIT); + FLUSH_VERTICES(ctx, _NEW_LIGHT_CONSTANTS | _NEW_LIGHT_FF_PROGRAM, + GL_LIGHTING_BIT | GL_ENABLE_BIT); FLUSH_CURRENT(ctx, 0); ctx->Light.ColorMaterialEnabled = state; if (state) { @@ -553,7 +554,8 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) goto invalid_enum_error; if (ctx->Light.Light[cap-GL_LIGHT0].Enabled == state) return; - FLUSH_VERTICES(ctx, _NEW_LIGHT, GL_LIGHTING_BIT | GL_ENABLE_BIT); + FLUSH_VERTICES(ctx, _NEW_LIGHT_CONSTANTS | _NEW_LIGHT_FF_PROGRAM, + GL_LIGHTING_BIT | GL_ENABLE_BIT); ctx->Light.Light[cap-GL_LIGHT0].Enabled = state; if (state) { ctx->Light._EnabledLights |= 1u << (cap - GL_LIGHT0); @@ -567,7 +569,8 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state) goto invalid_enum_error; if (ctx->Light.Enabled == state) return; - FLUSH_VERTICES(ctx, _NEW_LIGHT, GL_LIGHTING_BIT | GL_ENABLE_BIT); + FLUSH_VERTICES(ctx, _NEW_LIGHT_CONSTANTS | _NEW_LIGHT_FF_PROGRAM | + _NEW_LIGHT_STATE, GL_LIGHTING_BIT | GL_ENABLE_BIT); ctx->Light.Enabled = state; break; case GL_LINE_SMOOTH: diff --git a/src/mesa/main/ff_fragment_shader.cpp b/src/mesa/main/ff_fragment_shader.cpp index 2b48df62878..c03e42d8dab 100644 --- a/src/mesa/main/ff_fragment_shader.cpp +++ b/src/mesa/main/ff_fragment_shader.cpp @@ -205,7 +205,7 @@ static GLbitfield filter_fp_input_mask( GLbitfield fp_inputs, /* First look at what values may be computed by the generated * vertex program: */ - /* _NEW_LIGHT */ + /* _NEW_LIGHT_FF_PROGRAM */ if (ctx->Light.Enabled) { possible_inputs |= VARYING_BIT_COL0; @@ -267,7 +267,7 @@ static GLuint make_state_key( struct gl_context *ctx, struct state_key *key ) memset(key, 0, sizeof(*key)); - /* _NEW_TEXTURE_OBJECT */ + /* _NEW_TEXTURE_OBJECT | _NEW_TEXTURE_STATE */ mask = ctx->Texture._EnabledCoordUnits; int i = -1; while (mask) { @@ -305,7 +305,7 @@ static GLuint make_state_key( struct gl_context *ctx, struct state_key *key ) key->nr_enabled_units = i + 1; - /* _NEW_LIGHT | _NEW_FOG */ + /* _NEW_LIGHT_FF_PROGRAM | _NEW_FOG */ if (texenv_doing_secondary_color(ctx)) { key->separate_specular = 1; inputs_referenced |= VARYING_BIT_COL1; diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c index 497bbd3efc4..a3c99c07b4e 100644 --- a/src/mesa/main/light.c +++ b/src/mesa/main/light.c @@ -51,7 +51,7 @@ _mesa_ShadeModel( GLenum mode ) return; } - FLUSH_VERTICES(ctx, _NEW_LIGHT, GL_LIGHTING_BIT); + FLUSH_VERTICES(ctx, _NEW_LIGHT_STATE, GL_LIGHTING_BIT); ctx->Light.ShadeModel = mode; if (ctx->Driver.ShadeModel) @@ -84,7 +84,7 @@ _mesa_ProvokingVertex(GLenum mode) return; } - FLUSH_VERTICES(ctx, _NEW_LIGHT, GL_LIGHTING_BIT); + FLUSH_VERTICES(ctx, _NEW_LIGHT_STATE, GL_LIGHTING_BIT); ctx->Light.ProvokingVertex = mode; } @@ -110,31 +110,40 @@ _mesa_light(struct gl_context *ctx, GLuint lnum, GLenum pname, const GLfloat *pa case GL_AMBIENT: if (TEST_EQ_4V(lu->Ambient, params)) return; - FLUSH_VERTICES(ctx, _NEW_LIGHT, GL_LIGHTING_BIT); + FLUSH_VERTICES(ctx, _NEW_LIGHT_CONSTANTS, GL_LIGHTING_BIT); COPY_4V( lu->Ambient, params ); break; case GL_DIFFUSE: if (TEST_EQ_4V(lu->Diffuse, params)) return; - FLUSH_VERTICES(ctx, _NEW_LIGHT, GL_LIGHTING_BIT); + FLUSH_VERTICES(ctx, _NEW_LIGHT_CONSTANTS, GL_LIGHTING_BIT); COPY_4V( lu->Diffuse, params ); break; case GL_SPECULAR: if (TEST_EQ_4V(lu->Specular, params)) return; - FLUSH_VERTICES(ctx, _NEW_LIGHT, GL_LIGHTING_BIT); + FLUSH_VERTICES(ctx, _NEW_LIGHT_CONSTANTS, GL_LIGHTING_BIT); COPY_4V( lu->Specular, params ); break; case GL_POSITION: { /* NOTE: position has already been transformed by ModelView! */ if (TEST_EQ_4V(lu->EyePosition, params)) return; - FLUSH_VERTICES(ctx, _NEW_LIGHT, GL_LIGHTING_BIT); + FLUSH_VERTICES(ctx, _NEW_LIGHT_CONSTANTS, GL_LIGHTING_BIT); + + bool old_positional = lu->EyePosition[3] != 0.0f; + bool positional = params[3] != 0.0f; COPY_4V(lu->EyePosition, params); - if (lu->EyePosition[3] != 0.0F) - light->_Flags |= LIGHT_POSITIONAL; - else - light->_Flags &= ~LIGHT_POSITIONAL; + + if (positional != old_positional) { + if (positional) + light->_Flags |= LIGHT_POSITIONAL; + else + light->_Flags &= ~LIGHT_POSITIONAL; + + /* Used by fixed-func vertex program. */ + ctx->NewState |= _NEW_LIGHT_FF_PROGRAM; + } static const GLfloat eye_z[] = {0, 0, 1}; GLfloat p[3]; @@ -154,7 +163,7 @@ _mesa_light(struct gl_context *ctx, GLuint lnum, GLenum pname, const GLfloat *pa /* NOTE: Direction already transformed by inverse ModelView! */ if (TEST_EQ_3V(lu->SpotDirection, params)) return; - FLUSH_VERTICES(ctx, _NEW_LIGHT, GL_LIGHTING_BIT); + FLUSH_VERTICES(ctx, _NEW_LIGHT_CONSTANTS, GL_LIGHTING_BIT); COPY_3V(lu->SpotDirection, params); break; case GL_SPOT_EXPONENT: @@ -162,44 +171,81 @@ _mesa_light(struct gl_context *ctx, GLuint lnum, GLenum pname, const GLfloat *pa assert(params[0] <= ctx->Const.MaxSpotExponent); if (lu->SpotExponent == params[0]) return; - FLUSH_VERTICES(ctx, _NEW_LIGHT, GL_LIGHTING_BIT); + FLUSH_VERTICES(ctx, _NEW_LIGHT_CONSTANTS, GL_LIGHTING_BIT); lu->SpotExponent = params[0]; break; - case GL_SPOT_CUTOFF: + case GL_SPOT_CUTOFF: { assert(params[0] == 180.0F || (params[0] >= 0.0F && params[0] <= 90.0F)); if (lu->SpotCutoff == params[0]) return; - FLUSH_VERTICES(ctx, _NEW_LIGHT, GL_LIGHTING_BIT); + FLUSH_VERTICES(ctx, _NEW_LIGHT_CONSTANTS, GL_LIGHTING_BIT); + + bool old_is_180 = lu->SpotCutoff == 180.0f; + bool is_180 = params[0] == 180.0f; lu->SpotCutoff = params[0]; lu->_CosCutoff = (cosf(lu->SpotCutoff * M_PI / 180.0)); if (lu->_CosCutoff < 0) lu->_CosCutoff = 0; - if (lu->SpotCutoff != 180.0F) - light->_Flags |= LIGHT_SPOT; - else - light->_Flags &= ~LIGHT_SPOT; + + if (is_180 != old_is_180) { + if (!is_180) + light->_Flags |= LIGHT_SPOT; + else + light->_Flags &= ~LIGHT_SPOT; + + /* Used by fixed-func vertex program. */ + ctx->NewState |= _NEW_LIGHT_FF_PROGRAM; + } break; - case GL_CONSTANT_ATTENUATION: + } + case GL_CONSTANT_ATTENUATION: { assert(params[0] >= 0.0F); if (lu->ConstantAttenuation == params[0]) return; - FLUSH_VERTICES(ctx, _NEW_LIGHT, GL_LIGHTING_BIT); + FLUSH_VERTICES(ctx, _NEW_LIGHT_CONSTANTS, GL_LIGHTING_BIT); + + bool old_is_one = lu->ConstantAttenuation == 1.0f; + bool is_one = params[0] == 1.0f; lu->ConstantAttenuation = params[0]; + + if (old_is_one != is_one) { + /* Used by fixed-func vertex program. */ + ctx->NewState |= _NEW_LIGHT_FF_PROGRAM; + } break; - case GL_LINEAR_ATTENUATION: + } + case GL_LINEAR_ATTENUATION: { assert(params[0] >= 0.0F); if (lu->LinearAttenuation == params[0]) return; - FLUSH_VERTICES(ctx, _NEW_LIGHT, GL_LIGHTING_BIT); + FLUSH_VERTICES(ctx, _NEW_LIGHT_CONSTANTS, GL_LIGHTING_BIT); + + bool old_is_zero = lu->LinearAttenuation == 0.0f; + bool is_zero = params[0] == 0.0f; lu->LinearAttenuation = params[0]; + + if (old_is_zero != is_zero) { + /* Used by fixed-func vertex program. */ + ctx->NewState |= _NEW_LIGHT_FF_PROGRAM; + } break; - case GL_QUADRATIC_ATTENUATION: + } + case GL_QUADRATIC_ATTENUATION: { assert(params[0] >= 0.0F); if (lu->QuadraticAttenuation == params[0]) return; - FLUSH_VERTICES(ctx, _NEW_LIGHT, GL_LIGHTING_BIT); + FLUSH_VERTICES(ctx, _NEW_LIGHT_CONSTANTS, GL_LIGHTING_BIT); + + bool old_is_zero = lu->QuadraticAttenuation == 0.0f; + bool is_zero = params[0] == 0.0f; lu->QuadraticAttenuation = params[0]; + + if (old_is_zero != is_zero) { + /* Used by fixed-func vertex program. */ + ctx->NewState |= _NEW_LIGHT_FF_PROGRAM; + } break; + } default: unreachable("Unexpected pname in _mesa_light()"); } @@ -461,7 +507,7 @@ _mesa_LightModelfv( GLenum pname, const GLfloat *params ) case GL_LIGHT_MODEL_AMBIENT: if (TEST_EQ_4V( ctx->Light.Model.Ambient, params )) return; - FLUSH_VERTICES(ctx, _NEW_LIGHT, GL_LIGHTING_BIT); + FLUSH_VERTICES(ctx, _NEW_LIGHT_CONSTANTS, GL_LIGHTING_BIT); COPY_4V( ctx->Light.Model.Ambient, params ); break; case GL_LIGHT_MODEL_LOCAL_VIEWER: @@ -470,14 +516,16 @@ _mesa_LightModelfv( GLenum pname, const GLfloat *params ) newbool = (params[0] != 0.0F); if (ctx->Light.Model.LocalViewer == newbool) return; - FLUSH_VERTICES(ctx, _NEW_LIGHT, GL_LIGHTING_BIT); + FLUSH_VERTICES(ctx, _NEW_LIGHT_CONSTANTS | _NEW_LIGHT_FF_PROGRAM, + GL_LIGHTING_BIT); ctx->Light.Model.LocalViewer = newbool; break; case GL_LIGHT_MODEL_TWO_SIDE: newbool = (params[0] != 0.0F); if (ctx->Light.Model.TwoSide == newbool) return; - FLUSH_VERTICES(ctx, _NEW_LIGHT, GL_LIGHTING_BIT); + FLUSH_VERTICES(ctx, _NEW_LIGHT_CONSTANTS | _NEW_LIGHT_FF_PROGRAM | + _NEW_LIGHT_STATE, GL_LIGHTING_BIT); ctx->Light.Model.TwoSide = newbool; break; case GL_LIGHT_MODEL_COLOR_CONTROL: @@ -494,7 +542,8 @@ _mesa_LightModelfv( GLenum pname, const GLfloat *params ) } if (ctx->Light.Model.ColorControl == newenum) return; - FLUSH_VERTICES(ctx, _NEW_LIGHT, GL_LIGHTING_BIT); + FLUSH_VERTICES(ctx, _NEW_LIGHT_CONSTANTS | _NEW_LIGHT_FF_PROGRAM, + GL_LIGHTING_BIT); ctx->Light.Model.ColorControl = newenum; break; default: @@ -763,13 +812,14 @@ _mesa_ColorMaterial( GLenum face, GLenum mode ) ctx->Light.ColorMaterialMode == mode) return; - FLUSH_VERTICES(ctx, _NEW_LIGHT, GL_LIGHTING_BIT); + FLUSH_VERTICES(ctx, 0, GL_LIGHTING_BIT); ctx->Light._ColorMaterialBitmask = bitmask; ctx->Light.ColorMaterialFace = face; ctx->Light.ColorMaterialMode = mode; if (ctx->Light.ColorMaterialEnabled) { - FLUSH_CURRENT( ctx, 0 ); + /* Used by fixed-func vertex program. */ + FLUSH_CURRENT(ctx, _NEW_LIGHT_FF_PROGRAM); _mesa_update_color_material(ctx,ctx->Current.Attrib[VERT_ATTRIB_COLOR0]); } @@ -957,10 +1007,10 @@ _mesa_update_lighting( struct gl_context *ctx ) * Update state derived from light position, spot direction. * Called upon: * _NEW_MODELVIEW - * _NEW_LIGHT + * _NEW_LIGHT_CONSTANTS * _TNL_NEW_NEED_EYE_COORDS * - * Update on (_NEW_MODELVIEW | _NEW_LIGHT) when lighting is enabled. + * Update on (_NEW_MODELVIEW | _NEW_LIGHT_CONSTANTS) when lighting is enabled. * Also update on lighting space changes. */ static void @@ -1110,7 +1160,7 @@ _mesa_update_tnl_spaces( struct gl_context *ctx, GLuint new_state ) if (new_state2 & _NEW_MODELVIEW) update_modelview_scale(ctx); - if (new_state2 & (_NEW_LIGHT|_NEW_MODELVIEW)) + if (new_state2 & (_NEW_LIGHT_CONSTANTS | _NEW_MODELVIEW)) compute_light_positions( ctx ); } } diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index d31514396b4..661c0f0d2d5 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -4631,10 +4631,10 @@ struct gl_matrix_stack #define _NEW_TEXTURE_MATRIX (1u << 2) /**< gl_context::TextureMatrix */ #define _NEW_COLOR (1u << 3) /**< gl_context::Color */ #define _NEW_DEPTH (1u << 4) /**< gl_context::Depth */ -/* gap */ +#define _NEW_LIGHT_FF_PROGRAM (1u << 5) /**< gl_context::Light */ #define _NEW_FOG (1u << 6) /**< gl_context::Fog */ #define _NEW_HINT (1u << 7) /**< gl_context::Hint */ -#define _NEW_LIGHT (1u << 8) /**< gl_context::Light */ +#define _NEW_LIGHT_CONSTANTS (1u << 8) /**< gl_context::Light */ #define _NEW_LINE (1u << 9) /**< gl_context::Line */ #define _NEW_PIXEL (1u << 10) /**< gl_context::Pixel */ #define _NEW_POINT (1u << 11) /**< gl_context::Point */ @@ -4646,7 +4646,7 @@ struct gl_matrix_stack #define _NEW_TRANSFORM (1u << 17) /**< gl_context::Transform */ #define _NEW_VIEWPORT (1u << 18) /**< gl_context::Viewport */ #define _NEW_TEXTURE_STATE (1u << 19) /**< gl_context::Texture (states only) */ -/* gap */ +#define _NEW_LIGHT_STATE (1u << 20) /**< gl_context::Light */ #define _NEW_RENDERMODE (1u << 21) /**< gl_context::RenderMode, etc */ #define _NEW_BUFFERS (1u << 22) /**< gl_context::Visual, DrawBuffer, */ #define _NEW_CURRENT_ATTRIB (1u << 23) /**< gl_context::Current */ @@ -4666,9 +4666,14 @@ struct gl_matrix_stack * Composite state flags */ /*@{*/ +#define _NEW_LIGHT (_NEW_LIGHT_FF_PROGRAM | /* fixed-func programs */ \ + _NEW_LIGHT_CONSTANTS | /* state parameters */ \ + _NEW_LIGHT_STATE) /* rasterizer state */ + #define _NEW_TEXTURE (_NEW_TEXTURE_OBJECT | _NEW_TEXTURE_STATE) -#define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT | \ +#define _MESA_NEW_NEED_EYE_COORDS (_NEW_LIGHT_FF_PROGRAM | \ + _NEW_LIGHT_CONSTANTS | \ _NEW_TEXTURE_STATE | \ _NEW_POINT | \ _NEW_PROGRAM | \ diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 7b32a091d74..4406c81737f 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -462,7 +462,7 @@ _mesa_update_state_locked( struct gl_context *ctx ) if (new_state & (_NEW_TEXTURE_OBJECT | _NEW_TEXTURE_STATE | _NEW_PROGRAM)) _mesa_update_texture_state(ctx); - if (new_state & _NEW_LIGHT) + if (new_state & (_NEW_LIGHT_FF_PROGRAM | _NEW_LIGHT_CONSTANTS)) _mesa_update_lighting(ctx); if (new_state & _NEW_PIXEL) @@ -488,14 +488,15 @@ _mesa_update_state_locked( struct gl_context *ctx ) if (ctx->FragmentProgram._UsesTexEnvProgram) { prog_flags |= _NEW_BUFFERS | _NEW_TEXTURE_OBJECT | _NEW_FOG | - _NEW_VARYING_VP_INPUTS | _NEW_LIGHT | _NEW_POINT | - _NEW_RENDERMODE | _NEW_COLOR | _NEW_TEXTURE_STATE; + _NEW_VARYING_VP_INPUTS | _NEW_LIGHT_FF_PROGRAM | + _NEW_POINT | _NEW_RENDERMODE | _NEW_COLOR | + _NEW_TEXTURE_STATE; } if (ctx->VertexProgram._UsesTnlProgram) { prog_flags |= _NEW_VARYING_VP_INPUTS | _NEW_TEXTURE_OBJECT | _NEW_TEXTURE_MATRIX | _NEW_TRANSFORM | _NEW_POINT | - _NEW_FOG | _NEW_LIGHT | _NEW_TEXTURE_STATE | + _NEW_FOG | _NEW_LIGHT_FF_PROGRAM | _NEW_TEXTURE_STATE | _MESA_NEW_NEED_EYE_COORDS; } diff --git a/src/mesa/program/prog_statevars.c b/src/mesa/program/prog_statevars.c index 59f42d0d3e2..349e257d345 100644 --- a/src/mesa/program/prog_statevars.c +++ b/src/mesa/program/prog_statevars.c @@ -693,7 +693,7 @@ _mesa_program_state_flags(const gl_state_index16 state[STATE_LENGTH]) case STATE_LIGHTPROD: case STATE_LIGHTMODEL_SCENECOLOR: /* these can be effected by glColor when colormaterial mode is used */ - return _NEW_LIGHT | _NEW_CURRENT_ATTRIB; + return _NEW_LIGHT_CONSTANTS | _NEW_CURRENT_ATTRIB; case STATE_LIGHT: case STATE_LIGHT_ARRAY: @@ -702,7 +702,7 @@ _mesa_program_state_flags(const gl_state_index16 state[STATE_LENGTH]) case STATE_LIGHT_POSITION: case STATE_LIGHT_POSITION_NORMALIZED: case STATE_LIGHT_HALF_VECTOR: - return _NEW_LIGHT; + return _NEW_LIGHT_CONSTANTS; case STATE_TEXGEN: return _NEW_TEXTURE_STATE; @@ -775,7 +775,7 @@ _mesa_program_state_flags(const gl_state_index16 state[STATE_LENGTH]) case STATE_CURRENT_ATTRIB: return _NEW_CURRENT_ATTRIB; case STATE_CURRENT_ATTRIB_MAYBE_VP_CLAMPED: - return _NEW_CURRENT_ATTRIB | _NEW_LIGHT | _NEW_BUFFERS; + return _NEW_CURRENT_ATTRIB | _NEW_LIGHT_STATE | _NEW_BUFFERS; case STATE_POINT_SIZE_CLAMPED: return _NEW_POINT | _NEW_MULTISAMPLE; diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c index 4c1abfb6800..dec747b9ea7 100644 --- a/src/mesa/state_tracker/st_atom_rasterizer.c +++ b/src/mesa/state_tracker/st_atom_rasterizer.c @@ -92,19 +92,18 @@ st_update_rasterizer(struct st_context *st) } } - /* _NEW_LIGHT - */ + /* _NEW_LIGHT_STATE */ raster->flatshade = !st->lower_flatshade && ctx->Light.ShadeModel == GL_FLAT; raster->flatshade_first = ctx->Light.ProvokingVertex == GL_FIRST_VERTEX_CONVENTION_EXT; - /* _NEW_LIGHT | _NEW_PROGRAM */ + /* _NEW_LIGHT_STATE | _NEW_PROGRAM */ if (!st->lower_two_sided_color) raster->light_twoside = _mesa_vertex_program_two_side_enabled(ctx); - /*_NEW_LIGHT | _NEW_BUFFERS */ + /*_NEW_LIGHT_STATE | _NEW_BUFFERS */ raster->clamp_vertex_color = !st->clamp_vert_color_in_shader && ctx->Light._ClampVertexColor; diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c index 9d8311f5165..c44666ab16d 100644 --- a/src/mesa/state_tracker/st_atom_shader.c +++ b/src/mesa/state_tracker/st_atom_shader.c @@ -147,7 +147,7 @@ st_update_fp( struct st_context *st ) if (st->lower_alpha_test && _mesa_is_alpha_test_enabled(st->ctx)) key.lower_alpha_func = st->ctx->Color.AlphaFunc; - /* _NEW_LIGHT | _NEW_PROGRAM */ + /* _NEW_LIGHT_STATE | _NEW_PROGRAM */ key.lower_two_sided_color = st->lower_two_sided_color && _mesa_vertex_program_two_side_enabled(st->ctx); diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index ec325e6a6c3..c5ed8d88e8f 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -223,11 +223,11 @@ st_invalidate_state(struct gl_context *ctx) st->dirty |= ST_NEW_FS_STATE; } - if (new_state & (_NEW_LIGHT | + if (new_state & (_NEW_LIGHT_STATE | _NEW_POINT)) st->dirty |= ST_NEW_RASTERIZER; - if ((new_state & _NEW_LIGHT) && + if ((new_state & _NEW_LIGHT_STATE) && (st->lower_flatshade || st->lower_two_sided_color)) st->dirty |= ST_NEW_FS_STATE; @@ -255,7 +255,7 @@ st_invalidate_state(struct gl_context *ctx) } /* Update the vertex shader if ctx->Light._ClampVertexColor was changed. */ - if (st->clamp_vert_color_in_shader && (new_state & _NEW_LIGHT)) { + if (st->clamp_vert_color_in_shader && (new_state & _NEW_LIGHT_STATE)) { st->dirty |= ST_NEW_VS_STATE; if (st->ctx->API == API_OPENGL_COMPAT && ctx->Version >= 32) { st->dirty |= ST_NEW_GS_STATE | ST_NEW_TES_STATE; diff --git a/src/mesa/vbo/vbo_exec_api.c b/src/mesa/vbo/vbo_exec_api.c index e030b610536..fee3cbd3f60 100644 --- a/src/mesa/vbo/vbo_exec_api.c +++ b/src/mesa/vbo/vbo_exec_api.c @@ -225,8 +225,13 @@ vbo_exec_copy_to_current(struct vbo_exec_context *exec) */ if (i >= VBO_ATTRIB_MAT_FRONT_AMBIENT && i <= VBO_ATTRIB_MAT_BACK_INDEXES) { - ctx->NewState |= _NEW_LIGHT; + ctx->NewState |= _NEW_LIGHT_CONSTANTS; ctx->PopAttribState |= GL_LIGHTING_BIT; + + /* The fixed-func vertex program uses this. */ + if (i == VBO_ATTRIB_MAT_FRONT_SHININESS || + i == VBO_ATTRIB_MAT_BACK_SHININESS) + ctx->NewState |= _NEW_LIGHT_FF_PROGRAM; } ctx->NewState |= _NEW_CURRENT_ATTRIB; diff --git a/src/mesa/vbo/vbo_save_draw.c b/src/mesa/vbo/vbo_save_draw.c index 15ace15c673..ec667703e3b 100644 --- a/src/mesa/vbo/vbo_save_draw.c +++ b/src/mesa/vbo/vbo_save_draw.c @@ -53,7 +53,8 @@ copy_vao(struct gl_context *ctx, const struct gl_vertex_array_object *vao, while (mask) { const int i = u_bit_scan(&mask); const struct gl_array_attributes *attrib = &vao->VertexAttrib[i]; - struct gl_array_attributes *currval = &vbo->current[shift + i]; + unsigned current_index = shift + i; + struct gl_array_attributes *currval = &vbo->current[current_index]; const GLubyte size = attrib->Format.Size; const GLenum16 type = attrib->Format.Type; fi_type tmp[8]; @@ -74,6 +75,11 @@ copy_vao(struct gl_context *ctx, const struct gl_vertex_array_object *vao, vbo_set_vertex_format(&currval->Format, size, type); + /* The fixed-func vertex program uses this. */ + if (current_index == VBO_ATTRIB_MAT_FRONT_SHININESS || + current_index == VBO_ATTRIB_MAT_BACK_SHININESS) + ctx->NewState |= _NEW_LIGHT_FF_PROGRAM; + ctx->NewState |= state; ctx->PopAttribState |= pop_state; } @@ -99,7 +105,7 @@ playback_copy_to_current(struct gl_context *ctx, _NEW_CURRENT_ATTRIB, GL_CURRENT_BIT, 0, &data); /* Copy materials */ copy_vao(ctx, node->VAO[VP_MODE_FF], VERT_BIT_MAT_ALL, - _NEW_CURRENT_ATTRIB | _NEW_LIGHT, + _NEW_CURRENT_ATTRIB | _NEW_LIGHT_CONSTANTS, GL_CURRENT_BIT | GL_LIGHTING_BIT, VBO_MATERIAL_SHIFT, &data);