Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
pablode committed Jul 29, 2024
1 parent b636d49 commit aec30a3
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 13 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ foreach(CONFIG_TYPE ${CMAKE_CONFIGURATION_TYPES})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CONFIG_TYPE} ${OUTPUT_DIR})
endforeach()

option(GATLING_BUILD_HDGATLING "Build the gatling hydra render delegate." ON)
option(GTL_BUILD_HDGATLING "Build the gatling hydra render delegate." ON)
option(GTL_VERBOSE "Enable verbose logging." OFF)

if(${GATLING_BUILD_HDGATLING})
find_package(USD REQUIRED HINTS ${USD_ROOT} NAMES pxr)
Expand Down
14 changes: 8 additions & 6 deletions src/cgpu/impl/Cgpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@

#include <volk.h>

#include <gtl/gb/Fmt.h>
#include <gtl/gb/Log.h>

#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-variable"
Expand All @@ -36,12 +39,11 @@
#pragma clang diagnostic ignored "-Wnullability-completeness"
#endif

// Uncomment for VMA debug logging
//#define VMA_DEBUG_LOG_FORMAT(format, ...) do { \
// fprintf(stderr, (format), __VA_ARGS__); \
// fprintf(stderr, "\n"); \
// GB_LOG((format), __VA_ARGS__); \
// } while (false)
#ifdef GTL_VERBOSE
#define VMA_DEBUG_LOG_FORMAT(format, ...) do { \
GB_DEBUG_DYN("[VMA] {}", GB_FMT_SPRINTF((format), __VA_ARGS__)); \
} while (false)
#endif

#define VMA_IMPLEMENTATION
#include <vk_mem_alloc.h>
Expand Down
4 changes: 4 additions & 0 deletions src/gb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,9 @@ target_compile_options(
${GTL_COMPILE_OPTIONS}
)

if(GTL_VERBOSE)
target_compile_definitions(gb PUBLIC GTL_VERBOSE=1)
endif()

# Required since library is linked into hdGatling DSO
set_target_properties(gb PROPERTIES POSITION_INDEPENDENT_CODE ON)
2 changes: 2 additions & 0 deletions src/gb/gtl/gb/Fmt.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@
#pragma once

#include <quill/bundled/fmt/format.h>
#include <quill/bundled/fmt/printf.h>

#define GB_FMT(fmt, ...) fmtquill::format(fmt, __VA_ARGS__)
#define GB_FMT_SPRINTF(fmt, ...) fmtquill::sprintf(fmt, __VA_ARGS__)
6 changes: 4 additions & 2 deletions src/gb/gtl/gb/Log.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@
#include <quill/std/UnorderedSet.h>
#include <quill/std/Vector.h>

#define GB_LOG(fmt, ...) QUILL_LOG_INFO(gtl::gbGetLogger(), fmt, ##__VA_ARGS__)
#define GB_WARN(fmt, ...) QUILL_LOG_WARNING(gtl::gbGetLogger(), fmt, ##__VA_ARGS__)
#define GB_ERROR(fmt, ...) QUILL_LOG_ERROR(gtl::gbGetLogger(), fmt, ##__VA_ARGS__)
#define GB_WARN(fmt, ...) QUILL_LOG_WARNING(gtl::gbGetLogger(), fmt, ##__VA_ARGS__)
#define GB_LOG(fmt, ...) QUILL_LOG_INFO(gtl::gbGetLogger(), fmt, ##__VA_ARGS__)
#define GB_DEBUG(fmt, ...) QUILL_LOG_DEBUG(gtl::gbGetLogger(), fmt, ##__VA_ARGS__)
#define GB_DEBUG_DYN(fmt, ...) QUILL_LOG_DYNAMIC(gtl::gbGetLogger(), quill::LogLevel::Debug, fmt, ##__VA_ARGS__)

namespace gtl
{
Expand Down
3 changes: 3 additions & 0 deletions src/gb/impl/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ namespace gtl
const char* logPattern = "[%(time)] (%(log_level)) %(message)";
const char* timestampFormat = "%H:%M:%S.%Qms";
s_logger = quill::Frontend::create_or_get_logger("root", std::move(sink), logPattern, timestampFormat);
#ifdef GTL_VERBOSE
s_logger->set_log_level(quill::LogLevel::Debug);
#endif

quill::BackendOptions options;
options.thread_name = "GbLog";
Expand Down
2 changes: 1 addition & 1 deletion src/gi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ target_compile_definitions(
GI_REF_IMAGE_DIR="${CMAKE_CURRENT_SOURCE_DIR}/testenv"
)

if(${GATLING_BUILD_HDGATLING})
if(${GTL_BUILD_HDGATLING})
install(
FILES "${MDL_SHARED_LIB}"
DESTINATION "./hdGatling/resources"
Expand Down
9 changes: 6 additions & 3 deletions src/mc/impl/MdlLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,12 @@ namespace gtl
{
#ifdef NDEBUG
const mi::base::Message_severity minLogLevel = mi::base::MESSAGE_SEVERITY_ERROR;
#elif defined(GTL_VERBOSE)
const mi::base::Message_severity minLogLevel = mi::base::MESSAGE_SEVERITY_INFO;
#else
const mi::base::Message_severity minLogLevel = mi::base::MESSAGE_SEVERITY_WARNING;
#endif

if (level > minLogLevel)
{
return;
Expand All @@ -82,15 +85,15 @@ namespace gtl

if (level <= mi::base::MESSAGE_SEVERITY_ERROR)
{
GB_ERROR("{}", message);
GB_ERROR("[MDL] {}", message);
}
else if (level <= mi::base::MESSAGE_SEVERITY_WARNING)
{
GB_WARN("{}", message);
GB_WARN("[MDL] {}", message);
}
else
{
GB_LOG("{}", message);
GB_DEBUG("[MDL] {}", message);
}
}

Expand Down

0 comments on commit aec30a3

Please sign in to comment.