From 654cc9ed36933fa4de8ec47efe9080eca891065b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cle=CC=81ment=20Foucault?= Date: Fri, 8 Nov 2024 20:20:07 +0100 Subject: [PATCH] GPU: Fix printf force injection logic and limit it to material shader This fixes backend error caused by missing resource. --- source/blender/gpu/intern/gpu_shader_create_info.cc | 3 ++- source/blender/gpu/intern/gpu_shader_dependency.cc | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/source/blender/gpu/intern/gpu_shader_create_info.cc b/source/blender/gpu/intern/gpu_shader_create_info.cc index efe9a095be9..1bb023456d8 100644 --- a/source/blender/gpu/intern/gpu_shader_create_info.cc +++ b/source/blender/gpu/intern/gpu_shader_create_info.cc @@ -556,8 +556,9 @@ void gpu_shader_create_info_init() info->builtins_ |= gpu_shader_dependency_get_builtins(info->compute_source_); #if GPU_SHADER_PRINTF_ENABLE + const bool is_material_shader = info->name_.startswith("eevee_surf_"); if ((info->builtins_ & BuiltinBits::USE_PRINTF) == BuiltinBits::USE_PRINTF || - gpu_shader_dependency_force_gpu_print_injection()) + (gpu_shader_dependency_force_gpu_print_injection() && is_material_shader)) { info->additional_info("gpu_print"); } diff --git a/source/blender/gpu/intern/gpu_shader_dependency.cc b/source/blender/gpu/intern/gpu_shader_dependency.cc index 6da52d2315f..3ee0a566924 100644 --- a/source/blender/gpu/intern/gpu_shader_dependency.cc +++ b/source/blender/gpu/intern/gpu_shader_dependency.cc @@ -463,7 +463,7 @@ void gpu_shader_dependency_init() /* Detect if there is any printf in node lib files. * See gpu_shader_dependency_force_gpu_print_injection(). */ for (auto *value : g_sources->values()) { - if ((value->builtins & shader::BuiltinBits::USE_PRINTF) != shader::BuiltinBits::USE_PRINTF) { + if (bool(value->builtins & shader::BuiltinBits::USE_PRINTF)) { if (value->filename.startswith("gpu_shader_material_")) { force_printf_injection = true; break;