From 2dc5755799c92a74fddbe5516decd4cb4346c53b Mon Sep 17 00:00:00 2001 From: psucien Date: Sun, 22 Dec 2024 22:51:48 +0100 Subject: [PATCH] build: exclude Tracy from release builds --- externals/CMakeLists.txt | 6 +++++- src/common/debug.h | 4 ++++ src/video_core/renderer_vulkan/vk_scheduler.cpp | 8 ++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index dbe6794d..4350948b 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -189,7 +189,11 @@ add_library(Dear_ImGui target_include_directories(Dear_ImGui INTERFACE dear_imgui/) # Tracy -option(TRACY_ENABLE "" ON) +if (CMAKE_BUILD_TYPE STREQUAL "Release") + option(TRACY_ENABLE "" OFF) +else() + option(TRACY_ENABLE "" ON) +endif() option(TRACY_NO_CRASH_HANDLER "" ON) # Otherwise texture cache exceptions will be treaten as a crash option(TRACY_ON_DEMAND "" ON) option(TRACY_NO_FRAME_IMAGE "" ON) diff --git a/src/common/debug.h b/src/common/debug.h index 882e9e5c..92bf7255 100644 --- a/src/common/debug.h +++ b/src/common/debug.h @@ -14,7 +14,11 @@ #include static inline bool IsProfilerConnected() { +#if TRACY_ENABLE return tracy::GetProfiler().IsConnected(); +#else + return false; +#endif } #define TRACY_GPU_ENABLED 0 diff --git a/src/video_core/renderer_vulkan/vk_scheduler.cpp b/src/video_core/renderer_vulkan/vk_scheduler.cpp index f6b0edda..fd84c54e 100644 --- a/src/video_core/renderer_vulkan/vk_scheduler.cpp +++ b/src/video_core/renderer_vulkan/vk_scheduler.cpp @@ -14,12 +14,16 @@ std::mutex Scheduler::submit_mutex; Scheduler::Scheduler(const Instance& instance) : instance{instance}, master_semaphore{instance}, command_pool{instance, &master_semaphore} { +#if TRACY_GPU_ENABLED profiler_scope = reinterpret_cast(std::malloc(sizeof(tracy::VkCtxScope))); +#endif AllocateWorkerCommandBuffers(); } Scheduler::~Scheduler() { +#if TRACY_GPU_ENABLED std::free(profiler_scope); +#endif } void Scheduler::BeginRendering(const RenderState& new_state) { @@ -93,23 +97,27 @@ void Scheduler::AllocateWorkerCommandBuffers() { ASSERT_MSG(begin_result == vk::Result::eSuccess, "Failed to begin command buffer: {}", vk::to_string(begin_result)); +#if TRACY_GPU_ENABLED auto* profiler_ctx = instance.GetProfilerContext(); if (profiler_ctx) { static const auto scope_loc = GPU_SCOPE_LOCATION("Guest Frame", MarkersPalette::GpuMarkerColor); new (profiler_scope) tracy::VkCtxScope{profiler_ctx, &scope_loc, current_cmdbuf, true}; } +#endif } void Scheduler::SubmitExecution(SubmitInfo& info) { std::scoped_lock lk{submit_mutex}; const u64 signal_value = master_semaphore.NextTick(); +#if TRACY_GPU_ENABLED auto* profiler_ctx = instance.GetProfilerContext(); if (profiler_ctx) { profiler_scope->~VkCtxScope(); TracyVkCollect(profiler_ctx, current_cmdbuf); } +#endif EndRendering(); auto end_result = current_cmdbuf.end();