From 95828d8901ecccd4f36cd4ef933d65628773934d Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 11 Jun 2024 11:15:01 -0400 Subject: [PATCH] mesa/st: fix zombie shader handling for non-current programs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit for drivers that don't support PIPE_CAP_SHAREABLE_SHADERS, the zombie shader mechanism is used, storing shaders to delete after the next flush the zombie mechanism also calls bind_*_state(pipe, NULL) during deletion, however, which breaks drivers in the following scenario: * create_all_shaders(pipe_A) * bind_vs(pipe_A, vs_A) * bind_fs(pipe_A, fs_A) * draw(pipe_A) * makeCurrent(pipe_B) * delete_vs(pipe_B, vs_B) * vs_B must only be deleted on pipe_A * zombie_shader_add(pipe_A, vs_B) * makeCurrent(pipe_A) * free_zombie_shaders(pipe_A) * bind_vs(pipe_A, NULL) * delete_vs(pipe_A, vs_B) * draw(pipe_A) * boom the problem being that bind_vs(pipe_A, NULL) was called when deleting vs_B, but it was actually vs_A which was bound to solve this, just flag the shader state for updating and let st figure it out Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/11122 cc: mesa-stable Reviewed-by: Marek Olšák Part-of: --- src/mesa/state_tracker/st_context.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index bc4e435da27..3f0dace94d5 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -284,27 +284,27 @@ free_zombie_shaders(struct st_context *st) switch (entry->type) { case PIPE_SHADER_VERTEX: - st->pipe->bind_vs_state(st->pipe, NULL); + st->ctx->NewDriverState |= ST_NEW_VS_STATE; st->pipe->delete_vs_state(st->pipe, entry->shader); break; case PIPE_SHADER_FRAGMENT: - st->pipe->bind_fs_state(st->pipe, NULL); + st->ctx->NewDriverState |= ST_NEW_FS_STATE; st->pipe->delete_fs_state(st->pipe, entry->shader); break; case PIPE_SHADER_GEOMETRY: - st->pipe->bind_gs_state(st->pipe, NULL); + st->ctx->NewDriverState |= ST_NEW_GS_STATE; st->pipe->delete_gs_state(st->pipe, entry->shader); break; case PIPE_SHADER_TESS_CTRL: - st->pipe->bind_tcs_state(st->pipe, NULL); + st->ctx->NewDriverState |= ST_NEW_TCS_STATE; st->pipe->delete_tcs_state(st->pipe, entry->shader); break; case PIPE_SHADER_TESS_EVAL: - st->pipe->bind_tes_state(st->pipe, NULL); + st->ctx->NewDriverState |= ST_NEW_TES_STATE; st->pipe->delete_tes_state(st->pipe, entry->shader); break; case PIPE_SHADER_COMPUTE: - st->pipe->bind_compute_state(st->pipe, NULL); + st->ctx->NewDriverState |= ST_NEW_CS_STATE; st->pipe->delete_compute_state(st->pipe, entry->shader); break; default: