Cycles: add unit tests for supported constant folding rules.
Code coverage of different combinations of secondary conditions is obviously not complete because there are so many of them, but all main rules should be there. The reason for CORRECT vs INVALID is that both words have the same number of characters so calls line up, but look quite different. Reviewers: #cycles, sergey Reviewed By: #cycles, sergey Subscribers: dingto, sergey, brecht Differential Revision: https://developer.blender.org/D2130
This commit is contained in:
@@ -40,7 +40,8 @@ bool ConstantFolder::all_inputs_constant() const
|
||||
|
||||
void ConstantFolder::make_constant(float value) const
|
||||
{
|
||||
VLOG(1) << "Replacing " << node->name << " with constant " << value << ".";
|
||||
VLOG(1) << "Folding " << node->name << "::" << output->name() << " to constant (" << value << ").";
|
||||
|
||||
foreach(ShaderInput *sock, output->links) {
|
||||
sock->set(value);
|
||||
}
|
||||
@@ -50,6 +51,8 @@ void ConstantFolder::make_constant(float value) const
|
||||
|
||||
void ConstantFolder::make_constant(float3 value) const
|
||||
{
|
||||
VLOG(1) << "Folding " << node->name << "::" << output->name() << " to constant " << value << ".";
|
||||
|
||||
foreach(ShaderInput *sock, output->links) {
|
||||
sock->set(value);
|
||||
}
|
||||
@@ -90,6 +93,8 @@ void ConstantFolder::bypass(ShaderOutput *new_output) const
|
||||
{
|
||||
assert(new_output);
|
||||
|
||||
VLOG(1) << "Folding " << node->name << "::" << output->name() << " to socket " << new_output->parent->name << "::" << new_output->name() << ".";
|
||||
|
||||
/* Remove all outgoing links from socket and connect them to new_output instead.
|
||||
* The graph->relink method affects node inputs, so it's not safe to use in constant
|
||||
* folding if the node has multiple outputs and will thus be folded multiple times. */
|
||||
@@ -105,6 +110,9 @@ void ConstantFolder::bypass(ShaderOutput *new_output) const
|
||||
void ConstantFolder::discard() const
|
||||
{
|
||||
assert(output->type() == SocketType::CLOSURE);
|
||||
|
||||
VLOG(1) << "Discarding closure " << node->name << ".";
|
||||
|
||||
graph->disconnect(output);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user