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`.
This commit is contained in:
Clément Foucault
2025-05-30 15:20:58 +02:00
parent f82673afd9
commit 940ef330c8

View File

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