From 23fd84ffbe9f072c2adbffad123358cdabe137a6 Mon Sep 17 00:00:00 2001 From: Miguel Pozo Date: Mon, 11 Mar 2024 12:25:12 +0100 Subject: [PATCH] Fix #118764: Freezing on Viewport Render Image during shader compilation The shader compilation job assumes it can only be closed on program exit, leaving all their materials as queued. However, render tasks can kill it, causing drw_deferred_shader_add to get stuck in an infinite loop. Pull Request: https://projects.blender.org/blender/blender/pulls/119172 --- source/blender/draw/intern/draw_manager_shader.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source/blender/draw/intern/draw_manager_shader.cc b/source/blender/draw/intern/draw_manager_shader.cc index 769bb5c5594..caa2ca085aa 100644 --- a/source/blender/draw/intern/draw_manager_shader.cc +++ b/source/blender/draw/intern/draw_manager_shader.cc @@ -85,8 +85,6 @@ static void drw_deferred_shader_compilation_exec(void *custom_data, while (true) { if (worker_status->stop != 0) { - /* We don't want user to be able to cancel the compilation - * but wm can kill the task if we are closing blender. */ break; } @@ -151,6 +149,13 @@ static void drw_deferred_shader_compilation_free(void *custom_data) DRWShaderCompiler *comp = (DRWShaderCompiler *)custom_data; BLI_spin_lock(&comp->list_lock); + LISTBASE_FOREACH (LinkData *, link, &comp->queue) { + GPU_material_status_set(static_cast(link->data), GPU_MAT_CREATED); + } + LISTBASE_FOREACH (LinkData *, link, &comp->optimize_queue) { + GPU_material_optimization_status_set(static_cast(link->data), + GPU_MAT_OPTIMIZATION_READY); + } BLI_freelistN(&comp->queue); BLI_freelistN(&comp->optimize_queue); BLI_spin_unlock(&comp->list_lock);