From 535bb0bda4631a5eeb46ca14b6dbbf28fb92adf2 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Tue, 3 May 2022 15:34:38 +0200 Subject: [PATCH] u_threaded: clear non-async debug callback correctly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The following sequence: glEnable(GL_DEBUG_OUTPUT_KHR); glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_KHR); glDebugMessageCallbackKHR(my_callback, NULL); Will cause the 2nd call to be ignored - but since the callback function used by _mesa_update_debug_callback is always the same (_debug_message), this means we'll keep using it, causing "my_callback" to be called from driver-internal threads. So instead of skipping the 2nd call, make sure we pass the information to the driver. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5206 Reviewed-by: Marek Olšák Part-of: --- src/gallium/auxiliary/util/u_threaded_context.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/gallium/auxiliary/util/u_threaded_context.c b/src/gallium/auxiliary/util/u_threaded_context.c index c7a5857be49..8455bae9947 100644 --- a/src/gallium/auxiliary/util/u_threaded_context.c +++ b/src/gallium/auxiliary/util/u_threaded_context.c @@ -2774,15 +2774,16 @@ tc_set_debug_callback(struct pipe_context *_pipe, struct threaded_context *tc = threaded_context(_pipe); struct pipe_context *pipe = tc->pipe; + tc_sync(tc); + /* Drop all synchronous debug callbacks. Drivers are expected to be OK * with this. shader-db will use an environment variable to disable * the threaded context. */ - if (cb && cb->debug_message && !cb->async) - return; - - tc_sync(tc); - pipe->set_debug_callback(pipe, cb); + if (cb && !cb->async) + pipe->set_debug_callback(pipe, NULL); + else + pipe->set_debug_callback(pipe, cb); } static void