From ebef43e248a6911031751e60de23b654d2322c6c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Wed, 3 Feb 2021 14:02:39 -0500 Subject: [PATCH] mesa: don't update tnl spaces on irrelevant _NEW_POINT/TEXTURE_STATE changes MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Zoltán Böszörményi Acked-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/mesa/main/light.c | 14 ++++++++++---- src/mesa/main/light.h | 2 +- src/mesa/main/mtypes.h | 2 +- src/mesa/main/points.c | 3 ++- src/mesa/main/state.c | 6 +++--- src/mesa/main/texstate.c | 4 ++++ 6 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c index 8317173..bb513f7 100644 --- a/src/mesa/main/light.c +++ b/src/mesa/main/light.c @@ -949,14 +949,17 @@ _mesa_GetMaterialiv( GLenum face, GLenum pname, GLint *params ) * Also, precompute some lighting values such as the products of light * source and material ambient, diffuse and specular coefficients. */ -void +GLbitfield _mesa_update_lighting( struct gl_context *ctx ) { GLbitfield flags = 0; + bool old_need_eye_coords = ctx->Light._NeedEyeCoords; ctx->Light._NeedEyeCoords = GL_FALSE; - if (!ctx->Light.Enabled) - return; + if (!ctx->Light.Enabled) { + return old_need_eye_coords != ctx->Light._NeedEyeCoords ? + _NEW_TNL_SPACES : 0; + } GLbitfield mask = ctx->Light._EnabledLights; while (mask) { @@ -979,6 +982,9 @@ _mesa_update_lighting( struct gl_context *ctx ) */ if (ctx->Light._NeedVertices) ctx->Light._NeedEyeCoords = GL_TRUE; + + return old_need_eye_coords != ctx->Light._NeedEyeCoords ? + _NEW_TNL_SPACES : 0; } void @@ -1184,7 +1190,7 @@ void _mesa_allow_light_in_model( struct gl_context *ctx, GLboolean flag ) { ctx->_ForceEyeCoords = !flag; - ctx->NewState |= _NEW_POINT; /* for _mesa_update_tnl_spaces */ + ctx->NewState |= _NEW_TNL_SPACES; } diff --git a/src/mesa/main/light.h b/src/mesa/main/light.h index 973f7d4..855389e 100644 --- a/src/mesa/main/light.h +++ b/src/mesa/main/light.h @@ -91,7 +91,7 @@ extern GLuint _mesa_material_bitmask( struct gl_context *ctx, GLuint legal, const char * ); -extern void _mesa_update_lighting( struct gl_context *ctx ); +extern GLbitfield _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 ); diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 5f62ffc..ecdf2d0 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -4631,7 +4631,7 @@ 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_TNL_SPACES (1u << 5) /**< _mesa_update_tnl_spaces */ #define _NEW_FOG (1u << 6) /**< gl_context::Fog */ #define _NEW_HINT (1u << 7) /**< gl_context::Hint */ #define _NEW_LIGHT_CONSTANTS (1u << 8) /**< gl_context::Light */ diff --git a/src/mesa/main/points.c b/src/mesa/main/points.c index 1b0be65..c336d88 100644 --- a/src/mesa/main/points.c +++ b/src/mesa/main/points.c @@ -130,7 +130,8 @@ _mesa_PointParameterfv( GLenum pname, const GLfloat *params) case GL_DISTANCE_ATTENUATION_EXT: if (TEST_EQ_3V(ctx->Point.Params, params)) return; - FLUSH_VERTICES(ctx, _NEW_POINT | _NEW_FF_VERT_PROGRAM, GL_POINT_BIT); + FLUSH_VERTICES(ctx, _NEW_POINT | _NEW_FF_VERT_PROGRAM | + _NEW_TNL_SPACES, GL_POINT_BIT); COPY_3V(ctx->Point.Params, params); ctx->Point._Attenuated = (ctx->Point.Params[0] != 1.0F || ctx->Point.Params[1] != 0.0F || diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index 9a77ef3..e184338 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -463,7 +463,7 @@ _mesa_update_state_locked( struct gl_context *ctx ) new_state |= _mesa_update_texture_state(ctx); if (new_state & _NEW_LIGHT_CONSTANTS) - _mesa_update_lighting(ctx); + new_state |= _mesa_update_lighting(ctx); /* ctx->_NeedEyeCoords is determined here. * @@ -474,8 +474,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_CONSTANTS | _NEW_TEXTURE_STATE | - _NEW_POINT | _NEW_MODELVIEW)) { + if (new_state & (_NEW_TNL_SPACES | _NEW_LIGHT_CONSTANTS | + _NEW_MODELVIEW)) { if (_mesa_update_tnl_spaces(ctx, new_state)) new_state |= _NEW_FF_VERT_PROGRAM; } diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index 1e8baea..cbdfb18 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -903,6 +903,7 @@ _mesa_update_texture_state(struct gl_context *ctx) /* TODO: only set this if there are actual changes */ ctx->NewState |= _NEW_TEXTURE_OBJECT | _NEW_TEXTURE_STATE; + GLbitfield old_genflags = ctx->Texture._GenFlags; GLbitfield old_enabled_coord_units = ctx->Texture._EnabledCoordUnits; GLbitfield old_texgen_enabled = ctx->Texture._TexGenEnabled; GLbitfield old_texmat_enabled = ctx->Texture._TexMatEnabled; @@ -954,6 +955,9 @@ _mesa_update_texture_state(struct gl_context *ctx) new_state |= _NEW_FF_VERT_PROGRAM | _NEW_FF_FRAG_PROGRAM; } + if (old_genflags != ctx->Texture._GenFlags) + new_state |= _NEW_TNL_SPACES; + return new_state; } -- 2.7.4