From 546cb404baf491a06d826f4ffee0d49ae533ed82 Mon Sep 17 00:00:00 2001 From: Mike Smith Date: Sun, 2 Mar 2025 20:37:21 +0800 Subject: [PATCH] zero-overhead logging in more places --- include/luisa/core/logging.h | 10 ++++++++-- src/backends/fallback/fallback_motion_instance.cpp | 4 +++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/luisa/core/logging.h b/include/luisa/core/logging.h index b4aa903a4..982577f35 100644 --- a/include/luisa/core/logging.h +++ b/include/luisa/core/logging.h @@ -150,10 +150,16 @@ LC_CORE_API void log_flush() noexcept; LUISA_NOT_IMPLEMENTED_IMPL##__VA_OPT__(_WITH_MESSAGE)(__VA_ARGS__) #define LUISA_ASSERT_FAILED_IMPL(x) \ - LUISA_ERROR_WITH_LOCATION("Assertion '{}' failed.", #x) + LUISA_ERROR_WITH_LOCATION("Assertion '" #x "' failed.") + +#define LUISA_ASSERT_FAILED_IMPL_WITH_MESSAGE_IMPL_WITH_FMT(x, fmt, ...) \ + LUISA_ERROR_WITH_LOCATION("Assertion '{}' failed: " fmt, #x, __VA_ARGS__) + +#define LUISA_ASSERT_FAILED_IMPL_WITH_MESSAGE_IMPL(x, msg) \ + LUISA_ERROR_WITH_LOCATION("Assertion '" #x "' failed: " msg) #define LUISA_ASSERT_FAILED_IMPL_WITH_MESSAGE(x, fmt, ...) \ - LUISA_ERROR_WITH_LOCATION("Assertion '{}' failed: " fmt, #x __VA_OPT__(, ) __VA_ARGS__) + LUISA_ASSERT_FAILED_IMPL_WITH_MESSAGE_IMPL##__VA_OPT__(_WITH_FMT)(x, fmt __VA_OPT__(, ) __VA_ARGS__) #define LUISA_ASSERT(x, ...) \ do { \ diff --git a/src/backends/fallback/fallback_motion_instance.cpp b/src/backends/fallback/fallback_motion_instance.cpp index fcae74e93..125611495 100644 --- a/src/backends/fallback/fallback_motion_instance.cpp +++ b/src/backends/fallback/fallback_motion_instance.cpp @@ -5,7 +5,9 @@ namespace luisa::compute::fallback { FallbackMotionInstance::FallbackMotionInstance(const AccelMotionOption &option) noexcept : _option{option}, _child{nullptr} { - LUISA_ASSERT(option.keyframe_count <= 255u, "Motion keyframe count must be less than 256."); + LUISA_ASSERT(option.keyframe_count <= 255u, + "Motion keyframe count must be less than 256 (got {}).", + option.keyframe_count); } void FallbackMotionInstance::build(luisa::unique_ptr cmd) noexcept {