diff --git a/source/blender/gpu/intern/gpu_shader_create_info.cc b/source/blender/gpu/intern/gpu_shader_create_info.cc index 7e7e71348d3..7c5892c2419 100644 --- a/source/blender/gpu/intern/gpu_shader_create_info.cc +++ b/source/blender/gpu/intern/gpu_shader_create_info.cc @@ -24,6 +24,9 @@ #include "gpu_shader_create_info_private.hh" #include "gpu_shader_dependency_private.hh" +#include +#include + #undef GPU_SHADER_INTERFACE_INFO #undef GPU_SHADER_CREATE_INFO @@ -96,10 +99,19 @@ bool ShaderCreateInfo::is_vulkan_compatible() const void ShaderCreateInfo::finalize() { if (finalized_) { + if (!is_really_finalized_) { + printf("ShaderCreateInfo::finalize name:%s called while other thread is finalizing it\n", + name_.c_str()); + abort(); + } return; } finalized_ = true; + /* Sleep for a bit, to increase probability of threading conflict. */ + using namespace std::chrono_literals; + std::this_thread::sleep_for(50ms); + Set deps_merged; validate_vertex_attributes(); @@ -231,6 +243,8 @@ void ShaderCreateInfo::finalize() set_resource_slot(res); } } + + is_really_finalized_ = true; } std::string ShaderCreateInfo::check_error() const diff --git a/source/blender/gpu/intern/gpu_shader_create_info.hh b/source/blender/gpu/intern/gpu_shader_create_info.hh index c7e10447e97..52cda76b2cb 100644 --- a/source/blender/gpu/intern/gpu_shader_create_info.hh +++ b/source/blender/gpu/intern/gpu_shader_create_info.hh @@ -366,6 +366,7 @@ struct ShaderCreateInfo { bool do_static_compilation_ = false; /** If true, all additionally linked create info will be merged into this one. */ bool finalized_ = false; + bool is_really_finalized_ = false; /** If true, all resources will have an automatic location assigned. */ bool auto_resource_location_ = false; /** If true, force depth and stencil tests to always happen before fragment shader invocation. */