From 93390d4b73d1786070613fc685aed7d63b032ca7 Mon Sep 17 00:00:00 2001 From: Eric Engestrom Date: Tue, 6 Jan 2026 15:12:30 +0100 Subject: [PATCH] vk/runtime,zink: only integrate renderdoc on supported platforms It is not actually available to all the platforms mesa can be compiled to, so let's keep an opt-in list of supported platforms instead, and compile it out on all other platforms. Fixes: 48a0478126ffd4e0bc15 ("zink: add renderdoc handling") Part-of: --- meson.build | 7 +++++++ src/gallium/drivers/zink/zink_batch.c | 4 ++++ src/gallium/drivers/zink/zink_context.c | 4 ++++ src/gallium/drivers/zink/zink_screen.c | 4 +++- src/gallium/drivers/zink/zink_types.h | 4 ++++ src/vulkan/runtime/vk_instance.c | 8 +++++++- src/vulkan/runtime/vk_instance.h | 4 ++++ 7 files changed, 33 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index 88acde022e6..82433a969d0 100644 --- a/meson.build +++ b/meson.build @@ -2228,6 +2228,13 @@ if get_option('android-libperfetto').enabled() pre_args += '-DANDROID_LIBPERFETTO' endif +# Platforms where RenderDoc integration actually works +renderdoc_integration_supported = [ + 'linux', + 'android', +].contains(host_machine.system()) +pre_args += '-DHAVE_RENDERDOC_INTEGRATION=@0@'.format(renderdoc_integration_supported) + with_teflon = get_option('teflon') if with_teflon and with_tests dep_flatbuffers = dependency('flatbuffers') diff --git a/src/gallium/drivers/zink/zink_batch.c b/src/gallium/drivers/zink/zink_batch.c index 8f01baa168d..9f8f85a235a 100644 --- a/src/gallium/drivers/zink/zink_batch.c +++ b/src/gallium/drivers/zink/zink_batch.c @@ -570,6 +570,7 @@ zink_start_batch(struct zink_context *ctx) bs->fence.completed = false; +#if HAVE_RENDERDOC_INTEGRATION if (VKCTX(CmdInsertDebugUtilsLabelEXT) && screen->renderdoc_api) { VkDebugUtilsLabelEXT capture_label; /* Magic fallback which lets us bridge the Wine barrier over to Linux RenderDoc. */ @@ -588,6 +589,7 @@ zink_start_batch(struct zink_context *ctx) screen->renderdoc_api->StartFrameCapture(RENDERDOC_DEVICEPOINTER_FROM_VKINSTANCE(screen->instance), NULL); screen->renderdoc_capturing = true; } +#endif /* descriptor buffers must always be bound at the start of a batch */ if (zink_descriptor_mode == ZINK_DESCRIPTOR_MODE_DB && !(ctx->flags & ZINK_CONTEXT_COPY_ONLY)) @@ -940,11 +942,13 @@ zink_end_batch(struct zink_context *ctx) submit_queue(bs, NULL, 0); } +#if HAVE_RENDERDOC_INTEGRATION if (!(ctx->flags & ZINK_CONTEXT_COPY_ONLY) && screen->renderdoc_capturing && !screen->renderdoc_capture_all && p_atomic_read(&screen->renderdoc_frame) > screen->renderdoc_capture_end) { screen->renderdoc_api->EndFrameCapture(RENDERDOC_DEVICEPOINTER_FROM_VKINSTANCE(screen->instance), NULL); screen->renderdoc_capturing = false; } +#endif } static int diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index 889699d80f2..7c9a84db79c 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -116,11 +116,13 @@ zink_context_destroy(struct pipe_context *pctx) struct pipe_framebuffer_state fb = {0}; pctx->set_framebuffer_state(pctx, &fb); +#if HAVE_RENDERDOC_INTEGRATION if (screen->base.num_contexts == 1 && screen->renderdoc_capturing) { screen->renderdoc_capture_all = false; ctx->bs->has_work = true; pctx->flush(pctx, NULL, 0); } +#endif if (util_queue_is_initialized(&screen->flush_queue)) util_queue_finish(&screen->flush_queue); @@ -4223,7 +4225,9 @@ zink_flush(struct pipe_context *pctx, } if (flags & PIPE_FLUSH_END_OF_FRAME) { +#if HAVE_RENDERDOC_INTEGRATION p_atomic_inc(&screen->renderdoc_frame); +#endif if (ctx->needs_present && ctx->needs_present->obj->dt_idx != UINT32_MAX && zink_is_swapchain(ctx->needs_present)) { zink_kopper_readback_update(ctx, ctx->needs_present); diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c index bb6c837659f..a35bca6650e 100644 --- a/src/gallium/drivers/zink/zink_screen.c +++ b/src/gallium/drivers/zink/zink_screen.c @@ -1545,8 +1545,10 @@ zink_destroy_screen(struct pipe_screen *pscreen) } } +#if HAVE_RENDERDOC_INTEGRATION if (screen->renderdoc_capture_all && p_atomic_dec_zero(&num_screens)) screen->renderdoc_api->EndFrameCapture(RENDERDOC_DEVICEPOINTER_FROM_VKINSTANCE(screen->instance), NULL); +#endif hash_table_foreach(&screen->dts, entry) zink_kopper_deinit_displaytarget(screen, entry->data); @@ -2326,7 +2328,7 @@ populate_format_props(struct zink_screen *screen) static void setup_renderdoc(struct zink_screen *screen) { -#ifndef _WIN32 +#if HAVE_RENDERDOC_INTEGRATION const char *capture_id = debug_get_option("ZINK_RENDERDOC", NULL); if (!capture_id) return; diff --git a/src/gallium/drivers/zink/zink_types.h b/src/gallium/drivers/zink/zink_types.h index c174930e83b..fe6116bf5af 100644 --- a/src/gallium/drivers/zink/zink_types.h +++ b/src/gallium/drivers/zink/zink_types.h @@ -66,7 +66,9 @@ #include "vk_dispatch_table.h" #include "util/perf/cpu_trace.h" +#if HAVE_RENDERDOC_INTEGRATION #include "renderdoc_app.h" +#endif /* the descriptor binding id for fbfetch/input attachment */ #define ZINK_FBFETCH_BINDING 5 @@ -1487,12 +1489,14 @@ struct zink_screen { unsigned screen_id; +#if HAVE_RENDERDOC_INTEGRATION RENDERDOC_API_1_0_0 *renderdoc_api; unsigned renderdoc_capture_start; unsigned renderdoc_capture_end; unsigned renderdoc_frame; bool renderdoc_capturing; bool renderdoc_capture_all; +#endif struct vk_uncompacted_dispatch_table vk; diff --git a/src/vulkan/runtime/vk_instance.c b/src/vulkan/runtime/vk_instance.c index 2fc92e17b14..420ab21cd0b 100644 --- a/src/vulkan/runtime/vk_instance.c +++ b/src/vulkan/runtime/vk_instance.c @@ -210,7 +210,9 @@ vk_instance_init(struct vk_instance *instance, instance->trace_trigger_file = os_get_option_secure("MESA_VK_TRACE_TRIGGER"); } +#if HAVE_RENDERDOC_INTEGRATION simple_mtx_init(&instance->renderdoc_mtx, mtx_plain); +#endif #if !VK_LITE_RUNTIME_INSTANCE glsl_type_singleton_init_or_ref(); @@ -238,7 +240,9 @@ vk_instance_finish(struct vk_instance *instance) glsl_type_singleton_decref(); #endif +#if HAVE_RENDERDOC_INTEGRATION simple_mtx_destroy(&instance->renderdoc_mtx); +#endif if (unlikely(!list_is_empty(&instance->debug_utils.callbacks))) { list_for_each_entry_safe(struct vk_debug_utils_messenger, messenger, @@ -647,7 +651,7 @@ vk_icdNegotiateLoaderICDInterfaceVersion(uint32_t *pSupportedVersion) void vk_instance_start_renderdoc_capture(struct vk_instance *instance) { -#ifndef _WIN32 +#if HAVE_RENDERDOC_INTEGRATION simple_mtx_lock(&instance->renderdoc_mtx); if (!instance->renderdoc_api) { @@ -669,6 +673,7 @@ vk_instance_start_renderdoc_capture(struct vk_instance *instance) void vk_instance_end_renderdoc_capture(struct vk_instance *instance) { +#if HAVE_RENDERDOC_INTEGRATION if (!instance->renderdoc_api) return; @@ -678,4 +683,5 @@ vk_instance_end_renderdoc_capture(struct vk_instance *instance) instance->renderdoc_api->EndFrameCapture(NULL, NULL); simple_mtx_unlock(&instance->renderdoc_mtx); +#endif } diff --git a/src/vulkan/runtime/vk_instance.h b/src/vulkan/runtime/vk_instance.h index 4bad10ab6bf..067d8cbf375 100644 --- a/src/vulkan/runtime/vk_instance.h +++ b/src/vulkan/runtime/vk_instance.h @@ -32,7 +32,9 @@ #include "util/simple_mtx.h" #include "util/u_debug.h" +#if HAVE_RENDERDOC_INTEGRATION #include "renderdoc_app.h" +#endif #ifdef __cplusplus extern "C" { @@ -180,9 +182,11 @@ struct vk_instance { /** Whether the capture mode is per-submit. */ bool trace_per_submit; +#if HAVE_RENDERDOC_INTEGRATION /** For triggering renderdoc captures from inside the driver. */ simple_mtx_t renderdoc_mtx; RENDERDOC_API_1_0_0 *renderdoc_api; +#endif }; VK_DEFINE_HANDLE_CASTS(vk_instance, base, VkInstance,