From 1dd69912b159073b3714b58fd8b2e4555db8eacc Mon Sep 17 00:00:00 2001 From: Evan Husted Date: Sun, 29 Dec 2024 03:02:56 -0600 Subject: [PATCH] Partial revert, decouple TitleIDs.CurrentApplication from shader cache stuff; as I want that to ALWAYS reflect the current app. --- src/Ryujinx.Common/TitleIDs.cs | 2 +- src/Ryujinx.Graphics.Gpu/GraphicsConfig.cs | 6 ++++++ src/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs | 4 ++-- .../Loaders/Processes/Extensions/FileSystemExtensions.cs | 4 +++- src/Ryujinx.HLE/Loaders/Processes/ProcessLoader.cs | 6 +++++- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Ryujinx.Common/TitleIDs.cs b/src/Ryujinx.Common/TitleIDs.cs index aa858b763..a50121943 100644 --- a/src/Ryujinx.Common/TitleIDs.cs +++ b/src/Ryujinx.Common/TitleIDs.cs @@ -8,7 +8,7 @@ namespace Ryujinx.Common { public static class TitleIDs { - public static Optional CurrentApplication; + public static Optional CurrentApplication { get; set; } public static GraphicsBackend SelectGraphicsBackend(string titleId, GraphicsBackend currentBackend) { diff --git a/src/Ryujinx.Graphics.Gpu/GraphicsConfig.cs b/src/Ryujinx.Graphics.Gpu/GraphicsConfig.cs index 6b2a57ad9..066ac28f7 100644 --- a/src/Ryujinx.Graphics.Gpu/GraphicsConfig.cs +++ b/src/Ryujinx.Graphics.Gpu/GraphicsConfig.cs @@ -46,6 +46,12 @@ namespace Ryujinx.Graphics.Gpu /// Enables or disables high-level emulation of common GPU Macro code. /// public static bool EnableMacroHLE = true; + + /// + /// Title id of the current running game. + /// Used by the shader cache. + /// + public static string TitleId; /// /// Enables or disables the shader cache. diff --git a/src/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs b/src/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs index 2f4d98b9b..3a02eb615 100644 --- a/src/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs +++ b/src/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs @@ -117,8 +117,8 @@ namespace Ryujinx.Graphics.Gpu.Shader /// private static string GetDiskCachePath() { - return GraphicsConfig.EnableShaderCache && TitleIDs.CurrentApplication.HasValue - ? Path.Combine(AppDataManager.GamesDirPath, TitleIDs.CurrentApplication, "cache", "shader") + return GraphicsConfig.EnableShaderCache && GraphicsConfig.TitleId != null + ? Path.Combine(AppDataManager.GamesDirPath, GraphicsConfig.TitleId, "cache", "shader") : null; } diff --git a/src/Ryujinx.HLE/Loaders/Processes/Extensions/FileSystemExtensions.cs b/src/Ryujinx.HLE/Loaders/Processes/Extensions/FileSystemExtensions.cs index e4a5a547d..00ae4e5e1 100644 --- a/src/Ryujinx.HLE/Loaders/Processes/Extensions/FileSystemExtensions.cs +++ b/src/Ryujinx.HLE/Loaders/Processes/Extensions/FileSystemExtensions.cs @@ -7,6 +7,7 @@ using LibHac.Tools.FsSystem; using Ryujinx.Common; using Ryujinx.Common.Configuration; using Ryujinx.Common.Logging; +using Ryujinx.Graphics.Gpu; using Ryujinx.HLE.Loaders.Executables; using Ryujinx.Memory; using System; @@ -103,7 +104,8 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions } // Initialize GPU. - TitleIDs.CurrentApplication = programId.ToString("X16"); + GraphicsConfig.TitleId = programId.ToString("X16"); + TitleIDs.CurrentApplication = GraphicsConfig.TitleId; device.Gpu.HostInitalized.Set(); if (!MemoryBlock.SupportsFlags(MemoryAllocationFlags.ViewCompatible)) diff --git a/src/Ryujinx.HLE/Loaders/Processes/ProcessLoader.cs b/src/Ryujinx.HLE/Loaders/Processes/ProcessLoader.cs index 3e1929204..7a0c486bb 100644 --- a/src/Ryujinx.HLE/Loaders/Processes/ProcessLoader.cs +++ b/src/Ryujinx.HLE/Loaders/Processes/ProcessLoader.cs @@ -8,6 +8,7 @@ using LibHac.Tools.FsSystem; using LibHac.Tools.FsSystem.NcaUtils; using Ryujinx.Common; using Ryujinx.Common.Logging; +using Ryujinx.Graphics.Gpu; using Ryujinx.HLE.Loaders.Executables; using Ryujinx.HLE.Loaders.Processes.Extensions; using System; @@ -184,14 +185,17 @@ namespace Ryujinx.HLE.Loaders.Processes if (nacpData.Value.PresenceGroupId != 0) { programId = nacpData.Value.PresenceGroupId; + TitleIDs.CurrentApplication = programId.ToString("X16"); } else if (nacpData.Value.SaveDataOwnerId != 0) { programId = nacpData.Value.SaveDataOwnerId; + TitleIDs.CurrentApplication = programId.ToString("X16"); } else if (nacpData.Value.AddOnContentBaseId != 0) { programId = nacpData.Value.AddOnContentBaseId - 0x1000; + TitleIDs.CurrentApplication = programId.ToString("X16"); } } @@ -205,7 +209,7 @@ namespace Ryujinx.HLE.Loaders.Processes } // Explicitly null TitleId to disable the shader cache. - TitleIDs.CurrentApplication = default; + GraphicsConfig.TitleId = null; _device.Gpu.HostInitalized.Set(); ProcessResult processResult = ProcessLoaderHelper.LoadNsos(_device,