mesa: don't update derived material values in _mesa_update_state and elsewhere

To my great surprise, many drivers don't use these values at all.
Move the update to the places where they are used.

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:46:25 -05:00 committed by Marge Bot
parent 2060e952ec
commit 8e56ad6fae
5 changed files with 14 additions and 7 deletions

View file

@ -783,8 +783,6 @@ _mesa_update_color_material( struct gl_context *ctx, const GLfloat color[4] )
COPY_4FV( mat->Attrib[i], color );
}
_mesa_update_material( ctx, bitmask );
}
@ -978,7 +976,11 @@ _mesa_update_lighting( struct gl_context *ctx )
*/
if (ctx->Light._NeedVertices)
ctx->Light._NeedEyeCoords = GL_TRUE;
}
void
_mesa_update_light_materials(struct gl_context *ctx)
{
/* Precompute some shading values. Although we reference
* Light.Material here, we can get away without flushing
* FLUSH_UPDATE_CURRENT, as when any outstanding material changes

View file

@ -92,7 +92,7 @@ extern GLuint _mesa_material_bitmask( struct gl_context *ctx,
const char * );
extern void _mesa_update_lighting( struct gl_context *ctx );
extern void _mesa_update_light_materials(struct gl_context *ctx);
extern bool _mesa_update_tnl_spaces( struct gl_context *ctx, GLuint new_state );
extern void _mesa_update_material( struct gl_context *ctx,

View file

@ -35,6 +35,7 @@
#include "mtypes.h"
#include "rastpos.h"
#include "state.h"
#include "main/light.h"
#include "main/viewport.h"
#include "util/bitscan.h"
@ -145,6 +146,8 @@ shade_rastpos(struct gl_context *ctx,
GLbitfield mask;
GLfloat diffuseColor[4], specularColor[4]; /* for RGB mode only */
_mesa_update_light_materials(ctx);
COPY_3V(diffuseColor, base[0]);
diffuseColor[3] = CLAMP(
ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3], 0.0F, 1.0F );

View file

@ -462,8 +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_FF_PROGRAM | _NEW_LIGHT_CONSTANTS |
_NEW_MATERIAL))
if (new_state & _NEW_LIGHT_CONSTANTS)
_mesa_update_lighting(ctx);
if (new_state & _NEW_PIXEL)
@ -478,8 +477,8 @@ _mesa_update_state_locked( struct gl_context *ctx )
* If the lighting space hasn't changed, may still need to recompute
* light positions & normal transforms for other reasons.
*/
if (new_state & (_NEW_LIGHT_FF_PROGRAM | _NEW_LIGHT_CONSTANTS |
_NEW_TEXTURE_STATE | _NEW_POINT | _NEW_MODELVIEW)) {
if (new_state & (_NEW_LIGHT_CONSTANTS | _NEW_TEXTURE_STATE |
_NEW_POINT | _NEW_MODELVIEW)) {
if (_mesa_update_tnl_spaces(ctx, new_state))
new_state |= _NEW_FF_VERT_PROGRAM;
}

View file

@ -134,6 +134,9 @@ _tnl_InvalidateState( struct gl_context *ctx, GLuint new_state )
const struct gl_program *fp = ctx->FragmentProgram._Current;
GLuint i;
if (new_state & (_NEW_LIGHT_CONSTANTS | _NEW_MATERIAL))
_mesa_update_light_materials(ctx);
if (new_state & (_NEW_HINT | _NEW_PROGRAM)) {
assert(tnl->AllowVertexFog || tnl->AllowPixelFog);
tnl->_DoVertexFog = ((tnl->AllowVertexFog && (ctx->Hint.Fog != GL_NICEST))