[Bf-blender-cvs] [aaa731a7823] master: Partially fix T101702: OSL Shaders with boolean inputs crash

Lukas Stockner noreply at git.blender.org
Mon Oct 10 01:33:44 CEST 2022


Commit: aaa731a7823a986c37745a9c48b485ce03205593
Author: Lukas Stockner
Date:   Mon Oct 10 01:03:12 2022 +0200
Branches: master
https://developer.blender.org/rBaaa731a7823a986c37745a9c48b485ce03205593

Partially fix T101702: OSL Shaders with boolean inputs crash

OSL (like Cycles) has no internal boolean type, instead an integer
input can be flagged to be shown as a boolean in the UI.
Cycles reacts to this by creating a boolean socket on the Blender
side, but as a result incorrectly called the boolean overload of the
set function even though the internal type is an integer.

There's another unrelated crash in the GPU viewport shader code that
appears to apply to every OSL node that outputs a shader, and the file
in T101702 triggers both, so this is only a partial fix for the report.

===================================================================

M	intern/cycles/blender/shader.cpp

===================================================================

diff --git a/intern/cycles/blender/shader.cpp b/intern/cycles/blender/shader.cpp
index fd32e7ca1d7..dbc49df7f22 100644
--- a/intern/cycles/blender/shader.cpp
+++ b/intern/cycles/blender/shader.cpp
@@ -215,7 +215,9 @@ static void set_default_value(ShaderInput *input,
     }
     case SocketType::INT: {
       if (b_sock.type() == BL::NodeSocket::type_BOOLEAN) {
-        node->set(socket, get_boolean(b_sock.ptr, "default_value"));
+        /* Make sure to call the int overload of set() since this is an integer socket as far as
+         * Cycles is concerned. */
+        node->set(socket, get_boolean(b_sock.ptr, "default_value") ? 1 : 0);
       }
       else {
         node->set(socket, get_int(b_sock.ptr, "default_value"));



More information about the Bf-blender-cvs mailing list