From 94f34a9ed148623f1f412d48b553eda9e58438a4 Mon Sep 17 00:00:00 2001 From: Evan Husted Date: Tue, 4 Mar 2025 01:19:18 -0600 Subject: [PATCH] properly merge + move hleconfig tick scalar parameter --- src/Ryujinx.Cpu/ITickSource.cs | 2 + src/Ryujinx.HLE/HleConfiguration.cs | 4 +- src/Ryujinx.HLE/Switch.cs | 7 +- src/Ryujinx/AppHost.cs | 71 ++++----------- src/Ryujinx/Headless/HeadlessRyujinx.Init.cs | 86 +++++++++---------- .../Configuration/ConfigurationState.Model.cs | 2 +- 6 files changed, 66 insertions(+), 106 deletions(-) diff --git a/src/Ryujinx.Cpu/ITickSource.cs b/src/Ryujinx.Cpu/ITickSource.cs index c352df85a..4aff612f0 100644 --- a/src/Ryujinx.Cpu/ITickSource.cs +++ b/src/Ryujinx.Cpu/ITickSource.cs @@ -8,6 +8,8 @@ namespace Ryujinx.Cpu /// public interface ITickSource : ICounter { + public const long RealityTickScalar = 100; + /// /// Time elapsed since the counter was created. /// diff --git a/src/Ryujinx.HLE/HleConfiguration.cs b/src/Ryujinx.HLE/HleConfiguration.cs index 4d7b9d350..39745ff53 100644 --- a/src/Ryujinx.HLE/HleConfiguration.cs +++ b/src/Ryujinx.HLE/HleConfiguration.cs @@ -206,6 +206,7 @@ namespace Ryujinx.HLE VSyncMode vSyncMode, bool enableDockedMode, bool enablePtc, + long tickScalar, bool enableInternetAccess, IntegrityCheckLevel fsIntegrityCheckLevel, int fsGlobalAccessLogMode, @@ -222,7 +223,6 @@ namespace Ryujinx.HLE string multiplayerLdnPassphrase, string multiplayerLdnServer, int customVSyncInterval, - long tickScalar, EnabledDirtyHack[] dirtyHacks = null) { MemoryConfiguration = memoryConfiguration; @@ -232,6 +232,7 @@ namespace Ryujinx.HLE CustomVSyncInterval = customVSyncInterval; EnableDockedMode = enableDockedMode; EnablePtc = enablePtc; + TickScalar = tickScalar; EnableInternetAccess = enableInternetAccess; FsIntegrityCheckLevel = fsIntegrityCheckLevel; FsGlobalAccessLogMode = fsGlobalAccessLogMode; @@ -247,7 +248,6 @@ namespace Ryujinx.HLE MultiplayerDisableP2p = multiplayerDisableP2p; MultiplayerLdnPassphrase = multiplayerLdnPassphrase; MultiplayerLdnServer = multiplayerLdnServer; - TickScalar = tickScalar; Hacks = dirtyHacks ?? []; } diff --git a/src/Ryujinx.HLE/Switch.cs b/src/Ryujinx.HLE/Switch.cs index d973a30fc..e52b3df15 100644 --- a/src/Ryujinx.HLE/Switch.cs +++ b/src/Ryujinx.HLE/Switch.cs @@ -4,6 +4,7 @@ using Ryujinx.Audio.Backends.CompatLayer; using Ryujinx.Audio.Integration; using Ryujinx.Common; using Ryujinx.Common.Configuration; +using Ryujinx.Cpu; using Ryujinx.Graphics.Gpu; using Ryujinx.HLE.FileSystem; using Ryujinx.HLE.HOS; @@ -31,7 +32,7 @@ namespace Ryujinx.HLE public long TickScalar { - get => System?.TickSource?.TickScalar ?? 100; + get => System?.TickSource?.TickScalar ?? ITickSource.RealityTickScalar; set => System.TickSource.TickScalar = value; } @@ -83,7 +84,7 @@ namespace Ryujinx.HLE VSyncMode = Configuration.VSyncMode; CustomVSyncInterval = Configuration.CustomVSyncInterval; - TickScalar = TurboMode ? Configuration.TickScalar : 100; + TickScalar = TurboMode ? Configuration.TickScalar : ITickSource.RealityTickScalar; System.State.DockedMode = Configuration.EnableDockedMode; System.PerformanceState.PerformanceMode = System.State.DockedMode ? PerformanceMode.Boost : PerformanceMode.Default; System.EnablePtc = Configuration.EnablePtc; @@ -138,7 +139,7 @@ namespace Ryujinx.HLE public void ToggleTurbo() { TurboMode = !TurboMode; - TickScalar = TurboMode ? Configuration.TickScalar : 100; + TickScalar = TurboMode ? Configuration.TickScalar : ITickSource.RealityTickScalar; } public bool LoadCart(string exeFsDir, string romFsFile = null) => Processes.LoadUnpackedNca(exeFsDir, romFsFile); diff --git a/src/Ryujinx/AppHost.cs b/src/Ryujinx/AppHost.cs index 9901d4724..c2fb8b873 100644 --- a/src/Ryujinx/AppHost.cs +++ b/src/Ryujinx/AppHost.cs @@ -7,7 +7,6 @@ using DiscordRPC; using Gommon; using LibHac.Common; using LibHac.Ns; -using LibHac.Tools.FsSystem; using Ryujinx.Audio.Backends.Dummy; using Ryujinx.Audio.Backends.OpenAL; using Ryujinx.Audio.Backends.SDL2; @@ -36,11 +35,9 @@ using Ryujinx.Graphics.GAL.Multithreading; using Ryujinx.Graphics.Gpu; using Ryujinx.Graphics.OpenGL; using Ryujinx.Graphics.Vulkan; -using Ryujinx.HLE; using Ryujinx.HLE.FileSystem; using Ryujinx.HLE.HOS; using Ryujinx.HLE.HOS.Services.Account.Acc; -using Ryujinx.HLE.HOS.SystemState; using Ryujinx.Input; using Ryujinx.Input.HLE; using SkiaSharp; @@ -903,54 +900,19 @@ namespace Ryujinx.Ava _ => new OpenGLRenderer() }; - BackendThreading threadingMode = ConfigurationState.Instance.Graphics.BackendThreading; - - bool isGALThreaded = threadingMode == BackendThreading.On || (threadingMode == BackendThreading.Auto && renderer.PreferThreading); - if (isGALThreaded) - { - renderer = new ThreadedRenderer(renderer); - } - - Logger.Info?.PrintMsg(LogClass.Gpu, $"Backend Threading ({threadingMode}): {isGALThreaded}"); - // Initialize Configuration. - MemoryConfiguration memoryConfiguration = ConfigurationState.Instance.System.DramSize.Value; - - Device = new Switch(new HLEConfiguration( - VirtualFileSystem, - _viewModel.LibHacHorizonManager, - ContentManager, - _accountManager, - _userChannelPersistence, - renderer, - InitializeAudio(), - memoryConfiguration, - _viewModel.UiHandler, - (SystemLanguage)ConfigurationState.Instance.System.Language.Value, - (RegionCode)ConfigurationState.Instance.System.Region.Value, - ConfigurationState.Instance.Graphics.VSyncMode, - ConfigurationState.Instance.System.EnableDockedMode, - ConfigurationState.Instance.System.EnablePtc, - ConfigurationState.Instance.System.EnableInternetAccess, - ConfigurationState.Instance.System.EnableFsIntegrityChecks ? IntegrityCheckLevel.ErrorOnInvalid : IntegrityCheckLevel.None, - ConfigurationState.Instance.System.FsGlobalAccessLogMode, - ConfigurationState.Instance.System.MatchSystemTime - ? 0 - : ConfigurationState.Instance.System.SystemTimeOffset, - ConfigurationState.Instance.System.TimeZone, - ConfigurationState.Instance.System.MemoryManagerMode, - ConfigurationState.Instance.System.IgnoreMissingServices, - ConfigurationState.Instance.Graphics.AspectRatio, - ConfigurationState.Instance.System.AudioVolume, - ConfigurationState.Instance.System.UseHypervisor, - ConfigurationState.Instance.Multiplayer.LanInterfaceId.Value, - ConfigurationState.Instance.Multiplayer.Mode, - ConfigurationState.Instance.Multiplayer.DisableP2p, - ConfigurationState.Instance.Multiplayer.LdnPassphrase, - ConfigurationState.Instance.Multiplayer.GetLdnServer(), - ConfigurationState.Instance.Graphics.CustomVSyncInterval, - ConfigurationState.Instance.System.TickScalar, - ConfigurationState.Instance.Hacks.ShowDirtyHacks ? ConfigurationState.Instance.Hacks.EnabledHacks : null)); + Device = new Switch(ConfigurationState.Instance.CreateHleConfiguration() + .Configure( + VirtualFileSystem, + _viewModel.LibHacHorizonManager, + ContentManager, + _accountManager, + _userChannelPersistence, + renderer.TryMakeThreaded(ConfigurationState.Instance.Graphics.BackendThreading), + InitializeAudio(), + _viewModel.UiHandler + ) + ); } private static IHardwareDeviceDriver InitializeAudio() @@ -1196,6 +1158,9 @@ namespace Ryujinx.Ava private void UpdateShaderCount() { + if (_displayCount is 0 && _renderer.ProgramCount is 0) + return; + // If there is a mismatch between total program compile and previous count // this means new shaders have been compiled and should be displayed. if (_renderer.ProgramCount != _previousCount) @@ -1275,12 +1240,10 @@ namespace Ryujinx.Ava VSyncModeToggle(); break; case KeyboardHotkeyState.CustomVSyncIntervalDecrement: - Device.DecrementCustomVSyncInterval(); - _viewModel.CustomVSyncInterval -= 1; + _viewModel.CustomVSyncInterval = Device.DecrementCustomVSyncInterval(); break; case KeyboardHotkeyState.CustomVSyncIntervalIncrement: - Device.IncrementCustomVSyncInterval(); - _viewModel.CustomVSyncInterval += 1; + _viewModel.CustomVSyncInterval = Device.IncrementCustomVSyncInterval(); break; case KeyboardHotkeyState.TurboMode: if (!ConfigurationState.Instance.Hid.Hotkeys.Value.TurboModeWhileHeld) diff --git a/src/Ryujinx/Headless/HeadlessRyujinx.Init.cs b/src/Ryujinx/Headless/HeadlessRyujinx.Init.cs index b676b104e..beb28e885 100644 --- a/src/Ryujinx/Headless/HeadlessRyujinx.Init.cs +++ b/src/Ryujinx/Headless/HeadlessRyujinx.Init.cs @@ -10,6 +10,7 @@ using Ryujinx.Common.Configuration.Hid.Controller.Motion; using Ryujinx.Common.Configuration.Hid.Keyboard; using Ryujinx.Common.Logging; using Ryujinx.Common.Utilities; +using Ryujinx.Cpu; using Ryujinx.Graphics.GAL; using Ryujinx.Graphics.GAL.Multithreading; using Ryujinx.Graphics.OpenGL; @@ -311,51 +312,44 @@ namespace Ryujinx.Headless return new OpenGLRenderer(); } - - private static Switch InitializeEmulationContext(WindowBase window, IRenderer renderer, Options options) - { - BackendThreading threadingMode = options.BackendThreading; - - bool threadedGAL = threadingMode == BackendThreading.On || (threadingMode == BackendThreading.Auto && renderer.PreferThreading); - - if (threadedGAL) - { - renderer = new ThreadedRenderer(renderer); - } - - HLEConfiguration configuration = new(_virtualFileSystem, - _libHacHorizonManager, - _contentManager, - _accountManager, - _userChannelPersistence, - renderer, - new SDL2HardwareDeviceDriver(), - options.DramSize, - window, - options.SystemLanguage, - options.SystemRegion, - options.VSyncMode, - !options.DisableDockedMode, - !options.DisablePTC, - options.EnableInternetAccess, - !options.DisableFsIntegrityChecks ? IntegrityCheckLevel.ErrorOnInvalid : IntegrityCheckLevel.None, - options.FsGlobalAccessLogMode, - options.SystemTimeOffset, - options.SystemTimeZone, - options.MemoryManagerMode, - options.IgnoreMissingServices, - options.AspectRatio, - options.AudioVolume, - options.UseHypervisor ?? true, - options.MultiplayerLanInterfaceId, - Common.Configuration.Multiplayer.MultiplayerMode.Disabled, - false, - string.Empty, - string.Empty, - options.CustomVSyncInterval, - 100); - - return new Switch(configuration); - } + + private static Switch InitializeEmulationContext(WindowBase window, IRenderer renderer, Options options) => + new( + new HleConfiguration( + options.DramSize, + options.SystemLanguage, + options.SystemRegion, + options.VSyncMode, + !options.DisableDockedMode, + !options.DisablePTC, + ITickSource.RealityTickScalar, + options.EnableInternetAccess, + !options.DisableFsIntegrityChecks ? IntegrityCheckLevel.ErrorOnInvalid : IntegrityCheckLevel.None, + options.FsGlobalAccessLogMode, + options.SystemTimeOffset, + options.SystemTimeZone, + options.MemoryManagerMode, + options.IgnoreMissingServices, + options.AspectRatio, + options.AudioVolume, + options.UseHypervisor ?? true, + options.MultiplayerLanInterfaceId, + Common.Configuration.Multiplayer.MultiplayerMode.Disabled, + false, + string.Empty, + string.Empty, + options.CustomVSyncInterval + ) + .Configure( + _virtualFileSystem, + _libHacHorizonManager, + _contentManager, + _accountManager, + _userChannelPersistence, + renderer.TryMakeThreaded(options.BackendThreading), + new SDL2HardwareDeviceDriver(), + window + ) + ); } } diff --git a/src/Ryujinx/Utilities/Configuration/ConfigurationState.Model.cs b/src/Ryujinx/Utilities/Configuration/ConfigurationState.Model.cs index 82d1fc179..2d839f9b1 100644 --- a/src/Ryujinx/Utilities/Configuration/ConfigurationState.Model.cs +++ b/src/Ryujinx/Utilities/Configuration/ConfigurationState.Model.cs @@ -862,6 +862,7 @@ namespace Ryujinx.Ava.Utilities.Configuration Graphics.VSyncMode, System.EnableDockedMode, System.EnablePtc, + System.TickScalar, System.EnableInternetAccess, System.EnableFsIntegrityChecks ? IntegrityCheckLevel.ErrorOnInvalid @@ -882,7 +883,6 @@ namespace Ryujinx.Ava.Utilities.Configuration Multiplayer.LdnPassphrase, Multiplayer.GetLdnServer(), Graphics.CustomVSyncInterval, - System.TickScalar, Hacks.ShowDirtyHacks ? Hacks.EnabledHacks : null); } }