diff options
author | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2021-06-29 00:15:32 +0300 |
---|---|---|
committer | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2021-06-29 17:24:21 +0300 |
commit | e7fc15e2ef222b90e24594cdffe85894ff007e09 (patch) | |
tree | 296b660f3bc4d7d62e5a4b4bfe6850fc651044b8 /intern | |
parent | d1e0059eac99654624edee2a2390a3e2fdc4c7cb (diff) |
Fix T70615: Cycles ignores BSDF inputs when nodes are optimized
When compiling BSDF nodes, we only assing stack space to the normal and
tangent inputs if they are linked. However, it could be that the
ConstantFolder removed the link, so checking if there is a link fails
to take this into account.
To fix this, added a flag to ShaderInput to keep track of whether a
constant was folded into the input, and use it as well to verify that
the socket is linked when assigning stack space.
Reviewed By: brecht
Maniphest Tasks: T70615
Differential Revision: https://developer.blender.org/D11731
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/render/constant_fold.cpp | 2 | ||||
-rw-r--r-- | intern/cycles/render/graph.h | 10 | ||||
-rw-r--r-- | intern/cycles/render/svm.cpp | 2 |
3 files changed, 12 insertions, 2 deletions
diff --git a/intern/cycles/render/constant_fold.cpp b/intern/cycles/render/constant_fold.cpp index 800056d2899..a4d40ae8183 100644 --- a/intern/cycles/render/constant_fold.cpp +++ b/intern/cycles/render/constant_fold.cpp @@ -48,6 +48,7 @@ void ConstantFolder::make_constant(float value) const foreach (ShaderInput *sock, output->links) { sock->set(value); + sock->constant_folded_in = true; } graph->disconnect(output); @@ -59,6 +60,7 @@ void ConstantFolder::make_constant(float3 value) const foreach (ShaderInput *sock, output->links) { sock->set(value); + sock->constant_folded_in = true; } graph->disconnect(output); diff --git a/intern/cycles/render/graph.h b/intern/cycles/render/graph.h index f6ee708b3f8..24de06123ca 100644 --- a/intern/cycles/render/graph.h +++ b/intern/cycles/render/graph.h @@ -79,7 +79,11 @@ enum ShaderNodeSpecialType { class ShaderInput { public: ShaderInput(const SocketType &socket_type_, ShaderNode *parent_) - : socket_type(socket_type_), parent(parent_), link(NULL), stack_offset(SVM_STACK_INVALID) + : socket_type(socket_type_), + parent(parent_), + link(NULL), + stack_offset(SVM_STACK_INVALID), + constant_folded_in(false) { } @@ -111,6 +115,10 @@ class ShaderInput { ShaderNode *parent; ShaderOutput *link; int stack_offset; /* for SVM compiler */ + + /* Keeps track of whether a constant was folded in this socket, to avoid over-optimizing when the + * link is null. */ + bool constant_folded_in; }; /* Output diff --git a/intern/cycles/render/svm.cpp b/intern/cycles/render/svm.cpp index 5c793c5c016..dcb3976e15c 100644 --- a/intern/cycles/render/svm.cpp +++ b/intern/cycles/render/svm.cpp @@ -304,7 +304,7 @@ int SVMCompiler::stack_assign(ShaderOutput *output) int SVMCompiler::stack_assign_if_linked(ShaderInput *input) { - if (input->link) + if (input->link || input->constant_folded_in) return stack_assign(input); return SVM_STACK_INVALID; |