Skip to content

Commit

Permalink
zero-overhead logging in more places
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike-Leo-Smith committed Mar 2, 2025
1 parent ab7330a commit 546cb40
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 8 additions & 2 deletions include/luisa/core/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 { \
Expand Down
4 changes: 3 additions & 1 deletion src/backends/fallback/fallback_motion_instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<MotionInstanceBuildCommand> cmd) noexcept {
Expand Down

0 comments on commit 546cb40

Please sign in to comment.