gl_graphics_pipeline: Use GLsync objects only when building in parallel

This commit is contained in:
ameerj
2022-02-27 17:14:25 -05:00
parent cb9d3c78c5
commit b72ca10c94

View File

@@ -229,9 +229,10 @@ GraphicsPipeline::GraphicsPipeline(
if (key.xfb_enabled && device.UseAssemblyShaders()) { if (key.xfb_enabled && device.UseAssemblyShaders()) {
GenerateTransformFeedbackState(); GenerateTransformFeedbackState();
} }
const bool in_parallel = thread_worker != nullptr;
const auto backend = device.GetShaderBackend(); const auto backend = device.GetShaderBackend();
auto func{[this, sources = std::move(sources), sources_spirv = std::move(sources_spirv), auto func{[this, sources = std::move(sources), sources_spirv = std::move(sources_spirv),
shader_notify, backend](ShaderContext::Context*) mutable { shader_notify, backend, in_parallel](ShaderContext::Context*) mutable {
for (size_t stage = 0; stage < 5; ++stage) { for (size_t stage = 0; stage < 5; ++stage) {
switch (backend) { switch (backend) {
case Settings::ShaderBackend::GLSL: case Settings::ShaderBackend::GLSL:
@@ -251,12 +252,14 @@ GraphicsPipeline::GraphicsPipeline(
break; break;
} }
} }
{ if (in_parallel) {
std::lock_guard lock{built_mutex}; std::lock_guard lock{built_mutex};
built_fence.Create(); built_fence.Create();
// Flush this context to ensure compilation commands and fence are in the GPU pipe. // Flush this context to ensure compilation commands and fence are in the GPU pipe.
glFlush(); glFlush();
built_condvar.notify_one(); built_condvar.notify_one();
} else {
is_built = true;
} }
if (shader_notify) { if (shader_notify) {
shader_notify->MarkShaderComplete(); shader_notify->MarkShaderComplete();