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.
This commit is contained in:
Omar Emara 2022-08-19 14:55:25 +02:00
parent 1eeb174e72
commit d94aadf235
1 changed files with 4 additions and 0 deletions

View File

@ -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);