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: 015eda4a41 ("zink: deduplicate VkDevice and VkInstance")
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38414>
(cherry picked from commit 80db8171de)
This commit is contained in:
Mel Henning 2025-11-12 18:22:00 -05:00 committed by Dylan Baker
parent 3749881385
commit da11726bf7
3 changed files with 10 additions and 1 deletions

View file

@ -824,7 +824,7 @@
"description": "zink: Lock around screen_debug_marker_{begin,end}",
"nominated": true,
"nomination_type": 2,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "015eda4a4186c75538a0aa915e380c5ce5863319",
"notes": null

View file

@ -3778,7 +3778,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;
@ -3874,6 +3876,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;
@ -3899,6 +3903,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);
}

View file

@ -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);