Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Gavrilov <angavrilov@gmail.com>2016-07-16 14:16:54 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2016-07-18 23:54:30 +0300
commit5234e9ddd3ecefcf3a48d1f41e4dc18b89627f72 (patch)
treec30b3147018e688e46e5215287df2894a667f0d1 /intern/cycles/render/graph.cpp
parent10b0e33de1b9b57693ebcec7d503d3b204043f56 (diff)
Cycles: add ConstantFolder class for constant folding boilerplate.
Reviewed By: brecht, sergey Differential Revision: https://developer.blender.org/D2089
Diffstat (limited to 'intern/cycles/render/graph.cpp')
-rw-r--r--intern/cycles/render/graph.cpp36
1 files changed, 15 insertions, 21 deletions
diff --git a/intern/cycles/render/graph.cpp b/intern/cycles/render/graph.cpp
index fd48bf2631e..ac78238dfee 100644
--- a/intern/cycles/render/graph.cpp
+++ b/intern/cycles/render/graph.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2013 Blender Foundation
+ * Copyright 2011-2016 Blender Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
#include "graph.h"
#include "nodes.h"
#include "shader.h"
+#include "constant_fold.h"
#include "util_algorithm.h"
#include "util_debug.h"
@@ -126,17 +127,6 @@ ShaderOutput *ShaderNode::output(ustring name)
return NULL;
}
-bool ShaderNode::all_inputs_constant() const
-{
- foreach(ShaderInput *input, inputs) {
- if(input->link) {
- return false;
- }
- }
-
- return true;
-}
-
void ShaderNode::attributes(Shader *shader, AttributeRequestSet *attributes)
{
foreach(ShaderInput *input, inputs) {
@@ -278,6 +268,17 @@ void ShaderGraph::connect(ShaderOutput *from, ShaderInput *to)
}
}
+void ShaderGraph::disconnect(ShaderOutput *from)
+{
+ assert(!finalized);
+
+ foreach(ShaderInput *sock, from->links) {
+ sock->link = NULL;
+ }
+
+ from->links.clear();
+}
+
void ShaderGraph::disconnect(ShaderInput *to)
{
assert(!finalized);
@@ -525,15 +526,8 @@ void ShaderGraph::constant_fold()
}
}
/* Optimize current node. */
- if(node->constant_fold(this, output, output->links[0])) {
- /* Apply optimized value to other connected sockets and disconnect. */
- vector<ShaderInput*> links(output->links);
- for(size_t i = 0; i < links.size(); i++) {
- if(i > 0)
- links[i]->parent->copy_value(links[i]->socket_type, *links[0]->parent, links[0]->socket_type);
- disconnect(links[i]);
- }
- }
+ ConstantFolder folder(this, node, output);
+ node->constant_fold(folder);
}
}
}