mirror of
https://git.ryujinx.app/kenji-nx/ryujinx.git
synced 2025-12-16 04:37:02 +00:00
Add custom refresh rate mode to VSync option
This commit is contained in:
parent
86f2327468
commit
5d24fd119d
30 changed files with 718 additions and 132 deletions
|
|
@ -58,6 +58,7 @@ using MouseButton = Ryujinx.Input.MouseButton;
|
|||
using ScalingFilter = Ryujinx.Common.Configuration.ScalingFilter;
|
||||
using Size = Avalonia.Size;
|
||||
using Switch = Ryujinx.HLE.Switch;
|
||||
using VSyncMode = Ryujinx.Common.Configuration.VSyncMode;
|
||||
|
||||
namespace Ryujinx.Ava
|
||||
{
|
||||
|
|
@ -201,6 +202,9 @@ namespace Ryujinx.Ava
|
|||
ConfigurationState.Instance.Graphics.ScalingFilter.Event += UpdateScalingFilter;
|
||||
ConfigurationState.Instance.Graphics.ScalingFilterLevel.Event += UpdateScalingFilterLevel;
|
||||
ConfigurationState.Instance.Graphics.EnableColorSpacePassthrough.Event += UpdateColorSpacePassthrough;
|
||||
ConfigurationState.Instance.Graphics.VSyncMode.Event += UpdateVSyncMode;
|
||||
ConfigurationState.Instance.Graphics.CustomVSyncInterval.Event += UpdateCustomVSyncIntervalValue;
|
||||
ConfigurationState.Instance.Graphics.EnableCustomVSyncInterval.Event += UpdateCustomVSyncIntervalEnabled;
|
||||
|
||||
ConfigurationState.Instance.System.EnableInternetAccess.Event += UpdateEnableInternetAccessState;
|
||||
ConfigurationState.Instance.Multiplayer.LanInterfaceId.Event += UpdateLanInterfaceIdState;
|
||||
|
|
@ -290,6 +294,66 @@ namespace Ryujinx.Ava
|
|||
_renderer.Window?.SetColorSpacePassthrough((bool)ConfigurationState.Instance.Graphics.EnableColorSpacePassthrough.Value);
|
||||
}
|
||||
|
||||
public void UpdateVSyncMode(object sender, ReactiveEventArgs<VSyncMode> e)
|
||||
{
|
||||
if (Device != null)
|
||||
{
|
||||
Device.VSyncMode = e.NewValue;
|
||||
Device.UpdateVSyncInterval();
|
||||
}
|
||||
_renderer.Window?.ChangeVSyncMode((Ryujinx.Graphics.GAL.VSyncMode)e.NewValue);
|
||||
|
||||
_viewModel.ShowCustomVSyncIntervalPicker = (e.NewValue == VSyncMode.Custom);
|
||||
}
|
||||
|
||||
public void VSyncModeToggle()
|
||||
{
|
||||
VSyncMode oldVSyncMode = Device.VSyncMode;
|
||||
VSyncMode newVSyncMode = VSyncMode.Switch;
|
||||
bool customVSyncIntervalEnabled = ConfigurationState.Instance.Graphics.EnableCustomVSyncInterval.Value;
|
||||
|
||||
switch (oldVSyncMode)
|
||||
{
|
||||
case VSyncMode.Switch:
|
||||
newVSyncMode = VSyncMode.Unbounded;
|
||||
break;
|
||||
case VSyncMode.Unbounded:
|
||||
if (customVSyncIntervalEnabled)
|
||||
{
|
||||
newVSyncMode = VSyncMode.Custom;
|
||||
}
|
||||
else
|
||||
{
|
||||
newVSyncMode = VSyncMode.Switch;
|
||||
}
|
||||
|
||||
break;
|
||||
case VSyncMode.Custom:
|
||||
newVSyncMode = VSyncMode.Switch;
|
||||
break;
|
||||
}
|
||||
|
||||
UpdateVSyncMode(this, new ReactiveEventArgs<VSyncMode>(oldVSyncMode, newVSyncMode));
|
||||
}
|
||||
|
||||
private void UpdateCustomVSyncIntervalValue(object sender, ReactiveEventArgs<int> e)
|
||||
{
|
||||
if (Device != null)
|
||||
{
|
||||
Device.TargetVSyncInterval = e.NewValue;
|
||||
Device.UpdateVSyncInterval();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateCustomVSyncIntervalEnabled(object sender, ReactiveEventArgs<bool> e)
|
||||
{
|
||||
if (Device != null)
|
||||
{
|
||||
Device.CustomVSyncIntervalEnabled = e.NewValue;
|
||||
Device.UpdateVSyncInterval();
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowCursor()
|
||||
{
|
||||
Dispatcher.UIThread.Post(() =>
|
||||
|
|
@ -491,12 +555,6 @@ namespace Ryujinx.Ava
|
|||
Device.Configuration.MultiplayerMode = e.NewValue;
|
||||
}
|
||||
|
||||
public void ToggleVSync()
|
||||
{
|
||||
Device.EnableDeviceVsync = !Device.EnableDeviceVsync;
|
||||
_renderer.Window.ChangeVSyncMode(Device.EnableDeviceVsync);
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
_isActive = false;
|
||||
|
|
@ -850,31 +908,32 @@ namespace Ryujinx.Ava
|
|||
var memoryConfiguration = ConfigurationState.Instance.System.DramSize.Value;
|
||||
|
||||
HLEConfiguration configuration = new(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.EnableVsync,
|
||||
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.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);
|
||||
_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.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.Graphics.CustomVSyncInterval.Value);
|
||||
|
||||
Device = new Switch(configuration);
|
||||
}
|
||||
|
|
@ -999,7 +1058,7 @@ namespace Ryujinx.Ava
|
|||
Device.Gpu.SetGpuThread();
|
||||
Device.Gpu.InitializeShaderCache(_gpuCancellationTokenSource.Token);
|
||||
|
||||
_renderer.Window.ChangeVSyncMode(Device.EnableDeviceVsync);
|
||||
_renderer.Window.ChangeVSyncMode((Ryujinx.Graphics.GAL.VSyncMode)Device.VSyncMode);
|
||||
|
||||
while (_isActive)
|
||||
{
|
||||
|
|
@ -1060,6 +1119,7 @@ namespace Ryujinx.Ava
|
|||
{
|
||||
// Run a status update only when a frame is to be drawn. This prevents from updating the ui and wasting a render when no frame is queued.
|
||||
string dockedMode = ConfigurationState.Instance.System.EnableDockedMode ? LocaleManager.Instance[LocaleKeys.Docked] : LocaleManager.Instance[LocaleKeys.Handheld];
|
||||
string vSyncMode = Device.VSyncMode.ToString();
|
||||
|
||||
if (GraphicsConfig.ResScale != 1)
|
||||
{
|
||||
|
|
@ -1067,7 +1127,7 @@ namespace Ryujinx.Ava
|
|||
}
|
||||
|
||||
StatusUpdatedEvent?.Invoke(this, new StatusUpdatedEventArgs(
|
||||
Device.EnableDeviceVsync,
|
||||
vSyncMode,
|
||||
LocaleManager.Instance[LocaleKeys.VolumeShort] + $": {(int)(Device.GetVolume() * 100)}%",
|
||||
dockedMode,
|
||||
ConfigurationState.Instance.Graphics.AspectRatio.Value.ToText(),
|
||||
|
|
@ -1151,8 +1211,16 @@ namespace Ryujinx.Ava
|
|||
{
|
||||
switch (currentHotkeyState)
|
||||
{
|
||||
case KeyboardHotkeyState.ToggleVSync:
|
||||
ToggleVSync();
|
||||
case KeyboardHotkeyState.ToggleVSyncMode:
|
||||
VSyncModeToggle();
|
||||
break;
|
||||
case KeyboardHotkeyState.CustomVSyncIntervalDecrement:
|
||||
Device.DecrementCustomVSyncInterval();
|
||||
_viewModel.CustomVSyncInterval -= 1;
|
||||
break;
|
||||
case KeyboardHotkeyState.CustomVSyncIntervalIncrement:
|
||||
Device.IncrementCustomVSyncInterval();
|
||||
_viewModel.CustomVSyncInterval += 1;
|
||||
break;
|
||||
case KeyboardHotkeyState.Screenshot:
|
||||
ScreenshotRequested = true;
|
||||
|
|
@ -1239,9 +1307,9 @@ namespace Ryujinx.Ava
|
|||
{
|
||||
KeyboardHotkeyState state = KeyboardHotkeyState.None;
|
||||
|
||||
if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.ToggleVsync))
|
||||
if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.ToggleVSyncMode))
|
||||
{
|
||||
state = KeyboardHotkeyState.ToggleVSync;
|
||||
state = KeyboardHotkeyState.ToggleVSyncMode;
|
||||
}
|
||||
else if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.Screenshot))
|
||||
{
|
||||
|
|
@ -1275,6 +1343,14 @@ namespace Ryujinx.Ava
|
|||
{
|
||||
state = KeyboardHotkeyState.VolumeDown;
|
||||
}
|
||||
else if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.CustomVSyncIntervalIncrement))
|
||||
{
|
||||
state = KeyboardHotkeyState.CustomVSyncIntervalIncrement;
|
||||
}
|
||||
else if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.CustomVSyncIntervalDecrement))
|
||||
{
|
||||
state = KeyboardHotkeyState.CustomVSyncIntervalDecrement;
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue