From 4852fa32c1bfd7ec08fe24c84c1c520fd27740c6 Mon Sep 17 00:00:00 2001 From: Christian Gmeiner Date: Wed, 25 Mar 2026 22:49:21 +0100 Subject: [PATCH] mesa/st: Convert st_cb_drawtex to use st_context_invalidate_state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace CSO save/restore of atom-backed states with st_context_invalidate_state(). Only stream outputs (no atom) still use CSO save/restore. Signed-off-by: Christian Gmeiner Reviewed-by: Marek Olšák Part-of: --- src/mesa/state_tracker/st_cb_drawtex.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/mesa/state_tracker/st_cb_drawtex.c b/src/mesa/state_tracker/st_cb_drawtex.c index 35b6c16df00..dd77e225329 100644 --- a/src/mesa/state_tracker/st_cb_drawtex.c +++ b/src/mesa/state_tracker/st_cb_drawtex.c @@ -246,14 +246,8 @@ st_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z, #undef SET_ATTRIB } - cso_save_state(cso, (CSO_BIT_VIEWPORT | - CSO_BIT_STREAM_OUTPUTS | - CSO_BIT_VERTEX_SHADER | - CSO_BIT_TESSCTRL_SHADER | - CSO_BIT_TESSEVAL_SHADER | - CSO_BIT_GEOMETRY_SHADER | - CSO_BIT_MESH_SHADER | - CSO_BIT_VERTEX_ELEMENTS)); + /* Save only states that have no st_atom — they can't be re-derived. */ + cso_save_state(cso, CSO_BIT_STREAM_OUTPUTS); { void *vs = lookup_shader(st, numAttribs, slots); @@ -305,10 +299,20 @@ st_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z, pipe_resource_release(pipe, releasebuf); - /* restore state */ + /* Restore atomless states via CSO. */ cso_restore_state(cso, 0); - ctx->Array.NewVertexElements = true; - ST_SET_STATE(ctx->NewDriverState, ST_NEW_VERTEX_ARRAYS); + + /* Invalidate all states this meta-op modified. The atoms will + * re-derive them from GL state before the next draw. + */ + st_context_invalidate_state(st, + ST_INVALIDATE_VIEWPORT | + ST_INVALIDATE_VERTEX_BUFFERS | + ST_INVALIDATE_VS_STATE | + ST_INVALIDATE_GS_STATE | + ST_INVALIDATE_TCS_STATE | + ST_INVALIDATE_TES_STATE | + ST_INVALIDATE_MESH_STATE); } /**