Cycles: Remove glog dependency, redirect logs to CLOG

* Add own simple logging system to replace glog, which is no longer
  maintained by Google.
* When building in Blender, integrate with CLOG and print all messages
  through that system instead.
* --log cycles now replaces --debug-cycles. The latter still works but
  is no longer documented.

Pull Request: https://projects.blender.org/blender/blender/pulls/140244
This commit is contained in:
Brecht Van Lommel
2025-06-12 02:19:57 +02:00
parent 370ef854c0
commit 8392ca915b
19 changed files with 314 additions and 207 deletions

View File

@@ -625,7 +625,6 @@ option(WITH_CYCLES "Enable Cycles Render Engine" ON)
option(WITH_CYCLES_OSL "Build Cycles with OpenShadingLanguage support" ON) option(WITH_CYCLES_OSL "Build Cycles with OpenShadingLanguage support" ON)
option(WITH_CYCLES_PATH_GUIDING "Build Cycles with path guiding support" ON) option(WITH_CYCLES_PATH_GUIDING "Build Cycles with path guiding support" ON)
option(WITH_CYCLES_EMBREE "Build Cycles with Embree support" ON) option(WITH_CYCLES_EMBREE "Build Cycles with Embree support" ON)
option(WITH_CYCLES_LOGGING "Build Cycles with logging support" ON)
option(WITH_CYCLES_DEBUG "Build Cycles with options useful for debugging (e.g., MIS)" OFF) option(WITH_CYCLES_DEBUG "Build Cycles with options useful for debugging (e.g., MIS)" OFF)
option(WITH_CYCLES_STANDALONE "Build Cycles standalone application" OFF) option(WITH_CYCLES_STANDALONE "Build Cycles standalone application" OFF)
@@ -655,7 +654,6 @@ Run additional Cycles test with OSL enabled"
OFF OFF
) )
mark_as_advanced(WITH_CYCLES_KERNEL_ASAN) mark_as_advanced(WITH_CYCLES_KERNEL_ASAN)
mark_as_advanced(WITH_CYCLES_LOGGING)
mark_as_advanced(WITH_CYCLES_DEBUG_NAN) mark_as_advanced(WITH_CYCLES_DEBUG_NAN)
mark_as_advanced(WITH_CYCLES_NATIVE_ONLY) mark_as_advanced(WITH_CYCLES_NATIVE_ONLY)
mark_as_advanced(WITH_CYCLES_PRECOMPUTE) mark_as_advanced(WITH_CYCLES_PRECOMPUTE)
@@ -1711,7 +1709,7 @@ set_and_warn_incompatible(WITH_PYTHON_MODULE WITH_GTESTS OFF)
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# Configure `GLog/GFlags` # Configure `GLog/GFlags`
if(WITH_LIBMV OR WITH_GTESTS OR (WITH_CYCLES AND WITH_CYCLES_LOGGING)) if(WITH_LIBMV OR WITH_GTESTS)
if(WITH_SYSTEM_GFLAGS) if(WITH_SYSTEM_GFLAGS)
find_package(Gflags) find_package(Gflags)
if(NOT GFLAGS_FOUND) if(NOT GFLAGS_FOUND)
@@ -2686,12 +2684,6 @@ elseif(WITH_CYCLES_STANDALONE OR WITH_CYCLES_HYDRA_RENDER_DELEGATE)
add_subdirectory(intern/sky) add_subdirectory(intern/sky)
add_subdirectory(intern/cycles) add_subdirectory(intern/cycles)
if(WITH_CYCLES_LOGGING)
if(NOT WITH_SYSTEM_GFLAGS)
add_subdirectory(extern/gflags)
endif()
add_subdirectory(extern/glog)
endif()
if(WITH_CUDA_DYNLOAD) if(WITH_CUDA_DYNLOAD)
add_subdirectory(extern/cuew) add_subdirectory(extern/cuew)
endif() endif()

View File

@@ -86,7 +86,7 @@ if(WITH_LIBMV)
add_subdirectory(ceres) add_subdirectory(ceres)
endif() endif()
if(WITH_LIBMV OR WITH_GTESTS OR (WITH_CYCLES AND WITH_CYCLES_LOGGING)) if(WITH_LIBMV OR WITH_GTESTS)
if(NOT WITH_SYSTEM_GFLAGS) if(NOT WITH_SYSTEM_GFLAGS)
add_subdirectory(gflags) add_subdirectory(gflags)
endif() endif()

View File

