From d10a478cce295afe1de64c54fd9c265101047720 Mon Sep 17 00:00:00 2001 From: Otozinclus <58051309+Otozinclus@users.noreply.github.com> Date: Mon, 30 Dec 2024 08:12:51 +0100 Subject: [PATCH] Shader translation delay hack (#469) A workaround to avoid a freeze when translating shaders with the Metal backend, that would happen after changing version or going from Vulkan to Metal. Adds a delay in milliseconds, configurable in the UI behind the Dirty Hacks mechanism. --------- Co-authored-by: Evan Husted --- .../Shader/DiskCache/ParallelDiskCacheLoader.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs index 74922d1e3..9aa96a76f 100644 --- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs +++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs @@ -1,3 +1,4 @@ +using Ryujinx.Common.Configuration; using Ryujinx.Common.Logging; using Ryujinx.Graphics.GAL; using Ryujinx.Graphics.Shader; @@ -366,6 +367,9 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache { try { + if (_context.DirtyHacks.IsEnabled(DirtyHacks.ShaderCompilationThreadSleep)) + Thread.Sleep(_context.DirtyHacks[DirtyHacks.ShaderCompilationThreadSleep]); + AsyncProgramTranslation asyncTranslation = new(guestShaders, specState, programIndex, isCompute); _asyncTranslationQueue.Add(asyncTranslation, _cancellationToken); }