diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2016-07-30 21:03:49 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2016-07-31 03:34:34 +0300 |
commit | 1776f75c3b3621a28ed7af535192ce7f05faea8f (patch) | |
tree | 65df1e88a03007dd12444f73308292fd66eb9f06 /intern/cycles/render/constant_fold.h | |
parent | ea2ebf7a00f9adef9c14aaa24b79532b44043eba (diff) |
Cycles: constant fold add/mul type nodes with known 0 and 1 arguments.
These values often either turn the node into a no-op, or even make it
evaluate to 0 no matter what the other input value is, thus allowing
deletion of a branch of the node graph that otherwise is not constant.
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D2085
Diffstat (limited to 'intern/cycles/render/constant_fold.h')
-rw-r--r-- | intern/cycles/render/constant_fold.h | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/intern/cycles/render/constant_fold.h b/intern/cycles/render/constant_fold.h index 195e5b127e8..2b31c2a5887 100644 --- a/intern/cycles/render/constant_fold.h +++ b/intern/cycles/render/constant_fold.h @@ -18,7 +18,7 @@ #define __CONSTANT_FOLD_H__ #include "util_types.h" -#include "util_vector.h" +#include "svm_types.h" CCL_NAMESPACE_BEGIN @@ -37,11 +37,12 @@ public: bool all_inputs_constant() const; - /* Constant folding helpers, always return true for convenience. */ + /* Constant folding helpers */ void make_constant(float value) const; void make_constant(float3 value) const; void make_constant_clamp(float value, bool clamp) const; void make_constant_clamp(float3 value, bool clamp) const; + void make_zero() const; /* Bypass node, relinking to another output socket. */ void bypass(ShaderOutput *output) const; @@ -51,7 +52,16 @@ public: void bypass_or_discard(ShaderInput *input) const; /* Bypass or make constant, unless we can't due to clamp being true. */ - bool try_bypass_or_make_constant(ShaderInput *input, float3 input_value, bool clamp) const; + bool try_bypass_or_make_constant(ShaderInput *input, bool clamp = false) const; + + /* Test if shader inputs of the current nodes have fixed values. */ + bool is_zero(ShaderInput *input) const; + bool is_one(ShaderInput *input) const; + + /* Specific nodes. */ + void fold_mix(NodeMix type, bool clamp) const; + void fold_math(NodeMath type, bool clamp) const; + void fold_vector_math(NodeVectorMath type) const; }; CCL_NAMESPACE_END |