[Bf-blender-cvs] [d94aadf2357] master: Fix: Crash when realtime compositor node is unlinked

Omar Emara noreply at git.blender.org
Fri Aug 19 15:03:18 CEST 2022


Commit: d94aadf2357246bc93f38b8cf021a9e6cc64ed43
Author: Omar Emara
Date:   Fri Aug 19 14:55:25 2022 +0200
Branches: master
https://developer.blender.org/rBd94aadf2357246bc93f38b8cf021a9e6cc64ed43

Fix: Crash when realtime compositor node is unlinked

The realtime compositor crashes when some nodes are unlinked.

This happens for GPU material nodes if it was compiled into its own
shader operation. Since it is unlinked, the shader operation will have
no inputs, a case that the current code didn't consider.

This patch fixes this by skipping code generation for inputs if no
inputs exist for the shader operation.

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

M	source/blender/compositor/realtime_compositor/intern/shader_operation.cc

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

diff --git a/source/blender/compositor/realtime_compositor/intern/shader_operation.cc b/source/blender/compositor/realtime_compositor/intern/shader_operation.cc
index a097c81a4c5..5749d8c5f2e 100644
--- a/source/blender/compositor/realtime_compositor/intern/shader_operation.cc
+++ b/source/blender/compositor/realtime_compositor/intern/shader_operation.cc
@@ -481,6 +481,10 @@ void ShaderOperation::generate_code_for_inputs(GPUMaterial *material,
   /* The attributes of the GPU material represents the inputs of the operation. */
   ListBase attributes = GPU_material_attributes(material);
 
+  if (BLI_listbase_is_empty(&attributes)) {
+    return;
+  }
+
   /* Add a texture sampler for each of the inputs with the same name as the attribute. */
   LISTBASE_FOREACH (GPUMaterialAttribute *, attribute, &attributes) {
     shader_create_info.sampler(0, ImageType::FLOAT_2D, attribute->name, Frequency::BATCH);



More information about the Bf-blender-cvs mailing list