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:
Alexander Gavrilov 2016-08-01 18:53:20 +03:00
parent 473fc0cf0e
commit 138362a3c9
3 changed files with 1323 additions and 9 deletions

@ -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);
}

@ -26,12 +26,12 @@ set(ALL_CYCLES_LIBRARIES
cycles_device
cycles_bvh
cycles_graph
cycles_kernel_osl
cycles_util
${OPENIMAGEIO_LIBRARIES}
)
if(WITH_CYCLES_OSL)
list(APPEND ALL_CYCLES_LIBRARIES
cycles_kernel_osl
${OSL_LIBRARIES}
${LLVM_LIBRARIES}
)

File diff suppressed because it is too large Load Diff