refactor(agc): make frame timing logs optional by cmake option

This commit is contained in:
boykopovar committed 2026-09-28 10:51:29 +03:00
1 parent 34f0379d8a
commit 94c443e32f
3 files changed
+7 -3

No files matched your search

+2
View File
@@ -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=$<BOOL:${APS5_ENABLE_TIMING_LOG}>)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
@@ -15,6 +15,7 @@
#include <stdexcept>
#include <string_view>
#include <utility>
#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:
@@ -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)