From 62165661662a2153f5de1b0131652e1963dcd845 Mon Sep 17 00:00:00 2001 From: sunshineinabox Date: Mon, 30 Sep 2024 18:15:37 -0700 Subject: [PATCH] Update disk cache code generation version and use HashSet for processed pipelines Use a hashset to compare against all generated pipelines vs only against the most recent one. --- .../Shader/DiskCache/DiskCacheHostStorage.cs | 2 +- .../Shader/DiskCache/ParallelDiskCacheLoader.cs | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs index 3f3c3723d..32a592cb9 100644 --- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs +++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/DiskCacheHostStorage.cs @@ -22,7 +22,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache private const ushort FileFormatVersionMajor = 1; private const ushort FileFormatVersionMinor = 2; private const uint FileFormatVersionPacked = ((uint)FileFormatVersionMajor << 16) | FileFormatVersionMinor; - private const uint CodeGenVersion = 7332; + private const uint CodeGenVersion = 6877; private const string SharedTocFileName = "shared.toc"; private const string SharedDataFileName = "shared.data"; diff --git a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs index 2661a828b..1aec895f0 100644 --- a/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs +++ b/src/Ryujinx.Graphics.Gpu/Shader/DiskCache/ParallelDiskCacheLoader.cs @@ -22,6 +22,8 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache private readonly CancellationToken _cancellationToken; private readonly Action _stateChangeCallback; + private readonly HashSet _pipelineStateSet = new(); + /// /// Indicates if the cache should be loaded. /// @@ -302,7 +304,6 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache using var streams = _hostStorage.GetOutputStreams(_context); int packagedShaders = 0; - ProgramPipelineState previousPipelineState = default; ProgramPipelineState currentPipelineState = default; foreach (var kv in _programList) @@ -333,7 +334,6 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache currentPipelineState.PrimitiveRestartEnable = false; currentPipelineState.BiasEnable = 0; currentPipelineState.RasterizerDiscard = false; - } if (_context.Capabilities.SupportsLogicOpDynamicState) @@ -347,19 +347,20 @@ namespace Ryujinx.Graphics.Gpu.Shader.DiskCache } } - if (!currentPipelineState.Equals(previousPipelineState) || !_context.Capabilities.SupportsExtendedDynamicState || !program.SpecializationState.PipelineState.HasValue) + if (!_pipelineStateSet.Contains(currentPipelineState) || + !_context.Capabilities.SupportsExtendedDynamicState || + !program.SpecializationState.PipelineState.HasValue) { _hostStorage.AddShader(_context, program, binaryCode, streams); _stateChangeCallback(ShaderCacheState.Packaging, ++packagedShaders, _programList.Count); - } - if (_context.Capabilities.SupportsExtendedDynamicState) - { - previousPipelineState = currentPipelineState; + if (_context.Capabilities.SupportsExtendedDynamicState) + { + _pipelineStateSet.Add(currentPipelineState); + } } } - Logger.Info?.Print(LogClass.Gpu, $"Rebuilt {packagedShaders} shaders successfully."); } else