From 4fa743af85ecb95cc875d8d8150028719335da0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Wed, 18 May 2022 21:43:21 +0200 Subject: GPUSource: Add error message on source not found Without this, we could have crashes during static compilation of shaders without knowing where it would come from. --- source/blender/gpu/intern/gpu_shader_dependency.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'source/blender') diff --git a/source/blender/gpu/intern/gpu_shader_dependency.cc b/source/blender/gpu/intern/gpu_shader_dependency.cc index aa2033b9154..842914f5bed 100644 --- a/source/blender/gpu/intern/gpu_shader_dependency.cc +++ b/source/blender/gpu/intern/gpu_shader_dependency.cc @@ -670,14 +670,20 @@ Vector gpu_shader_dependency_get_resolved_source( const StringRefNull shader_source_name) { Vector result; - GPUSource *source = g_sources->lookup(shader_source_name); - source->build(result); + GPUSource *src = g_sources->lookup_default(shader_source_name, nullptr); + if (src == nullptr) { + std::cout << "Error source not found : " << shader_source_name << std::endl; + } + src->build(result); return result; } StringRefNull gpu_shader_dependency_get_source(const StringRefNull shader_source_name) { - GPUSource *src = g_sources->lookup(shader_source_name); + GPUSource *src = g_sources->lookup_default(shader_source_name, nullptr); + if (src == nullptr) { + std::cout << "Error source not found : " << shader_source_name << std::endl; + } return src->source; } -- cgit v1.2.3