Refactor: Cycles: Replace remaining fprintf with logging
Pull Request: https://projects.blender.org/blender/blender/pulls/140244
This commit is contained in:
@@ -539,7 +539,7 @@ using namespace ccl;
|
||||
|
||||
int main(const int argc, const char **argv)
|
||||
{
|
||||
log_init(argv[0]);
|
||||
log_init(nullptr);
|
||||
path_init();
|
||||
options_parse(argc, argv);
|
||||
|
||||
|
||||
@@ -22,8 +22,10 @@
|
||||
#include "scene/shader_graph.h"
|
||||
#include "scene/shader_nodes.h"
|
||||
|
||||
#include "util/log.h"
|
||||
#include "util/path.h"
|
||||
#include "util/projection.h"
|
||||
#include "util/string.h"
|
||||
#include "util/transform.h"
|
||||
#include "util/xml.h"
|
||||
|
||||
@@ -261,14 +263,12 @@ static void xml_read_shader_graph(XMLReadState &state, Shader *shader, const xml
|
||||
}
|
||||
|
||||
if (!output) {
|
||||
fprintf(stderr,
|
||||
"Unknown output socket name \"%s\" on \"%s\".\n",
|
||||
from_node_name.c_str(),
|
||||
from_socket_name.c_str());
|
||||
LOG(ERROR) << "Unknown output socket name \"" << from_node_name << "\" on \""
|
||||
<< from_socket_name << "\".";
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "Unknown shader node name \"%s\".\n", from_node_name.c_str());
|
||||
LOG(ERROR) << "Unknown shader node name \"" << from_node_name << "\"";
|
||||
}
|
||||
|
||||
if (graph_reader.node_map.find(to_node_name) != graph_reader.node_map.end()) {
|
||||
@@ -281,14 +281,12 @@ static void xml_read_shader_graph(XMLReadState &state, Shader *shader, const xml
|
||||
}
|
||||
|
||||
if (!input) {
|
||||
fprintf(stderr,
|
||||
"Unknown input socket name \"%s\" on \"%s\".\n",
|
||||
to_socket_name.c_str(),
|
||||
to_node_name.c_str());
|
||||
LOG(ERROR) << "Unknown input socket name \"" << to_socket_name << "\" on \""
|
||||
<< to_node_name << "\"";
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "Unknown shader node name \"%s\".\n", to_node_name.c_str());
|
||||
LOG(ERROR) << "Unknown shader node name \"" << to_node_name << "\"";
|
||||
}
|
||||
|
||||
/* connect */
|
||||
@@ -297,7 +295,7 @@ static void xml_read_shader_graph(XMLReadState &state, Shader *shader, const xml
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "Invalid from or to value for connect node.\n");
|
||||
LOG(ERROR) << "Invalid from or to value for connect node.";
|
||||
}
|
||||
|
||||
continue;
|
||||
@@ -320,17 +318,17 @@ static void xml_read_shader_graph(XMLReadState &state, Shader *shader, const xml
|
||||
snode = OSLShaderManager::osl_node(graph.get(), state.scene, filepath, "");
|
||||
|
||||
if (!snode) {
|
||||
fprintf(stderr, "Failed to create OSL node from \"%s\".\n", filepath.c_str());
|
||||
LOG(ERROR) << "Failed to create OSL node from \"" << filepath << "\"";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "OSL node missing \"src\" attribute.\n");
|
||||
LOG(ERROR) << "OSL node missing \"src\" attribute.";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "OSL node without using --shadingsys osl.\n");
|
||||
LOG(ERROR) << "OSL node without using --shadingsys osl.";
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -345,15 +343,16 @@ static void xml_read_shader_graph(XMLReadState &state, Shader *shader, const xml
|
||||
const NodeType *node_type = NodeType::find(node_name);
|
||||
|
||||
if (!node_type) {
|
||||
fprintf(stderr, "Unknown shader node \"%s\".\n", node.name());
|
||||
LOG(ERROR) << "Unknown shader node \"" << node.name() << "\"";
|
||||
continue;
|
||||
}
|
||||
if (node_type->type != NodeType::SHADER) {
|
||||
fprintf(stderr, "Node type \"%s\" is not a shader node.\n", node_type->name.c_str());
|
||||
LOG(ERROR) << "Node type \"" << node_type->name << "\" is not a shader node";
|
||||
continue;
|
||||
}
|
||||
if (node_type->create == nullptr) {
|
||||
fprintf(stderr, "Can't create abstract node type \"%s\".\n", node_type->name.c_str());
|
||||
LOG(ERROR) << "Can't create abstract node type \""
|
||||
<< "\"";
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -698,7 +697,7 @@ static void xml_read_state(XMLReadState &state, const xml_node node)
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
fprintf(stderr, "Unknown shader \"%s\".\n", shadername.c_str());
|
||||
LOG(ERROR) << "Unknown shader \"" << shadername << "\"";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -717,7 +716,7 @@ static void xml_read_state(XMLReadState &state, const xml_node node)
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
fprintf(stderr, "Unknown object \"%s\".\n", objectname.c_str());
|
||||
LOG(ERROR) << "Unknown object \"" << objectname << "\"";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -808,7 +807,7 @@ static void xml_read_scene(XMLReadState &state, const xml_node scene_node)
|
||||
}
|
||||
#endif
|
||||
else {
|
||||
fprintf(stderr, "Unknown node \"%s\".\n", node.name());
|
||||
LOG(ERROR) << "Unknown node \"" << node.name() << "\"";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -832,7 +831,7 @@ static void xml_read_include(XMLReadState &state, const string &src)
|
||||
xml_read_scene(substate, cycles);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "%s read error: %s\n", src.c_str(), parse_result.description());
|
||||
LOG(ERROR) << "\"" << src << "\" read error: " << parse_result.description();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "app/opengl/window.h"
|
||||
|
||||
#include "util/log.h"
|
||||
#include "util/string.h"
|
||||
#include "util/thread.h"
|
||||
#include "util/version.h"
|
||||
@@ -66,7 +67,7 @@ static void window_display_text(int /*x*/, int /*y*/, const char *text)
|
||||
static string last_text;
|
||||
|
||||
if (text != last_text) {
|
||||
printf("%s\n", text);
|
||||
LOG(INFO_IMPORTANT) << text;
|
||||
last_text = text;
|
||||
}
|
||||
#endif
|
||||
@@ -291,7 +292,7 @@ void window_main_loop(const char *title,
|
||||
height,
|
||||
SDL_WINDOW_RESIZABLE | SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN);
|
||||
if (V.window == nullptr) {
|
||||
fprintf(stderr, "Failed to create window: %s\n", SDL_GetError());
|
||||
LOG(ERROR) << "Failed to create window: " << SDL_GetError();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ void CCL_log_init()
|
||||
CLG_log_str(log_type, CLG_SEVERITY_WARN, file_line, func, msg);
|
||||
return;
|
||||
case ccl::INFO:
|
||||
case ccl::INFO_IMPORTANT:
|
||||
case ccl::WORK:
|
||||
case ccl::STATS:
|
||||
case ccl::DEBUG:
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "util/debug.h"
|
||||
|
||||
#include "util/guiding.h"
|
||||
#include "util/md5.h"
|
||||
#include "util/log.h"
|
||||
#include "util/openimagedenoise.h"
|
||||
#include "util/path.h"
|
||||
#include "util/string.h"
|
||||
@@ -727,7 +727,7 @@ static PyObject *set_device_override_func(PyObject * /*self*/, PyObject *arg)
|
||||
BlenderSession::device_override = DEVICE_MASK_ONEAPI;
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "\nError: %s is not a valid Cycles device.\n", override.c_str());
|
||||
LOG(ERROR) << override << " is not a valid Cycles device.";
|
||||
Py_RETURN_FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#include "blender/sync.h"
|
||||
#include "blender/util.h"
|
||||
|
||||
#include "util/log.h"
|
||||
|
||||
#include "BKE_volume_grid.hh"
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
@@ -140,16 +142,15 @@ class BlenderSmokeLoader : public ImageLoader {
|
||||
}
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,
|
||||
"Cycles error: unknown volume attribute %s, skipping\n",
|
||||
Attribute::standard_name(attribute));
|
||||
LOG(ERROR) << "Unknown volume attribute " << Attribute::standard_name(attribute)
|
||||
<< "skipping ";
|
||||
fpixels[0] = 0.0f;
|
||||
return false;
|
||||
}
|
||||
#else
|
||||
(void)pixels;
|
||||
#endif
|
||||
fprintf(stderr, "Cycles error: unexpected smoke volume resolution, skipping\n");
|
||||
LOG(ERROR) << "Unexpected smoke volume resolution, skipping";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ void device_cuda_info(vector<DeviceInfo> &devices)
|
||||
CUresult result = device_cuda_safe_init();
|
||||
if (result != CUDA_SUCCESS) {
|
||||
if (result != CUDA_ERROR_NO_DEVICE) {
|
||||
fprintf(stderr, "CUDA cuInit: %s\n", cuewErrorString(result));
|
||||
LOG(ERROR) << "CUDA cuInit: " << cuewErrorString(result);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -117,7 +117,7 @@ void device_cuda_info(vector<DeviceInfo> &devices)
|
||||
int count = 0;
|
||||
result = cuDeviceGetCount(&count);
|
||||
if (result != CUDA_SUCCESS) {
|
||||
fprintf(stderr, "CUDA cuDeviceGetCount: %s\n", cuewErrorString(result));
|
||||
LOG(ERROR) << "CUDA cuDeviceGetCount: " << cuewErrorString(result);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ void device_cuda_info(vector<DeviceInfo> &devices)
|
||||
|
||||
result = cuDeviceGetName(name, 256, num);
|
||||
if (result != CUDA_SUCCESS) {
|
||||
fprintf(stderr, "CUDA cuDeviceGetName: %s\n", cuewErrorString(result));
|
||||
LOG(ERROR) << "CUDA cuDeviceGetName: " << cuewErrorString(result);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
# include <cstdio>
|
||||
# include <cstdlib>
|
||||
# include <cstring>
|
||||
# include <iomanip>
|
||||
|
||||
# include "device/cuda/device_impl.h"
|
||||
|
||||
@@ -339,19 +340,13 @@ string CUDADevice::compile_kernel(const string &common_cflags,
|
||||
const int nvcc_cuda_version = cuewCompilerVersion();
|
||||
LOG(INFO) << "Found nvcc " << nvcc << ", CUDA version " << nvcc_cuda_version << ".";
|
||||
if (nvcc_cuda_version < 101) {
|
||||
printf(
|
||||
"Unsupported CUDA version %d.%d detected, "
|
||||
"you need CUDA 10.1 or newer.\n",
|
||||
nvcc_cuda_version / 10,
|
||||
nvcc_cuda_version % 10);
|
||||
LOG(WARNING) << "Unsupported CUDA version " << nvcc_cuda_version / 10 << "."
|
||||
<< nvcc_cuda_version % 10 << ", you need CUDA 10.1 or newer";
|
||||
return string();
|
||||
}
|
||||
if (!(nvcc_cuda_version >= 102 && nvcc_cuda_version < 130)) {
|
||||
printf(
|
||||
"CUDA version %d.%d detected, build may succeed but only "
|
||||
"CUDA 10.1 to 12 are officially supported.\n",
|
||||
nvcc_cuda_version / 10,
|
||||
nvcc_cuda_version % 10);
|
||||
LOG(WARNING) << "CUDA version " << nvcc_cuda_version / 10 << "." << nvcc_cuda_version % 10
|
||||
<< "CUDA 10.1 to 12 are officially supported.";
|
||||
}
|
||||
|
||||
double starttime = time_dt();
|
||||
@@ -376,9 +371,9 @@ string CUDADevice::compile_kernel(const string &common_cflags,
|
||||
cubin.c_str(),
|
||||
common_cflags.c_str());
|
||||
|
||||
printf("Compiling %sCUDA kernel ...\n%s\n",
|
||||
(use_adaptive_compilation()) ? "adaptive " : "",
|
||||
command.c_str());
|
||||
LOG(INFO_IMPORTANT) << "Compiling " << ((use_adaptive_compilation()) ? "adaptive " : "")
|
||||
<< "CUDA kernel ...";
|
||||
LOG(INFO_IMPORTANT) << command;
|
||||
|
||||
# ifdef _WIN32
|
||||
command = "call " + command;
|
||||
@@ -398,7 +393,8 @@ string CUDADevice::compile_kernel(const string &common_cflags,
|
||||
return string();
|
||||
}
|
||||
|
||||
printf("Kernel compilation finished in %.2lfs.\n", time_dt() - starttime);
|
||||
LOG(INFO_IMPORTANT) << "Kernel compilation finished in " << std::fixed << std::setprecision(2)
|
||||
<< time_dt() - starttime << "s";
|
||||
|
||||
return cubin;
|
||||
}
|
||||
|
||||
@@ -49,6 +49,15 @@ uint Device::devices_initialized_mask = 0;
|
||||
|
||||
Device::~Device() noexcept(false) = default;
|
||||
|
||||
void Device::set_error(const string &error)
|
||||
{
|
||||
if (!have_error()) {
|
||||
error_msg = error;
|
||||
}
|
||||
LOG(ERROR) << error;
|
||||
fflush(stderr);
|
||||
}
|
||||
|
||||
void Device::build_bvh(BVH *bvh, Progress &progress, bool refit)
|
||||
{
|
||||
assert(bvh->params.bvh_layout == BVH_LAYOUT_BVH2);
|
||||
|
||||
@@ -158,14 +158,7 @@ class Device {
|
||||
{
|
||||
return !error_message().empty();
|
||||
}
|
||||
virtual void set_error(const string &error)
|
||||
{
|
||||
if (!have_error()) {
|
||||
error_msg = error;
|
||||
}
|
||||
fprintf(stderr, "%s\n", error.c_str());
|
||||
fflush(stderr);
|
||||
}
|
||||
virtual void set_error(const string &error);
|
||||
virtual BVHLayoutMask get_bvh_layout_mask(const uint kernel_features) const = 0;
|
||||
|
||||
/* statistics */
|
||||
|
||||
@@ -129,7 +129,7 @@ void device_hip_info(vector<DeviceInfo> &devices)
|
||||
hipError_t result = device_hip_safe_init();
|
||||
if (result != hipSuccess) {
|
||||
if (result != hipErrorNoDevice) {
|
||||
fprintf(stderr, "HIP hipInit: %s\n", hipewErrorString(result));
|
||||
LOG(ERROR) << "HIP hipInit: " << hipewErrorString(result);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -137,7 +137,7 @@ void device_hip_info(vector<DeviceInfo> &devices)
|
||||
int count = 0;
|
||||
result = hipGetDeviceCount(&count);
|
||||
if (result != hipSuccess) {
|
||||
fprintf(stderr, "HIP hipGetDeviceCount: %s\n", hipewErrorString(result));
|
||||
LOG(ERROR) << "HIP hipGetDeviceCount: " << hipewErrorString(result);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ void device_hip_info(vector<DeviceInfo> &devices)
|
||||
|
||||
result = hipDeviceGetName(name, 256, num);
|
||||
if (result != hipSuccess) {
|
||||
fprintf(stderr, "HIP :hipDeviceGetName: %s\n", hipewErrorString(result));
|
||||
LOG(ERROR) << "HIP hipDeviceGetName: " << hipewErrorString(result);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
# include <cstdio>
|
||||
# include <cstdlib>
|
||||
# include <cstring>
|
||||
# include <iomanip>
|
||||
|
||||
# include "device/hip/device_impl.h"
|
||||
|
||||
@@ -345,9 +346,8 @@ string HIPDevice::compile_kernel(const uint kernel_features, const char *name, c
|
||||
fatbin.c_str(),
|
||||
common_cflags.c_str());
|
||||
|
||||
printf("Compiling %sHIP kernel ...\n%s\n",
|
||||
(use_adaptive_compilation()) ? "adaptive " : "",
|
||||
command.c_str());
|
||||
LOG(INFO_IMPORTANT) << "Compiling " << ((use_adaptive_compilation()) ? "adaptive " : "")
|
||||
<< "HIP kernel ...";
|
||||
|
||||
# ifdef _WIN32
|
||||
command = "call " + command;
|
||||
@@ -367,7 +367,8 @@ string HIPDevice::compile_kernel(const uint kernel_features, const char *name, c
|
||||
return string();
|
||||
}
|
||||
|
||||
printf("Kernel compilation finished in %.2lfs.\n", time_dt() - starttime);
|
||||
LOG(INFO_IMPORTANT) << "Kernel compilation finished in " << std::fixed << std::setprecision(2)
|
||||
<< time_dt() - starttime << "s";
|
||||
|
||||
return fatbin;
|
||||
}
|
||||
|
||||
@@ -4,8 +4,10 @@
|
||||
|
||||
#ifdef WITH_HIPRT
|
||||
|
||||
# include "device/hiprt/device_impl.h"
|
||||
# include <iomanip>
|
||||
|
||||
# include "device/hip/util.h"
|
||||
# include "device/hiprt/device_impl.h"
|
||||
# include "kernel/device/hiprt/globals.h"
|
||||
|
||||
# include "util/log.h"
|
||||
@@ -152,9 +154,9 @@ string HIPRTDevice::compile_kernel(const uint kernel_features, const char *name,
|
||||
|
||||
if (!use_adaptive_compilation()) {
|
||||
const string fatbin = path_get(string_printf("lib/%s_rt_%s.hipfb.zst", name, arch.c_str()));
|
||||
VLOG(1) << "Testing for pre-compiled kernel " << fatbin << ".";
|
||||
LOG(INFO) << "Testing for pre-compiled kernel " << fatbin << ".";
|
||||
if (path_exists(fatbin)) {
|
||||
VLOG(1) << "Using precompiled kernel.";
|
||||
LOG(INFO) << "Using precompiled kernel.";
|
||||
return fatbin;
|
||||
}
|
||||
}
|
||||
@@ -171,9 +173,9 @@ string HIPRTDevice::compile_kernel(const uint kernel_features, const char *name,
|
||||
const string fatbin = path_cache_get(path_join("kernels", fatbin_file));
|
||||
const string hiprt_include_path = path_join(source_path, "kernel/device/hiprt");
|
||||
|
||||
VLOG(1) << "Testing for locally compiled kernel " << fatbin << ".";
|
||||
LOG(INFO) << "Testing for locally compiled kernel " << fatbin << ".";
|
||||
if (path_exists(fatbin)) {
|
||||
VLOG(1) << "Using locally compiled kernel.";
|
||||
LOG(INFO) << "Using locally compiled kernel.";
|
||||
return fatbin;
|
||||
}
|
||||
|
||||
@@ -208,11 +210,8 @@ string HIPRTDevice::compile_kernel(const uint kernel_features, const char *name,
|
||||
const int hipcc_hip_version = hipewCompilerVersion();
|
||||
LOG(INFO) << "Found hipcc " << hipcc << ", HIP version " << hipcc_hip_version << ".";
|
||||
if (hipcc_hip_version < 40) {
|
||||
printf(
|
||||
"Unsupported HIP version %d.%d detected, "
|
||||
"you need HIP 4.0 or newer.\n",
|
||||
hipcc_hip_version / 10,
|
||||
hipcc_hip_version % 10);
|
||||
LOG(WARNING) << "Unsupported HIP version " << hipcc_hip_version / 10 << "."
|
||||
<< hipcc_hip_version % 10 << ", you need HIP 4.0 or newer.\n";
|
||||
return string();
|
||||
}
|
||||
|
||||
@@ -235,7 +234,7 @@ string HIPRTDevice::compile_kernel(const uint kernel_features, const char *name,
|
||||
options.append(" -D WITH_NANOVDB");
|
||||
# endif
|
||||
|
||||
printf("Compiling %s and caching to %s", source_path.c_str(), fatbin.c_str());
|
||||
LOG(INFO_IMPORTANT) << "Compiling " << source_path << " and caching to " << fatbin;
|
||||
|
||||
double starttime = time_dt();
|
||||
|
||||
@@ -258,7 +257,8 @@ string HIPRTDevice::compile_kernel(const uint kernel_features, const char *name,
|
||||
return string();
|
||||
}
|
||||
|
||||
printf("Kernel compilation finished in %.2lfs.\n", time_dt() - starttime);
|
||||
LOG(INFO_IMPORTANT) << "Kernel compilation finished in " << std::fixed << std::setprecision(2)
|
||||
<< time_dt() - starttime << "s";
|
||||
|
||||
return fatbin;
|
||||
}
|
||||
@@ -267,7 +267,7 @@ bool HIPRTDevice::load_kernels(const uint kernel_features)
|
||||
{
|
||||
if (hipModule) {
|
||||
if (use_adaptive_compilation()) {
|
||||
VLOG(1) << "Skipping HIP kernel reload for adaptive compilation, not currently supported.";
|
||||
LOG(INFO) << "Skipping HIP kernel reload for adaptive compilation, not currently supported.";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 */
|
||||
|
||||
#include "device/queue.h"
|
||||
#include <iomanip>
|
||||
|
||||
#include "device/kernel.h"
|
||||
#include "device/queue.h"
|
||||
|
||||
#include "util/algorithm.h"
|
||||
#include "util/log.h"
|
||||
#include "util/time.h"
|
||||
|
||||
#include <iomanip>
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
DeviceQueue::DeviceQueue(Device *device) : device(device)
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "graph/node_type.h"
|
||||
|
||||
#include "util/log.h"
|
||||
#include "util/transform.h"
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
@@ -214,7 +215,7 @@ NodeType *NodeType::add(const char *name_, CreateFunc create_, Type type_, const
|
||||
const ustring name(name_);
|
||||
|
||||
if (types().find(name) != types().end()) {
|
||||
fprintf(stderr, "Node type %s registered twice!\n", name_);
|
||||
LOG(ERROR) << "Node type " << name_ << " registered twice";
|
||||
assert(0);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "graph/node_enum.h"
|
||||
|
||||
#include "util/array.h" // IWYU pragma: keep
|
||||
#include "util/map.h"
|
||||
#include "util/param.h"
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
# include "graph/node_xml.h"
|
||||
# include "graph/node.h"
|
||||
|
||||
# include "util/log.h"
|
||||
# include "util/string.h"
|
||||
# include "util/transform.h"
|
||||
|
||||
@@ -158,10 +159,8 @@ void xml_read_node(XMLReader &reader, Node *node, const xml_node xml_node)
|
||||
node->set(socket, value);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,
|
||||
"Unknown value \"%s\" for attribute \"%s\".\n",
|
||||
value.c_str(),
|
||||
socket.name.c_str());
|
||||
LOG(ERROR) << "Unknown value \"" << value.c_str() << "\" for attribute \""
|
||||
<< socket.name.c_str() << "\"";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "hydra/camera.h"
|
||||
#include "hydra/render_delegate.h"
|
||||
|
||||
#include "util/log.h"
|
||||
#include "util/path.h"
|
||||
#include "util/unique_ptr.h"
|
||||
|
||||
@@ -59,7 +60,7 @@ void HdCyclesFileReader::read(Session *session, const char *filepath, const bool
|
||||
/* Open Stage. */
|
||||
const UsdStageRefPtr stage = UsdStage::Open(filepath);
|
||||
if (!stage) {
|
||||
fprintf(stderr, "%s read error\n", filepath);
|
||||
LOG(ERROR) << "USD failed to read " << filepath;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ class OIDNDenoiseContext {
|
||||
const char *custom_weight_path = getenv("CYCLES_OIDN_CUSTOM_WEIGHTS");
|
||||
if (custom_weight_path) {
|
||||
if (!path_read_binary(custom_weight_path, custom_weights)) {
|
||||
fprintf(stderr, "Cycles: Failed to load custom OIDN weights!");
|
||||
LOG(ERROR) << "Failed to load custom OpenImageDenoise weights";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,7 +335,7 @@ bool OIDNDenoiserGPU::denoise_create_if_needed(DenoiseContext &context)
|
||||
oidn_filter_, "weights", custom_weights.data(), custom_weights.size());
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "Cycles: Failed to load custom OIDN weights!");
|
||||
LOG(ERROR) << "Failed to load custom OpenImageDenoise weights";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -567,7 +567,7 @@ const char *OSLManager::shader_load_filepath(string filepath)
|
||||
string bytecode;
|
||||
|
||||
if (!path_read_text(filepath, bytecode)) {
|
||||
fprintf(stderr, "Cycles shader graph: failed to read file %s\n", filepath.c_str());
|
||||
LOG(ERROR) << "Shader graph: failed to read file " << filepath;
|
||||
const OSLShaderInfo info;
|
||||
loaded_shaders[bytecode_hash] = info; /* to avoid repeat tries */
|
||||
return nullptr;
|
||||
@@ -588,7 +588,7 @@ const char *OSLManager::shader_load_bytecode(const string &hash, const string &b
|
||||
OSLShaderInfo info;
|
||||
|
||||
if (!info.query.open_bytecode(bytecode)) {
|
||||
fprintf(stderr, "OSL query error: %s\n", info.query.geterror().c_str());
|
||||
LOG(ERROR) << "OSL query error: " << info.query.geterror();
|
||||
}
|
||||
|
||||
/* this is a bit weak, but works */
|
||||
|
||||
@@ -241,20 +241,16 @@ void ShaderGraph::connect(ShaderOutput *from, ShaderInput *to)
|
||||
assert(from && to);
|
||||
|
||||
if (to->link) {
|
||||
fprintf(stderr, "Cycles shader graph connect: input already connected.\n");
|
||||
LOG(WARNING) << "Sraph connect: input already connected.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (from->type() != to->type()) {
|
||||
/* can't do automatic conversion from closure */
|
||||
if (from->type() == SocketType::CLOSURE) {
|
||||
fprintf(stderr,
|
||||
"Cycles shader graph connect: can only connect closure to closure "
|
||||
"(%s.%s to %s.%s).\n",
|
||||
from->parent->name.c_str(),
|
||||
from->name().c_str(),
|
||||
to->parent->name.c_str(),
|
||||
to->name().c_str());
|
||||
LOG(WARNING) << "Shader graph connect: can only connect closure to closure ("
|
||||
<< from->parent->name.c_str() << "." << from->name().c_str() << " to "
|
||||
<< to->parent->name.c_str() << "." << to->name().c_str() << ")";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -721,7 +717,7 @@ void ShaderGraph::break_cycles(ShaderNode *node, vector<bool> &visited, vector<b
|
||||
if (on_stack[depnode->id]) {
|
||||
/* break cycle */
|
||||
disconnect(input);
|
||||
fprintf(stderr, "Cycles shader graph: detected cycle in graph, connection removed.\n");
|
||||
LOG(WARNING) << "Shader graph: detected cycle in graph, connection removed.";
|
||||
}
|
||||
else if (!visited[depnode->id]) {
|
||||
/* visit dependencies */
|
||||
@@ -1200,7 +1196,7 @@ void ShaderGraph::dump_graph(const char *filename)
|
||||
FILE *fd = fopen(filename, "w");
|
||||
|
||||
if (fd == nullptr) {
|
||||
printf("Error opening file for dumping the graph: %s\n", filename);
|
||||
LOG(ERROR) << "Error opening file for dumping the graph: " << filename;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -217,9 +217,8 @@ int SVMCompiler::stack_find_offset(const int size)
|
||||
|
||||
if (!compile_failed) {
|
||||
compile_failed = true;
|
||||
fprintf(stderr,
|
||||
"Cycles: out of SVM stack space, shader \"%s\" too big.\n",
|
||||
current_shader->name.c_str());
|
||||
LOG(ERROR) << "Shader graph: out of SVM stack space, shader \"" << current_shader->name
|
||||
<< "\" too big.";
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -292,8 +292,6 @@ bool DenoiseTask::exec()
|
||||
}
|
||||
out += image.num_channels * image.width;
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -152,7 +152,7 @@ size_t util_guarded_get_mem_peak();
|
||||
(func)(__VA_ARGS__); \
|
||||
} \
|
||||
catch (std::bad_alloc &) { \
|
||||
fprintf(stderr, "Error: run out of memory!\n"); \
|
||||
LOG(ERROR) << "Out of memory"; \
|
||||
fflush(stderr); \
|
||||
(progress)->set_error("Out of memory"); \
|
||||
} \
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
LogLevel LOG_LEVEL = DWARNING;
|
||||
LogLevel LOG_LEVEL = INFO_IMPORTANT;
|
||||
static LogFunction LOG_FUNCTION;
|
||||
static double LOG_START_TIME = time_dt();
|
||||
|
||||
@@ -30,6 +30,7 @@ const char *log_level_to_string(const LogLevel level)
|
||||
case WARNING:
|
||||
case DWARNING:
|
||||
return "WARNING";
|
||||
case INFO_IMPORTANT:
|
||||
case INFO:
|
||||
return "INFO";
|
||||
case WORK:
|
||||
@@ -59,7 +60,7 @@ LogLevel log_string_to_level(const string &str)
|
||||
return WARNING;
|
||||
}
|
||||
if (str_lower == "info") {
|
||||
return FATAL;
|
||||
return INFO;
|
||||
}
|
||||
if (str_lower == "work") {
|
||||
return WORK;
|
||||
|
||||
@@ -15,16 +15,17 @@ CCL_NAMESPACE_BEGIN
|
||||
/* Log Levels */
|
||||
|
||||
enum LogLevel {
|
||||
FATAL = 0, /* Fatal error, application will abort */
|
||||
DFATAL = 1, /* Fatal error in debug build only */
|
||||
ERROR = 2, /* Error */
|
||||
DERROR = 3, /* Error in debug build only */
|
||||
WARNING = 4, /* Warning */
|
||||
DWARNING = 5, /* Warning in debug build only */
|
||||
INFO = 6, /* Info about devices, scene contents and features used. */
|
||||
WORK = 7, /* Work being performed and timing/memory stats about that work. */
|
||||
STATS = 8, /* Detailed device timing stats. */
|
||||
DEBUG = 9, /* Verbose debug messages. */
|
||||
FATAL = 0, /* Fatal error, application will abort */
|
||||
DFATAL = 1, /* Fatal error in debug build only */
|
||||
ERROR = 2, /* Error */
|
||||
DERROR = 3, /* Error in debug build only */
|
||||
WARNING = 4, /* Warning */
|
||||
DWARNING = 5, /* Warning in debug build only */
|
||||
INFO_IMPORTANT = 6, /* Important info that is printed by default */
|
||||
INFO = 7, /* Info about devices, scene contents and features used. */
|
||||
WORK = 8, /* Work being performed and timing/memory stats about that work. */
|
||||
STATS = 9, /* Detailed device timing stats. */
|
||||
DEBUG = 10, /* Verbose debug messages. */
|
||||
UNKNOWN = -1,
|
||||
};
|
||||
|
||||
@@ -78,19 +79,16 @@ extern LogLevel LOG_LEVEL;
|
||||
#define LOG_STRINGIFY_APPEND(a, b) "" a #b
|
||||
#define LOG_STRINGIFY(x) LOG_STRINGIFY_APPEND("", x)
|
||||
|
||||
/* Macro to ensure lazy evaluation of both condition and logging text. */
|
||||
#ifdef NDEBUG
|
||||
# define LOG_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()
|
||||
if (UNLIKELY(level <= LOG_LEVEL && (condition))) \
|
||||
LogMessage(level, __FILE__ ":" LOG_STRINGIFY(__LINE__), __func__).stream()
|
||||
#else
|
||||
# define LOG_IF(level, condition) \
|
||||
if (LIKELY(!(level <= LOG_LEVEL && (condition)))) \
|
||||
; \
|
||||
else \
|
||||
LogMessage(level, __FILE__ ":" LOG_STRINGIFY(__LINE__), __func__).stream()
|
||||
if (UNLIKELY(level <= LOG_LEVEL && (condition))) \
|
||||
LogMessage(level, __FILE__ ":" LOG_STRINGIFY(__LINE__), __func__).stream()
|
||||
#endif
|
||||
|
||||
/* Log a message at the desired level.
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
/* Minor modifications done to remove some code and change style. */
|
||||
|
||||
#include "util/md5.h"
|
||||
#include "util/log.h"
|
||||
#include "util/path.h"
|
||||
|
||||
#include <cstdio>
|
||||
@@ -311,7 +312,7 @@ bool MD5Hash::append_file(const string &filepath)
|
||||
FILE *f = path_fopen(filepath, "rb");
|
||||
|
||||
if (!f) {
|
||||
fprintf(stderr, "MD5: failed to open file %s\n", filepath.c_str());
|
||||
LOG(ERROR) << "MD5: failed to open file " << filepath;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user