Merge branch 'master' into blender2.8

This commit is contained in:
Sergey Sharybin
2017-10-24 12:19:48 +02:00
17 changed files with 335 additions and 325 deletions

View File

@@ -240,7 +240,7 @@ void Device::draw_pixels(
{
const bool use_fallback_shader = (draw_params.bind_display_space_shader_cb == NULL);
assert(mem.type == MEM_PIXELS);
assert(rgba.type == MEM_PIXELS);
mem_copy_from(rgba, y, w, h, rgba.memory_elements_size(1));
GLuint texid;

View File

@@ -303,7 +303,7 @@ public:
data_width = width;
data_height = height;
data_depth = depth;
assert(device_ptr == 0);
assert(device_pointer == 0);
return get_data();
}
@@ -331,7 +331,7 @@ public:
data_width = width;
data_height = height;
data_depth = depth;
assert(device_ptr == 0);
assert(device_pointer == 0);
return get_data();
}

View File

@@ -251,26 +251,36 @@ public:
if(!tiles[i].buffers) {
continue;
}
/* If the tile was rendered on another device, copy its memory to
* to the current device now, for the duration of the denoising task.
* Note that this temporarily modifies the RenderBuffers and calls
* the device, so this function is not thread safe. */
device_vector<float> &mem = tiles[i].buffers->buffer;
if(mem.device != sub_device) {
tiles[i].buffers->copy_from_device();
/* Only copy from device to host once. This is faster, but
* also required for the case where a CPU thread is denoising
* a tile rendered on the GPU. In that case we have to avoid
* overwriting the buffer being denoised by the CPU thread. */
if(!tiles[i].buffers->map_neighbor_copied) {
tiles[i].buffers->map_neighbor_copied = true;
mem.copy_from_device(0, mem.data_size, 1);
}
Device *original_device = mem.device;
device_ptr original_ptr = mem.device_pointer;
size_t original_size = mem.device_size;
mem.device = sub_device;
mem.device_pointer = 0;
mem.device_size = 0;
sub_device->mem_alloc(mem);
sub_device->mem_copy_to(mem);
mem.copy_to_device();
tiles[i].buffer = mem.device_pointer;
mem.device = original_device;
mem.device_pointer = original_ptr;
mem.device_size = original_size;
}
}
}
@@ -293,7 +303,7 @@ public:
/* Copy denoised tile to the host. */
if(i == 4) {
tiles[i].buffers->copy_from_device();
mem.copy_from_device(0, mem.data_size, 1);
}
sub_device->mem_free(mem);

View File

