From 4bc0edd1cf9207ce3023cd45ba20bc1efb730da3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Fri, 18 Nov 2022 06:53:48 -0500 Subject: [PATCH] st/mesa: update st_context::active_states in _mesa_update_state just a code movement to a better place Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/mesa/main/state.c | 32 +++++++++++++++++++++++++++++++- src/mesa/main/state.h | 3 +++ src/mesa/state_tracker/st_context.c | 36 +----------------------------------- 3 files changed, 35 insertions(+), 36 deletions(-) diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index daf5688..5cba82c 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -150,6 +150,33 @@ _mesa_update_allow_draw_out_of_order(struct gl_context *ctx) FLUSH_VERTICES(ctx, 0, 0); } +uint64_t +_mesa_get_active_states(struct gl_context *ctx) +{ + struct gl_program *vp = ctx->VertexProgram._Current; + struct gl_program *tcp = ctx->TessCtrlProgram._Current; + struct gl_program *tep = ctx->TessEvalProgram._Current; + struct gl_program *gp = ctx->GeometryProgram._Current; + struct gl_program *fp = ctx->FragmentProgram._Current; + struct gl_program *cp = ctx->ComputeProgram._Current; + uint64_t active_shader_states = 0; + + if (vp) + active_shader_states |= vp->affected_states; + if (tcp) + active_shader_states |= tcp->affected_states; + if (tep) + active_shader_states |= tep->affected_states; + if (gp) + active_shader_states |= gp->affected_states; + if (fp) + active_shader_states |= fp->affected_states; + if (cp) + active_shader_states |= cp->affected_states; + + /* Mark non-shader-resource shader states as "always active". */ + return active_shader_states | ~ST_ALL_SHADER_RESOURCES; +} /** * Update the ctx->*Program._Current pointers to point to the @@ -364,8 +391,11 @@ update_program(struct gl_context *ctx) /* Let the driver know what's happening: */ if (fp_changed || vp_changed || gp_changed || tep_changed || - tcp_changed || cp_changed) + tcp_changed || cp_changed) { + /* This will mask out unused shader resources. */ + st->active_states = _mesa_get_active_states(ctx); return _NEW_PROGRAM; + } return 0; } diff --git a/src/mesa/main/state.h b/src/mesa/main/state.h index 411cbcc..c7cb6f2 100644 --- a/src/mesa/main/state.h +++ b/src/mesa/main/state.h @@ -31,6 +31,9 @@ extern void _mesa_update_allow_draw_out_of_order(struct gl_context *ctx); +extern uint64_t +_mesa_get_active_states(struct gl_context *ctx); + extern void _mesa_update_state(struct gl_context *ctx); diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index f46eee4..c3b18c3 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -71,35 +71,6 @@ DEBUG_GET_ONCE_BOOL_OPTION(mesa_mvp_dp4, "MESA_MVP_DP4", FALSE) -static uint64_t -st_get_active_states(struct gl_context *ctx) -{ - struct gl_program *vp = ctx->VertexProgram._Current; - struct gl_program *tcp = ctx->TessCtrlProgram._Current; - struct gl_program *tep = ctx->TessEvalProgram._Current; - struct gl_program *gp = ctx->GeometryProgram._Current; - struct gl_program *fp = ctx->FragmentProgram._Current; - struct gl_program *cp = ctx->ComputeProgram._Current; - uint64_t active_shader_states = 0; - - if (vp) - active_shader_states |= vp->affected_states; - if (tcp) - active_shader_states |= tcp->affected_states; - if (tep) - active_shader_states |= tep->affected_states; - if (gp) - active_shader_states |= gp->affected_states; - if (fp) - active_shader_states |= fp->affected_states; - if (cp) - active_shader_states |= cp->affected_states; - - /* Mark non-shader-resource shader states as "always active". */ - return active_shader_states | ~ST_ALL_SHADER_RESOURCES; -} - - void st_invalidate_buffers(struct st_context *st) { @@ -183,12 +154,6 @@ st_invalidate_state(struct gl_context *ctx) st->dirty |= ST_NEW_VS_STATE | ST_NEW_VS_CONSTANTS; } - /* Which shaders are dirty will be determined manually. */ - if (new_state & _NEW_PROGRAM) { - /* This will mask out unused shader resources. */ - st->active_states = st_get_active_states(ctx); - } - if (new_state & _NEW_TEXTURE_OBJECT) { st->dirty |= st->active_states & (ST_NEW_SAMPLER_VIEWS | @@ -803,6 +768,7 @@ st_create_context_priv(struct gl_context *ctx, struct pipe_context *pipe, ctx->Const.DriverSupportedPrimMask = screen->get_param(screen, PIPE_CAP_SUPPORTED_PRIM_MODES) | /* patches is always supported */ BITFIELD_BIT(PIPE_PRIM_PATCHES); + st->active_states = _mesa_get_active_states(ctx); return st; } -- 2.7.4