Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmar Emara <mail@OmarEmara.dev>2022-08-19 15:55:25 +0300
committerOmar Emara <mail@OmarEmara.dev>2022-08-19 16:03:14 +0300
commitd94aadf2357246bc93f38b8cf021a9e6cc64ed43 (patch)
treec629d7ad02cd39bc1383bc78e2c617dedea257e1
parent1eeb174e724cd32aab446d2b0fe2f5508e0e0740 (diff)
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.
-rw-r--r--source/blender/compositor/realtime_compositor/intern/shader_operation.cc4
1 files changed, 4 insertions, 0 deletions
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);