From 74f20c38e0c87c6f825ce8210ee6ff25121ccc57 Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Thu, 4 Jun 2026 04:58:35 +0200 Subject: [PATCH] Don't send debug groups to Aurora if not enabled (#1984) Intended together with https://github.com/encounter/aurora/pull/221 --- CMakeLists.txt | 12 ++++++++++++ include/dusk/gx_helper.h | 8 ++++++++ src/d/d_drawlist.cpp | 4 ++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a25eb0cfee..f36987ad96 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -137,11 +137,18 @@ target_compile_definitions(aurora_mtx PRIVATE MTX_USE_PS=1) add_subdirectory(libs/freeverb) +if (CMAKE_BUILD_TYPE STREQUAL "Debug") + set(DUSK_GFX_DEBUG_GROUPS_DEFAULT ON) +else () + set(DUSK_GFX_DEBUG_GROUPS_DEFAULT OFF) +endif () + option(DUSK_BUILD_WARNINGS "Enable compiler warnings (off by default)") option(DUSK_SELECTED_OPT "If on, selected parts of the project will be compiled with optimizations on Debug, intending to make the game run at 30 FPS. Note for MSVC: you will need to remove '/RTC1' from your debug flags in CMake.") option(DUSK_MOVIE_SUPPORT "If on, compile against libjpeg-turbo to enable THP file decoding" ON) option(DUSK_ENABLE_UPDATE_CHECKER "Enable update checking support" ON) option(DUSK_ENABLE_SENTRY_NATIVE "Enable sentry-native crash reporting support" OFF) +option(DUSK_GFX_DEBUG_GROUPS "Report debug groups to the native graphics API" ${DUSK_GFX_DEBUG_GROUPS_DEFAULT}) set(DUSK_SENTRY_DSN "" CACHE STRING "Sentry DSN") set(DUSK_SENTRY_ENVIRONMENT "development" CACHE STRING "Sentry environment") @@ -418,6 +425,11 @@ if(ANDROID) list(APPEND GAME_COMPILE_DEFS TARGET_ANDROID=1) endif () +if (DUSK_GFX_DEBUG_GROUPS) + list(APPEND GAME_COMPILE_DEFS DUSK_GFX_DEBUG_GROUPS=1) + target_compile_definitions(aurora_gx PRIVATE AURORA_GFX_DEBUG_GROUPS) +endif () + # game_debug is for game code files that we know work when compiled with DEBUG=1 # Of course, if building a release build, this distinction is irrelevant set(GAME_DEBUG_FILES diff --git a/include/dusk/gx_helper.h b/include/dusk/gx_helper.h index 8f71cbdf26..8ed97e917a 100644 --- a/include/dusk/gx_helper.h +++ b/include/dusk/gx_helper.h @@ -7,12 +7,16 @@ #include #include "tracy/Tracy.hpp" +#if DUSK_GFX_DEBUG_GROUPS #define GX_DEBUG_GROUP(name, ...) \ do { \ GXPushDebugGroup(#name); \ name(__VA_ARGS__); \ GXPopDebugGroup(); \ } while (0) +#else +#define GX_DEBUG_GROUP(name, ...) name(__VA_ARGS__) +#endif #ifdef TARGET_PC class GXTexObjRAII : public GXTexObj { @@ -45,10 +49,14 @@ typedef GXTexObj TGXTexObj; struct GXScopedDebugGroup { explicit GXScopedDebugGroup(const char* text) { +#if DUSK_GFX_DEBUG_GROUPS GXPushDebugGroup(text); +#endif } ~GXScopedDebugGroup() { +#if DUSK_GFX_DEBUG_GROUPS GXPopDebugGroup(); +#endif } }; diff --git a/src/d/d_drawlist.cpp b/src/d/d_drawlist.cpp index 7725e8e079..8387047252 100644 --- a/src/d/d_drawlist.cpp +++ b/src/d/d_drawlist.cpp @@ -1996,7 +1996,7 @@ int dDlst_list_c::set(dDlst_base_c**& p_start, dDlst_base_c**& p_end, dDlst_base return 1; } -#if TARGET_PC && (TRACY_ENABLE || PARTIAL_DEBUG) +#if DUSK_GFX_DEBUG_GROUPS static absl::flat_hash_map typeDrawNames; static const char* getTypeDrawName(dDlst_base_c* dlst) { @@ -2019,7 +2019,7 @@ void dDlst_list_c::draw(dDlst_base_c** p_start, dDlst_base_c** p_end) { for (; p_start < p_end; p_start++) { dDlst_base_c* dlst = *p_start; -#if TARGET_PC && (TRACY_ENABLE || PARTIAL_DEBUG) +#if DUSK_GFX_DEBUG_GROUPS const auto name = getTypeDrawName(dlst); GXScopedDebugGroup scope(name); #endif