mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-12-20 14:32:00 +00:00
Fix Multithreaded Compilation of Shader Cache on OpenGL (#3540)
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.
This commit is contained in:
parent
842cb26ba5
commit
c48a75979f
1 changed files with 6 additions and 2 deletions
|
@ -434,7 +434,10 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
||||||
_needsHostRegen = true;
|
_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();
|
SignalCompiled();
|
||||||
}
|
}
|
||||||
else if (entry.IsBinary)
|
else if (entry.IsBinary)
|
||||||
|
@ -502,7 +505,8 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache
|
||||||
IProgram hostProgram = _context.Renderer.CreateProgram(shaderSources, shaderInfo);
|
IProgram hostProgram = _context.Renderer.CreateProgram(shaderSources, shaderInfo);
|
||||||
CachedShaderProgram program = new CachedShaderProgram(hostProgram, compilation.SpecializationState, compilation.Shaders);
|
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));
|
EnqueueForValidation(new ProgramEntry(program, binaryCode, compilation.ProgramIndex, compilation.IsCompute, isBinary: false));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue