From 940ef330c84d144a705dd358c2bfe2fc690e000e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Fri, 30 May 2025 15:20:58 +0200 Subject: [PATCH] Fix: GPU: Make `StaticShader::ensure_compile_async` request for ready state This was missing from the initial implementation. This did not affect any user code path since they were not checking for completion and only blocking on first `get`. --- source/blender/gpu/GPU_shader.hh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/source/blender/gpu/GPU_shader.hh b/source/blender/gpu/GPU_shader.hh index 427b356d8fa..1939313fc22 100644 --- a/source/blender/gpu/GPU_shader.hh +++ b/source/blender/gpu/GPU_shader.hh @@ -486,12 +486,20 @@ class StaticShader : NonCopyable { /* Schedule the shader to be compile in a worker thread. */ void ensure_compile_async() { - if (shader_ || failed_ || compilation_handle_) { + if (is_ready()) { return; } std::scoped_lock lock(mutex_); + if (compilation_handle_) { + if (GPU_shader_batch_is_ready(compilation_handle_)) { + shader_ = GPU_shader_batch_finalize(compilation_handle_)[0]; + failed_ = shader_ == nullptr; + } + return; + } + if (!shader_ && !failed_ && !compilation_handle_) { BLI_assert(!info_name_.empty()); const GPUShaderCreateInfo *create_info = GPU_shader_create_info_get(info_name_.c_str()); @@ -501,12 +509,12 @@ class StaticShader : NonCopyable { bool is_ready() { - return shader_ != nullptr; + return shader_ || failed_; } GPUShader *get() { - if (shader_ || failed_) { + if (is_ready()) { return shader_; }