aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs
diff options
context:
space:
mode:
authorriperiperi <rhy3756547@hotmail.com>2022-08-03 23:37:56 +0100
committerGitHub <noreply@github.com>2022-08-03 19:37:56 -0300
commitc48a75979fad2cf7909f128e265086ff83c2ba55 (patch)
treeda0a2768a2316afcb8f1564fdfba1ee1bbe68a86 /Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs
parent842cb26ba55382874f4cabe641efa0ad124d0fac (diff)
Fix Multithreaded Compilation of Shader Cache on OpenGL (#3540)1.1.206
This was broken by the Vulkan changes - OpenGL was building host caches at boot on one thread, which is very notably slower than when it is multithreaded. This was caused by trying to get the program binary immediately after compilation started, which blocks. Now it does it after compilation has completed.
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs')
-rw-r--r--Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs8
1 files changed, 6 insertions, 2 deletions
diff --git a/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs b/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs
index 7bf1cf4b..cb70811b 100644
--- a/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs
+++ b/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs
@@ -434,7 +434,10 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
_needsHostRegen = true;
}
- _programList.Add(entry.ProgramIndex, (entry.CachedProgram, entry.BinaryCode));
+ // Fetch the binary code from the backend if it isn't already present.
+ byte[] binaryCode = entry.BinaryCode ?? entry.CachedProgram.HostProgram.GetBinary();
+
+ _programList.Add(entry.ProgramIndex, (entry.CachedProgram, binaryCode));
SignalCompiled();
}
else if (entry.IsBinary)
@@ -502,7 +505,8 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
IProgram hostProgram = _context.Renderer.CreateProgram(shaderSources, shaderInfo);
CachedShaderProgram program = new CachedShaderProgram(hostProgram, compilation.SpecializationState, compilation.Shaders);
- byte[] binaryCode = _context.Capabilities.Api == TargetApi.Vulkan ? ShaderBinarySerializer.Pack(shaderSources) : hostProgram.GetBinary();
+ // Vulkan's binary code is the SPIR-V used for compilation, so it is ready immediately. Other APIs get this after compilation.
+ byte[] binaryCode = _context.Capabilities.Api == TargetApi.Vulkan ? ShaderBinarySerializer.Pack(shaderSources) : null;
EnqueueForValidation(new ProgramEntry(program, binaryCode, compilation.ProgramIndex, compilation.IsCompute, isBinary: false));
}