From 80db8171debdf68edcc64ddd73280a95fb1a8367 Mon Sep 17 00:00:00 2001 From: Mel Henning Date: Wed, 12 Nov 2025 18:22:00 -0500 Subject: [PATCH] zink: Lock around screen_debug_marker_{begin,end} vkQueueBeginDebugUtilsLabelEXT and vkQueueEndDebugUtilsLabelEXT require queue to be externally synchronized, which means these functions require the lock. Unfortunately, there's no guarantee that the debug markers will be matched in the multithreaded case, but I suppose this is better than crashing. Fixes: 015eda4a4186c ("zink: deduplicate VkDevice and VkInstance") Reviewed-by: Dave Airlie Part-of: --- src/gallium/drivers/zink/zink_screen.c | 6 ++++++ src/gallium/drivers/zink/zink_screen.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c index ecc91a86eb4..1dddcf9ee90 100644 --- a/src/gallium/drivers/zink/zink_screen.c +++ b/src/gallium/drivers/zink/zink_screen.c @@ -3779,7 +3779,9 @@ zink_internal_create_screen(const struct pipe_screen_config *config, int64_t dev zink_tracing = screen->instance_info->have_EXT_debug_utils && (u_trace_is_enabled(U_TRACE_TYPE_PERFETTO) || u_trace_is_enabled(U_TRACE_TYPE_MARKERS)); + simple_mtx_lock(screen->queue_lock); screen->frame_marker_emitted = zink_screen_debug_marker_begin(screen, "frame"); + simple_mtx_unlock(screen->queue_lock); return screen; @@ -3875,6 +3877,8 @@ void VKAPI_PTR zink_stub_function_not_loaded() bool zink_screen_debug_marker_begin(struct zink_screen *screen, const char *fmt, ...) { + simple_mtx_assert_locked(screen->queue_lock); + if (!zink_tracing) return false; @@ -3900,6 +3904,8 @@ zink_screen_debug_marker_begin(struct zink_screen *screen, const char *fmt, ...) void zink_screen_debug_marker_end(struct zink_screen *screen, bool emitted) { + simple_mtx_assert_locked(screen->queue_lock); + if (emitted) VKSCR(QueueEndDebugUtilsLabelEXT)(screen->queue); } diff --git a/src/gallium/drivers/zink/zink_screen.h b/src/gallium/drivers/zink/zink_screen.h index a8e03ebc972..7e6ce005030 100644 --- a/src/gallium/drivers/zink/zink_screen.h +++ b/src/gallium/drivers/zink/zink_screen.h @@ -203,8 +203,11 @@ zink_screen_get_pipeline_cache(struct zink_screen *screen, struct zink_program * void VKAPI_PTR zink_stub_function_not_loaded(void); +/** Requires queue_lock to be held */ bool zink_screen_debug_marker_begin(struct zink_screen *screen, const char *fmt, ...); + +/** Requires queue_lock to be held */ void zink_screen_debug_marker_end(struct zink_screen *screen, bool emitted);