mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 07:18:17 +02:00
mesa: rework _MESA_NEW_NEED_EYE_COORDS to reduce fixed-func program updates
This eliminates a lot of the remaining no-op fixed-func program key recomputations 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:
parent
14c933b900
commit
bc05833c8a
4 changed files with 18 additions and 11 deletions
|
|
@ -1120,8 +1120,10 @@ update_modelview_scale( struct gl_context *ctx )
|
|||
|
||||
/**
|
||||
* Bring up to date any state that relies on _NeedEyeCoords.
|
||||
*
|
||||
* Return true if ctx->_NeedEyeCoords has been changed.
|
||||
*/
|
||||
void
|
||||
bool
|
||||
_mesa_update_tnl_spaces( struct gl_context *ctx, GLuint new_state )
|
||||
{
|
||||
const GLuint oldneedeyecoords = ctx->_NeedEyeCoords;
|
||||
|
|
@ -1150,6 +1152,7 @@ _mesa_update_tnl_spaces( struct gl_context *ctx, GLuint new_state )
|
|||
|
||||
if (ctx->Driver.LightingSpaceChange)
|
||||
ctx->Driver.LightingSpaceChange( ctx );
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
GLuint new_state2 = ctx->NewState;
|
||||
|
|
@ -1162,6 +1165,8 @@ _mesa_update_tnl_spaces( struct gl_context *ctx, GLuint new_state )
|
|||
|
||||
if (new_state2 & (_NEW_LIGHT_CONSTANTS | _NEW_MODELVIEW))
|
||||
compute_light_positions( ctx );
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1174,9 +1179,7 @@ void
|
|||
_mesa_allow_light_in_model( struct gl_context *ctx, GLboolean flag )
|
||||
{
|
||||
ctx->_ForceEyeCoords = !flag;
|
||||
ctx->NewState |= _NEW_POINT; /* one of the bits from
|
||||
* _MESA_NEW_NEED_EYE_COORDS.
|
||||
*/
|
||||
ctx->NewState |= _NEW_POINT; /* for _mesa_update_tnl_spaces */
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
#define LIGHT_H
|
||||
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "glheader.h"
|
||||
|
||||
struct gl_context;
|
||||
|
|
@ -92,7 +93,7 @@ extern GLuint _mesa_material_bitmask( struct gl_context *ctx,
|
|||
|
||||
extern void _mesa_update_lighting( struct gl_context *ctx );
|
||||
|
||||
extern void _mesa_update_tnl_spaces( struct gl_context *ctx, GLuint new_state );
|
||||
extern bool _mesa_update_tnl_spaces( struct gl_context *ctx, GLuint new_state );
|
||||
|
||||
extern void _mesa_update_material( struct gl_context *ctx,
|
||||
GLuint bitmask );
|
||||
|
|
|
|||
|
|
@ -4654,7 +4654,7 @@ struct gl_matrix_stack
|
|||
#define _NEW_TRACK_MATRIX (1u << 25) /**< gl_context::VertexProgram */
|
||||
#define _NEW_PROGRAM (1u << 26) /**< New program/shader state */
|
||||
#define _NEW_PROGRAM_CONSTANTS (1u << 27)
|
||||
/* gap */
|
||||
#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_VARYING_VP_INPUTS (1u << 31) /**< gl_context::VertexProgram._VaryingInputs */
|
||||
|
|
@ -4663,7 +4663,7 @@ struct gl_matrix_stack
|
|||
|
||||
|
||||
/**
|
||||
* Composite state flags
|
||||
* Composite state flags, deprecated and inefficient, do not use.
|
||||
*/
|
||||
/*@{*/
|
||||
#define _NEW_LIGHT (_NEW_LIGHT_FF_PROGRAM | /* fixed-func programs */ \
|
||||
|
|
|
|||
|
|
@ -468,7 +468,7 @@ _mesa_update_state_locked( struct gl_context *ctx )
|
|||
if (new_state & _NEW_PIXEL)
|
||||
_mesa_update_pixel( ctx );
|
||||
|
||||
/* ctx->_NeedEyeCoords is now up to date.
|
||||
/* ctx->_NeedEyeCoords is determined here.
|
||||
*
|
||||
* If the truth value of this variable has changed, update for the
|
||||
* new lighting space and recompute the positions of lights and the
|
||||
|
|
@ -477,8 +477,11 @@ _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 & _MESA_NEW_NEED_EYE_COORDS)
|
||||
_mesa_update_tnl_spaces( ctx, new_state );
|
||||
if (new_state & (_NEW_LIGHT_FF_PROGRAM | _NEW_LIGHT_CONSTANTS |
|
||||
_NEW_TEXTURE_STATE | _NEW_POINT | _NEW_MODELVIEW)) {
|
||||
if (_mesa_update_tnl_spaces(ctx, new_state))
|
||||
new_state |= _NEW_FF_VERT_PROGRAM;
|
||||
}
|
||||
|
||||
if (new_state & _NEW_PROGRAM)
|
||||
update_fixed_func_program_usage(ctx);
|
||||
|
|
@ -497,7 +500,7 @@ _mesa_update_state_locked( struct gl_context *ctx )
|
|||
prog_flags |= _NEW_VARYING_VP_INPUTS | _NEW_TEXTURE_OBJECT |
|
||||
_NEW_TEXTURE_MATRIX | _NEW_TRANSFORM | _NEW_POINT |
|
||||
_NEW_FOG | _NEW_LIGHT_FF_PROGRAM | _NEW_TEXTURE_STATE |
|
||||
_MESA_NEW_NEED_EYE_COORDS;
|
||||
_NEW_FF_VERT_PROGRAM;
|
||||
}
|
||||
|
||||
if (new_state & prog_flags) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue