mesa: add _NEW_MATERIAL to reduce the weight of _NEW_LIGHT_CONSTANTS

This reduces no-op compute_light_positions in _mesa_update_state.

Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8850>
This commit is contained in:
Marek Olšák 2021-02-01 15:07:31 -05:00 committed by Marge Bot
parent 10371c520c
commit 2060e952ec
6 changed files with 15 additions and 13 deletions

View file

@ -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_CONSTANTS because current attribs may reference materials. */
ctx->NewState |= _NEW_CURRENT_ATTRIB | _NEW_LIGHT_CONSTANTS;
/* Set _NEW_MATERIAL because current attribs may reference materials. */
ctx->NewState |= _NEW_CURRENT_ATTRIB | _NEW_MATERIAL;
}
if (mask & GL_DEPTH_BUFFER_BIT) {
@ -1021,7 +1021,7 @@ _mesa_PopAttrib(void)
attr->Light.ColorMaterialEnabled, GL_COLOR_MATERIAL);
/* Materials - they might be used by current attribs. */
/* Shininess material is used by the fixed-func vertex program. */
ctx->NewState |= _NEW_CURRENT_ATTRIB | _NEW_LIGHT_FF_PROGRAM;
ctx->NewState |= _NEW_MATERIAL | _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) {

View file

@ -4656,7 +4656,7 @@ struct gl_matrix_stack
#define _NEW_PROGRAM_CONSTANTS (1u << 27)
#define _NEW_FF_VERT_PROGRAM (1u << 28)
#define _NEW_FRAG_CLAMP (1u << 29)
/* gap, re-use for core Mesa state only; use ctx->DriverFlags otherwise */
#define _NEW_MATERIAL (1u << 30) /**< gl_context::Light.Material */
#define _NEW_VARYING_VP_INPUTS (1u << 31) /**< gl_context::VertexProgram._VaryingInputs */
#define _NEW_ALL ~0
/*@}*/
@ -4668,7 +4668,8 @@ struct gl_matrix_stack
/*@{*/
#define _NEW_LIGHT (_NEW_LIGHT_FF_PROGRAM | /* fixed-func programs */ \
_NEW_LIGHT_CONSTANTS | /* state parameters */ \
_NEW_LIGHT_STATE) /* rasterizer state */
_NEW_LIGHT_STATE | /* rasterizer state */ \
_NEW_MATERIAL) /* light materials */
#define _NEW_TEXTURE (_NEW_TEXTURE_OBJECT | _NEW_TEXTURE_STATE)

View file

@ -462,7 +462,8 @@ _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_FF_PROGRAM | _NEW_LIGHT_CONSTANTS))
if (new_state & (_NEW_LIGHT_FF_PROGRAM | _NEW_LIGHT_CONSTANTS |
_NEW_MATERIAL))
_mesa_update_lighting(ctx);
if (new_state & _NEW_PIXEL)

View file

@ -694,10 +694,13 @@ _mesa_program_state_flags(const gl_state_index16 state[STATE_LENGTH])
{
switch (state[0]) {
case STATE_MATERIAL:
/* these can be affected by glColor when colormaterial mode is used */
return _NEW_MATERIAL | _NEW_CURRENT_ATTRIB;
case STATE_LIGHTPROD:
case STATE_LIGHTMODEL_SCENECOLOR:
/* these can be effected by glColor when colormaterial mode is used */
return _NEW_LIGHT_CONSTANTS | _NEW_CURRENT_ATTRIB;
/* these can be affected by glColor when colormaterial mode is used */
return _NEW_LIGHT_CONSTANTS | _NEW_MATERIAL | _NEW_CURRENT_ATTRIB;
case STATE_LIGHT:
case STATE_LIGHT_ARRAY:

View file

@ -220,12 +220,9 @@ vbo_exec_copy_to_current(struct vbo_exec_context *exec)
exec->vtx.attr[i].size / dmul,
exec->vtx.attr[i].type);
/* This triggers rather too much recalculation of Mesa state
* that doesn't get used (eg light positions).
*/
if (i >= VBO_ATTRIB_MAT_FRONT_AMBIENT &&
i <= VBO_ATTRIB_MAT_BACK_INDEXES) {
ctx->NewState |= _NEW_LIGHT_CONSTANTS;
ctx->NewState |= _NEW_MATERIAL;
ctx->PopAttribState |= GL_LIGHTING_BIT;
/* The fixed-func vertex program uses this. */

View file

@ -105,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_CONSTANTS,
_NEW_CURRENT_ATTRIB | _NEW_MATERIAL,
GL_CURRENT_BIT | GL_LIGHTING_BIT,
VBO_MATERIAL_SHIFT, &data);