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_; }