diff options
| author | riperiperi <rhy3756547@hotmail.com> | 2021-04-04 14:01:33 +0100 |
|---|---|---|
| committer | riperiperi <rhy3756547@hotmail.com> | 2021-04-18 17:33:59 +0100 |
| commit | 35eac315ab6f5cfb089422794e695fda3e9cfd53 (patch) | |
| tree | 1edf1131cbf979352351413cd971971ba94ffaf0 | |
| parent | a0aa09912cb8f35ae06834b08308a128886f207f (diff) | |
The task isn't required for loading compute binary.
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs b/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs index 5ee41cdf..aae4d1c7 100644 --- a/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs +++ b/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs @@ -114,7 +114,7 @@ namespace Ryujinx.Graphics.Gpu.Shader // This thread dispatches tasks to do shader translation, and creates programs that OpenGL will link in the background. // The program link status is checked in a non-blocking manner so that multiple shaders can be compiled at once. - + while (programIndex < guestProgramList.Length || activeTasks.Count > 0) { if (activeTasks.Count < maxTaskCount && programIndex < guestProgramList.Length) @@ -168,29 +168,34 @@ namespace Ryujinx.Graphics.Gpu.Shader ShaderProgram program = null; ShaderProgramInfo shaderProgramInfo = null; - Task compileTask = Task.Run(() => + if (isHostProgramValid) { // Reconstruct code holder. - if (isHostProgramValid) - { - program = new ShaderProgram(entry.Header.Stage, ""); - shaderProgramInfo = hostShaderEntries[0].ToShaderProgramInfo(); - } - else - { - IGpuAccessor gpuAccessor = new CachedGpuAccessor(_context, entry.Code, entry.Header.GpuAccessorHeader, entry.TextureDescriptors); - program = Translator.CreateContext(0, gpuAccessor, DefaultFlags | TranslationFlags.Compute).Translate(out shaderProgramInfo); - } - }); + program = new ShaderProgram(entry.Header.Stage, ""); + shaderProgramInfo = hostShaderEntries[0].ToShaderProgramInfo(); - task.OnTask(compileTask, (bool _, ShaderCompileTask task) => - { ShaderCodeHolder shader = new ShaderCodeHolder(program, shaderProgramInfo, entry.Code); + _cpProgramsDiskCache.Add(key, new ShaderBundle(hostProgram, shader)); + + return true; + } + else + { // If the host program was rejected by the gpu driver or isn't in cache, try to build from program sources again. - if (!isHostProgramValid) + + Task compileTask = Task.Run(() => + { + IGpuAccessor gpuAccessor = new CachedGpuAccessor(_context, entry.Code, entry.Header.GpuAccessorHeader, entry.TextureDescriptors); + + program = Translator.CreateContext(0, gpuAccessor, DefaultFlags | TranslationFlags.Compute).Translate(out shaderProgramInfo); + }); + + task.OnTask(compileTask, (bool _, ShaderCompileTask task) => { + ShaderCodeHolder shader = new ShaderCodeHolder(program, shaderProgramInfo, entry.Code); + Logger.Info?.Print(LogClass.Gpu, $"Host shader {key} got invalidated, rebuilding from guest..."); // Compile shader and create program as the shader program binary got invalidated. @@ -222,18 +227,12 @@ namespace Ryujinx.Graphics.Gpu.Shader }); return false; // Not finished: still need to compile the host program. - } - else - { - _cpProgramsDiskCache.Add(key, new ShaderBundle(hostProgram, shader)); + }); - return true; - } - }); - - return false; // Not finished: translating the shaders. + return false; // Not finished: translating the program. + } }); - + } else { @@ -394,7 +393,7 @@ namespace Ryujinx.Graphics.Gpu.Shader } }); - return false; // Not finished: translating the shaders. + return false; // Not finished: translating the program. }); } |
