From 94c443e32f9589e998d4dd83f0a0ba63a6566d46 Mon Sep 17 00:00:00 2001 From: boykopovar Date: Mon, 28 Sep 2026 10:51:29 +0300 Subject: [PATCH] refactor(agc): make frame timing logs optional by cmake option --- CMakeLists.txt | 2 ++ .../libSceAgcDriver/Execution/include/PerformanceTimer.hpp | 5 ++--- core/libs/prx/libc/include/general/LogMacros.hpp | 3 +++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 30724ac32..62dd3d872 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,8 @@ if(BUILD_TESTING) endif() option(ANYPS5_ENABLE_SPIRV_TOOLS "Enable SPIRV-Tools validation and optimization" OFF) +option(APS5_ENABLE_TIMING_LOG "Enable frame timing logging" OFF) +add_compile_definitions(APS5_ENABLE_TIMING_LOG=$) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) diff --git a/core/libs/prx/libSceAgcDriver/Execution/include/PerformanceTimer.hpp b/core/libs/prx/libSceAgcDriver/Execution/include/PerformanceTimer.hpp index b1ebdc2c3..6ce0b2d54 100644 --- a/core/libs/prx/libSceAgcDriver/Execution/include/PerformanceTimer.hpp +++ b/core/libs/prx/libSceAgcDriver/Execution/include/PerformanceTimer.hpp @@ -15,6 +15,7 @@ #include #include #include +#include "prx/libc/include/general/LogMacros.hpp" namespace AgcDriver { @@ -138,9 +139,7 @@ public: if (metric.bytes != 0) output << ',' << metric.bytes; output << ')'; } - output << '\n'; - const auto text = output.str(); - if (std::fwrite(text.data(), 1, text.size(), stdout) != text.size() || std::fflush(stdout) != 0) throw std::runtime_error("Frame timing: report write failed"); + APS5_LOG_TIMING("%s", output.str().c_str()); } private: diff --git a/core/libs/prx/libc/include/general/LogMacros.hpp b/core/libs/prx/libc/include/general/LogMacros.hpp index 213789e1f..f9c5f24c2 100644 --- a/core/libs/prx/libc/include/general/LogMacros.hpp +++ b/core/libs/prx/libc/include/general/LogMacros.hpp @@ -56,6 +56,9 @@ _APS5_LOG_IMPL_NF(stdout, fmt); \ } \ } while (0) +#define APS5_LOG_TIMING(fmt, ...) APS5_LOG_OUT_IF(APS5_ENABLE_TIMING_LOG, fmt, __VA_ARGS__) +#define APS5_LOG_CHARS_OUT_TIMING(fmt) APS5_LOG_CHARS_OUT_IF(APS5_ENABLE_TIMING_LOG, fmt) + #ifdef APS5_DEBUG_LOG #define APS5_LOG_DEBUG(fmt, ...) _APS5_LOG_IMPL(stdout, fmt, __VA_ARGS__) #define APS5_LOG_CHARS_OUT_DEBUG(fmt) _APS5_LOG_IMPL_NF(stdout, fmt)