From 089fa6bd547936afcdc98fc95571fe3c44a1b6d2 Mon Sep 17 00:00:00 2001 From: riperiperi Date: Fri, 11 Mar 2022 21:21:08 +0000 Subject: [PATCH] Make more robust to shader compilation failure - Don't freeze when GLSL compilation fails - Background SPIR-V pipeline compile failure results in skipped draws, similar to GLSL compilation failure. --- Ryujinx.Graphics.Vulkan/ShaderCollection.cs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Ryujinx.Graphics.Vulkan/ShaderCollection.cs b/Ryujinx.Graphics.Vulkan/ShaderCollection.cs index 3c8601c43..74894d615 100644 --- a/Ryujinx.Graphics.Vulkan/ShaderCollection.cs +++ b/Ryujinx.Graphics.Vulkan/ShaderCollection.cs @@ -135,6 +135,13 @@ namespace Ryujinx.Graphics.Vulkan { await Task.WhenAll(_shaders.Select(shader => ((Shader)shader).CompileTask)); + if (_shaders.Any(shader => ((Shader)shader).CompileStatus == ProgramLinkStatus.Failure)) + { + LinkStatus = ProgramLinkStatus.Failure; + + return; + } + try { if (_isCompute) @@ -149,6 +156,8 @@ namespace Ryujinx.Graphics.Vulkan catch (VulkanException e) { Logger.Error?.PrintMsg(LogClass.Gpu, $"Background Compilation failed: {e.Message}"); + + LinkStatus = ProgramLinkStatus.Failure; } } @@ -172,7 +181,11 @@ namespace Ryujinx.Graphics.Vulkan _infos[i] = shader.GetInfo(); } - LinkStatus = resultStatus; + // If the link status was already set as failure by background compilation, prefer that decision. + if (LinkStatus != ProgramLinkStatus.Failure) + { + LinkStatus = resultStatus; + } _initialized = true; } @@ -265,6 +278,11 @@ namespace Ryujinx.Graphics.Vulkan if (blocking) { _compileTask.Wait(); + + if (LinkStatus == ProgramLinkStatus.Failure) + { + return ProgramLinkStatus.Failure; + } } else {