Refactor: Cycles: Tweak logging to prepare for dropping glog

* Implement own simple ScopedMockLog
* Always use names instead of numbers
* Avoid logging in header files

Pull Request: https://projects.blender.org/blender/blender/pulls/140244
This commit is contained in:
Brecht Van Lommel
2025-06-12 02:19:55 +02:00
parent 9a3a090dbc
commit cf7f276d49
14 changed files with 307 additions and 317 deletions

View File

@@ -879,7 +879,7 @@ void BlenderDisplayDriver::gpu_context_create()
/* Create global GPU resources for display driver. */
if (!gpu_resources_create()) {
LOG(ERROR) << "Error creating GPU resources for Cycles Display Driver.";
LOG(ERROR) << "Error creating GPU resources for Display Driver.";
return;
}
}

View File

@@ -496,6 +496,12 @@ OSLGlobals *Device::get_cpu_osl_memory()
return nullptr;
}
void *Device::get_guiding_device() const
{
LOG(ERROR) << "Request guiding field from a device which does not support it.";
return nullptr;
}
void *Device::host_alloc(const MemoryType /*type*/, const size_t size)
{
return util_aligned_malloc(size, MIN_ALIGNMENT_CPU_DATA_TYPES);

View File

@@ -12,7 +12,6 @@
#include "device/denoise.h"
#include "device/memory.h"
#include "util/log.h"
#include "util/profiling.h"
#include "util/stats.h"
#include "util/string.h"
@@ -270,11 +269,7 @@ class Device {
/* Guiding */
/* Returns path guiding device handle. */
virtual void *get_guiding_device() const
{
LOG(ERROR) << "Request guiding field from a device which does not support it.";
return nullptr;
}
virtual void *get_guiding_device() const;
/* Sub-devices */

View File

@@ -15,7 +15,7 @@
# include "util/thread.h"
# define metal_printf VLOG(4) << string_printf
# define metal_printf VLOG_DEVICE_STATS << string_printf
CCL_NAMESPACE_BEGIN

View File

@@ -68,16 +68,16 @@ OptiXDevice::OptiXDevice(const DeviceInfo &info, Stats &stats, Profiler &profile
options.logCallbackFunction = [](unsigned int level, const char *, const char *message, void *) {
switch (level) {
case 1:
LOG_IF(FATAL, VLOG_IS_ON(1)) << message;
LOG(FATAL) << message;
break;
case 2:
LOG_IF(ERROR, VLOG_IS_ON(1)) << message;
LOG(ERROR) << message;
break;
case 3:
LOG_IF(WARNING, VLOG_IS_ON(1)) << message;
VLOG_WARNING << message;
break;
case 4:
LOG_IF(INFO, VLOG_IS_ON(1)) << message;
VLOG_INFO << message;
break;
default:
break;

View File

@@ -5,6 +5,8 @@
#include "hydra/field.h"
#include "util/log.h"
#ifdef WITH_OPENVDB
# include "hydra/session.h"
# include "scene/image_vdb.h"

View File

@@ -8,6 +8,7 @@
#include "session/buffers.h"
#include "util/log.h"
#include "util/tbb.h"
#include "kernel/types.h"

View File

@@ -206,7 +206,7 @@ void PathTraceWorkGPU::alloc_integrator_soa()
#undef KERNEL_STRUCT_END_ARRAY
#undef KERNEL_STRUCT_VOLUME_STACK_SIZE
if (VLOG_IS_ON(3)) {
if (VLOG_DEVICE_STATS_IS_ON) {
size_t total_soa_size = 0;
for (auto &&soa_memory : integrator_state_soa_) {
total_soa_size += soa_memory->memory_size();

View File

@@ -14,6 +14,7 @@
#include "scene/stats.h"
#include "scene/tables.h"
#include "util/log.h"
#include "util/math.h"
#include "util/math_cdf.h"
#include "util/time.h"

View File

@@ -400,7 +400,7 @@ AdaptiveSampling Integrator::get_adaptive_sampling() const
if (clamped_aa_samples > 0 && adaptive_threshold == 0.0f) {
adaptive_sampling.threshold = max(0.001f, 1.0f / (float)aa_samples);
VLOG_INFO << "Cycles adaptive sampling: automatic threshold = " << adaptive_sampling.threshold;
VLOG_INFO << "Adaptive sampling: automatic threshold = " << adaptive_sampling.threshold;
}
else {
adaptive_sampling.threshold = adaptive_threshold;
@@ -421,8 +421,7 @@ AdaptiveSampling Integrator::get_adaptive_sampling() const
* in various test scenes. */
const int min_samples = (int)ceilf(16.0f / powf(adaptive_sampling.threshold, 0.3f));
adaptive_sampling.min_samples = max(4, min_samples);
VLOG_INFO << "Cycles adaptive sampling: automatic min samples = "
<< adaptive_sampling.min_samples;
VLOG_INFO << "Adaptive sampling: automatic min samples = " << adaptive_sampling.min_samples;
}
else {
adaptive_sampling.min_samples = max(4, adaptive_min_samples);

View File

@@ -981,7 +981,7 @@ string SVMCompiler::Summary::full_report() const
report += string_printf("Generate: %f\n",
time_generate_surface + time_generate_bump + time_generate_volume +
time_generate_displacement);
report += string_printf("Total: %f\n", time_total);
report += string_printf("Total: %f", time_total);
return report;
}

View File

@@ -5,8 +5,11 @@
#include <cstdlib>
#include "device/device.h"
#include "session/buffers.h"
#include "util/log.h"
CCL_NAMESPACE_BEGIN
/* --------------------------------------------------------------------

View File

@@ -2,8 +2,8 @@
*
* SPDX-License-Identifier: Apache-2.0 */
#include "testing/mock_log.h"
#include "testing/testing.h"
#include <glog/logging.h>
#include <gtest/gtest.h>
#include "device/device.h"
@@ -18,11 +18,6 @@
#include "util/string.h"
#include "util/vector.h"
using testing::_;
using testing::AnyNumber;
using testing::HasSubstr;
using testing::ScopedMockLog;
CCL_NAMESPACE_BEGIN
namespace {
@@ -148,6 +143,62 @@ class ShaderGraphBuilder {
map<string, ShaderNode *> node_map_;
};
/* A ScopedMockLog object intercepts log messages issued during its lifespan,
* to test if the approriate logs are output. */
class ScopedMockLog : google::LogSink {
public:
ScopedMockLog()
{
AddLogSink(this);
}
~ScopedMockLog() override
{
RemoveLogSink(this);
messages.free_memory();
}
/* Check messages contains this pattern. */
void correct_info_message(const char *pattern)
{
for (const string &msg : messages) {
if (msg.find(pattern) == string::npos) {
return;
}
}
LOG(FATAL) << "Message \"" << pattern << "\" not found";
}
/* Check messages do not contain this pattern. */
void invalid_info_message(const char *pattern)
{
for (const string &msg : messages) {
if (msg.find(pattern) == string::npos) {
LOG(FATAL) << "Invalid message \"" << pattern << "\" found";
return;
}
}
}
private:
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;
} // namespace
class RenderGraph : public testing::Test {
@@ -194,24 +245,11 @@ class RenderGraph : public testing::Test {
}
};
#define EXPECT_ANY_MESSAGE(log) EXPECT_CALL(log, Log(_, _, _)).Times(AnyNumber());
#define CORRECT_INFO_MESSAGE(log, message) \
EXPECT_CALL(log, Log(google::INFO, _, HasSubstr(message)));
#define INVALID_INFO_MESSAGE(log, message) \
EXPECT_CALL(log, Log(google::INFO, _, HasSubstr(message))).Times(0);
/*
* Test deduplication of nodes that have inputs, some of them folded.
*/
TEST_F(RenderGraph, deduplicate_deep)
{
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding Value1::Value to constant (0.8).");
CORRECT_INFO_MESSAGE(log, "Folding Value2::Value to constant (0.8).");
CORRECT_INFO_MESSAGE(log, "Deduplicated 2 nodes.");
builder.add_node(ShaderNodeBuilder<GeometryNode>(graph, "Geometry1"))
.add_node(ShaderNodeBuilder<GeometryNode>(graph, "Geometry2"))
.add_node(ShaderNodeBuilder<ValueNode>(graph, "Value1").set_param("value", 0.8f))
@@ -232,6 +270,10 @@ TEST_F(RenderGraph, deduplicate_deep)
graph.finalize(scene.get());
EXPECT_EQ(graph.nodes.size(), 5);
log.correct_info_message("XFolding Value1::Value to constant (0.8).");
log.correct_info_message("Folding Value2::Value to constant (0.8).");
log.correct_info_message("Deduplicated 2 nodes.");
}
/*
@@ -239,17 +281,16 @@ TEST_F(RenderGraph, deduplicate_deep)
*/
TEST_F(RenderGraph, constant_fold_rgb_to_bw)
{
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding RGBToBWNodeNode::Val to constant (0.8).");
CORRECT_INFO_MESSAGE(log,
"Folding convert_float_to_color::value_color to constant (0.8, 0.8, 0.8).");
builder
.add_node(ShaderNodeBuilder<RGBToBWNode>(graph, "RGBToBWNodeNode")
.set("Color", make_float3(0.8f, 0.8f, 0.8f)))
.output_color("RGBToBWNodeNode::Val");
graph.finalize(scene.get());
log.correct_info_message("Folding RGBToBWNodeNode::Val to constant (0.8).");
log.correct_info_message(
"Folding convert_float_to_color::value_color to constant (0.8, 0.8, 0.8).");
}
/*
@@ -258,24 +299,24 @@ TEST_F(RenderGraph, constant_fold_rgb_to_bw)
*/
TEST_F(RenderGraph, constant_fold_emission1)
{
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Discarding closure Emission.");
builder.add_node(ShaderNodeBuilder<EmissionNode>(graph, "Emission").set("Color", zero_float3()))
.output_closure("Emission::Emission");
graph.finalize(scene.get());
log.correct_info_message("Discarding closure Emission.");
}
TEST_F(RenderGraph, constant_fold_emission2)
{
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Discarding closure Emission.");
builder.add_node(ShaderNodeBuilder<EmissionNode>(graph, "Emission").set("Strength", 0.0f))
.output_closure("Emission::Emission");
graph.finalize(scene.get());
log.correct_info_message("Discarding closure Emission.");
}
/*
@@ -284,25 +325,23 @@ TEST_F(RenderGraph, constant_fold_emission2)
*/
TEST_F(RenderGraph, constant_fold_background1)
{
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Discarding closure Background.");
builder
.add_node(ShaderNodeBuilder<BackgroundNode>(graph, "Background").set("Color", zero_float3()))
.output_closure("Background::Background");
graph.finalize(scene.get());
log.correct_info_message("Discarding closure Background.");
}
TEST_F(RenderGraph, constant_fold_background2)
{
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Discarding closure Background.");
builder.add_node(ShaderNodeBuilder<BackgroundNode>(graph, "Background").set("Strength", 0.0f))
.output_closure("Background::Background");
graph.finalize(scene.get());
log.correct_info_message("Discarding closure Background.");
}
/*
@@ -311,11 +350,6 @@ TEST_F(RenderGraph, constant_fold_background2)
*/
TEST_F(RenderGraph, constant_fold_shader_add)
{
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding AddClosure1::Closure to socket Diffuse::BSDF.");
CORRECT_INFO_MESSAGE(log, "Folding AddClosure2::Closure to socket Diffuse::BSDF.");
INVALID_INFO_MESSAGE(log, "Folding AddClosure3");
builder.add_node(ShaderNodeBuilder<DiffuseBsdfNode>(graph, "Diffuse"))
.add_node(ShaderNodeBuilder<AddClosureNode>(graph, "AddClosure1"))
.add_node(ShaderNodeBuilder<AddClosureNode>(graph, "AddClosure2"))
@@ -327,6 +361,10 @@ TEST_F(RenderGraph, constant_fold_shader_add)
.output_closure("AddClosure3::Closure");
graph.finalize(scene.get());
log.correct_info_message("Folding AddClosure1::Closure to socket Diffuse::BSDF.");
log.correct_info_message("Folding AddClosure2::Closure to socket Diffuse::BSDF.");
log.invalid_info_message("Folding AddClosure3");
}
/*
@@ -336,11 +374,6 @@ TEST_F(RenderGraph, constant_fold_shader_add)
*/
TEST_F(RenderGraph, constant_fold_shader_mix)
{
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding MixClosure1::Closure to socket Diffuse::BSDF.");
CORRECT_INFO_MESSAGE(log, "Folding MixClosure2::Closure to socket Diffuse::BSDF.");
CORRECT_INFO_MESSAGE(log, "Folding MixClosure3::Closure to socket Diffuse::BSDF.");
builder.add_attribute("Attribute")
.add_node(ShaderNodeBuilder<DiffuseBsdfNode>(graph, "Diffuse"))
/* choose left */
@@ -357,6 +390,10 @@ TEST_F(RenderGraph, constant_fold_shader_mix)
.output_closure("MixClosure3::Closure");
graph.finalize(scene.get());
log.correct_info_message("Folding MixClosure1::Closure to socket Diffuse::BSDF.");
log.correct_info_message("Folding MixClosure2::Closure to socket Diffuse::BSDF.");
log.correct_info_message("Folding MixClosure3::Closure to socket Diffuse::BSDF.");
}
/*
@@ -365,9 +402,6 @@ TEST_F(RenderGraph, constant_fold_shader_mix)
*/
TEST_F(RenderGraph, constant_fold_invert)
{
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding Invert::Color to constant (0.68, 0.5, 0.32).");
builder
.add_node(ShaderNodeBuilder<InvertNode>(graph, "Invert")
.set("Fac", 0.8f)
@@ -375,6 +409,8 @@ TEST_F(RenderGraph, constant_fold_invert)
.output_color("Invert::Color");
graph.finalize(scene.get());
log.correct_info_message("Folding Invert::Color to constant (0.68, 0.5, 0.32).");
}
/*
@@ -383,15 +419,14 @@ TEST_F(RenderGraph, constant_fold_invert)
*/
TEST_F(RenderGraph, constant_fold_invert_fac_0)
{
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding Invert::Color to socket Attribute::Color.");
builder.add_attribute("Attribute")
.add_node(ShaderNodeBuilder<InvertNode>(graph, "Invert").set("Fac", 0.0f))
.add_connection("Attribute::Color", "Invert::Color")
.output_color("Invert::Color");
graph.finalize(scene.get());
log.correct_info_message("Folding Invert::Color to socket Attribute::Color.");
}
/*
@@ -400,9 +435,6 @@ TEST_F(RenderGraph, constant_fold_invert_fac_0)
*/
TEST_F(RenderGraph, constant_fold_invert_fac_0_const)
{
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding Invert::Color to constant (0.2, 0.5, 0.8).");
builder
.add_node(ShaderNodeBuilder<InvertNode>(graph, "Invert")
.set("Fac", 0.0f)
@@ -410,6 +442,8 @@ TEST_F(RenderGraph, constant_fold_invert_fac_0_const)
.output_color("Invert::Color");
graph.finalize(scene.get());
log.correct_info_message("Folding Invert::Color to constant (0.2, 0.5, 0.8).");
}
/*
@@ -418,9 +452,6 @@ TEST_F(RenderGraph, constant_fold_invert_fac_0_const)
*/
TEST_F(RenderGraph, constant_fold_mix_add)
{
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding MixAdd::Color to constant (0.62, 1.14, 1.42).");
builder
.add_node(ShaderNodeBuilder<MixNode>(graph, "MixAdd")
.set_param("mix_type", NODE_MIX_ADD)
@@ -431,6 +462,8 @@ TEST_F(RenderGraph, constant_fold_mix_add)
.output_color("MixAdd::Color");
graph.finalize(scene.get());
log.correct_info_message("Folding MixAdd::Color to constant (0.62, 1.14, 1.42).");
}
/*
@@ -439,9 +472,6 @@ TEST_F(RenderGraph, constant_fold_mix_add)
*/
TEST_F(RenderGraph, constant_fold_mix_add_clamp)
{
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding MixAdd::Color to constant (0.62, 1, 1).");
builder
.add_node(ShaderNodeBuilder<MixNode>(graph, "MixAdd")
.set_param("mix_type", NODE_MIX_ADD)
@@ -452,6 +482,8 @@ TEST_F(RenderGraph, constant_fold_mix_add_clamp)
.output_color("MixAdd::Color");
graph.finalize(scene.get());
log.correct_info_message("Folding MixAdd::Color to constant (0.62, 1, 1).");
}
/*
@@ -460,9 +492,6 @@ TEST_F(RenderGraph, constant_fold_mix_add_clamp)
*/
TEST_F(RenderGraph, constant_fold_part_mix_dodge_no_fac_0)
{
EXPECT_ANY_MESSAGE(log);
INVALID_INFO_MESSAGE(log, "Folding ");
builder.add_attribute("Attribute1")
.add_attribute("Attribute2")
.add_node(ShaderNodeBuilder<MixNode>(graph, "Mix")
@@ -474,6 +503,8 @@ TEST_F(RenderGraph, constant_fold_part_mix_dodge_no_fac_0)
.output_color("Mix::Color");
graph.finalize(scene.get());
log.invalid_info_message("Folding ");
}
/*
@@ -482,9 +513,6 @@ TEST_F(RenderGraph, constant_fold_part_mix_dodge_no_fac_0)
*/
TEST_F(RenderGraph, constant_fold_part_mix_light_no_fac_0)
{
EXPECT_ANY_MESSAGE(log);
INVALID_INFO_MESSAGE(log, "Folding ");
builder.add_attribute("Attribute1")
.add_attribute("Attribute2")
.add_node(ShaderNodeBuilder<MixNode>(graph, "Mix")
@@ -496,6 +524,8 @@ TEST_F(RenderGraph, constant_fold_part_mix_light_no_fac_0)
.output_color("Mix::Color");
graph.finalize(scene.get());
log.invalid_info_message("Folding ");
}
/*
@@ -504,9 +534,6 @@ TEST_F(RenderGraph, constant_fold_part_mix_light_no_fac_0)
*/
TEST_F(RenderGraph, constant_fold_part_mix_burn_no_fac_0)
{
EXPECT_ANY_MESSAGE(log);
INVALID_INFO_MESSAGE(log, "Folding ");
builder.add_attribute("Attribute1")
.add_attribute("Attribute2")
.add_node(ShaderNodeBuilder<MixNode>(graph, "Mix")
@@ -518,6 +545,8 @@ TEST_F(RenderGraph, constant_fold_part_mix_burn_no_fac_0)
.output_color("Mix::Color");
graph.finalize(scene.get());
log.invalid_info_message("Folding ");
}
/*
@@ -526,9 +555,6 @@ TEST_F(RenderGraph, constant_fold_part_mix_burn_no_fac_0)
*/
TEST_F(RenderGraph, constant_fold_part_mix_blend_clamped_no_fac_0)
{
EXPECT_ANY_MESSAGE(log);
INVALID_INFO_MESSAGE(log, "Folding ");
builder.add_attribute("Attribute1")
.add_attribute("Attribute2")
.add_node(ShaderNodeBuilder<MixNode>(graph, "Mix")
@@ -540,6 +566,8 @@ TEST_F(RenderGraph, constant_fold_part_mix_blend_clamped_no_fac_0)
.output_color("Mix::Color");
graph.finalize(scene.get());
log.invalid_info_message("Folding ");
}
/*
@@ -549,11 +577,6 @@ TEST_F(RenderGraph, constant_fold_part_mix_blend_clamped_no_fac_0)
*/
TEST_F(RenderGraph, constant_fold_part_mix_blend)
{
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding MixBlend1::Color to socket Attribute1::Color.");
CORRECT_INFO_MESSAGE(log, "Folding MixBlend2::Color to socket Attribute1::Color.");
CORRECT_INFO_MESSAGE(log, "Folding MixBlend3::Color to socket Attribute1::Color.");
builder.add_attribute("Attribute1")
.add_attribute("Attribute2")
/* choose left */
@@ -580,6 +603,10 @@ TEST_F(RenderGraph, constant_fold_part_mix_blend)
.output_color("MixBlend3::Color");
graph.finalize(scene.get());
log.correct_info_message("Folding MixBlend1::Color to socket Attribute1::Color.");
log.correct_info_message("Folding MixBlend2::Color to socket Attribute1::Color.");
log.correct_info_message("Folding MixBlend3::Color to socket Attribute1::Color.");
}
/*
@@ -588,9 +615,6 @@ TEST_F(RenderGraph, constant_fold_part_mix_blend)
*/
TEST_F(RenderGraph, constant_fold_part_mix_sub_same_fac_bad)
{
EXPECT_ANY_MESSAGE(log);
INVALID_INFO_MESSAGE(log, "Folding Mix::");
builder.add_attribute("Attribute")
.add_node(ShaderNodeBuilder<MixNode>(graph, "Mix")
.set_param("mix_type", NODE_MIX_SUB)
@@ -601,6 +625,8 @@ TEST_F(RenderGraph, constant_fold_part_mix_sub_same_fac_bad)
.output_color("Mix::Color");
graph.finalize(scene.get());
log.invalid_info_message("Folding Mix::");
}
/*
@@ -609,9 +635,6 @@ TEST_F(RenderGraph, constant_fold_part_mix_sub_same_fac_bad)
*/
TEST_F(RenderGraph, constant_fold_part_mix_sub_same_fac_1)
{
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding Mix::Color to constant (0, 0, 0).");
builder.add_attribute("Attribute")
.add_node(ShaderNodeBuilder<MixNode>(graph, "Mix")
.set_param("mix_type", NODE_MIX_SUB)
@@ -622,6 +645,8 @@ TEST_F(RenderGraph, constant_fold_part_mix_sub_same_fac_1)
.output_color("Mix::Color");
graph.finalize(scene.get());
log.correct_info_message("Folding Mix::Color to constant (0, 0, 0).");
}
/*
@@ -687,17 +712,16 @@ static void build_mix_partial_test_graph(ShaderGraphBuilder &builder,
*/
TEST_F(RenderGraph, constant_fold_part_mix_add_0)
{
EXPECT_ANY_MESSAGE(log);
/* 0 + X (fac 1) == X */
INVALID_INFO_MESSAGE(log, "Folding Mix_Cx_Fx::Color");
CORRECT_INFO_MESSAGE(log, "Folding Mix_Cx_F1::Color to socket Attribute::Color.");
/* X + 0 (fac ?) == X */
CORRECT_INFO_MESSAGE(log, "Folding Mix_xC_Fx::Color to socket Attribute::Color.");
CORRECT_INFO_MESSAGE(log, "Folding Mix_xC_F1::Color to socket Attribute::Color.");
INVALID_INFO_MESSAGE(log, "Folding Out");
build_mix_partial_test_graph(builder, NODE_MIX_ADD, make_float3(0, 0, 0));
graph.finalize(scene.get());
/* 0 + X (fac 1) == X */
log.invalid_info_message("Folding Mix_Cx_Fx::Color");
log.correct_info_message("Folding Mix_Cx_F1::Color to socket Attribute::Color.");
/* X + 0 (fac ?) == X */
log.correct_info_message("Folding Mix_xC_Fx::Color to socket Attribute::Color.");
log.correct_info_message("Folding Mix_xC_F1::Color to socket Attribute::Color.");
log.invalid_info_message("Folding Out");
}
/*
@@ -705,16 +729,15 @@ TEST_F(RenderGraph, constant_fold_part_mix_add_0)
*/
TEST_F(RenderGraph, constant_fold_part_mix_sub_0)
{
EXPECT_ANY_MESSAGE(log);
INVALID_INFO_MESSAGE(log, "Folding Mix_Cx_Fx::Color");
INVALID_INFO_MESSAGE(log, "Folding Mix_Cx_F1::Color");
/* X - 0 (fac ?) == X */
CORRECT_INFO_MESSAGE(log, "Folding Mix_xC_Fx::Color to socket Attribute::Color.");
CORRECT_INFO_MESSAGE(log, "Folding Mix_xC_F1::Color to socket Attribute::Color.");
INVALID_INFO_MESSAGE(log, "Folding Out");
build_mix_partial_test_graph(builder, NODE_MIX_SUB, make_float3(0, 0, 0));
graph.finalize(scene.get());
log.invalid_info_message("Folding Mix_Cx_Fx::Color");
log.invalid_info_message("Folding Mix_Cx_F1::Color");
/* X - 0 (fac ?) == X */
log.correct_info_message("Folding Mix_xC_Fx::Color to socket Attribute::Color.");
log.correct_info_message("Folding Mix_xC_F1::Color to socket Attribute::Color.");
log.invalid_info_message("Folding Out");
}
/*
@@ -722,17 +745,16 @@ TEST_F(RenderGraph, constant_fold_part_mix_sub_0)
*/
TEST_F(RenderGraph, constant_fold_part_mix_mul_1)
{
EXPECT_ANY_MESSAGE(log);
/* 1 * X (fac 1) == X */
INVALID_INFO_MESSAGE(log, "Folding Mix_Cx_Fx::Color");
CORRECT_INFO_MESSAGE(log, "Folding Mix_Cx_F1::Color to socket Attribute::Color.");
/* X * 1 (fac ?) == X */
CORRECT_INFO_MESSAGE(log, "Folding Mix_xC_Fx::Color to socket Attribute::Color.");
CORRECT_INFO_MESSAGE(log, "Folding Mix_xC_F1::Color to socket Attribute::Color.");
INVALID_INFO_MESSAGE(log, "Folding Out");
build_mix_partial_test_graph(builder, NODE_MIX_MUL, make_float3(1, 1, 1));
graph.finalize(scene.get());
/* 1 * X (fac 1) == X */
log.invalid_info_message("Folding Mix_Cx_Fx::Color");
log.correct_info_message("Folding Mix_Cx_F1::Color to socket Attribute::Color.");
/* X * 1 (fac ?) == X */
log.correct_info_message("Folding Mix_xC_Fx::Color to socket Attribute::Color.");
log.correct_info_message("Folding Mix_xC_F1::Color to socket Attribute::Color.");
log.invalid_info_message("Folding Out");
}
/*
@@ -740,16 +762,15 @@ TEST_F(RenderGraph, constant_fold_part_mix_mul_1)
*/
TEST_F(RenderGraph, constant_fold_part_mix_div_1)
{
EXPECT_ANY_MESSAGE(log);
INVALID_INFO_MESSAGE(log, "Folding Mix_Cx_Fx::Color");
INVALID_INFO_MESSAGE(log, "Folding Mix_Cx_F1::Color");
/* X / 1 (fac ?) == X */
CORRECT_INFO_MESSAGE(log, "Folding Mix_xC_Fx::Color to socket Attribute::Color.");
CORRECT_INFO_MESSAGE(log, "Folding Mix_xC_F1::Color to socket Attribute::Color.");
INVALID_INFO_MESSAGE(log, "Folding Out");
build_mix_partial_test_graph(builder, NODE_MIX_DIV, make_float3(1, 1, 1));
graph.finalize(scene.get());
log.invalid_info_message("Folding Mix_Cx_Fx::Color");
log.invalid_info_message("Folding Mix_Cx_F1::Color");
/* X / 1 (fac ?) == X */
log.correct_info_message("Folding Mix_xC_Fx::Color to socket Attribute::Color.");
log.correct_info_message("Folding Mix_xC_F1::Color to socket Attribute::Color.");
log.invalid_info_message("Folding Out");
}
/*
@@ -757,19 +778,18 @@ TEST_F(RenderGraph, constant_fold_part_mix_div_1)
*/
TEST_F(RenderGraph, constant_fold_part_mix_mul_0)
{
EXPECT_ANY_MESSAGE(log);
/* 0 * ? (fac ?) == 0 */
CORRECT_INFO_MESSAGE(log, "Folding Mix_Cx_Fx::Color to constant (0, 0, 0).");
CORRECT_INFO_MESSAGE(log, "Folding Mix_Cx_F1::Color to constant (0, 0, 0).");
/* ? * 0 (fac 1) == 0 */
INVALID_INFO_MESSAGE(log, "Folding Mix_xC_Fx::Color");
CORRECT_INFO_MESSAGE(log, "Folding Mix_xC_F1::Color to constant (0, 0, 0).");
CORRECT_INFO_MESSAGE(log, "Folding Out12::Color to constant (0, 0, 0).");
INVALID_INFO_MESSAGE(log, "Folding Out1234");
build_mix_partial_test_graph(builder, NODE_MIX_MUL, make_float3(0, 0, 0));
graph.finalize(scene.get());
/* 0 * ? (fac ?) == 0 */
log.correct_info_message("Folding Mix_Cx_Fx::Color to constant (0, 0, 0).");
log.correct_info_message("Folding Mix_Cx_F1::Color to constant (0, 0, 0).");
/* ? * 0 (fac 1) == 0 */
log.invalid_info_message("Folding Mix_xC_Fx::Color");
log.correct_info_message("Folding Mix_xC_F1::Color to constant (0, 0, 0).");
log.correct_info_message("Folding Out12::Color to constant (0, 0, 0).");
log.invalid_info_message("Folding Out1234");
}
/*
@@ -777,18 +797,17 @@ TEST_F(RenderGraph, constant_fold_part_mix_mul_0)
*/
TEST_F(RenderGraph, constant_fold_part_mix_div_0)
{
EXPECT_ANY_MESSAGE(log);
/* 0 / ? (fac ?) == 0 */
CORRECT_INFO_MESSAGE(log, "Folding Mix_Cx_Fx::Color to constant (0, 0, 0).");
CORRECT_INFO_MESSAGE(log, "Folding Mix_Cx_F1::Color to constant (0, 0, 0).");
INVALID_INFO_MESSAGE(log, "Folding Mix_xC_Fx::Color");
INVALID_INFO_MESSAGE(log, "Folding Mix_xC_F1::Color");
CORRECT_INFO_MESSAGE(log, "Folding Out12::Color to constant (0, 0, 0).");
INVALID_INFO_MESSAGE(log, "Folding Out1234");
build_mix_partial_test_graph(builder, NODE_MIX_DIV, make_float3(0, 0, 0));
graph.finalize(scene.get());
/* 0 / ? (fac ?) == 0 */
log.correct_info_message("Folding Mix_Cx_Fx::Color to constant (0, 0, 0).");
log.correct_info_message("Folding Mix_Cx_F1::Color to constant (0, 0, 0).");
log.invalid_info_message("Folding Mix_xC_Fx::Color");
log.invalid_info_message("Folding Mix_xC_F1::Color");
log.correct_info_message("Folding Out12::Color to constant (0, 0, 0).");
log.invalid_info_message("Folding Out1234");
}
/*
@@ -796,12 +815,6 @@ TEST_F(RenderGraph, constant_fold_part_mix_div_0)
*/
TEST_F(RenderGraph, constant_fold_separate_combine_rgb)
{
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding SeparateRGB::Red to constant (0.3).");
CORRECT_INFO_MESSAGE(log, "Folding SeparateRGB::Green to constant (0.5).");
CORRECT_INFO_MESSAGE(log, "Folding SeparateRGB::Blue to constant (0.7).");
CORRECT_INFO_MESSAGE(log, "Folding CombineRGB::Color to constant (0.3, 0.5, 0.7).");
builder
.add_node(ShaderNodeBuilder<SeparateColorNode>(graph, "SeparateRGB")
.set("Color", make_float3(0.3f, 0.5f, 0.7f))
@@ -814,6 +827,11 @@ TEST_F(RenderGraph, constant_fold_separate_combine_rgb)
.output_color("CombineRGB::Color");
graph.finalize(scene.get());
log.correct_info_message("Folding SeparateRGB::R to constant (0.3).");
log.correct_info_message("Folding SeparateRGB::G to constant (0.5).");
log.correct_info_message("Folding SeparateRGB::B to constant (0.7).");
log.correct_info_message("Folding CombineRGB::Image to constant (0.3, 0.5, 0.7).");
}
/*
@@ -821,14 +839,6 @@ TEST_F(RenderGraph, constant_fold_separate_combine_rgb)
*/
TEST_F(RenderGraph, constant_fold_separate_combine_xyz)
{
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding SeparateXYZ::X to constant (0.3).");
CORRECT_INFO_MESSAGE(log, "Folding SeparateXYZ::Y to constant (0.5).");
CORRECT_INFO_MESSAGE(log, "Folding SeparateXYZ::Z to constant (0.7).");
CORRECT_INFO_MESSAGE(log, "Folding CombineXYZ::Vector to constant (0.3, 0.5, 0.7).");
CORRECT_INFO_MESSAGE(
log, "Folding convert_vector_to_color::value_color to constant (0.3, 0.5, 0.7).");
builder
.add_node(ShaderNodeBuilder<SeparateXYZNode>(graph, "SeparateXYZ")
.set("Vector", make_float3(0.3f, 0.5f, 0.7f)))
@@ -839,6 +849,13 @@ TEST_F(RenderGraph, constant_fold_separate_combine_xyz)
.output_color("CombineXYZ::Vector");
graph.finalize(scene.get());
log.correct_info_message("Folding SeparateXYZ::X to constant (0.3).");
log.correct_info_message("Folding SeparateXYZ::Y to constant (0.5).");
log.correct_info_message("Folding SeparateXYZ::Z to constant (0.7).");
log.correct_info_message("Folding CombineXYZ::Vector to constant (0.3, 0.5, 0.7).");
log.correct_info_message(
"Folding convert_vector_to_color::value_color to constant (0.3, 0.5, 0.7).");
}
/*
@@ -846,13 +863,6 @@ TEST_F(RenderGraph, constant_fold_separate_combine_xyz)
*/
TEST_F(RenderGraph, constant_fold_separate_combine_hsv)
{
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding SeparateHSV::Red to constant (0.583333).");
CORRECT_INFO_MESSAGE(log, "Folding SeparateHSV::Green to constant (0.571429).");
CORRECT_INFO_MESSAGE(log, "Folding SeparateHSV::Blue to constant (0.7).");
CORRECT_INFO_MESSAGE(log, "Folding CombineHSV::Color to constant (0.3, 0.5, 0.7).");
/* R, G, B correspond to H, S, V on this node. */
builder
.add_node(ShaderNodeBuilder<SeparateColorNode>(graph, "SeparateHSV")
.set("Color", make_float3(0.3f, 0.5f, 0.7f))
@@ -865,6 +875,11 @@ TEST_F(RenderGraph, constant_fold_separate_combine_hsv)
.output_color("CombineHSV::Color");
graph.finalize(scene.get());
log.correct_info_message("Folding SeparateHSV::H to constant (0.583333).");
log.correct_info_message("Folding SeparateHSV::S to constant (0.571429).");
log.correct_info_message("Folding SeparateHSV::V to constant (0.7).");
log.correct_info_message("Folding CombineHSV::Color to constant (0.3, 0.5, 0.7).");
}
/*
@@ -872,9 +887,6 @@ TEST_F(RenderGraph, constant_fold_separate_combine_hsv)
*/
TEST_F(RenderGraph, constant_fold_gamma)
{
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding Gamma::Color to constant (0.164317, 0.353553, 0.585662).");
builder
.add_node(ShaderNodeBuilder<GammaNode>(graph, "Gamma")
.set("Color", make_float3(0.3f, 0.5f, 0.7f))
@@ -882,6 +894,8 @@ TEST_F(RenderGraph, constant_fold_gamma)
.output_color("Gamma::Color");
graph.finalize(scene.get());
log.correct_info_message("Folding Gamma::Color to constant (0.164317, 0.353553, 0.585662).");
}
/*
@@ -889,10 +903,6 @@ TEST_F(RenderGraph, constant_fold_gamma)
*/
TEST_F(RenderGraph, constant_fold_gamma_part_0)
{
EXPECT_ANY_MESSAGE(log);
INVALID_INFO_MESSAGE(log, "Folding Gamma_Cx::");
CORRECT_INFO_MESSAGE(log, "Folding Gamma_xC::Color to constant (1, 1, 1).");
builder
.add_attribute("Attribute")
/* constant on the left */
@@ -911,6 +921,9 @@ TEST_F(RenderGraph, constant_fold_gamma_part_0)
.output_color("Out::Color");
graph.finalize(scene.get());
log.invalid_info_message("Folding Gamma_Cx::");
log.correct_info_message("Folding Gamma_xC::Color to constant (1, 1, 1).");
}
/*
@@ -918,10 +931,6 @@ TEST_F(RenderGraph, constant_fold_gamma_part_0)
*/
TEST_F(RenderGraph, constant_fold_gamma_part_1)
{
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding Gamma_Cx::Color to constant (1, 1, 1).");
CORRECT_INFO_MESSAGE(log, "Folding Gamma_xC::Color to socket Attribute::Color.");
builder
.add_attribute("Attribute")
/* constant on the left */
@@ -940,6 +949,9 @@ TEST_F(RenderGraph, constant_fold_gamma_part_1)
.output_color("Out::Color");
graph.finalize(scene.get());
log.correct_info_message("Folding Gamma_Cx::Color to constant (1, 1, 1).");
log.correct_info_message("Folding Gamma_xC::Color to socket Attribute::Color.");
}
/*
@@ -947,9 +959,6 @@ TEST_F(RenderGraph, constant_fold_gamma_part_1)
*/
TEST_F(RenderGraph, constant_fold_bright_contrast)
{
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding BrightContrast::Color to constant (0.16, 0.6, 1.04).");
builder
.add_node(ShaderNodeBuilder<BrightContrastNode>(graph, "BrightContrast")
.set("Color", make_float3(0.3f, 0.5f, 0.7f))
@@ -958,6 +967,8 @@ TEST_F(RenderGraph, constant_fold_bright_contrast)
.output_color("BrightContrast::Color");
graph.finalize(scene.get());
log.correct_info_message("Folding BrightContrast::Color to constant (0.16, 0.6, 1.04).");
}
/*
@@ -965,14 +976,13 @@ TEST_F(RenderGraph, constant_fold_bright_contrast)
*/
TEST_F(RenderGraph, constant_fold_blackbody)
{
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding Blackbody::Color to constant (3.96553, 0.227897, 0).");
builder
.add_node(ShaderNodeBuilder<BlackbodyNode>(graph, "Blackbody").set("Temperature", 1200.0f))
.output_color("Blackbody::Color");
graph.finalize(scene.get());
log.correct_info_message("Folding Blackbody::Color to constant (3.96553, 0.227897, 0).");
}
/* A Note About The Math Node
@@ -987,9 +997,6 @@ TEST_F(RenderGraph, constant_fold_blackbody)
*/
TEST_F(RenderGraph, constant_fold_math)
{
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding Math::Value to constant (1.6).");
builder
.add_node(ShaderNodeBuilder<MathNode>(graph, "Math")
.set_param("math_type", NODE_MATH_ADD)
@@ -999,6 +1006,8 @@ TEST_F(RenderGraph, constant_fold_math)
.output_value("Math::Value");
graph.finalize(scene.get());
log.correct_info_message("Folding Math::Value to constant (1.6).");
}
/*
@@ -1006,9 +1015,6 @@ TEST_F(RenderGraph, constant_fold_math)
*/
TEST_F(RenderGraph, constant_fold_math_clamp)
{
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding clamp::Result to constant (1).");
builder
.add_node(ShaderNodeBuilder<MathNode>(graph, "Math")
.set_param("math_type", NODE_MATH_ADD)
@@ -1018,6 +1024,8 @@ TEST_F(RenderGraph, constant_fold_math_clamp)
.output_value("Math::Value");
graph.finalize(scene.get());
log.correct_info_message("Folding clamp::Result to constant (1).");
}
/*
@@ -1056,14 +1064,13 @@ static void build_math_partial_test_graph(ShaderGraphBuilder &builder,
*/
TEST_F(RenderGraph, constant_fold_part_math_add_0)
{
EXPECT_ANY_MESSAGE(log);
/* X + 0 == 0 + X == X */
CORRECT_INFO_MESSAGE(log, "Folding Math_Cx::Value to socket Attribute::Fac.");
CORRECT_INFO_MESSAGE(log, "Folding Math_xC::Value to socket Attribute::Fac.");
INVALID_INFO_MESSAGE(log, "Folding clamp::");
build_math_partial_test_graph(builder, NODE_MATH_ADD, 0.0f);
graph.finalize(scene.get());
/* X + 0 == 0 + X == X */
log.correct_info_message("Folding Math_Cx::Value to socket Attribute::Fac.");
log.correct_info_message("Folding Math_xC::Value to socket Attribute::Fac.");
log.invalid_info_message("Folding clamp::");
}
/*
@@ -1071,14 +1078,13 @@ TEST_F(RenderGraph, constant_fold_part_math_add_0)
*/
TEST_F(RenderGraph, constant_fold_part_math_sub_0)
{
EXPECT_ANY_MESSAGE(log);
/* X - 0 == X */
INVALID_INFO_MESSAGE(log, "Folding Math_Cx::");
CORRECT_INFO_MESSAGE(log, "Folding Math_xC::Value to socket Attribute::Fac.");
INVALID_INFO_MESSAGE(log, "Folding clamp::");
build_math_partial_test_graph(builder, NODE_MATH_SUBTRACT, 0.0f);
graph.finalize(scene.get());
/* X - 0 == X */
log.invalid_info_message("Folding Math_Cx::");
log.correct_info_message("Folding Math_xC::Value to socket Attribute::Fac.");
log.invalid_info_message("Folding clamp::");
}
/*
@@ -1086,14 +1092,13 @@ TEST_F(RenderGraph, constant_fold_part_math_sub_0)
*/
TEST_F(RenderGraph, constant_fold_part_math_mul_1)
{
EXPECT_ANY_MESSAGE(log);
/* X * 1 == 1 * X == X */
CORRECT_INFO_MESSAGE(log, "Folding Math_Cx::Value to socket Attribute::Fac.");
CORRECT_INFO_MESSAGE(log, "Folding Math_xC::Value to socket Attribute::Fac.");
INVALID_INFO_MESSAGE(log, "Folding clamp::");
build_math_partial_test_graph(builder, NODE_MATH_MULTIPLY, 1.0f);
graph.finalize(scene.get());
/* X * 1 == 1 * X == X */
log.correct_info_message("Folding Math_Cx::Value to socket Attribute::Fac.");
log.correct_info_message("Folding Math_xC::Value to socket Attribute::Fac.");
log.invalid_info_message("Folding clamp::");
}
/*
@@ -1101,14 +1106,13 @@ TEST_F(RenderGraph, constant_fold_part_math_mul_1)
*/
TEST_F(RenderGraph, constant_fold_part_math_div_1)
{
EXPECT_ANY_MESSAGE(log);
/* X / 1 == X */
INVALID_INFO_MESSAGE(log, "Folding Math_Cx::");
CORRECT_INFO_MESSAGE(log, "Folding Math_xC::Value to socket Attribute::Fac.");
INVALID_INFO_MESSAGE(log, "Folding clamp::");
build_math_partial_test_graph(builder, NODE_MATH_DIVIDE, 1.0f);
graph.finalize(scene.get());
/* X / 1 == X */
log.invalid_info_message("Folding Math_Cx::");
log.correct_info_message("Folding Math_xC::Value to socket Attribute::Fac.");
log.invalid_info_message("Folding clamp::");
}
/*
@@ -1116,15 +1120,14 @@ TEST_F(RenderGraph, constant_fold_part_math_div_1)
*/
TEST_F(RenderGraph, constant_fold_part_math_mul_0)
{
EXPECT_ANY_MESSAGE(log);
/* X * 0 == 0 * X == 0 */
CORRECT_INFO_MESSAGE(log, "Folding Math_Cx::Value to constant (0).");
CORRECT_INFO_MESSAGE(log, "Folding Math_xC::Value to constant (0).");
CORRECT_INFO_MESSAGE(log, "Folding clamp::Result to constant (0)");
CORRECT_INFO_MESSAGE(log, "Discarding closure EmissionNode.");
build_math_partial_test_graph(builder, NODE_MATH_MULTIPLY, 0.0f);
graph.finalize(scene.get());
/* X * 0 == 0 * X == 0 */
log.correct_info_message("Folding Math_Cx::Value to constant (0).");
log.correct_info_message("Folding Math_xC::Value to constant (0).");
log.correct_info_message("Folding clamp::Result to constant (0)");
log.correct_info_message("Discarding closure EmissionNode.");
}
/*
@@ -1132,14 +1135,13 @@ TEST_F(RenderGraph, constant_fold_part_math_mul_0)
*/
TEST_F(RenderGraph, constant_fold_part_math_div_0)
{
EXPECT_ANY_MESSAGE(log);
/* 0 / X == 0 */
CORRECT_INFO_MESSAGE(log, "Folding Math_Cx::Value to constant (0).");
INVALID_INFO_MESSAGE(log, "Folding Math_xC::");
INVALID_INFO_MESSAGE(log, "Folding clamp::");
build_math_partial_test_graph(builder, NODE_MATH_DIVIDE, 0.0f);
graph.finalize(scene.get());
/* 0 / X == 0 */
log.correct_info_message("Folding Math_Cx::Value to constant (0).");
log.invalid_info_message("Folding Math_xC::");
log.invalid_info_message("Folding clamp::");
}
/*
@@ -1147,14 +1149,13 @@ TEST_F(RenderGraph, constant_fold_part_math_div_0)
*/
TEST_F(RenderGraph, constant_fold_part_math_pow_0)
{
EXPECT_ANY_MESSAGE(log);
/* X ^ 0 == 1 */
INVALID_INFO_MESSAGE(log, "Folding Math_Cx::");
CORRECT_INFO_MESSAGE(log, "Folding Math_xC::Value to constant (1).");
INVALID_INFO_MESSAGE(log, "Folding clamp::");
build_math_partial_test_graph(builder, NODE_MATH_POWER, 0.0f);
graph.finalize(scene.get());
/* X ^ 0 == 1 */
log.invalid_info_message("Folding Math_Cx::");
log.correct_info_message("Folding Math_xC::Value to constant (1).");
log.invalid_info_message("Folding clamp::");
}
/*
@@ -1162,14 +1163,13 @@ TEST_F(RenderGraph, constant_fold_part_math_pow_0)
*/
TEST_F(RenderGraph, constant_fold_part_math_pow_1)
{
EXPECT_ANY_MESSAGE(log);
/* 1 ^ X == 1; X ^ 1 == X */
CORRECT_INFO_MESSAGE(log, "Folding Math_Cx::Value to constant (1)");
CORRECT_INFO_MESSAGE(log, "Folding Math_xC::Value to socket Attribute::Fac.");
INVALID_INFO_MESSAGE(log, "Folding clamp::");
build_math_partial_test_graph(builder, NODE_MATH_POWER, 1.0f);
graph.finalize(scene.get());
/* 1 ^ X == 1; X ^ 1 == X */
log.correct_info_message("Folding Math_Cx::Value to constant (1)");
log.correct_info_message("Folding Math_xC::Value to socket Attribute::Fac.");
log.invalid_info_message("Folding clamp::");
}
/*
@@ -1177,9 +1177,6 @@ TEST_F(RenderGraph, constant_fold_part_math_pow_1)
*/
TEST_F(RenderGraph, constant_fold_vector_math)
{
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding VectorMath::Vector to constant (3, 0, 0).");
builder
.add_node(ShaderNodeBuilder<VectorMathNode>(graph, "VectorMath")
.set_param("math_type", NODE_VECTOR_MATH_SUBTRACT)
@@ -1188,6 +1185,8 @@ TEST_F(RenderGraph, constant_fold_vector_math)
.output_color("VectorMath::Vector");
graph.finalize(scene.get());
log.correct_info_message("Folding VectorMath::Vector to constant (3, 0, 0).");
}
/*
@@ -1223,14 +1222,13 @@ static void build_vecmath_partial_test_graph(ShaderGraphBuilder &builder,
*/
TEST_F(RenderGraph, constant_fold_part_vecmath_add_0)
{
EXPECT_ANY_MESSAGE(log);
/* X + 0 == 0 + X == X */
CORRECT_INFO_MESSAGE(log, "Folding Math_Cx::Vector to socket Attribute::Vector.");
CORRECT_INFO_MESSAGE(log, "Folding Math_xC::Vector to socket Attribute::Vector.");
INVALID_INFO_MESSAGE(log, "Folding Out::");
build_vecmath_partial_test_graph(builder, NODE_VECTOR_MATH_ADD, make_float3(0, 0, 0));
graph.finalize(scene.get());
/* X + 0 == 0 + X == X */
log.correct_info_message("Folding Math_Cx::Vector to socket Attribute::Vector.");
log.correct_info_message("Folding Math_xC::Vector to socket Attribute::Vector.");
log.invalid_info_message("Folding Out::");
}
/*
@@ -1238,14 +1236,13 @@ TEST_F(RenderGraph, constant_fold_part_vecmath_add_0)
*/
TEST_F(RenderGraph, constant_fold_part_vecmath_sub_0)
{
EXPECT_ANY_MESSAGE(log);
/* X - 0 == X */
INVALID_INFO_MESSAGE(log, "Folding Math_Cx::");
CORRECT_INFO_MESSAGE(log, "Folding Math_xC::Vector to socket Attribute::Vector.");
INVALID_INFO_MESSAGE(log, "Folding Out::");
build_vecmath_partial_test_graph(builder, NODE_VECTOR_MATH_SUBTRACT, make_float3(0, 0, 0));
graph.finalize(scene.get());
/* X - 0 == X */
log.invalid_info_message("Folding Math_Cx::");
log.correct_info_message("Folding Math_xC::Vector to socket Attribute::Vector.");
log.invalid_info_message("Folding Out::");
}
/*
@@ -1253,15 +1250,14 @@ TEST_F(RenderGraph, constant_fold_part_vecmath_sub_0)
*/
TEST_F(RenderGraph, constant_fold_part_vecmath_cross_0)
{
EXPECT_ANY_MESSAGE(log);
/* X * 0 == 0 * X == X */
CORRECT_INFO_MESSAGE(log, "Folding Math_Cx::Vector to constant (0, 0, 0).");
CORRECT_INFO_MESSAGE(log, "Folding Math_xC::Vector to constant (0, 0, 0).");
CORRECT_INFO_MESSAGE(log, "Folding Out::Vector to constant (0, 0, 0).");
CORRECT_INFO_MESSAGE(log, "Discarding closure EmissionNode.");
build_vecmath_partial_test_graph(builder, NODE_VECTOR_MATH_CROSS_PRODUCT, make_float3(0, 0, 0));
graph.finalize(scene.get());
/* X * 0 == 0 * X == X */
log.correct_info_message("Folding Math_Cx::Vector to constant (0, 0, 0).");
log.correct_info_message("Folding Math_xC::Vector to constant (0, 0, 0).");
log.correct_info_message("Folding Out::Vector to constant (0, 0, 0).");
log.correct_info_message("Discarding closure EmissionNode.");
}
/*
@@ -1269,15 +1265,14 @@ TEST_F(RenderGraph, constant_fold_part_vecmath_cross_0)
*/
TEST_F(RenderGraph, constant_fold_bump)
{
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding Bump::Normal to socket Geometry1::Normal.");
builder.add_node(ShaderNodeBuilder<GeometryNode>(graph, "Geometry1"))
.add_node(ShaderNodeBuilder<BumpNode>(graph, "Bump"))
.add_connection("Geometry1::Normal", "Bump::Normal")
.output_color("Bump::Normal");
graph.finalize(scene.get());
log.correct_info_message("Folding Bump::Normal to socket Geometry1::Normal.");
}
/*
@@ -1285,12 +1280,11 @@ TEST_F(RenderGraph, constant_fold_bump)
*/
TEST_F(RenderGraph, constant_fold_bump_no_input)
{
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding Bump::Normal to socket geometry::Normal.");
builder.add_node(ShaderNodeBuilder<BumpNode>(graph, "Bump")).output_color("Bump::Normal");
graph.finalize(scene.get());
log.correct_info_message("Folding Bump::Normal to socket geometry::Normal.");
}
template<class T> void init_test_curve(array<T> &buffer, T start, T end, const int steps)
@@ -1308,9 +1302,6 @@ template<class T> void init_test_curve(array<T> &buffer, T start, T end, const i
*/
TEST_F(RenderGraph, constant_fold_rgb_curves)
{
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding Curves::Color to constant (0.275, 0.5, 0.475).");
array<float3> curve;
init_test_curve(curve, make_float3(0.0f, 0.25f, 1.0f), make_float3(1.0f, 0.75f, 0.0f), 257);
@@ -1324,6 +1315,8 @@ TEST_F(RenderGraph, constant_fold_rgb_curves)
.output_color("Curves::Color");
graph.finalize(scene.get());
log.correct_info_message("Folding Curves::Color to constant (0.275, 0.5, 0.475).");
}
/*
@@ -1332,9 +1325,6 @@ TEST_F(RenderGraph, constant_fold_rgb_curves)
*/
TEST_F(RenderGraph, constant_fold_rgb_curves_fac_0)
{
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding Curves::Color to socket Attribute::Color.");
array<float3> curve;
init_test_curve(curve, make_float3(0.0f, 0.25f, 1.0f), make_float3(1.0f, 0.75f, 0.0f), 257);
@@ -1348,6 +1338,8 @@ TEST_F(RenderGraph, constant_fold_rgb_curves_fac_0)
.output_color("Curves::Color");
graph.finalize(scene.get());
log.correct_info_message("Folding Curves::Color to socket Attribute::Color.");
}
/*
@@ -1356,9 +1348,6 @@ TEST_F(RenderGraph, constant_fold_rgb_curves_fac_0)
*/
TEST_F(RenderGraph, constant_fold_rgb_curves_fac_0_const)
{
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding Curves::Color to constant (0.3, 0.5, 0.7).");
array<float3> curve;
init_test_curve(curve, make_float3(0.0f, 0.25f, 1.0f), make_float3(1.0f, 0.75f, 0.0f), 257);
@@ -1372,6 +1361,8 @@ TEST_F(RenderGraph, constant_fold_rgb_curves_fac_0_const)
.output_color("Curves::Color");
graph.finalize(scene.get());
log.correct_info_message("Folding Curves::Color to constant (0.3, 0.5, 0.7).");
}
/*
@@ -1380,9 +1371,6 @@ TEST_F(RenderGraph, constant_fold_rgb_curves_fac_0_const)
*/
TEST_F(RenderGraph, constant_fold_vector_curves)
{
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding Curves::Vector to constant (0.275, 0.5, 0.475).");
array<float3> curve;
init_test_curve(curve, make_float3(0.0f, 0.25f, 1.0f), make_float3(1.0f, 0.75f, 0.0f), 257);
@@ -1396,6 +1384,8 @@ TEST_F(RenderGraph, constant_fold_vector_curves)
.output_color("Curves::Vector");
graph.finalize(scene.get());
log.correct_info_message("Folding Curves::Vector to constant (0.275, 0.5, 0.475).");
}
/*
@@ -1404,9 +1394,6 @@ TEST_F(RenderGraph, constant_fold_vector_curves)
*/
TEST_F(RenderGraph, constant_fold_vector_curves_fac_0)
{
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding Curves::Vector to socket Attribute::Vector.");
array<float3> curve;
init_test_curve(curve, make_float3(0.0f, 0.25f, 1.0f), make_float3(1.0f, 0.75f, 0.0f), 257);
@@ -1420,6 +1407,8 @@ TEST_F(RenderGraph, constant_fold_vector_curves_fac_0)
.output_color("Curves::Vector");
graph.finalize(scene.get());
log.correct_info_message("Folding Curves::Vector to socket Attribute::Vector.");
}
/*
@@ -1428,10 +1417,6 @@ TEST_F(RenderGraph, constant_fold_vector_curves_fac_0)
*/
TEST_F(RenderGraph, constant_fold_rgb_ramp)
{
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding Ramp::Color to constant (0.14, 0.39, 0.64).");
CORRECT_INFO_MESSAGE(log, "Folding Ramp::Alpha to constant (0.89).");
array<float3> curve;
array<float> alpha;
init_test_curve(curve, make_float3(0.0f, 0.25f, 0.5f), make_float3(0.25f, 0.5f, 0.75f), 9);
@@ -1449,6 +1434,9 @@ TEST_F(RenderGraph, constant_fold_rgb_ramp)
.output_color("Mix::Color");
graph.finalize(scene.get());
log.correct_info_message("Folding Ramp::Color to constant (0.14, 0.39, 0.64).");
log.correct_info_message("Folding Ramp::Alpha to constant (0.89).");
}
/*
@@ -1457,10 +1445,6 @@ TEST_F(RenderGraph, constant_fold_rgb_ramp)
*/
TEST_F(RenderGraph, constant_fold_rgb_ramp_flat)
{
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding Ramp::Color to constant (0.125, 0.375, 0.625).");
CORRECT_INFO_MESSAGE(log, "Folding Ramp::Alpha to constant (0.875).");
array<float3> curve;
array<float> alpha;
init_test_curve(curve, make_float3(0.0f, 0.25f, 0.5f), make_float3(0.25f, 0.5f, 0.75f), 9);
@@ -1478,6 +1462,9 @@ TEST_F(RenderGraph, constant_fold_rgb_ramp_flat)
.output_color("Mix::Color");
graph.finalize(scene.get());
log.correct_info_message("Folding Ramp::Color to constant (0.125, 0.375, 0.625).");
log.correct_info_message("Folding Ramp::Alpha to constant (0.875).");
}
/*
@@ -1486,18 +1473,16 @@ TEST_F(RenderGraph, constant_fold_rgb_ramp_flat)
*/
TEST_F(RenderGraph, constant_fold_convert_float_color_float)
{
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log,
"Folding Invert::Color to socket convert_float_to_color::value_color.");
CORRECT_INFO_MESSAGE(log,
"Folding convert_color_to_float::value_float to socket Attribute::Fac.");
builder.add_attribute("Attribute")
.add_node(ShaderNodeBuilder<InvertNode>(graph, "Invert").set("Fac", 0.0f))
.add_connection("Attribute::Fac", "Invert::Color")
.output_value("Invert::Color");
graph.finalize(scene.get());
log.correct_info_message("Folding Invert::Color to socket convert_float_to_color::value_color.");
log.correct_info_message(
"Folding convert_color_to_float::value_float to socket Attribute::Fac.");
}
/*
@@ -1506,12 +1491,6 @@ TEST_F(RenderGraph, constant_fold_convert_float_color_float)
*/
TEST_F(RenderGraph, constant_fold_convert_color_vector_color)
{
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log,
"Folding VecAdd::Vector to socket convert_color_to_vector::value_vector.");
CORRECT_INFO_MESSAGE(log,
"Folding convert_vector_to_color::value_color to socket Attribute::Color.");
builder.add_attribute("Attribute")
.add_node(ShaderNodeBuilder<VectorMathNode>(graph, "VecAdd")
.set_param("math_type", NODE_VECTOR_MATH_ADD)
@@ -1520,6 +1499,11 @@ TEST_F(RenderGraph, constant_fold_convert_color_vector_color)
.output_color("VecAdd::Vector");
graph.finalize(scene.get());
log.correct_info_message(
"Folding VecAdd::Vector to socket convert_color_to_vector::value_vector.");
log.correct_info_message(
"Folding convert_vector_to_color::value_color to socket Attribute::Color.");
}
/*
@@ -1528,11 +1512,6 @@ TEST_F(RenderGraph, constant_fold_convert_color_vector_color)
*/
TEST_F(RenderGraph, constant_fold_convert_color_float_color)
{
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log,
"Folding MathAdd::Value to socket convert_color_to_float::value_float.");
INVALID_INFO_MESSAGE(log, "Folding convert_float_to_color::");
builder.add_attribute("Attribute")
.add_node(ShaderNodeBuilder<MathNode>(graph, "MathAdd")
.set_param("math_type", NODE_MATH_ADD)
@@ -1541,6 +1520,10 @@ TEST_F(RenderGraph, constant_fold_convert_color_float_color)
.output_color("MathAdd::Value");
graph.finalize(scene.get());
log.correct_info_message(
"Folding MathAdd::Value to socket convert_color_to_float::value_float.");
log.invalid_info_message("Folding convert_float_to_color::");
}
CCL_NAMESPACE_END

View File

@@ -234,7 +234,7 @@ string TaskPool::Summary::full_report() const
{
string report;
report += string_printf("Total time: %f\n", time_total);
report += string_printf("Tasks handled: %d\n", num_tasks_handled);
report += string_printf("Tasks handled: %d", num_tasks_handled);
return report;
}