Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/test/render_graph_finalize_test.cpp
| Show All 37 Lines | |||||
| namespace { | namespace { | ||||
| template<typename T> class ShaderNodeBuilder { | template<typename T> class ShaderNodeBuilder { | ||||
| public: | public: | ||||
| ShaderNodeBuilder(ShaderGraph &graph, const string &name) : name_(name) | ShaderNodeBuilder(ShaderGraph &graph, const string &name) : name_(name) | ||||
| { | { | ||||
| node_ = graph.create_node<T>(); | node_ = graph.create_node<T>(); | ||||
| node_->name = name; | node_->set_name(ustring(name)); | ||||
| } | } | ||||
| const string &name() const | const string &name() const | ||||
| { | { | ||||
| return name_; | return name_; | ||||
| } | } | ||||
| ShaderNode *node() const | ShaderNode *node() const | ||||
| { | { | ||||
| return node_; | return node_; | ||||
| } | } | ||||
| template<typename V> ShaderNodeBuilder &set(const string &input_name, V value) | template<typename V> ShaderNodeBuilder &set(const string &input_name, V value) | ||||
| { | { | ||||
| ShaderInput *input_socket = node_->input(input_name.c_str()); | ShaderInput *input_socket = node_->input(input_name.c_str()); | ||||
| EXPECT_NE((void *)NULL, input_socket); | EXPECT_NE((void *)NULL, input_socket); | ||||
| input_socket->set(value); | input_socket->set(value); | ||||
| return *this; | return *this; | ||||
| } | } | ||||
| template<typename V> ShaderNodeBuilder &set_param(const string &input_name, V value) | template<typename V> ShaderNodeBuilder &set_param(const string &input_name, V value) | ||||
| { | { | ||||
| const SocketType *input_socket = node_->type->find_input(ustring(input_name.c_str())); | const SocketType *input_socket = node_->get_type()->find_input(ustring(input_name.c_str())); | ||||
| EXPECT_NE((void *)NULL, input_socket); | EXPECT_NE((void *)NULL, input_socket); | ||||
| node_->set(*input_socket, value); | node_->set(*input_socket, value); | ||||
| return *this; | return *this; | ||||
| } | } | ||||
| protected: | protected: | ||||
| string name_; | string name_; | ||||
| ShaderNode *node_; | ShaderNode *node_; | ||||
| ▲ Show 20 Lines • Show All 146 Lines • ▼ Show 20 Lines | builder.add_node(ShaderNodeBuilder<GeometryNode>(graph, "Geometry1")) | ||||
| .add_connection("Noise1::Color", "Mix::Color1") | .add_connection("Noise1::Color", "Mix::Color1") | ||||
| .add_connection("Geometry2::Parametric", "Noise2::Vector") | .add_connection("Geometry2::Parametric", "Noise2::Vector") | ||||
| .add_connection("Value2::Value", "Noise2::Scale") | .add_connection("Value2::Value", "Noise2::Scale") | ||||
| .add_connection("Noise2::Color", "Mix::Color2") | .add_connection("Noise2::Color", "Mix::Color2") | ||||
| .output_color("Mix::Color"); | .output_color("Mix::Color"); | ||||
| graph.finalize(scene); | graph.finalize(scene); | ||||
| EXPECT_EQ(graph.nodes.size(), 5); | EXPECT_EQ(graph.get_nodes().size(), 5); | ||||
| } | } | ||||
| /* | /* | ||||
| * Test RGB to BW node. | * Test RGB to BW node. | ||||
| */ | */ | ||||
| TEST_F(RenderGraph, constant_fold_rgb_to_bw) | TEST_F(RenderGraph, constant_fold_rgb_to_bw) | ||||
| { | { | ||||
| EXPECT_ANY_MESSAGE(log); | EXPECT_ANY_MESSAGE(log); | ||||
| ▲ Show 20 Lines • Show All 1,304 Lines • Show Last 20 Lines | |||||