Browse Source

Partial revert, decouple TitleIDs.CurrentApplication from shader cache stuff; as I want that to ALWAYS reflect the current app.

Evan Husted 1 year ago
parent
commit
1dd69912b1

+ 1 - 1
src/Ryujinx.Common/TitleIDs.cs

@@ -8,7 +8,7 @@ namespace Ryujinx.Common
 {
 {
     public static class TitleIDs
     public static class TitleIDs
     {
     {
-        public static Optional<string> CurrentApplication;
+        public static Optional<string> CurrentApplication { get; set; }
         
         
         public static GraphicsBackend SelectGraphicsBackend(string titleId, GraphicsBackend currentBackend)
         public static GraphicsBackend SelectGraphicsBackend(string titleId, GraphicsBackend currentBackend)
         {
         {

+ 6 - 0
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.
         /// Enables or disables high-level emulation of common GPU Macro code.
         /// </summary>
         /// </summary>
         public static bool EnableMacroHLE = true;
         public static bool EnableMacroHLE = true;
+        
+        /// <summary>
+        /// Title id of the current running game.
+        /// Used by the shader cache.
+        /// </summary>
+        public static string TitleId;
 
 
         /// <summary>
         /// <summary>
         /// Enables or disables the shader cache.
         /// Enables or disables the shader cache.

+ 2 - 2
src/Ryujinx.Graphics.Gpu/Shader/ShaderCache.cs

@@ -117,8 +117,8 @@ namespace Ryujinx.Graphics.Gpu.Shader
         /// </summary>
         /// </summary>
         private static string GetDiskCachePath()
         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;
                 : null;
         }
         }
 
 

+ 3 - 1
src/Ryujinx.HLE/Loaders/Processes/Extensions/FileSystemExtensions.cs

@@ -7,6 +7,7 @@ using LibHac.Tools.FsSystem;
 using Ryujinx.Common;
 using Ryujinx.Common;
 using Ryujinx.Common.Configuration;
 using Ryujinx.Common.Configuration;
 using Ryujinx.Common.Logging;
 using Ryujinx.Common.Logging;
+using Ryujinx.Graphics.Gpu;
 using Ryujinx.HLE.Loaders.Executables;
 using Ryujinx.HLE.Loaders.Executables;
 using Ryujinx.Memory;
 using Ryujinx.Memory;
 using System;
 using System;
@@ -103,7 +104,8 @@ namespace Ryujinx.HLE.Loaders.Processes.Extensions
             }
             }
 
 
             // Initialize GPU.
             // Initialize GPU.
-            TitleIDs.CurrentApplication = programId.ToString("X16");
+            GraphicsConfig.TitleId = programId.ToString("X16");
+            TitleIDs.CurrentApplication = GraphicsConfig.TitleId;
             device.Gpu.HostInitalized.Set();
             device.Gpu.HostInitalized.Set();
 
 
             if (!MemoryBlock.SupportsFlags(MemoryAllocationFlags.ViewCompatible))
             if (!MemoryBlock.SupportsFlags(MemoryAllocationFlags.ViewCompatible))

+ 5 - 1
src/Ryujinx.HLE/Loaders/Processes/ProcessLoader.cs

@@ -8,6 +8,7 @@ using LibHac.Tools.FsSystem;
 using LibHac.Tools.FsSystem.NcaUtils;
 using LibHac.Tools.FsSystem.NcaUtils;
 using Ryujinx.Common;
 using Ryujinx.Common;
 using Ryujinx.Common.Logging;
 using Ryujinx.Common.Logging;
+using Ryujinx.Graphics.Gpu;
 using Ryujinx.HLE.Loaders.Executables;
 using Ryujinx.HLE.Loaders.Executables;
 using Ryujinx.HLE.Loaders.Processes.Extensions;
 using Ryujinx.HLE.Loaders.Processes.Extensions;
 using System;
 using System;
@@ -184,14 +185,17 @@ namespace Ryujinx.HLE.Loaders.Processes
                     if (nacpData.Value.PresenceGroupId != 0)
                     if (nacpData.Value.PresenceGroupId != 0)
                     {
                     {
                         programId = nacpData.Value.PresenceGroupId;
                         programId = nacpData.Value.PresenceGroupId;
+                        TitleIDs.CurrentApplication = programId.ToString("X16");
                     }
                     }
                     else if (nacpData.Value.SaveDataOwnerId != 0)
                     else if (nacpData.Value.SaveDataOwnerId != 0)
                     {
                     {
                         programId = nacpData.Value.SaveDataOwnerId;
                         programId = nacpData.Value.SaveDataOwnerId;
+                        TitleIDs.CurrentApplication = programId.ToString("X16");
                     }
                     }
                     else if (nacpData.Value.AddOnContentBaseId != 0)
                     else if (nacpData.Value.AddOnContentBaseId != 0)
                     {
                     {
                         programId = nacpData.Value.AddOnContentBaseId - 0x1000;
                         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.
             // Explicitly null TitleId to disable the shader cache.
-            TitleIDs.CurrentApplication = default;
+            GraphicsConfig.TitleId = null;
             _device.Gpu.HostInitalized.Set();
             _device.Gpu.HostInitalized.Set();
 
 
             ProcessResult processResult = ProcessLoaderHelper.LoadNsos(_device,
             ProcessResult processResult = ProcessLoaderHelper.LoadNsos(_device,