misc: chore: rework HLEConfiguration

This commit is contained in:
Evan Husted 2025-03-04 00:08:01 -06:00
parent c410474d83
commit b45a65fbdc
8 changed files with 134 additions and 109 deletions

View file

@ -19,7 +19,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnMitm
private readonly LanDiscovery _lanDiscovery;
public LdnMitmClient(HLEConfiguration config)
public LdnMitmClient(HleConfiguration config)
{
UnicastIPAddressInformation localIpInterface = NetworkHelpers.GetLocalInterface(config.MultiplayerLanInterfaceId).Item2;

View file

@ -51,13 +51,13 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu
private string _passphrase;
private byte[] _gameVersion = new byte[0x10];
private readonly HLEConfiguration _config;
private readonly HleConfiguration _config;
public event EventHandler<NetworkChangeEventArgs> NetworkChange;
public ProxyConfig Config { get; private set; }
public LdnMasterProxyClient(string address, int port, HLEConfiguration config) : base(address, port)
public LdnMasterProxyClient(string address, int port, HleConfiguration config) : base(address, port)
{
if (ProxyHelpers.SupportsNoDelay())
{

View file

@ -15,55 +15,55 @@ namespace Ryujinx.HLE
/// <summary>
/// HLE configuration.
/// </summary>
public class HLEConfiguration
public class HleConfiguration
{
/// <summary>
/// The virtual file system used by the FS service.
/// </summary>
/// <remarks>This cannot be changed after <see cref="Switch"/> instantiation.</remarks>
internal readonly VirtualFileSystem VirtualFileSystem;
internal VirtualFileSystem VirtualFileSystem { get; private set; }
/// <summary>
/// The manager for handling a LibHac Horizon instance.
/// </summary>
/// <remarks>This cannot be changed after <see cref="Switch"/> instantiation.</remarks>
internal readonly LibHacHorizonManager LibHacHorizonManager;
internal LibHacHorizonManager LibHacHorizonManager { get; private set; }
/// <summary>
/// The account manager used by the account service.
/// </summary>
/// <remarks>This cannot be changed after <see cref="Switch"/> instantiation.</remarks>
internal readonly AccountManager AccountManager;
internal AccountManager AccountManager { get; private set; }
/// <summary>
/// The content manager used by the NCM service.
/// </summary>
/// <remarks>This cannot be changed after <see cref="Switch"/> instantiation.</remarks>
internal readonly ContentManager ContentManager;
internal ContentManager ContentManager { get; private set; }
/// <summary>
/// The persistent information between run for multi-application capabilities.
/// </summary>
/// <remarks>This cannot be changed after <see cref="Switch"/> instantiation.</remarks>
public readonly UserChannelPersistence UserChannelPersistence;
public UserChannelPersistence UserChannelPersistence { get; private set; }
/// <summary>
/// The GPU renderer to use for all GPU operations.
/// </summary>
/// <remarks>This cannot be changed after <see cref="Switch"/> instantiation.</remarks>
internal readonly IRenderer GpuRenderer;
internal IRenderer GpuRenderer { get; private set; }
/// <summary>
/// The audio device driver to use for all audio operations.
/// </summary>
/// <remarks>This cannot be changed after <see cref="Switch"/> instantiation.</remarks>
internal readonly IHardwareDeviceDriver AudioDeviceDriver;
internal IHardwareDeviceDriver AudioDeviceDriver { get; private set; }
/// <summary>
/// The handler for various UI related operations needed outside of HLE.
/// </summary>
/// <remarks>This cannot be changed after <see cref="Switch"/> instantiation.</remarks>
internal readonly IHostUIHandler HostUIHandler;
internal IHostUIHandler HostUIHandler { get; private set; }
/// <summary>
/// Control the memory configuration used by the emulation context.
@ -195,15 +195,7 @@ namespace Ryujinx.HLE
/// <remarks>This cannot be changed after <see cref="Switch"/> instantiation.</remarks>
public EnabledDirtyHack[] Hacks { internal get; set; }
public HLEConfiguration(VirtualFileSystem virtualFileSystem,
LibHacHorizonManager libHacHorizonManager,
ContentManager contentManager,
AccountManager accountManager,
UserChannelPersistence userChannelPersistence,
IRenderer gpuRenderer,
IHardwareDeviceDriver audioDeviceDriver,
MemoryConfiguration memoryConfiguration,
IHostUIHandler hostUIHandler,
public HleConfiguration(MemoryConfiguration memoryConfiguration,
SystemLanguage systemLanguage,
RegionCode region,
VSyncMode vSyncMode,
@ -227,15 +219,7 @@ namespace Ryujinx.HLE
int customVSyncInterval,
EnabledDirtyHack[] dirtyHacks = null)
{
VirtualFileSystem = virtualFileSystem;
LibHacHorizonManager = libHacHorizonManager;
AccountManager = accountManager;
ContentManager = contentManager;
UserChannelPersistence = userChannelPersistence;
GpuRenderer = gpuRenderer;
AudioDeviceDriver = audioDeviceDriver;
MemoryConfiguration = memoryConfiguration;
HostUIHandler = hostUIHandler;
SystemLanguage = systemLanguage;
Region = region;
VSyncMode = vSyncMode;
@ -259,5 +243,30 @@ namespace Ryujinx.HLE
MultiplayerLdnServer = multiplayerLdnServer;
Hacks = dirtyHacks ?? [];
}
/// <summary>
/// Set the pre-configured services to use for this <see cref="HleConfiguration"/> instance.
/// </summary>
public HleConfiguration Configure(
VirtualFileSystem virtualFileSystem,
LibHacHorizonManager libHacHorizonManager,
ContentManager contentManager,
AccountManager accountManager,
UserChannelPersistence userChannelPersistence,
IRenderer gpuRenderer,
IHardwareDeviceDriver audioDeviceDriver,
IHostUIHandler hostUIHandler
)
{
VirtualFileSystem = virtualFileSystem;
LibHacHorizonManager = libHacHorizonManager;
AccountManager = accountManager;
ContentManager = contentManager;
UserChannelPersistence = userChannelPersistence;
GpuRenderer = gpuRenderer;
AudioDeviceDriver = audioDeviceDriver;
HostUIHandler = hostUIHandler;
return this;
}
}
}

View file

@ -20,7 +20,7 @@ namespace Ryujinx.HLE
{
public static Switch Shared { get; private set; }
public HLEConfiguration Configuration { get; }
public HleConfiguration Configuration { get; }
public IHardwareDeviceDriver AudioDeviceDriver { get; }
public MemoryBlock Memory { get; }
public GpuContext Gpu { get; }
@ -44,7 +44,7 @@ namespace Ryujinx.HLE
public DirtyHacks DirtyHacks { get; }
public Switch(HLEConfiguration configuration)
public Switch(HleConfiguration configuration)
{
ArgumentNullException.ThrowIfNull(configuration.GpuRenderer);
ArgumentNullException.ThrowIfNull(configuration.AudioDeviceDriver);
@ -94,16 +94,20 @@ namespace Ryujinx.HLE
Gpu.GPFifo.DispatchCalls();
}
public void IncrementCustomVSyncInterval()
public int IncrementCustomVSyncInterval()
{
CustomVSyncInterval += 1;
UpdateVSyncInterval();
return CustomVSyncInterval;
}
public void DecrementCustomVSyncInterval()
public int DecrementCustomVSyncInterval()
{
CustomVSyncInterval -= 1;
UpdateVSyncInterval();
return CustomVSyncInterval;
}
public void UpdateVSyncInterval()