@@ -325,18 +325,6 @@ if(WITH_OPENIMAGEDENOISE)
) )
endif() endif()
# Logging capabilities using GLog library.
if(WITH_CYCLES_LOGGING)
add_definitions(-DWITH_CYCLES_LOGGING)
add_definitions(${GLOG_DEFINES})
add_definitions(-DCYCLES_GFLAGS_NAMESPACE=${GFLAGS_NAMESPACE})
include_directories(
SYSTEM
${GLOG_INCLUDE_DIRS}
${GFLAGS_INCLUDE_DIRS}
)
endif()
if(WITH_ALEMBIC) if(WITH_ALEMBIC)
add_definitions(-DWITH_ALEMBIC) add_definitions(-DWITH_ALEMBIC)
include_directories( include_directories(

View File

@@ -405,9 +405,8 @@ static void options_parse(const int argc, const char **argv)
ArgParse ap; ArgParse ap;
bool help = false; bool help = false;
bool profile = false; bool profile = false;
bool debug = false;
bool version = false; bool version = false;
int verbosity = 1; string log_level;
ap.usage("cycles [options] file.xml"); ap.usage("cycles [options] file.xml");
ap.arg("filename").hidden().action([&](auto argv) { options.filepath = argv[0]; }); ap.arg("filename").hidden().action([&](auto argv) { options.filepath = argv[0]; });
@@ -442,12 +441,9 @@ static void options_parse(const int argc, const char **argv)
}); });
ap.arg("--list-devices", &list).help("List information about all available devices"); ap.arg("--list-devices", &list).help("List information about all available devices");
ap.arg("--profile", &profile).help("Enable profile logging"); ap.arg("--profile", &profile).help("Enable profile logging");
#ifdef WITH_CYCLES_LOGGING ap.arg("--log-level %s:LEVEL")
ap.arg("--debug", &debug).help("Enable debug logging"); .help("Log verbosity: fatal, error, warning, info, stats, debug")
ap.arg("--verbose %d:VERBOSE").help("Set verbosity of the logger").action([&](auto argv) { .action([&](auto argv) { parse_string(argv, &log_level); });
parse_int(argv, &verbosity);
});
#endif
ap.arg("--help", &help).help("Print help message"); ap.arg("--help", &help).help("Print help message");
ap.arg("--version", &version).help("Print version number"); ap.arg("--version", &version).help("Print version number");
@@ -457,9 +453,8 @@ static void options_parse(const int argc, const char **argv)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (debug) { if (!log_level.empty()) {
util_logging_start(); log_level_set(log_level);
util_logging_verbosity_set(verbosity);
} }
if (list) { if (list) {
@@ -544,7 +539,7 @@ using namespace ccl;
int main(const int argc, const char **argv) int main(const int argc, const char **argv)
{ {
util_logging_init(argv[0]); log_init(argv[0]);
path_init(); path_init();
options_parse(argc, argv); options_parse(argc, argv);

View File

@@ -12,9 +12,7 @@ extern "C" {
void *CCL_python_module_init(void); void *CCL_python_module_init(void);
void CCL_init_logging(const char *argv0); void CCL_log_init(void);
void CCL_start_debug_logging(void);
void CCL_logging_verbosity_set(const int verbosity);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@@ -58,6 +58,7 @@ set(LIB
PRIVATE bf::imbuf PRIVATE bf::imbuf
PRIVATE bf::gpu PRIVATE bf::gpu
PRIVATE bf::intern::guardedalloc PRIVATE bf::intern::guardedalloc
PRIVATE bf::intern::clog
PRIVATE bf::render PRIVATE bf::render
cycles_bvh cycles_bvh
cycles_device cycles_device
@@ -73,13 +74,6 @@ set(LIB
${PYTHON_LIBRARIES} ${PYTHON_LIBRARIES}
) )
if(WITH_CYCLES_LOGGING)
list(APPEND LIB
${GLOG_LIBRARIES}
${GFLAGS_LIBRARIES}
)
endif()
set(ADDON_FILES set(ADDON_FILES
addon/__init__.py addon/__init__.py
addon/camera.py addon/camera.py

View File

@@ -5,17 +5,59 @@
#include "blender/CCL_api.h" #include "blender/CCL_api.h"
#include "util/log.h" #include "util/log.h"
void CCL_init_logging(const char *argv0) #include "CLG_log.h"
{
ccl::util_logging_init(argv0);
}
void CCL_start_debug_logging() static CLG_LogRef LOG = {"cycles"};
{
ccl::util_logging_start();
}
void CCL_logging_verbosity_set(const int verbosity) void CCL_log_init()
{ {
ccl::util_logging_verbosity_set(verbosity); /* Set callback to pass log messages to CLOG. */
ccl::log_init(
[](const ccl::LogLevel level, const char *file_line, const char *func, const char *msg) {
const CLG_LogType *log_type = CLOG_ENSURE(&LOG);
switch (level) {
case ccl::FATAL:
case ccl::DFATAL:
CLG_log_str(log_type, CLG_SEVERITY_FATAL, file_line, func, msg);
return;
case ccl::ERROR:
case ccl::DERROR:
CLG_log_str(log_type, CLG_SEVERITY_ERROR, file_line, func, msg);
return;
case ccl::WARNING:
case ccl::DWARNING:
CLG_log_str(log_type, CLG_SEVERITY_WARN, file_line, func, msg);
return;
case ccl::INFO:
case ccl::WORK:
case ccl::STATS:
case ccl::DEBUG:
case ccl::UNKNOWN:
CLG_log_str(log_type, CLG_SEVERITY_INFO, file_line, func, msg);
return;
}
});
/* Map log level from CLOG. */
const CLG_LogType *log_type = CLOG_ENSURE(&LOG);
if (log_type->flag & CLG_FLAG_USE) {
switch (log_type->level) {
case 0:
case 1:
ccl::log_level_set(ccl::INFO);
break;
case 2:
ccl::log_level_set(ccl::WORK);
break;
case 3:
ccl::log_level_set(ccl::STATS);
break;
default:
ccl::log_level_set(ccl::DEBUG);
break;
}
}
else {
ccl::log_level_set(ccl::ERROR);
}
} }

View File

@@ -85,9 +85,6 @@ macro(cycles_external_libraries_append libraries)
list(APPEND ${libraries} "opengl32") list(APPEND ${libraries} "opengl32")
endif() endif()
endif() endif()
if(WITH_CYCLES_LOGGING)
list(APPEND ${libraries} ${GLOG_LIBRARIES} ${GFLAGS_LIBRARIES})
endif()
if(WITH_CYCLES_OSL) if(WITH_CYCLES_OSL)
list(APPEND ${libraries} ${OSL_LIBRARIES}) list(APPEND ${libraries} ${OSL_LIBRARIES})
endif() endif()

View File

@@ -16,10 +16,8 @@
PXR_NAMESPACE_OPEN_SCOPE PXR_NAMESPACE_OPEN_SCOPE
#ifdef WITH_CYCLES_LOGGING
TF_DEFINE_ENV_SETTING(CYCLES_LOGGING, false, "Enable Cycles logging") TF_DEFINE_ENV_SETTING(CYCLES_LOGGING, false, "Enable Cycles logging")
TF_DEFINE_ENV_SETTING(CYCLES_LOGGING_SEVERITY, 1, "Cycles logging verbosity") TF_DEFINE_ENV_SETTING(CYCLES_LOGGING_LEVEL, "warning", "Cycles logging level")
#endif
HdCyclesPlugin::HdCyclesPlugin() HdCyclesPlugin::HdCyclesPlugin()
{ {
@@ -28,12 +26,9 @@ HdCyclesPlugin::HdCyclesPlugin()
const std::string rootPath = PXR_NS::ArchAbsPath(plugin->GetResourcePath()); const std::string rootPath = PXR_NS::ArchAbsPath(plugin->GetResourcePath());
CCL_NS::path_init(std::move(rootPath)); CCL_NS::path_init(std::move(rootPath));
#ifdef WITH_CYCLES_LOGGING
if (TfGetEnvSetting(CYCLES_LOGGING)) { if (TfGetEnvSetting(CYCLES_LOGGING)) {
CCL_NS::util_logging_start(); CCL_NS::log_level_set(TfGetEnvSetting(CYCLES_LOGGING_LEVEL));
CCL_NS::util_logging_verbosity_set(TfGetEnvSetting(CYCLES_LOGGING_SEVERITY));
} }
#endif
} }
HdCyclesPlugin::~HdCyclesPlugin() {} HdCyclesPlugin::~HdCyclesPlugin() {}

View File

@@ -2,7 +2,7 @@
# #
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
if(WITH_GTESTS AND WITH_CYCLES_LOGGING) if(WITH_GTESTS)
# Otherwise we get warnings here that we can't fix in external projects # Otherwise we get warnings here that we can't fix in external projects
remove_strict_flags() remove_strict_flags()
endif() endif()
@@ -58,7 +58,7 @@ if(NOT APPLE)
endif() endif()
endif() endif()
if(WITH_GTESTS AND WITH_CYCLES_LOGGING) if(WITH_GTESTS)
set(INC_SYS ) set(INC_SYS )
blender_add_test_suite_executable(cycles "${SRC}" "${INC}" "${INC_SYS}" "${LIB}") blender_add_test_suite_executable(cycles "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
endif() endif()

View File

@@ -2,7 +2,6 @@
* *
* SPDX-License-Identifier: Apache-2.0 */ * SPDX-License-Identifier: Apache-2.0 */
#include <glog/logging.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "device/device.h" #include "device/device.h"
@@ -145,16 +144,23 @@ class ShaderGraphBuilder {
/* A ScopedMockLog object intercepts log messages issued during its lifespan, /* A ScopedMockLog object intercepts log messages issued during its lifespan,
* to test if the approriate logs are output. */ * to test if the approriate logs are output. */
class ScopedMockLog : google::LogSink { class ScopedMockLog {
public: public:
ScopedMockLog() ScopedMockLog()
{ {
AddLogSink(this); log_init([](const LogLevel /*level*/,
const char * /*file_line*/,
const char * /*func*/,
const char *msg) {
static thread_mutex mutex;
thread_scoped_lock lock(mutex);
messages.push_back(msg);
});
} }
~ScopedMockLog() override ~ScopedMockLog()
{ {
RemoveLogSink(this); log_init(nullptr);
messages.free_memory(); messages.free_memory();
} }
@@ -182,19 +188,6 @@ class ScopedMockLog : google::LogSink {
private: private:
static vector<string> messages; static vector<string> messages;
void send(google::LogSeverity /*severity*/,
const char * /*full_filename*/,
const char * /*base_filename*/,
int /*line*/,
const tm * /*tm_time*/,
const char *message,
size_t /*message_len*/) override
{
static thread_mutex mutex;
thread_scoped_lock lock(mutex);
messages.push_back(message);
}
}; };
vector<string> ScopedMockLog::messages; vector<string> ScopedMockLog::messages;
@@ -230,15 +223,14 @@ class RenderGraph : public testing::Test {
/* Initialize logging after the creation of the essential resources. This way the logging /* Initialize logging after the creation of the essential resources. This way the logging
* mock sink does not warn about uninteresting messages which happens prior to the setup of * mock sink does not warn about uninteresting messages which happens prior to the setup of
* the actual mock sinks. */ * the actual mock sinks. */
util_logging_start(); log_level_set(DEBUG);
util_logging_verbosity_set(5);
} }
void TearDown() override void TearDown() override
{ {
/* Effectively disable logging, so that the next test suit starts in an environment which is /* Effectively disable logging, so that the next test suit starts in an environment which is
* not logging by default. */ * not logging by default. */
util_logging_verbosity_set(0); log_level_set(FATAL);
scene.reset(); scene.reset();
device_cpu.reset(); device_cpu.reset();

View File

@@ -3,9 +3,9 @@
* SPDX-License-Identifier: Apache-2.0 */ * SPDX-License-Identifier: Apache-2.0 */
#include "util/log.h" #include "util/log.h"
#include "util/math.h" #include "util/math.h"
#include "util/string.h" #include "util/string.h"
#include "util/time.h"
#include <cstdio> #include <cstdio>
#ifdef _MSC_VER #ifdef _MSC_VER
@@ -14,59 +14,122 @@
CCL_NAMESPACE_BEGIN CCL_NAMESPACE_BEGIN
#ifdef WITH_CYCLES_LOGGING LogLevel LOG_LEVEL = DWARNING;
static bool is_verbosity_set() static LogFunction LOG_FUNCTION;
static double LOG_START_TIME = time_dt();
const char *log_level_to_string(const LogLevel level)
{ {
using CYCLES_GFLAGS_NAMESPACE::GetCommandLineOption; switch (level) {
case FATAL:
string verbosity; case DFATAL:
if (!GetCommandLineOption("v", &verbosity)) { return "FATAL";
return false; case ERROR:
case DERROR:
return "ERROR";
case WARNING:
case DWARNING:
return "WARNING";
case INFO:
return "INFO";
case WORK:
return "WORK";
case STATS:
return "STATS";
case DEBUG:
return "DEBUG";
case UNKNOWN:
return "UNKNOWN";
} }
return verbosity != "0";
}
#endif
void util_logging_init(const char *argv0) return "";
{
#ifdef WITH_CYCLES_LOGGING
using CYCLES_GFLAGS_NAMESPACE::SetCommandLineOption;
google::InitGoogleLogging(argv0);
SetCommandLineOption("logtostderr", "1");
if (!is_verbosity_set()) {
SetCommandLineOption("v", "0");
}
SetCommandLineOption("stderrthreshold", "0");
SetCommandLineOption("minloglevel", "0");
#else
(void)argv0;
#endif
} }
void util_logging_start() LogLevel log_string_to_level(const string &str)
{ {
#ifdef WITH_CYCLES_LOGGING const std::string str_lower = string_to_lower(str);
using CYCLES_GFLAGS_NAMESPACE::SetCommandLineOption;
SetCommandLineOption("logtostderr", "1"); if (str_lower == "fatal") {
if (!is_verbosity_set()) { return FATAL;
SetCommandLineOption("v", "2");
} }
SetCommandLineOption("stderrthreshold", "0"); if (str_lower == "error") {
SetCommandLineOption("minloglevel", "0"); return ERROR;
#endif }
if (str_lower == "warning") {
return WARNING;
}
if (str_lower == "info") {
return FATAL;
}
if (str_lower == "work") {
return WORK;
}
if (str_lower == "stats") {
return STATS;
}
if (str_lower == "debug") {
return DEBUG;
}
return UNKNOWN;
} }
void util_logging_verbosity_set(const int verbosity) void log_init(const LogFunction func)
{ {
#ifdef WITH_CYCLES_LOGGING LOG_FUNCTION = func;
using CYCLES_GFLAGS_NAMESPACE::SetCommandLineOption; LOG_START_TIME = time_dt();
char val[10]; }
snprintf(val, sizeof(val), "%d", verbosity);
SetCommandLineOption("v", val); void log_level_set(const LogLevel level)
#else {
(void)verbosity; LOG_LEVEL = level;
#endif }
void log_level_set(const std::string &level)
{
const LogLevel new_level = log_string_to_level(level);
if (new_level == UNKNOWN) {
LOG(ERROR) << "Unknown log level specified: " << level;
return;
}
LOG_LEVEL = new_level;
}
static void log_default(const LogLevel level, const std::string &time_str, const char *msg)
{
if (level >= INFO) {
printf("%s | %s\n", time_str.c_str(), msg);
}
else {
fflush(stdout);
fprintf(stderr, "%s | %s: %s\n", time_str.c_str(), log_level_to_string(level), msg);
}
}
void _log_message(const LogLevel level, const char *file_line, const char *func, const char *msg)
{
assert(level <= LOG_LEVEL);
if (LOG_FUNCTION) {
LOG_FUNCTION(level, file_line, func, msg);
return;
}
const std::string time_str = time_human_readable_from_seconds(time_dt() - LOG_START_TIME);
if (strchr(msg, '\n') == nullptr) {
log_default(level, time_str, msg);
return;
}
vector<string> lines;
string_split(lines, msg, "\n", false);
for (const string &line : lines) {
log_default(level, time_str, line.c_str());
}
if (level == FATAL || level == DFATAL) {
abort();
}
} }
std::ostream &operator<<(std::ostream &os, const int2 &value) std::ostream &operator<<(std::ostream &os, const int2 &value)

View File

@@ -4,89 +4,154 @@
#pragma once #pragma once
#if defined(WITH_CYCLES_LOGGING) && !defined(__KERNEL_GPU__) #include "util/defines.h"
# include <gflags/gflags.h> // IWYU pragma: export #include "util/string.h"
# include <glog/logging.h> // IWYU pragma: export #include "util/types.h"
#endif
#include <iosfwd> #include <sstream>
CCL_NAMESPACE_BEGIN CCL_NAMESPACE_BEGIN
#if !defined(WITH_CYCLES_LOGGING) || defined(__KERNEL_GPU__) enum LogLevel {
class StubStream { FATAL = 0,
DFATAL = 1,
ERROR = 2,
DERROR = 3,
WARNING = 4,
DWARNING = 5,
INFO = 6,
WORK = 7,
STATS = 8,
DEBUG = 9,
UNKNOWN = -1,
};
const char *log_level_to_string(const LogLevel level);
LogLevel log_string_to_level(const string &str);
using LogFunction = void (*)(const LogLevel level,
const char *file_line,
const char *func,
const char *msg);
void log_init(const LogFunction func = nullptr);
void log_level_set(const LogLevel level);
void log_level_set(const string &level);
void _log_message(const LogLevel level, const char *file_line, const char *func, const char *msg);
class LogMessage {
public: public:
template<class T> StubStream &operator<<(const T &) LogMessage(enum LogLevel level, const char *file_line, const char *func)
: level_(level), file_line_(file_line), func_(func)
{ {
return *this;
} }
~LogMessage()
{
_log_message(level_, file_line_, func_, stream_.str().c_str());
}
std::ostream &stream()
{
return stream_;
}
protected:
LogLevel level_;
const char *file_line_;
const char *func_;
std::stringstream stream_;
}; };
class LogMessageVoidify { extern LogLevel LOG_LEVEL;
public:
LogMessageVoidify() {}
void operator&(const StubStream &) {}
};
# define LOG_SUPPRESS() (true) ? ((void)0) : LogMessageVoidify() & StubStream() #define LOG_STRINGIFY_APPEND(a, b) "" a #b
# define LOG(severity) LOG_SUPPRESS() #define LOG_STRINGIFY(x) LOG_STRINGIFY_APPEND("", x)
# define VLOG(severity) LOG_SUPPRESS()
# define VLOG_IF(severity, condition) LOG_SUPPRESS()
# define VLOG_IS_ON(severity) false
# define CHECK(expression) LOG_SUPPRESS() #ifdef NDEBUG
# define VLOG_IF(level, condition) \
if constexpr (level != DFATAL && level != DERROR && level != DWARNING) \
if (LIKELY(!(level <= LOG_LEVEL && (condition)))) \
; \
else \
LogMessage(level, __FILE__ ":" LOG_STRINGIFY(__LINE__), __func__).stream()
#else
# define VLOG_IF(level, condition) \
if (LIKELY(!(level <= LOG_LEVEL && (condition)))) \
; \
else \
LogMessage(level, __FILE__ ":" LOG_STRINGIFY(__LINE__), __func__).stream()
#endif
# define CHECK_NOTNULL(expression) (expression) // TODO: remove distinction
#define VLOG(level) VLOG_IF(level, true)
#define LOG(level) VLOG_IF(level, true)
# define CHECK_NEAR(actual, expected, eps) LOG_SUPPRESS() #define VLOG_IS_ON(level) ((level) <= LOG_LEVEL)
# define CHECK_GE(a, b) LOG_SUPPRESS() #define CHECK(expression) VLOG_IF(FATAL, !(expression))
# define CHECK_NE(a, b) LOG_SUPPRESS() #define CHECK_OP(op, a, b) VLOG_IF(FATAL, !((a)op(b)))
# define CHECK_EQ(a, b) LOG_SUPPRESS() #define CHECK_GE(a, b) CHECK_OP(>=, a, b)
# define CHECK_GT(a, b) LOG_SUPPRESS() #define CHECK_NE(a, b) CHECK_OP(!=, a, b)
# define CHECK_LT(a, b) LOG_SUPPRESS() #define CHECK_EQ(a, b) CHECK_OP(==, a, b)
# define CHECK_LE(a, b) LOG_SUPPRESS() #define CHECK_GT(a, b) CHECK_OP(>, a, b)
#define CHECK_LT(a, b) CHECK_OP(<, a, b)
#define CHECK_LE(a, b) CHECK_OP(<=, a, b)
#ifndef NDEBUG
template<typename T> T DCheckNotNull(T &&t, const char *expression)
{
if (t == nullptr) {
LOG(FATAL) << "Failed " << expression << "is not null";
}
return std::forward<T>(t);
}
# define DCHECK(expression) VLOG_IF(DFATAL, !(expression)) << LOG_STRINGIFY(expression) << " "
# define DCHECK_NOTNULL(expression) DCheckNotNull(expression, LOG_STRINGIFY(expression))
# define DCHECK_OP(op, a, b) \
VLOG_IF(DFATAL, !((a)op(b))) << "Failed " << LOG_STRINGIFY(a) << " (" << a << ") " \
<< LOG_STRINGIFY(op) << " " << LOG_STRINGIFY(b) << " (" << b \
<< ") "
# define DCHECK_GE(a, b) DCHECK_OP(>=, a, b)
# define DCHECK_NE(a, b) DCHECK_OP(!=, a, b)
# define DCHECK_EQ(a, b) DCHECK_OP(==, a, b)
# define DCHECK_GT(a, b) DCHECK_OP(>, a, b)
# define DCHECK_LT(a, b) DCHECK_OP(<, a, b)
# define DCHECK_LE(a, b) DCHECK_OP(<=, a, b)
#else
# define LOG_SUPPRESS() VLOG_IF(DEBUG, false)
# define DCHECK(expression) LOG_SUPPRESS() # define DCHECK(expression) LOG_SUPPRESS()
# define DCHECK_NOTNULL(expression) (expression) # define DCHECK_NOTNULL(expression) (expression)
# define DCHECK_NEAR(actual, expected, eps) LOG_SUPPRESS()
# define DCHECK_GE(a, b) LOG_SUPPRESS() # define DCHECK_GE(a, b) LOG_SUPPRESS()
# define DCHECK_NE(a, b) LOG_SUPPRESS() # define DCHECK_NE(a, b) LOG_SUPPRESS()
# define DCHECK_EQ(a, b) LOG_SUPPRESS() # define DCHECK_EQ(a, b) LOG_SUPPRESS()
# define DCHECK_GT(a, b) LOG_SUPPRESS() # define DCHECK_GT(a, b) LOG_SUPPRESS()
# define DCHECK_LT(a, b) LOG_SUPPRESS() # define DCHECK_LT(a, b) LOG_SUPPRESS()
# define DCHECK_LE(a, b) LOG_SUPPRESS() # define DCHECK_LE(a, b) LOG_SUPPRESS()
# define LOG_ASSERT(expression) LOG_SUPPRESS()
#endif #endif
/* Verbose logging categories. */ /* Verbose logging categories. */
/* Warnings. */ /* Warnings. */
#define VLOG_WARNING VLOG(1) #define VLOG_WARNING VLOG(WARNING)
/* Info about devices, scene contents and features used. */ /* Info about devices, scene contents and features used. */
#define VLOG_INFO VLOG(2) #define VLOG_INFO VLOG(INFO)
#define VLOG_INFO_IS_ON VLOG_IS_ON(2) #define VLOG_INFO_IS_ON VLOG_IS_ON(INFO)
/* Work being performed and timing/memory stats about that work. */ /* Work being performed and timing/memory stats about that work. */
#define VLOG_WORK VLOG(3) #define VLOG_WORK VLOG(WORK)
#define VLOG_WORK_IS_ON VLOG_IS_ON(3) #define VLOG_WORK_IS_ON VLOG_IS_ON(WORK)
/* Detailed device timing stats. */ /* Detailed device timing stats. */
#define VLOG_DEVICE_STATS VLOG(4) #define VLOG_DEVICE_STATS VLOG(STATS)
#define VLOG_DEVICE_STATS_IS_ON VLOG_IS_ON(4) #define VLOG_DEVICE_STATS_IS_ON VLOG_IS_ON(STATS)
/* Verbose debug messages. */ /* Verbose debug messages. */
#define VLOG_DEBUG VLOG(5) #define VLOG_DEBUG VLOG(DEBUG)
#define VLOG_DEBUG_IS_ON VLOG_IS_ON(5) #define VLOG_DEBUG_IS_ON VLOG_IS_ON(DEBUG)
struct int2; struct int2;
struct float3; struct float3;
void util_logging_init(const char *argv0);
void util_logging_start();
void util_logging_verbosity_set(const int verbosity);
std::ostream &operator<<(std::ostream &os, const int2 &value); std::ostream &operator<<(std::ostream &os, const int2 &value);
std::ostream &operator<<(std::ostream &os, const float3 &value); std::ostream &operator<<(std::ostream &os, const float3 &value);

View File

@@ -16,5 +16,5 @@ set PYTHONPATH=
set DEBUGLOGS="%temp%\blender\debug_logs" set DEBUGLOGS="%temp%\blender\debug_logs"
mkdir "%DEBUGLOGS%" > NUL 2>&1 mkdir "%DEBUGLOGS%" > NUL 2>&1
"%~dp0\blender" --debug --debug-cycles --verbose 8 --log-level -1 --python-expr "import bpy; bpy.context.preferences.filepaths.temporary_directory=r'%DEBUGLOGS%'; bpy.ops.wm.sysinfo(filepath=r'%DEBUGLOGS%\blender_system_info.txt')" > "%DEBUGLOGS%\blender_debug_output.txt" 2>&1 < %0 "%~dp0\blender" --debug --log cycles --log-level 4 --python-expr "import bpy; bpy.context.preferences.filepaths.temporary_directory=r'%DEBUGLOGS%'; bpy.ops.wm.sysinfo(filepath=r'%DEBUGLOGS%\blender_system_info.txt')" > "%DEBUGLOGS%\blender_debug_output.txt" 2>&1 < %0
explorer "%DEBUGLOGS%" explorer "%DEBUGLOGS%"

View File

@@ -17,5 +17,5 @@ set DEBUGLOGS="%temp%\blender\debug_logs"
set VK_LOADER_DEBUG=all set VK_LOADER_DEBUG=all
mkdir "%DEBUGLOGS%" > NUL 2>&1 mkdir "%DEBUGLOGS%" > NUL 2>&1
"%~dp0\blender" --debug --debug-gpu --debug-cycles --python-expr "import bpy; bpy.context.preferences.filepaths.temporary_directory=r'%DEBUGLOGS%'; bpy.ops.wm.sysinfo(filepath=r'%DEBUGLOGS%\blender_system_info.txt')" > "%DEBUGLOGS%\blender_debug_output.txt" 2>&1 < %0 "%~dp0\blender" --debug --debug-gpu --log cycles --python-expr "import bpy; bpy.context.preferences.filepaths.temporary_directory=r'%DEBUGLOGS%'; bpy.ops.wm.sysinfo(filepath=r'%DEBUGLOGS%\blender_system_info.txt')" > "%DEBUGLOGS%\blender_debug_output.txt" 2>&1 < %0
explorer "%DEBUGLOGS%" explorer "%DEBUGLOGS%"

View File

@@ -16,5 +16,5 @@ set PYTHONPATH=
set DEBUGLOGS="%temp%\blender\debug_logs" set DEBUGLOGS="%temp%\blender\debug_logs"
mkdir "%DEBUGLOGS%" > NUL 2>&1 mkdir "%DEBUGLOGS%" > NUL 2>&1
"%~dp0\blender" --debug --debug-cycles --python-expr "import bpy; bpy.context.preferences.filepaths.temporary_directory=r'%DEBUGLOGS%'; bpy.ops.wm.sysinfo(filepath=r'%DEBUGLOGS%\blender_system_info.txt')" > "%DEBUGLOGS%\blender_debug_output.txt" 2>&1 < %0 "%~dp0\blender" --debug --log cycles --python-expr "import bpy; bpy.context.preferences.filepaths.temporary_directory=r'%DEBUGLOGS%'; bpy.ops.wm.sysinfo(filepath=r'%DEBUGLOGS%\blender_system_info.txt')" > "%DEBUGLOGS%\blender_debug_output.txt" 2>&1 < %0
explorer "%DEBUGLOGS%" explorer "%DEBUGLOGS%"

View File

@@ -52,10 +52,7 @@ endif()
if(WITH_CYCLES) if(WITH_CYCLES)
add_definitions(-DWITH_CYCLES) add_definitions(-DWITH_CYCLES)
if(WITH_CYCLES_LOGGING) list(APPEND INC ../../intern/cycles/blender)
list(APPEND INC ../../intern/cycles/blender)
add_definitions(-DWITH_CYCLES_LOGGING)
endif()
endif() endif()
if(WITH_OPENGL_BACKEND) if(WITH_OPENGL_BACKEND)

View File

@@ -93,7 +93,9 @@
#ifdef WITH_LIBMV #ifdef WITH_LIBMV
# include "libmv-capi.h" # include "libmv-capi.h"
#elif defined(WITH_CYCLES_LOGGING) #endif
#ifdef WITH_CYCLES
# include "CCL_api.h" # include "CCL_api.h"
#endif #endif
@@ -405,8 +407,6 @@ int main(int argc,
#ifdef WITH_LIBMV #ifdef WITH_LIBMV
libmv_initLogging(argv[0]); libmv_initLogging(argv[0]);
#elif defined(WITH_CYCLES_LOGGING)
CCL_init_logging(argv[0]);
#endif #endif
#if defined(WITH_TBB_MALLOC) && defined(_MSC_VER) && defined(NDEBUG) && defined(WITH_GMP) #if defined(WITH_TBB_MALLOC) && defined(_MSC_VER) && defined(NDEBUG) && defined(WITH_GMP)
@@ -496,6 +496,10 @@ int main(int argc,
/* Continue with regular initialization, no need to use "early" exit. */ /* Continue with regular initialization, no need to use "early" exit. */
app_init_data.early_exit = nullptr; app_init_data.early_exit = nullptr;
#ifdef WITH_CYCLES
CCL_log_init();
#endif
/* Must be initialized after #BKE_appdir_init to account for color-management paths. */ /* Must be initialized after #BKE_appdir_init to account for color-management paths. */
IMB_init(); IMB_init();
/* Keep after #ARG_PASS_SETTINGS since debug flags are checked. */ /* Keep after #ARG_PASS_SETTINGS since debug flags are checked. */

View File

@@ -69,7 +69,7 @@
# include "libmv-capi.h" # include "libmv-capi.h"
# endif # endif
# ifdef WITH_CYCLES_LOGGING # ifdef WITH_CYCLES
# include "CCL_api.h" # include "CCL_api.h"
# endif # endif
@@ -90,7 +90,6 @@
struct BuildDefs { struct BuildDefs {
bool win32; bool win32;
bool with_cycles; bool with_cycles;
bool with_cycles_logging;
bool with_ffmpeg; bool with_ffmpeg;
bool with_freestyle; bool with_freestyle;
bool with_libmv; bool with_libmv;
@@ -117,9 +116,6 @@ static void build_defs_init(BuildDefs *build_defs, bool force_all)
# ifdef WITH_CYCLES # ifdef WITH_CYCLES
build_defs->with_cycles = true; build_defs->with_cycles = true;
# endif # endif
# ifdef WITH_CYCLES_LOGGING
build_defs->with_cycles_logging = true;
# endif
# ifdef WITH_FFMPEG # ifdef WITH_FFMPEG
build_defs->with_ffmpeg = true; build_defs->with_ffmpeg = true;
# endif # endif
@@ -741,9 +737,6 @@ static void print_help(bArgs *ba, bool all)
if (defs.with_libmv) { if (defs.with_libmv) {
BLI_args_print_arg_doc(ba, "--debug-libmv"); BLI_args_print_arg_doc(ba, "--debug-libmv");
} }
if (defs.with_cycles_logging) {
BLI_args_print_arg_doc(ba, "--debug-cycles");
}
BLI_args_print_arg_doc(ba, "--debug-memory"); BLI_args_print_arg_doc(ba, "--debug-memory");
BLI_args_print_arg_doc(ba, "--debug-jobs"); BLI_args_print_arg_doc(ba, "--debug-jobs");
BLI_args_print_arg_doc(ba, "--debug-python"); BLI_args_print_arg_doc(ba, "--debug-python");
@@ -1393,9 +1386,6 @@ static int arg_handle_debug_mode_all(int /*argc*/, const char ** /*argv*/, void
G.debug |= G_DEBUG_ALL; G.debug |= G_DEBUG_ALL;
# ifdef WITH_LIBMV # ifdef WITH_LIBMV
libmv_startDebugLogging(); libmv_startDebugLogging();
# endif
# ifdef WITH_CYCLES_LOGGING
CCL_start_debug_logging();
# endif # endif
return 0; return 0;
} }
@@ -1416,9 +1406,8 @@ static const char arg_handle_debug_mode_cycles_doc[] =
"Enable debug messages from Cycles."; "Enable debug messages from Cycles.";
static int arg_handle_debug_mode_cycles(int /*argc*/, const char ** /*argv*/, void * /*data*/) static int arg_handle_debug_mode_cycles(int /*argc*/, const char ** /*argv*/, void * /*data*/)
{ {
# ifdef WITH_CYCLES_LOGGING const char *cycles_filter = "cycles.*";
CCL_start_debug_logging(); CLG_type_filter_include(cycles_filter, strlen(cycles_filter));
# endif
return 0; return 0;
} }
@@ -2094,10 +2083,6 @@ static int arg_handle_verbosity_set(int argc, const char **argv, void * /*data*/
# ifdef WITH_LIBMV # ifdef WITH_LIBMV
libmv_setLoggingVerbosity(level); libmv_setLoggingVerbosity(level);
# elif defined(WITH_CYCLES_LOGGING)
CCL_logging_verbosity_set(level);
# else
(void)level;
# endif # endif
return 1; return 1;
@@ -2821,7 +2806,7 @@ void main_args_setup(bContext *C, bArgs *ba, bool all)
if (defs.with_libmv) { if (defs.with_libmv) {
BLI_args_add(ba, nullptr, "--debug-libmv", CB(arg_handle_debug_mode_libmv), nullptr); BLI_args_add(ba, nullptr, "--debug-libmv", CB(arg_handle_debug_mode_libmv), nullptr);
} }
if (defs.with_cycles_logging) { if (defs.with_cycles) {
BLI_args_add(ba, nullptr, "--debug-cycles", CB(arg_handle_debug_mode_cycles), nullptr); BLI_args_add(ba, nullptr, "--debug-cycles", CB(arg_handle_debug_mode_cycles), nullptr);
} }
BLI_args_add(ba, nullptr, "--debug-memory", CB(arg_handle_debug_mode_memory_set), nullptr); BLI_args_add(ba, nullptr, "--debug-memory", CB(arg_handle_debug_mode_memory_set), nullptr);