[Bf-blender-cvs] [a04c29e8aba] blender2.8: Fix crash and assert failure when using OCIO GLSL draw mode and color management disabled

Sergey Sharybin noreply at git.blender.org
Mon May 8 17:06:04 CEST 2017


Commit: a04c29e8abae93bb27d22ce1d7322b793fc19fa9
Author: Sergey Sharybin
Date:   Mon May 8 16:45:07 2017 +0200
Branches: blender2.8
https://developer.blender.org/rBa04c29e8abae93bb27d22ce1d7322b793fc19fa9

Fix crash and assert failure when using OCIO GLSL draw mode and color management disabled

The issue was happening when display device is set to None, which makes it so
all the color transformation is a no-op which does not really require any LUT.

This is something we can not know from Blender side easily, because LUT sampling
and related logic is fully done in OCIO library itself. The following happens:

- OCIO sees that no LUT is needed and uses simple pass-through logic in the
  color conversion function.

- GLSL compiles sees that uniform used for LUT is unused in the GLSL code and
  strips it out.

We can not know this from Blender side because technically any conversion to
the same space might be a no-op and that we wouldn't know without some tricky
parse of the OCIO configuration.

So for now we simply avoid crash but are disabling checks for existence of the
uniform.

Ideally would be nice to have some GLSL-code parses which gets the uniforms
from the code itself, so we can distinguish between typo in the uniform name
and uniform being optimized out.

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

M	intern/gawain/src/immediate.c

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

diff --git a/intern/gawain/src/immediate.c b/intern/gawain/src/immediate.c
index 03c097023ce..ae691c71a72 100644
--- a/intern/gawain/src/immediate.c
+++ b/intern/gawain/src/immediate.c
@@ -757,10 +757,20 @@ void immVertex2iv(unsigned attrib_id, const int data[2])
 
 // --- generic uniform functions ---
 
-#if TRUST_NO_ONE
-  #define GET_UNIFORM const ShaderInput* uniform = ShaderInterface_uniform(imm.shader_interface, name); assert(uniform);
+#if 0
+  #if TRUST_NO_ONE
+    #define GET_UNIFORM const ShaderInput* uniform = ShaderInterface_uniform(imm.shader_interface, name); assert(uniform);
+  #else
+    #define GET_UNIFORM const ShaderInput* uniform = ShaderInterface_uniform(imm.shader_interface, name);
+  #endif
 #else
-  #define GET_UNIFORM const ShaderInput* uniform = ShaderInterface_uniform(imm.shader_interface, name);
+/* NOTE: It is possible to have uniform fully optimized out from the shader.
+ * In this case we can't assert failure or allow NULL-pointer dereference.
+ *
+ * TODO(sergey): How can we detect existing-but-optimized-out uniform but still
+ * catch typos in uniform names passed to immUniform*() functions?
+ */
+  #define GET_UNIFORM const ShaderInput* uniform = ShaderInterface_uniform(imm.shader_interface, name); if (uniform == NULL) return;
 #endif
 
 void immUniform1f(const char* name, float x)




More information about the Bf-blender-cvs mailing list