@@ -35,6 +35,25 @@ CCL_NAMESPACE_BEGIN
class OpenCLSplitKernel;
namespace {
/* Copy dummy KernelGlobals related to OpenCL from kernel_globals.h to
* fetch its size.
*/
typedef struct KernelGlobalsDummy {
ccl_constant KernelData *data;
ccl_global char *buffers[8];
#define KERNEL_TEX(type, name) \
TextureInfo name;
# include "kernel/kernel_textures.h"
#undef KERNEL_TEX
SplitData split_data;
SplitParams split_param_data;
} KernelGlobalsDummy;
} // namespace
static string get_build_options(OpenCLDeviceBase *device, const DeviceRequestedFeatures& requested_features)
{
string build_options = "-D__SPLIT_KERNEL__ ";
@@ -110,24 +129,8 @@ public:
else if(task->type == DeviceTask::RENDER) {
RenderTile tile;
/* Copy dummy KernelGlobals related to OpenCL from kernel_globals.h to
* fetch its size.
*/
typedef struct KernelGlobals {
ccl_constant KernelData *data;
ccl_global char *buffers[8];
#define KERNEL_TEX(type, name) \
TextureInfo name;
#include "kernel/kernel_textures.h"
#undef KERNEL_TEX
SplitData split_data;
SplitParams split_param_data;
} KernelGlobals;
/* Allocate buffer for kernel globals */
device_only_memory<KernelGlobals> kgbuffer(this, "kernel_globals");
device_only_memory<KernelGlobalsDummy> kgbuffer(this, "kernel_globals");
kgbuffer.alloc_to_device(1);
/* Keep rendering tiles until done. */

View File

@@ -115,7 +115,8 @@ RenderTile::RenderTile()
/* Render Buffers */
RenderBuffers::RenderBuffers(Device *device)
: buffer(device, "RenderBuffers", MEM_READ_WRITE)
: buffer(device, "RenderBuffers", MEM_READ_WRITE),
map_neighbor_copied(false)
{
}

View File

@@ -74,6 +74,7 @@ public:
/* float buffer */
device_vector<float> buffer;
bool map_neighbor_copied;
explicit RenderBuffers(Device *device);
~RenderBuffers();

View File

@@ -22,12 +22,17 @@ set(INC
)
set(ALL_CYCLES_LIBRARIES
cycles_render
cycles_device
cycles_kernel
cycles_render
cycles_bvh
cycles_graph
cycles_subd
cycles_util
extern_clew
${BLENDER_GL_LIBRARIES}
${BLENDER_GLEW_LIBRARIES}
${CYCLES_APP_GLEW_LIBRARY}
${OPENIMAGEIO_LIBRARIES}
)
if(WITH_CYCLES_OSL)
@@ -52,6 +57,15 @@ if(WITH_CYCLES_OPENSUBDIV)
${OPENSUBDIV_LIBRARIES}
)
endif()
if(WITH_CUDA_DYNLOAD)
list(APPEND ALL_CYCLES_LIBRARIES extern_cuew)
else()
list(APPEND ALL_CYCLES_LIBRARIES ${CUDA_CUDA_LIBRARY})
endif()
if(NOT CYCLES_STANDALONE_REPOSITORY)
list(APPEND ALL_CYCLES_LIBRARIES bf_intern_glew_mx bf_intern_guardedalloc ${GLEW_LIBRARY})
endif()
list(APPEND ALL_CYCLES_LIBRARIES
${BOOST_LIBRARIES}
${PNG_LIBRARIES}

View File

@@ -74,7 +74,7 @@ protected:
class ShaderGraphBuilder {
public:
explicit ShaderGraphBuilder(ShaderGraph *graph)
ShaderGraphBuilder(ShaderGraph *graph)
: graph_(graph)
{
node_map_["Output"] = graph->output();
@@ -155,15 +155,39 @@ protected:
} // namespace
#define DEFINE_COMMON_VARIABLES(builder_name, mock_log_name) \
util_logging_start(); \
util_logging_verbosity_set(1); \
ScopedMockLog mock_log_name; \
DeviceInfo device_info; \
SceneParams scene_params; \
Scene scene(scene_params, device_info); \
ShaderGraph graph; \
ShaderGraphBuilder builder(&graph); \
class RenderGraph : public testing::Test
{
protected:
ScopedMockLog log;
Stats stats;
DeviceInfo device_info;
Device *device_cpu;
SceneParams scene_params;
Scene *scene;
ShaderGraph graph;
ShaderGraphBuilder builder;
RenderGraph()
: testing::Test(),
builder(&graph)
{
}
virtual void SetUp()
{
util_logging_start();
util_logging_verbosity_set(1);
device_cpu = Device::create(device_info, stats, true);
scene = new Scene(scene_params, device_cpu);
}
virtual void TearDown()
{
delete scene;
delete device_cpu;
}
};
#define EXPECT_ANY_MESSAGE(log) \
EXPECT_CALL(log, Log(_, _, _)).Times(AnyNumber()); \
@@ -177,10 +201,8 @@ protected:
/*
* Test deduplication of nodes that have inputs, some of them folded.
*/
TEST(render_graph, deduplicate_deep)
TEST_F(RenderGraph, deduplicate_deep)
{
DEFINE_COMMON_VARIABLES(builder, log);
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).");
@@ -206,7 +228,7 @@ TEST(render_graph, deduplicate_deep)
.add_connection("Noise2::Color", "Mix::Color2")
.output_color("Mix::Color");
graph.finalize(&scene);
graph.finalize(scene);
EXPECT_EQ(graph.nodes.size(), 5);
}
@@ -214,10 +236,8 @@ TEST(render_graph, deduplicate_deep)
/*
* Test RGB to BW node.
*/
TEST(render_graph, constant_fold_rgb_to_bw)
TEST_F(RenderGraph, constant_fold_rgb_to_bw)
{
DEFINE_COMMON_VARIABLES(builder, log);
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).");
@@ -227,17 +247,15 @@ TEST(render_graph, constant_fold_rgb_to_bw)
.set("Color", make_float3(0.8f, 0.8f, 0.8f)))
.output_color("RGBToBWNodeNode::Val");
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests:
* - folding of Emission nodes that don't emit to nothing.
*/
TEST(render_graph, constant_fold_emission1)
TEST_F(RenderGraph, constant_fold_emission1)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Discarding closure Emission.");
@@ -246,13 +264,11 @@ TEST(render_graph, constant_fold_emission1)
.set("Color", make_float3(0.0f, 0.0f, 0.0f)))
.output_closure("Emission::Emission");
graph.finalize(&scene);
graph.finalize(scene);
}
TEST(render_graph, constant_fold_emission2)
TEST_F(RenderGraph, constant_fold_emission2)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Discarding closure Emission.");
@@ -261,17 +277,15 @@ TEST(render_graph, constant_fold_emission2)
.set("Strength", 0.0f))
.output_closure("Emission::Emission");
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests:
* - folding of Background nodes that don't emit to nothing.
*/
TEST(render_graph, constant_fold_background1)
TEST_F(RenderGraph, constant_fold_background1)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Discarding closure Background.");
@@ -280,13 +294,11 @@ TEST(render_graph, constant_fold_background1)
.set("Color", make_float3(0.0f, 0.0f, 0.0f)))
.output_closure("Background::Background");
graph.finalize(&scene);
graph.finalize(scene);
}
TEST(render_graph, constant_fold_background2)
TEST_F(RenderGraph, constant_fold_background2)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Discarding closure Background.");
@@ -295,17 +307,15 @@ TEST(render_graph, constant_fold_background2)
.set("Strength", 0.0f))
.output_closure("Background::Background");
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests:
* - Folding of Add Closure with only one input.
*/
TEST(render_graph, constant_fold_shader_add)
TEST_F(RenderGraph, constant_fold_shader_add)
{
DEFINE_COMMON_VARIABLES(builder, log);
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.");
@@ -322,7 +332,7 @@ TEST(render_graph, constant_fold_shader_add)
.add_connection("AddClosure2::Closure", "AddClosure3::Closure2")
.output_closure("AddClosure3::Closure");
graph.finalize(&scene);
graph.finalize(scene);
}
/*
@@ -330,10 +340,8 @@ TEST(render_graph, constant_fold_shader_add)
* - Folding of Mix Closure with 0 or 1 fac.
* - Folding of Mix Closure with both inputs folded to the same node.
*/
TEST(render_graph, constant_fold_shader_mix)
TEST_F(RenderGraph, constant_fold_shader_mix)
{
DEFINE_COMMON_VARIABLES(builder, log);
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.");
@@ -357,17 +365,15 @@ TEST(render_graph, constant_fold_shader_mix)
.add_connection("MixClosure2::Closure", "MixClosure3::Closure2")
.output_closure("MixClosure3::Closure");
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests:
* - Folding of Invert with all constant inputs.
*/
TEST(render_graph, constant_fold_invert)
TEST_F(RenderGraph, constant_fold_invert)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding Invert::Color to constant (0.68, 0.5, 0.32).");
@@ -377,17 +383,15 @@ TEST(render_graph, constant_fold_invert)
.set("Color", make_float3(0.2f, 0.5f, 0.8f)))
.output_color("Invert::Color");
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests:
* - Folding of Invert with zero Fac.
*/
TEST(render_graph, constant_fold_invert_fac_0)
TEST_F(RenderGraph, constant_fold_invert_fac_0)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding Invert::Color to socket Attribute::Color.");
@@ -398,17 +402,15 @@ TEST(render_graph, constant_fold_invert_fac_0)
.add_connection("Attribute::Color", "Invert::Color")
.output_color("Invert::Color");
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests:
* - Folding of Invert with zero Fac and constant input.
*/
TEST(render_graph, constant_fold_invert_fac_0_const)
TEST_F(RenderGraph, constant_fold_invert_fac_0_const)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding Invert::Color to constant (0.2, 0.5, 0.8).");
@@ -418,17 +420,15 @@ TEST(render_graph, constant_fold_invert_fac_0_const)
.set("Color", make_float3(0.2f, 0.5f, 0.8f)))
.output_color("Invert::Color");
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests:
* - Folding of MixRGB Add with all constant inputs (clamp false).
*/
TEST(render_graph, constant_fold_mix_add)
TEST_F(RenderGraph, constant_fold_mix_add)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding MixAdd::Color to constant (0.62, 1.14, 1.42).");
@@ -441,17 +441,15 @@ TEST(render_graph, constant_fold_mix_add)
.set("Color2", make_float3(0.4, 0.8, 0.9)))
.output_color("MixAdd::Color");
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests:
* - Folding of MixRGB Add with all constant inputs (clamp true).
*/
TEST(render_graph, constant_fold_mix_add_clamp)
TEST_F(RenderGraph, constant_fold_mix_add_clamp)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding MixAdd::Color to constant (0.62, 1, 1).");
@@ -464,17 +462,15 @@ TEST(render_graph, constant_fold_mix_add_clamp)
.set("Color2", make_float3(0.4, 0.8, 0.9)))
.output_color("MixAdd::Color");
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests:
* - No folding on fac 0 for dodge.
*/
TEST(render_graph, constant_fold_part_mix_dodge_no_fac_0)
TEST_F(RenderGraph, constant_fold_part_mix_dodge_no_fac_0)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
INVALID_INFO_MESSAGE(log, "Folding ");
@@ -489,17 +485,15 @@ TEST(render_graph, constant_fold_part_mix_dodge_no_fac_0)
.add_connection("Attribute2::Color", "Mix::Color2")
.output_color("Mix::Color");
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests:
* - No folding on fac 0 for light.
*/
TEST(render_graph, constant_fold_part_mix_light_no_fac_0)
TEST_F(RenderGraph, constant_fold_part_mix_light_no_fac_0)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
INVALID_INFO_MESSAGE(log, "Folding ");
@@ -514,17 +508,15 @@ TEST(render_graph, constant_fold_part_mix_light_no_fac_0)
.add_connection("Attribute2::Color", "Mix::Color2")
.output_color("Mix::Color");
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests:
* - No folding on fac 0 for burn.
*/
TEST(render_graph, constant_fold_part_mix_burn_no_fac_0)
TEST_F(RenderGraph, constant_fold_part_mix_burn_no_fac_0)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
INVALID_INFO_MESSAGE(log, "Folding ");
@@ -539,17 +531,15 @@ TEST(render_graph, constant_fold_part_mix_burn_no_fac_0)
.add_connection("Attribute2::Color", "Mix::Color2")
.output_color("Mix::Color");
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests:
* - No folding on fac 0 for clamped blend.
*/
TEST(render_graph, constant_fold_part_mix_blend_clamped_no_fac_0)
TEST_F(RenderGraph, constant_fold_part_mix_blend_clamped_no_fac_0)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
INVALID_INFO_MESSAGE(log, "Folding ");
@@ -564,7 +554,7 @@ TEST(render_graph, constant_fold_part_mix_blend_clamped_no_fac_0)
.add_connection("Attribute2::Color", "Mix::Color2")
.output_color("Mix::Color");
graph.finalize(&scene);
graph.finalize(scene);
}
/*
@@ -572,10 +562,8 @@ TEST(render_graph, constant_fold_part_mix_blend_clamped_no_fac_0)
* - Folding of Mix with 0 or 1 Fac.
* - Folding of Mix with both inputs folded to the same node.
*/
TEST(render_graph, constant_fold_part_mix_blend)
TEST_F(RenderGraph, constant_fold_part_mix_blend)
{
DEFINE_COMMON_VARIABLES(builder, log);
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.");
@@ -607,17 +595,15 @@ TEST(render_graph, constant_fold_part_mix_blend)
.add_connection("MixBlend2::Color", "MixBlend3::Color2")
.output_color("MixBlend3::Color");
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests:
* - NOT folding of MixRGB Sub with the same inputs and fac NOT 1.
*/
TEST(render_graph, constant_fold_part_mix_sub_same_fac_bad)
TEST_F(RenderGraph, constant_fold_part_mix_sub_same_fac_bad)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
INVALID_INFO_MESSAGE(log, "Folding Mix::");
@@ -631,17 +617,15 @@ TEST(render_graph, constant_fold_part_mix_sub_same_fac_bad)
.add_connection("Attribute::Color", "Mix::Color2")
.output_color("Mix::Color");
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests:
* - Folding of MixRGB Sub with the same inputs and fac 1.
*/
TEST(render_graph, constant_fold_part_mix_sub_same_fac_1)
TEST_F(RenderGraph, constant_fold_part_mix_sub_same_fac_1)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding Mix::Color to constant (0, 0, 0).");
@@ -655,7 +639,7 @@ TEST(render_graph, constant_fold_part_mix_sub_same_fac_1)
.add_connection("Attribute::Color", "Mix::Color2")
.output_color("Mix::Color");
graph.finalize(&scene);
graph.finalize(scene);
}
/*
@@ -717,10 +701,8 @@ static void build_mix_partial_test_graph(ShaderGraphBuilder &builder, NodeMix ty
/*
* Tests: partial folding for RGB Add with known 0.
*/
TEST(render_graph, constant_fold_part_mix_add_0)
TEST_F(RenderGraph, constant_fold_part_mix_add_0)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
/* 0 + X (fac 1) == X */
INVALID_INFO_MESSAGE(log, "Folding Mix_Cx_Fx::Color");
@@ -731,16 +713,14 @@ TEST(render_graph, constant_fold_part_mix_add_0)
INVALID_INFO_MESSAGE(log, "Folding Out");
build_mix_partial_test_graph(builder, NODE_MIX_ADD, make_float3(0, 0, 0));
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests: partial folding for RGB Sub with known 0.
*/
TEST(render_graph, constant_fold_part_mix_sub_0)
TEST_F(RenderGraph, constant_fold_part_mix_sub_0)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
INVALID_INFO_MESSAGE(log, "Folding Mix_Cx_Fx::Color");
INVALID_INFO_MESSAGE(log, "Folding Mix_Cx_F1::Color");
@@ -750,16 +730,14 @@ TEST(render_graph, constant_fold_part_mix_sub_0)
INVALID_INFO_MESSAGE(log, "Folding Out");
build_mix_partial_test_graph(builder, NODE_MIX_SUB, make_float3(0, 0, 0));
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests: partial folding for RGB Mul with known 1.
*/
TEST(render_graph, constant_fold_part_mix_mul_1)
TEST_F(RenderGraph, constant_fold_part_mix_mul_1)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
/* 1 * X (fac 1) == X */
INVALID_INFO_MESSAGE(log, "Folding Mix_Cx_Fx::Color");
@@ -770,16 +748,14 @@ TEST(render_graph, constant_fold_part_mix_mul_1)
INVALID_INFO_MESSAGE(log, "Folding Out");
build_mix_partial_test_graph(builder, NODE_MIX_MUL, make_float3(1, 1, 1));
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests: partial folding for RGB Div with known 1.
*/
TEST(render_graph, constant_fold_part_mix_div_1)
TEST_F(RenderGraph, constant_fold_part_mix_div_1)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
INVALID_INFO_MESSAGE(log, "Folding Mix_Cx_Fx::Color");
INVALID_INFO_MESSAGE(log, "Folding Mix_Cx_F1::Color");
@@ -789,16 +765,14 @@ TEST(render_graph, constant_fold_part_mix_div_1)
INVALID_INFO_MESSAGE(log, "Folding Out");
build_mix_partial_test_graph(builder, NODE_MIX_DIV, make_float3(1, 1, 1));
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests: partial folding for RGB Mul with known 0.
*/
TEST(render_graph, constant_fold_part_mix_mul_0)
TEST_F(RenderGraph, constant_fold_part_mix_mul_0)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
/* 0 * ? (fac ?) == 0 */
CORRECT_INFO_MESSAGE(log, "Folding Mix_Cx_Fx::Color to constant (0, 0, 0).");
@@ -811,16 +785,14 @@ TEST(render_graph, constant_fold_part_mix_mul_0)
INVALID_INFO_MESSAGE(log, "Folding Out1234");
build_mix_partial_test_graph(builder, NODE_MIX_MUL, make_float3(0, 0, 0));
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests: partial folding for RGB Div with known 0.
*/
TEST(render_graph, constant_fold_part_mix_div_0)
TEST_F(RenderGraph, constant_fold_part_mix_div_0)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
/* 0 / ? (fac ?) == 0 */
CORRECT_INFO_MESSAGE(log, "Folding Mix_Cx_Fx::Color to constant (0, 0, 0).");
@@ -832,16 +804,14 @@ TEST(render_graph, constant_fold_part_mix_div_0)
INVALID_INFO_MESSAGE(log, "Folding Out1234");
build_mix_partial_test_graph(builder, NODE_MIX_DIV, make_float3(0, 0, 0));
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests: Separate/Combine RGB with all constant inputs.
*/
TEST(render_graph, constant_fold_separate_combine_rgb)
TEST_F(RenderGraph, constant_fold_separate_combine_rgb)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding SeparateRGB::R to constant (0.3).");
CORRECT_INFO_MESSAGE(log, "Folding SeparateRGB::G to constant (0.5).");
@@ -857,16 +827,14 @@ TEST(render_graph, constant_fold_separate_combine_rgb)
.add_connection("SeparateRGB::B", "CombineRGB::B")
.output_color("CombineRGB::Image");
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests: Separate/Combine XYZ with all constant inputs.
*/
TEST(render_graph, constant_fold_separate_combine_xyz)
TEST_F(RenderGraph, constant_fold_separate_combine_xyz)
{
DEFINE_COMMON_VARIABLES(builder, log);
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).");
@@ -883,16 +851,14 @@ TEST(render_graph, constant_fold_separate_combine_xyz)
.add_connection("SeparateXYZ::Z", "CombineXYZ::Z")
.output_color("CombineXYZ::Vector");
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests: Separate/Combine HSV with all constant inputs.
*/
TEST(render_graph, constant_fold_separate_combine_hsv)
TEST_F(RenderGraph, constant_fold_separate_combine_hsv)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding SeparateHSV::H to constant (0.583333).");
CORRECT_INFO_MESSAGE(log, "Folding SeparateHSV::S to constant (0.571429).");
@@ -908,16 +874,14 @@ TEST(render_graph, constant_fold_separate_combine_hsv)
.add_connection("SeparateHSV::V", "CombineHSV::V")
.output_color("CombineHSV::Color");
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests: Gamma with all constant inputs.
*/
TEST(render_graph, constant_fold_gamma)
TEST_F(RenderGraph, constant_fold_gamma)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding Gamma::Color to constant (0.164317, 0.353553, 0.585662).");
@@ -927,16 +891,14 @@ TEST(render_graph, constant_fold_gamma)
.set("Gamma", 1.5f))
.output_color("Gamma::Color");
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests: Gamma with one constant 0 input.
*/
TEST(render_graph, constant_fold_gamma_part_0)
TEST_F(RenderGraph, constant_fold_gamma_part_0)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
INVALID_INFO_MESSAGE(log, "Folding Gamma_Cx::");
CORRECT_INFO_MESSAGE(log, "Folding Gamma_xC::Color to constant (1, 1, 1).");
@@ -960,16 +922,14 @@ TEST(render_graph, constant_fold_gamma_part_0)
.add_connection("Gamma_xC::Color", "Out::Color2")
.output_color("Out::Color");
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests: Gamma with one constant 1 input.
*/
TEST(render_graph, constant_fold_gamma_part_1)
TEST_F(RenderGraph, constant_fold_gamma_part_1)
{
DEFINE_COMMON_VARIABLES(builder, log);
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.");
@@ -993,16 +953,14 @@ TEST(render_graph, constant_fold_gamma_part_1)
.add_connection("Gamma_xC::Color", "Out::Color2")
.output_color("Out::Color");
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests: BrightnessContrast with all constant inputs.
*/
TEST(render_graph, constant_fold_bright_contrast)
TEST_F(RenderGraph, constant_fold_bright_contrast)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding BrightContrast::Color to constant (0.16, 0.6, 1.04).");
@@ -1013,16 +971,14 @@ TEST(render_graph, constant_fold_bright_contrast)
.set("Contrast", 1.2f))
.output_color("BrightContrast::Color");
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests: blackbody with all constant inputs.
*/
TEST(render_graph, constant_fold_blackbody)
TEST_F(RenderGraph, constant_fold_blackbody)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding Blackbody::Color to constant (3.94163, 0.226523, 0).");
@@ -1031,16 +987,14 @@ TEST(render_graph, constant_fold_blackbody)
.set("Temperature", 1200.0f))
.output_color("Blackbody::Color");
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests: Math with all constant inputs (clamp false).
*/
TEST(render_graph, constant_fold_math)
TEST_F(RenderGraph, constant_fold_math)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding Math::Value to constant (1.6).");
@@ -1052,16 +1006,14 @@ TEST(render_graph, constant_fold_math)
.set("Value2", 0.9f))
.output_value("Math::Value");
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests: Math with all constant inputs (clamp true).
*/
TEST(render_graph, constant_fold_math_clamp)
TEST_F(RenderGraph, constant_fold_math_clamp)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding Math::Value to constant (1).");
@@ -1073,7 +1025,7 @@ TEST(render_graph, constant_fold_math_clamp)
.set("Value2", 0.9f))
.output_value("Math::Value");
graph.finalize(&scene);
graph.finalize(scene);
}
/*
@@ -1108,10 +1060,8 @@ static void build_math_partial_test_graph(ShaderGraphBuilder &builder, NodeMath
/*
* Tests: partial folding for Math Add with known 0.
*/
TEST(render_graph, constant_fold_part_math_add_0)
TEST_F(RenderGraph, constant_fold_part_math_add_0)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
/* X + 0 == 0 + X == X */
CORRECT_INFO_MESSAGE(log, "Folding Math_Cx::Value to socket Attribute::Fac.");
@@ -1119,16 +1069,14 @@ TEST(render_graph, constant_fold_part_math_add_0)
INVALID_INFO_MESSAGE(log, "Folding Out::");
build_math_partial_test_graph(builder, NODE_MATH_ADD, 0.0f);
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests: partial folding for Math Sub with known 0.
*/
TEST(render_graph, constant_fold_part_math_sub_0)
TEST_F(RenderGraph, constant_fold_part_math_sub_0)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
/* X - 0 == X */
INVALID_INFO_MESSAGE(log, "Folding Math_Cx::");
@@ -1136,16 +1084,14 @@ TEST(render_graph, constant_fold_part_math_sub_0)
INVALID_INFO_MESSAGE(log, "Folding Out::");
build_math_partial_test_graph(builder, NODE_MATH_SUBTRACT, 0.0f);
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests: partial folding for Math Mul with known 1.
*/
TEST(render_graph, constant_fold_part_math_mul_1)
TEST_F(RenderGraph, constant_fold_part_math_mul_1)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
/* X * 1 == 1 * X == X */
CORRECT_INFO_MESSAGE(log, "Folding Math_Cx::Value to socket Attribute::Fac.");
@@ -1153,16 +1099,14 @@ TEST(render_graph, constant_fold_part_math_mul_1)
INVALID_INFO_MESSAGE(log, "Folding Out::");
build_math_partial_test_graph(builder, NODE_MATH_MULTIPLY, 1.0f);
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests: partial folding for Math Div with known 1.
*/
TEST(render_graph, constant_fold_part_math_div_1)
TEST_F(RenderGraph, constant_fold_part_math_div_1)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
/* X / 1 == X */
INVALID_INFO_MESSAGE(log, "Folding Math_Cx::");
@@ -1170,16 +1114,14 @@ TEST(render_graph, constant_fold_part_math_div_1)
INVALID_INFO_MESSAGE(log, "Folding Out::");
build_math_partial_test_graph(builder, NODE_MATH_DIVIDE, 1.0f);
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests: partial folding for Math Mul with known 0.
*/
TEST(render_graph, constant_fold_part_math_mul_0)
TEST_F(RenderGraph, constant_fold_part_math_mul_0)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
/* X * 0 == 0 * X == 0 */
CORRECT_INFO_MESSAGE(log, "Folding Math_Cx::Value to constant (0).");
@@ -1188,16 +1130,14 @@ TEST(render_graph, constant_fold_part_math_mul_0)
CORRECT_INFO_MESSAGE(log, "Discarding closure EmissionNode.");
build_math_partial_test_graph(builder, NODE_MATH_MULTIPLY, 0.0f);
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests: partial folding for Math Div with known 0.
*/
TEST(render_graph, constant_fold_part_math_div_0)
TEST_F(RenderGraph, constant_fold_part_math_div_0)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
/* 0 / X == 0 */
CORRECT_INFO_MESSAGE(log, "Folding Math_Cx::Value to constant (0).");
@@ -1205,16 +1145,14 @@ TEST(render_graph, constant_fold_part_math_div_0)
INVALID_INFO_MESSAGE(log, "Folding Out::");
build_math_partial_test_graph(builder, NODE_MATH_DIVIDE, 0.0f);
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests: partial folding for Math Power with known 0.
*/
TEST(render_graph, constant_fold_part_math_pow_0)
TEST_F(RenderGraph, constant_fold_part_math_pow_0)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
/* X ^ 0 == 1 */
INVALID_INFO_MESSAGE(log, "Folding Math_Cx::");
@@ -1222,16 +1160,14 @@ TEST(render_graph, constant_fold_part_math_pow_0)
INVALID_INFO_MESSAGE(log, "Folding Out::");
build_math_partial_test_graph(builder, NODE_MATH_POWER, 0.0f);
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests: partial folding for Math Power with known 1.
*/
TEST(render_graph, constant_fold_part_math_pow_1)
TEST_F(RenderGraph, constant_fold_part_math_pow_1)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
/* 1 ^ X == 1; X ^ 1 == X */
CORRECT_INFO_MESSAGE(log, "Folding Math_Cx::Value to constant (1)");
@@ -1239,16 +1175,14 @@ TEST(render_graph, constant_fold_part_math_pow_1)
INVALID_INFO_MESSAGE(log, "Folding Out::");
build_math_partial_test_graph(builder, NODE_MATH_POWER, 1.0f);
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests: Vector Math with all constant inputs.
*/
TEST(render_graph, constant_fold_vector_math)
TEST_F(RenderGraph, constant_fold_vector_math)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding VectorMath::Value to constant (1).");
CORRECT_INFO_MESSAGE(log, "Folding VectorMath::Vector to constant (3, 0, 0).");
@@ -1267,7 +1201,7 @@ TEST(render_graph, constant_fold_vector_math)
.add_connection("VectorMath::Value", "Math::Value2")
.output_color("Math::Value");
graph.finalize(&scene);
graph.finalize(scene);
}
/*
@@ -1299,10 +1233,8 @@ static void build_vecmath_partial_test_graph(ShaderGraphBuilder &builder, NodeVe
/*
* Tests: partial folding for Vector Math Add with known 0.
*/
TEST(render_graph, constant_fold_part_vecmath_add_0)
TEST_F(RenderGraph, constant_fold_part_vecmath_add_0)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
/* X + 0 == 0 + X == X */
CORRECT_INFO_MESSAGE(log, "Folding Math_Cx::Vector to socket Attribute::Vector.");
@@ -1310,16 +1242,14 @@ TEST(render_graph, constant_fold_part_vecmath_add_0)
INVALID_INFO_MESSAGE(log, "Folding Out::");
build_vecmath_partial_test_graph(builder, NODE_VECTOR_MATH_ADD, make_float3(0,0,0));
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests: partial folding for Vector Math Sub with known 0.
*/
TEST(render_graph, constant_fold_part_vecmath_sub_0)
TEST_F(RenderGraph, constant_fold_part_vecmath_sub_0)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
/* X - 0 == X */
INVALID_INFO_MESSAGE(log, "Folding Math_Cx::");
@@ -1327,16 +1257,14 @@ TEST(render_graph, constant_fold_part_vecmath_sub_0)
INVALID_INFO_MESSAGE(log, "Folding Out::");
build_vecmath_partial_test_graph(builder, NODE_VECTOR_MATH_SUBTRACT, make_float3(0,0,0));
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests: partial folding for Vector Math Dot Product with known 0.
*/
TEST(render_graph, constant_fold_part_vecmath_dot_0)
TEST_F(RenderGraph, constant_fold_part_vecmath_dot_0)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
/* X * 0 == 0 * X == X */
CORRECT_INFO_MESSAGE(log, "Folding Math_Cx::Vector to constant (0, 0, 0).");
@@ -1345,16 +1273,14 @@ TEST(render_graph, constant_fold_part_vecmath_dot_0)
CORRECT_INFO_MESSAGE(log, "Discarding closure EmissionNode.");
build_vecmath_partial_test_graph(builder, NODE_VECTOR_MATH_DOT_PRODUCT, make_float3(0,0,0));
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests: partial folding for Vector Math Cross Product with known 0.
*/
TEST(render_graph, constant_fold_part_vecmath_cross_0)
TEST_F(RenderGraph, constant_fold_part_vecmath_cross_0)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
/* X * 0 == 0 * X == X */
CORRECT_INFO_MESSAGE(log, "Folding Math_Cx::Vector to constant (0, 0, 0).");
@@ -1363,16 +1289,14 @@ TEST(render_graph, constant_fold_part_vecmath_cross_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);
graph.finalize(scene);
}
/*
* Tests: Bump with no height input folded to Normal input.
*/
TEST(render_graph, constant_fold_bump)
TEST_F(RenderGraph, constant_fold_bump)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding Bump::Normal to socket Geometry1::Normal.");
@@ -1382,16 +1306,14 @@ TEST(render_graph, constant_fold_bump)
.add_connection("Geometry1::Normal", "Bump::Normal")
.output_color("Bump::Normal");
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests: Bump with no inputs folded to Geometry::Normal.
*/
TEST(render_graph, constant_fold_bump_no_input)
TEST_F(RenderGraph, constant_fold_bump_no_input)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding Bump::Normal to socket geometry::Normal.");
@@ -1399,7 +1321,7 @@ TEST(render_graph, constant_fold_bump_no_input)
.add_node(ShaderNodeBuilder<BumpNode>("Bump"))
.output_color("Bump::Normal");
graph.finalize(&scene);
graph.finalize(scene);
}
template<class T>
@@ -1416,10 +1338,8 @@ void init_test_curve(array<T> &buffer, T start, T end, int steps)
* Tests:
* - Folding of RGB Curves with all constant inputs.
*/
TEST(render_graph, constant_fold_rgb_curves)
TEST_F(RenderGraph, constant_fold_rgb_curves)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding Curves::Color to constant (0.275, 0.5, 0.475).");
@@ -1435,17 +1355,15 @@ TEST(render_graph, constant_fold_rgb_curves)
.set("Color", make_float3(0.3f, 0.5f, 0.7f)))
.output_color("Curves::Color");
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests:
* - Folding of RGB Curves with zero Fac.
*/
TEST(render_graph, constant_fold_rgb_curves_fac_0)
TEST_F(RenderGraph, constant_fold_rgb_curves_fac_0)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding Curves::Color to socket Attribute::Color.");
@@ -1462,7 +1380,7 @@ TEST(render_graph, constant_fold_rgb_curves_fac_0)
.add_connection("Attribute::Color", "Curves::Color")
.output_color("Curves::Color");
graph.finalize(&scene);
graph.finalize(scene);
}
@@ -1470,10 +1388,8 @@ TEST(render_graph, constant_fold_rgb_curves_fac_0)
* Tests:
* - Folding of RGB Curves with zero Fac and all constant inputs.
*/
TEST(render_graph, constant_fold_rgb_curves_fac_0_const)
TEST_F(RenderGraph, constant_fold_rgb_curves_fac_0_const)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding Curves::Color to constant (0.3, 0.5, 0.7).");
@@ -1489,17 +1405,15 @@ TEST(render_graph, constant_fold_rgb_curves_fac_0_const)
.set("Color", make_float3(0.3f, 0.5f, 0.7f)))
.output_color("Curves::Color");
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests:
* - Folding of Vector Curves with all constant inputs.
*/
TEST(render_graph, constant_fold_vector_curves)
TEST_F(RenderGraph, constant_fold_vector_curves)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding Curves::Vector to constant (0.275, 0.5, 0.475).");
@@ -1515,17 +1429,15 @@ TEST(render_graph, constant_fold_vector_curves)
.set("Vector", make_float3(0.3f, 0.5f, 0.7f)))
.output_color("Curves::Vector");
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests:
* - Folding of Vector Curves with zero Fac.
*/
TEST(render_graph, constant_fold_vector_curves_fac_0)
TEST_F(RenderGraph, constant_fold_vector_curves_fac_0)
{
DEFINE_COMMON_VARIABLES(builder, log);
EXPECT_ANY_MESSAGE(log);
CORRECT_INFO_MESSAGE(log, "Folding Curves::Vector to socket Attribute::Vector.");
@@ -1542,17 +1454,15 @@ TEST(render_graph, constant_fold_vector_curves_fac_0)
.add_connection("Attribute::Vector", "Curves::Vector")
.output_color("Curves::Vector");
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests:
* - Folding of Color Ramp with all constant inputs.
*/
TEST(render_graph, constant_fold_rgb_ramp)
TEST_F(RenderGraph, constant_fold_rgb_ramp)
{
DEFINE_COMMON_VARIABLES(builder, log);
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).");
@@ -1574,17 +1484,15 @@ TEST(render_graph, constant_fold_rgb_ramp)
.add_connection("Ramp::Alpha", "Mix::Color2")
.output_color("Mix::Color");
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests:
* - Folding of Color Ramp with all constant inputs (interpolate false).
*/
TEST(render_graph, constant_fold_rgb_ramp_flat)
TEST_F(RenderGraph, constant_fold_rgb_ramp_flat)
{
DEFINE_COMMON_VARIABLES(builder, log);
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).");
@@ -1606,17 +1514,15 @@ TEST(render_graph, constant_fold_rgb_ramp_flat)
.add_connection("Ramp::Alpha", "Mix::Color2")
.output_color("Mix::Color");
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests:
* - Folding of redundant conversion of float to color to float.
*/
TEST(render_graph, constant_fold_convert_float_color_float)
TEST_F(RenderGraph, constant_fold_convert_float_color_float)
{
DEFINE_COMMON_VARIABLES(builder, log);
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.");
@@ -1628,17 +1534,15 @@ TEST(render_graph, constant_fold_convert_float_color_float)
.add_connection("Attribute::Fac", "Invert::Color")
.output_value("Invert::Color");
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests:
* - Folding of redundant conversion of color to vector to color.
*/
TEST(render_graph, constant_fold_convert_color_vector_color)
TEST_F(RenderGraph, constant_fold_convert_color_vector_color)
{
DEFINE_COMMON_VARIABLES(builder, log);
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.");
@@ -1651,17 +1555,15 @@ TEST(render_graph, constant_fold_convert_color_vector_color)
.add_connection("Attribute::Color", "VecAdd::Vector1")
.output_color("VecAdd::Vector");
graph.finalize(&scene);
graph.finalize(scene);
}
/*
* Tests:
* - NOT folding conversion of color to float to color.
*/
TEST(render_graph, constant_fold_convert_color_float_color)
TEST_F(RenderGraph, constant_fold_convert_color_float_color)
{
DEFINE_COMMON_VARIABLES(builder, log);
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::");
@@ -1674,7 +1576,7 @@ TEST(render_graph, constant_fold_convert_color_float_color)
.add_connection("Attribute::Color", "MathAdd::Value1")
.output_color("MathAdd::Value");
graph.finalize(&scene);
graph.finalize(scene);
}
CCL_NAMESPACE_END

View File

@@ -341,9 +341,9 @@ enum {
/* spare tag, assumed dirty, use define in each function to name based on use */
// _BM_ELEM_TAG_ALT = (1 << 6), // UNUSED
/**
* for low level internal API tagging,
* since tools may want to tag verts and
* not have functions clobber them */
* For low level internal API tagging,
* since tools may want to tag verts and not have functions clobber them.
* Leave cleared! */
BM_ELEM_INTERNAL_TAG = (1 << 7),
};

View File

@@ -2090,25 +2090,33 @@ BMFace *bmesh_kernel_join_face_kill_edge(BMesh *bm, BMFace *f1, BMFace *f2, BMEd
}
/* validate no internal join */
for (i = 0, l_iter = BM_FACE_FIRST_LOOP(f1); i < f1len; i++, l_iter = l_iter->next) {
BM_elem_flag_disable(l_iter->v, BM_ELEM_INTERNAL_TAG);
}
for (i = 0, l_iter = BM_FACE_FIRST_LOOP(f2); i < f2len; i++, l_iter = l_iter->next) {
BM_elem_flag_disable(l_iter->v, BM_ELEM_INTERNAL_TAG);
}
{
bool is_dupe = false;
for (i = 0, l_iter = BM_FACE_FIRST_LOOP(f1); i < f1len; i++, l_iter = l_iter->next) {
if (l_iter != l_f1) {
BM_elem_flag_enable(l_iter->v, BM_ELEM_INTERNAL_TAG);
/* TODO: skip clearing once this is ensured. */
for (i = 0, l_iter = BM_FACE_FIRST_LOOP(f2); i < f2len; i++, l_iter = l_iter->next) {
BM_elem_flag_disable(l_iter->v, BM_ELEM_INTERNAL_TAG);
}
}
for (i = 0, l_iter = BM_FACE_FIRST_LOOP(f2); i < f2len; i++, l_iter = l_iter->next) {
if (l_iter != l_f2) {
/* as soon as a duplicate is found, bail out */
if (BM_elem_flag_test(l_iter->v, BM_ELEM_INTERNAL_TAG)) {
return NULL;
for (i = 0, l_iter = BM_FACE_FIRST_LOOP(f1); i < f1len; i++, l_iter = l_iter->next) {
BM_elem_flag_set(l_iter->v, BM_ELEM_INTERNAL_TAG, l_iter != l_f1);
}
for (i = 0, l_iter = BM_FACE_FIRST_LOOP(f2); i < f2len; i++, l_iter = l_iter->next) {
if (l_iter != l_f2) {
/* as soon as a duplicate is found, bail out */
if (BM_elem_flag_test(l_iter->v, BM_ELEM_INTERNAL_TAG)) {
is_dupe = true;
break;
}
}
}
/* Cleanup tags. */
for (i = 0, l_iter = BM_FACE_FIRST_LOOP(f1); i < f1len; i++, l_iter = l_iter->next) {
BM_elem_flag_disable(l_iter->v, BM_ELEM_INTERNAL_TAG);
}
if (is_dupe) {
return NULL;
}
}
/* join the two loop */

View File

@@ -33,6 +33,7 @@
#include "BLI_listbase.h"
#include "BLI_mempool.h"
#include "BLI_utildefines_iter.h"
#include "BLI_stack.h"
#include "bmesh.h"
@@ -141,28 +142,36 @@ int BM_mesh_edgeloops_find(
}
/* first flush edges to tags, and tag verts */
BLI_Stack *edge_stack = BLI_stack_new(sizeof(BMEdge *), __func__);
BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
BLI_assert(!BM_elem_flag_test(e, BM_ELEM_INTERNAL_TAG));
if (test_fn(e, user_data)) {
BM_elem_flag_enable(e, BM_ELEM_INTERNAL_TAG);
BM_elem_flag_enable(e->v1, BM_ELEM_INTERNAL_TAG);
BM_elem_flag_enable(e->v2, BM_ELEM_INTERNAL_TAG);
BLI_stack_push(edge_stack, (void *)&e);
}
else {
BM_elem_flag_disable(e, BM_ELEM_INTERNAL_TAG);
}
}
BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
const uint edges_len = BLI_stack_count(edge_stack);
BMEdge **edges = MEM_mallocN(sizeof(*edges) * edges_len, __func__);
BLI_stack_pop_n_reverse(edge_stack, edges, BLI_stack_count(edge_stack));
BLI_stack_free(edge_stack);
for (uint i = 0; i < edges_len; i += 1) {
e = edges[i];
if (BM_elem_flag_test(e, BM_ELEM_INTERNAL_TAG)) {
BMEdgeLoopStore *el_store = MEM_callocN(sizeof(BMEdgeLoopStore), __func__);
/* add both directions */
if (bm_loop_build(el_store, e->v1, e->v2, 1) &&
bm_loop_build(el_store, e->v2, e->v1, -1) &&
el_store->len > 1)
bm_loop_build(el_store, e->v2, e->v1, -1) &&
el_store->len > 1)
{
BLI_addtail(r_eloops, el_store);
BM_elem_flag_disable(e, BM_ELEM_INTERNAL_TAG);
count++;
}
else {
@@ -170,6 +179,15 @@ int BM_mesh_edgeloops_find(
}
}
}
for (uint i = 0; i < edges_len; i += 1) {
e = edges[i];
BM_elem_flag_disable(e, BM_ELEM_INTERNAL_TAG);
BM_elem_flag_disable(e->v1, BM_ELEM_INTERNAL_TAG);
BM_elem_flag_disable(e->v2, BM_ELEM_INTERNAL_TAG);
}
MEM_freeN(edges);
return count;
}
@@ -267,6 +285,7 @@ bool BM_mesh_edgeloops_find_path(
{
BMIter iter;
BMEdge *e;
bool found = false;
BLI_assert(v_src != v_dst);
@@ -274,28 +293,43 @@ bool BM_mesh_edgeloops_find_path(
BMVert *v;
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
BM_elem_index_set(v, 0);
BM_elem_flag_disable(v, BM_ELEM_INTERNAL_TAG);
}
}
bm->elem_index_dirty |= BM_VERT;
/* first flush edges to tags, and tag verts */
int edges_len;
BMEdge **edges;
if (test_fn) {
BLI_Stack *edge_stack = BLI_stack_new(sizeof(BMEdge *), __func__);
BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
if (test_fn(e, user_data)) {
BM_elem_flag_enable(e, BM_ELEM_INTERNAL_TAG);
BM_elem_flag_enable(e->v1, BM_ELEM_INTERNAL_TAG);
BM_elem_flag_enable(e->v2, BM_ELEM_INTERNAL_TAG);
BLI_stack_push(edge_stack, (void *)&e);
}
else {
BM_elem_flag_disable(e, BM_ELEM_INTERNAL_TAG);
}
}
edges_len = BLI_stack_count(edge_stack);
edges = MEM_mallocN(sizeof(*edges) * edges_len, __func__);
BLI_stack_pop_n_reverse(edge_stack, edges, BLI_stack_count(edge_stack));
BLI_stack_free(edge_stack);
}
else {
BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
int i = 0;
edges_len = bm->totedge;
edges = MEM_mallocN(sizeof(*edges) * edges_len, __func__);
BM_ITER_MESH_INDEX (e, &iter, bm, BM_EDGES_OF_MESH, i) {
BM_elem_flag_enable(e, BM_ELEM_INTERNAL_TAG);
BM_elem_flag_enable(e->v1, BM_ELEM_INTERNAL_TAG);
BM_elem_flag_enable(e->v2, BM_ELEM_INTERNAL_TAG);
edges[i] = e;
}
}
@@ -354,11 +388,19 @@ bool BM_mesh_edgeloops_find_path(
BLI_addtail(r_eloops, el_store);
return true;
found = true;
}
}
return false;
for (uint i = 0; i < edges_len; i += 1) {
e = edges[i];
BM_elem_flag_disable(e, BM_ELEM_INTERNAL_TAG);
BM_elem_flag_disable(e->v1, BM_ELEM_INTERNAL_TAG);
BM_elem_flag_disable(e->v2, BM_ELEM_INTERNAL_TAG);
}
MEM_freeN(edges);
return found;
}
@@ -753,19 +795,29 @@ bool BM_edgeloop_overlap_check(struct BMEdgeLoopStore *el_store_a, struct BMEdge
{
LinkData *node;
/* init */
for (node = el_store_a->verts.first; node; node = node->next) {
BM_elem_flag_disable((BMVert *)node->data, BM_ELEM_INTERNAL_TAG);
}
for (node = el_store_b->verts.first; node; node = node->next) {
BM_elem_flag_enable((BMVert *)node->data, BM_ELEM_INTERNAL_TAG);
/* A little more efficient if 'a' as smaller. */
if (el_store_a->len > el_store_b->len) {
SWAP(BMEdgeLoopStore *, el_store_a, el_store_b);
}
/* check 'a' */
/* init */
for (node = el_store_a->verts.first; node; node = node->next) {
if (BM_elem_flag_test((BMVert *)node->data, BM_ELEM_INTERNAL_TAG)) {
BM_elem_flag_enable((BMVert *)node->data, BM_ELEM_INTERNAL_TAG);
}
for (node = el_store_b->verts.first; node; node = node->next) {
BM_elem_flag_disable((BMVert *)node->data, BM_ELEM_INTERNAL_TAG);
}
/* Check 'a' (clear as we go). */
for (node = el_store_a->verts.first; node; node = node->next) {
if (!BM_elem_flag_test((BMVert *)node->data, BM_ELEM_INTERNAL_TAG)) {
/* Finish clearing 'a', leave tag clean. */
while ((node = node->next)) {
BM_elem_flag_disable((BMVert *)node->data, BM_ELEM_INTERNAL_TAG);
}
return true;
}
BM_elem_flag_disable((BMVert *)node->data, BM_ELEM_INTERNAL_TAG);
}
return false;
}

View File

@@ -957,7 +957,7 @@ static void bm_loop_walk_add(struct LoopWalkCtx *lwc, BMLoop *l)
{
const int i = BM_elem_index_get(l);
const float w = lwc->loop_weights[i];
BM_elem_flag_enable(l, BM_ELEM_INTERNAL_TAG);
BM_elem_flag_disable(l, BM_ELEM_INTERNAL_TAG);
lwc->data_array[lwc->data_len] = BM_ELEM_CD_GET_VOID_P(l, lwc->cd_layer_offset);
lwc->data_index_array[lwc->data_len] = i;
lwc->weight_array[lwc->data_len] = w;
@@ -976,7 +976,7 @@ static void bm_loop_walk_data(struct LoopWalkCtx *lwc, BMLoop *l_walk)
int i;
BLI_assert(CustomData_data_equals(lwc->type, lwc->data_ref, BM_ELEM_CD_GET_VOID_P(l_walk, lwc->cd_layer_offset)));
BLI_assert(BM_elem_flag_test(l_walk, BM_ELEM_INTERNAL_TAG) == false);
BLI_assert(BM_elem_flag_test(l_walk, BM_ELEM_INTERNAL_TAG));
bm_loop_walk_add(lwc, l_walk);
@@ -988,7 +988,7 @@ static void bm_loop_walk_data(struct LoopWalkCtx *lwc, BMLoop *l_walk)
l_other = l_other->next;
}
BLI_assert(l_other->v == l_walk->v);
if (!BM_elem_flag_test(l_other, BM_ELEM_INTERNAL_TAG)) {
if (BM_elem_flag_test(l_other, BM_ELEM_INTERNAL_TAG)) {
if (CustomData_data_equals(lwc->type, lwc->data_ref, BM_ELEM_CD_GET_VOID_P(l_other, lwc->cd_layer_offset))) {
bm_loop_walk_data(lwc, l_other);
}
@@ -1012,9 +1012,10 @@ LinkNode *BM_vert_loop_groups_data_layer_create(
lwc.loop_weights = loop_weights;
lwc.arena = arena;
/* Enable 'BM_ELEM_INTERNAL_TAG', leaving the flag clean on completion. */
loop_num = 0;
BM_ITER_ELEM (l, &liter, v, BM_LOOPS_OF_VERT) {
BM_elem_flag_disable(l, BM_ELEM_INTERNAL_TAG);
BM_elem_flag_enable(l, BM_ELEM_INTERNAL_TAG);
BM_elem_index_set(l, loop_num); /* set_dirty! */
loop_num++;
}
@@ -1026,7 +1027,7 @@ LinkNode *BM_vert_loop_groups_data_layer_create(
lwc.weight_array = BLI_memarena_alloc(lwc.arena, sizeof(float) * loop_num);
BM_ITER_ELEM (l, &liter, v, BM_LOOPS_OF_VERT) {
if (!BM_elem_flag_test(l, BM_ELEM_INTERNAL_TAG)) {
if (BM_elem_flag_test(l, BM_ELEM_INTERNAL_TAG)) {
struct LoopGroupCD *lf = BLI_memarena_alloc(lwc.arena, sizeof(*lf));
int len_prev = lwc.data_len;

View File

@@ -1236,6 +1236,8 @@ bool BM_face_split_edgenet_connect_islands(
BMLoop *l_iter, *l_first;
l_iter = l_first = BM_FACE_FIRST_LOOP(f);
do {
BLI_assert(!BM_elem_flag_test(l_iter->v, VERT_NOT_IN_STACK));
BLI_assert(!BM_elem_flag_test(l_iter->e, EDGE_NOT_IN_STACK));
edge_arr[i++] = l_iter->e;
} while ((l_iter = l_iter->next) != l_first);
BLI_assert(i == edge_arr_len);

View File

@@ -2108,7 +2108,8 @@ bool BM_face_exists_multi(BMVert **varr, BMEdge **earr, int len)
if (tot_tag == 0) {
/* no faces use only boundary verts, quit early */
return false;
ok = false;
goto finally;
}
/* 2) loop over non-boundary edges that use boundary verts,
@@ -2143,6 +2144,12 @@ bool BM_face_exists_multi(BMVert **varr, BMEdge **earr, int len)
}
}
finally:
/* Cleanup */
for (i = 0; i < len; i++) {
BM_elem_flag_disable(varr[i], BM_ELEM_INTERNAL_TAG);
BM_elem_flag_disable(earr[i], BM_ELEM_INTERNAL_TAG);
}
return ok;
}

View File

@@ -50,5 +50,5 @@ void bmo_split_edges_exec(BMesh *bm, BMOperator *op)
/* this is where everything happens */
BM_mesh_edgesplit(bm, use_verts, true, false);
BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "edges.out", BM_EDGE, BM_ELEM_INTERNAL_TAG);
BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "edges.out", BM_EDGE, BM_ELEM_TAG);
}

View File

@@ -1085,6 +1085,8 @@ typedef struct tNearestVertInfo {
int dist; /* distance from mouse to vert */
eAnim_ChannelType ctype; /* type of animation channel this FCurve comes from */
float frame; /* frame that point was on when it matched (global time) */
} tNearestVertInfo;
/* Tags for the type of graph vert that we have */
@@ -1151,6 +1153,8 @@ static void nearest_fcurve_vert_store(
nvi->hpoint = hpoint;
nvi->dist = dist;
nvi->frame = bezt->vec[1][0]; /* currently in global time... */
nvi->sel = BEZT_ISSEL_ANY(bezt); // XXX... should this use the individual verts instead?
/* add to list of matches if appropriate... */
@@ -1435,10 +1439,7 @@ static void graphkeys_mselect_column(bAnimContext *ac, const int mval[2], short
/* get frame number on which elements should be selected */
// TODO: should we restrict to integer frames only?
if (nvi->bezt)
selx = nvi->bezt->vec[1][0];
else if (nvi->fpt)
selx = nvi->fpt->vec[0];
selx = nvi->frame;
/* if select mode is replace, deselect all keyframes first */
if (select_mode == SELECT_REPLACE) {

View File

@@ -3872,7 +3872,7 @@ void *BPy_BMElem_PySeq_As_Array_FAST(
BMesh *bm = (r_bm && *r_bm) ? *r_bm : NULL;
PyObject **seq_fast_items = PySequence_Fast_ITEMS(seq_fast);
const Py_ssize_t seq_len = PySequence_Fast_GET_SIZE(seq_fast);
Py_ssize_t i;
Py_ssize_t i, i_last_dirty = PY_SSIZE_T_MAX;
BPy_BMElem *item;
BMElem **alloc;
@@ -3921,6 +3921,7 @@ void *BPy_BMElem_PySeq_As_Array_FAST(
if (do_unique_check) {
BM_elem_flag_enable(item->ele, BM_ELEM_INTERNAL_TAG);
i_last_dirty = i;
}
}
@@ -3937,6 +3938,8 @@ void *BPy_BMElem_PySeq_As_Array_FAST(
}
if (ok == false) {
/* Cleared above. */
i_last_dirty = PY_SSIZE_T_MAX;
PyErr_Format(PyExc_ValueError,
"%s: found the same %.200s used multiple times",
error_prefix, BPy_BMElem_StringFromHType(htype));
@@ -3949,6 +3952,11 @@ void *BPy_BMElem_PySeq_As_Array_FAST(
return alloc;
err_cleanup:
if (do_unique_check && (i_last_dirty != PY_SSIZE_T_MAX)) {
for (i = 0; i <= i_last_dirty; i++) {
BM_elem_flag_disable(alloc[i], BM_ELEM_INTERNAL_TAG);
}
}
PyMem_FREE(alloc);
return NULL;