Add custom refresh rate mode to VSync option

This commit is contained in:
jcm 2024-05-13 11:52:24 -05:00
parent a23d8cb92f
commit 525ee47cc7
34 changed files with 738 additions and 148 deletions

View file

@ -2,7 +2,7 @@ namespace Ryujinx.Common.Configuration.Hid
{ {
public class KeyboardHotkeys public class KeyboardHotkeys
{ {
public Key ToggleVsync { get; set; } public Key ToggleVSyncMode { get; set; }
public Key Screenshot { get; set; } public Key Screenshot { get; set; }
public Key ShowUI { get; set; } public Key ShowUI { get; set; }
public Key Pause { get; set; } public Key Pause { get; set; }
@ -11,5 +11,7 @@ namespace Ryujinx.Common.Configuration.Hid
public Key ResScaleDown { get; set; } public Key ResScaleDown { get; set; }
public Key VolumeUp { get; set; } public Key VolumeUp { get; set; }
public Key VolumeDown { get; set; } public Key VolumeDown { get; set; }
public Key CustomVSyncIntervalIncrement { get; set; }
public Key CustomVSyncIntervalDecrement { get; set; }
} }
} }

View file

@ -0,0 +1,9 @@
namespace Ryujinx.Common.Configuration
{
public enum VSyncMode
{
Switch,
Unbounded,
Custom
}
}

View file

@ -8,7 +8,7 @@ namespace Ryujinx.Graphics.GAL
void SetSize(int width, int height); void SetSize(int width, int height);
void ChangeVSyncMode(bool vsyncEnabled); void ChangeVSyncMode(VSyncMode vSyncMode);
void SetAntiAliasing(AntiAliasing antialiasing); void SetAntiAliasing(AntiAliasing antialiasing);
void SetScalingFilter(ScalingFilter type); void SetScalingFilter(ScalingFilter type);

View file

@ -31,7 +31,7 @@ namespace Ryujinx.Graphics.GAL.Multithreading
_impl.Window.SetSize(width, height); _impl.Window.SetSize(width, height);
} }
public void ChangeVSyncMode(bool vsyncEnabled) { } public void ChangeVSyncMode(VSyncMode vSyncMode) { }
public void SetAntiAliasing(AntiAliasing effect) { } public void SetAntiAliasing(AntiAliasing effect) { }

View file

@ -0,0 +1,9 @@
namespace Ryujinx.Graphics.GAL
{
public enum VSyncMode
{
Switch,
Unbounded,
Custom
}
}

View file

@ -54,7 +54,7 @@ namespace Ryujinx.Graphics.OpenGL
GL.PixelStore(PixelStoreParameter.UnpackAlignment, 4); GL.PixelStore(PixelStoreParameter.UnpackAlignment, 4);
} }
public void ChangeVSyncMode(bool vsyncEnabled) { } public void ChangeVSyncMode(VSyncMode vSyncMode) { }
public void SetSize(int width, int height) public void SetSize(int width, int height)
{ {

View file

@ -29,7 +29,7 @@ namespace Ryujinx.Graphics.Vulkan
private int _width; private int _width;
private int _height; private int _height;
private bool _vsyncEnabled; private VSyncMode _vSyncMode;
private bool _swapchainIsDirty; private bool _swapchainIsDirty;
private VkFormat _format; private VkFormat _format;
private AntiAliasing _currentAntiAliasing; private AntiAliasing _currentAntiAliasing;
@ -139,7 +139,7 @@ namespace Ryujinx.Graphics.Vulkan
ImageArrayLayers = 1, ImageArrayLayers = 1,
PreTransform = capabilities.CurrentTransform, PreTransform = capabilities.CurrentTransform,
CompositeAlpha = ChooseCompositeAlpha(capabilities.SupportedCompositeAlpha), CompositeAlpha = ChooseCompositeAlpha(capabilities.SupportedCompositeAlpha),
PresentMode = ChooseSwapPresentMode(presentModes, _vsyncEnabled), PresentMode = ChooseSwapPresentMode(presentModes, _vSyncMode),
Clipped = true, Clipped = true,
}; };
@ -279,9 +279,9 @@ namespace Ryujinx.Graphics.Vulkan
} }
} }
private static PresentModeKHR ChooseSwapPresentMode(PresentModeKHR[] availablePresentModes, bool vsyncEnabled) private static PresentModeKHR ChooseSwapPresentMode(PresentModeKHR[] availablePresentModes, VSyncMode vSyncMode)
{ {
if (!vsyncEnabled && availablePresentModes.Contains(PresentModeKHR.ImmediateKhr)) if (vSyncMode == VSyncMode.Unbounded && availablePresentModes.Contains(PresentModeKHR.ImmediateKhr))
{ {
return PresentModeKHR.ImmediateKhr; return PresentModeKHR.ImmediateKhr;
} }
@ -626,9 +626,10 @@ namespace Ryujinx.Graphics.Vulkan
// Not needed as we can get the size from the surface. // Not needed as we can get the size from the surface.
} }
public override void ChangeVSyncMode(bool vsyncEnabled) public override void ChangeVSyncMode(VSyncMode vSyncMode)
{ {
_vsyncEnabled = vsyncEnabled; _vSyncMode = vSyncMode;
//present mode may change, so mark the swapchain for recreation
_swapchainIsDirty = true; _swapchainIsDirty = true;
} }

View file

@ -10,7 +10,7 @@ namespace Ryujinx.Graphics.Vulkan
public abstract void Dispose(); public abstract void Dispose();
public abstract void Present(ITexture texture, ImageCrop crop, Action swapBuffersCallback); public abstract void Present(ITexture texture, ImageCrop crop, Action swapBuffersCallback);
public abstract void SetSize(int width, int height); public abstract void SetSize(int width, int height);
public abstract void ChangeVSyncMode(bool vsyncEnabled); public abstract void ChangeVSyncMode(VSyncMode vSyncMode);
public abstract void SetAntiAliasing(AntiAliasing effect); public abstract void SetAntiAliasing(AntiAliasing effect);
public abstract void SetScalingFilter(ScalingFilter scalerType); public abstract void SetScalingFilter(ScalingFilter scalerType);
public abstract void SetScalingFilterLevel(float scale); public abstract void SetScalingFilterLevel(float scale);

View file

@ -44,6 +44,7 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using GUI = Gtk.Builder.ObjectAttribute; using GUI = Gtk.Builder.ObjectAttribute;
using ShaderCacheLoadingState = Ryujinx.Graphics.Gpu.Shader.ShaderCacheState; using ShaderCacheLoadingState = Ryujinx.Graphics.Gpu.Shader.ShaderCacheState;
using VSyncMode = Ryujinx.Common.Configuration.VSyncMode;
namespace Ryujinx.UI namespace Ryujinx.UI
{ {
@ -655,7 +656,7 @@ namespace Ryujinx.UI
_uiHandler, _uiHandler,
(SystemLanguage)ConfigurationState.Instance.System.Language.Value, (SystemLanguage)ConfigurationState.Instance.System.Language.Value,
(RegionCode)ConfigurationState.Instance.System.Region.Value, (RegionCode)ConfigurationState.Instance.System.Region.Value,
ConfigurationState.Instance.Graphics.EnableVsync, ConfigurationState.Instance.Graphics.VSyncMode,
ConfigurationState.Instance.System.EnableDockedMode, ConfigurationState.Instance.System.EnableDockedMode,
ConfigurationState.Instance.System.EnablePtc, ConfigurationState.Instance.System.EnablePtc,
ConfigurationState.Instance.System.EnableInternetAccess, ConfigurationState.Instance.System.EnableInternetAccess,
@ -669,7 +670,8 @@ namespace Ryujinx.UI
ConfigurationState.Instance.System.AudioVolume, ConfigurationState.Instance.System.AudioVolume,
ConfigurationState.Instance.System.UseHypervisor, ConfigurationState.Instance.System.UseHypervisor,
ConfigurationState.Instance.Multiplayer.LanInterfaceId.Value, ConfigurationState.Instance.Multiplayer.LanInterfaceId.Value,
ConfigurationState.Instance.Multiplayer.Mode); ConfigurationState.Instance.Multiplayer.Mode,
ConfigurationState.Instance.Graphics.CustomVSyncInterval);
_emulationContext = new HLE.Switch(configuration); _emulationContext = new HLE.Switch(configuration);
} }
@ -1211,7 +1213,7 @@ namespace Ryujinx.UI
_gpuBackend.Text = args.GpuBackend; _gpuBackend.Text = args.GpuBackend;
_volumeStatus.Text = GetVolumeLabelText(args.Volume); _volumeStatus.Text = GetVolumeLabelText(args.Volume);
if (args.VSyncEnabled) if (args.VSyncMode == VSyncMode.Switch.ToString())
{ {
_vSyncStatus.Attributes = new Pango.AttrList(); _vSyncStatus.Attributes = new Pango.AttrList();
_vSyncStatus.Attributes.Insert(new Pango.AttrForeground(11822, 60138, 51657)); _vSyncStatus.Attributes.Insert(new Pango.AttrForeground(11822, 60138, 51657));
@ -1260,9 +1262,9 @@ namespace Ryujinx.UI
private void VSyncStatus_Clicked(object sender, ButtonReleaseEventArgs args) private void VSyncStatus_Clicked(object sender, ButtonReleaseEventArgs args)
{ {
_emulationContext.EnableDeviceVsync = !_emulationContext.EnableDeviceVsync; _emulationContext.VSyncMode = _emulationContext.VSyncMode == VSyncMode.Switch ? VSyncMode.Unbounded : VSyncMode.Switch;
Logger.Info?.Print(LogClass.Application, $"VSync toggled to: {_emulationContext.EnableDeviceVsync}"); Logger.Info?.Print(LogClass.Application, $"VSync toggled to: {_emulationContext.VSyncMode}");
} }
private void DockedMode_Clicked(object sender, ButtonReleaseEventArgs args) private void DockedMode_Clicked(object sender, ButtonReleaseEventArgs args)

View file

@ -26,6 +26,7 @@ using Image = SixLabors.ImageSharp.Image;
using Key = Ryujinx.Input.Key; using Key = Ryujinx.Input.Key;
using ScalingFilter = Ryujinx.Graphics.GAL.ScalingFilter; using ScalingFilter = Ryujinx.Graphics.GAL.ScalingFilter;
using Switch = Ryujinx.HLE.Switch; using Switch = Ryujinx.HLE.Switch;
using VSyncMode = Ryujinx.Graphics.GAL.VSyncMode;
namespace Ryujinx.UI namespace Ryujinx.UI
{ {
@ -455,7 +456,7 @@ namespace Ryujinx.UI
Device.Gpu.SetGpuThread(); Device.Gpu.SetGpuThread();
Device.Gpu.InitializeShaderCache(_gpuCancellationTokenSource.Token); Device.Gpu.InitializeShaderCache(_gpuCancellationTokenSource.Token);
Renderer.Window.ChangeVSyncMode(Device.EnableDeviceVsync); Renderer.Window.ChangeVSyncMode(Device.VSyncMode == (Ryujinx.Common.Configuration.VSyncMode)VSyncMode.Switch ? VSyncMode.Switch : VSyncMode.Unbounded);
(Toplevel as MainWindow)?.ActivatePauseMenu(); (Toplevel as MainWindow)?.ActivatePauseMenu();
@ -492,7 +493,7 @@ namespace Ryujinx.UI
} }
StatusUpdatedEvent?.Invoke(this, new StatusUpdatedEventArgs( StatusUpdatedEvent?.Invoke(this, new StatusUpdatedEventArgs(
Device.EnableDeviceVsync, Device.VSyncMode == Ryujinx.Common.Configuration.VSyncMode.Switch ? VSyncMode.Switch.ToString() : VSyncMode.Unbounded.ToString(),
Device.GetVolume(), Device.GetVolume(),
_gpuBackendName, _gpuBackendName,
dockedMode, dockedMode,
@ -653,7 +654,7 @@ namespace Ryujinx.UI
if (currentHotkeyState.HasFlag(KeyboardHotkeyState.ToggleVSync) && if (currentHotkeyState.HasFlag(KeyboardHotkeyState.ToggleVSync) &&
!_prevHotkeyState.HasFlag(KeyboardHotkeyState.ToggleVSync)) !_prevHotkeyState.HasFlag(KeyboardHotkeyState.ToggleVSync))
{ {
Device.EnableDeviceVsync = !Device.EnableDeviceVsync; Device.VSyncMode = Device.VSyncMode == Ryujinx.Common.Configuration.VSyncMode.Switch ? Ryujinx.Common.Configuration.VSyncMode.Unbounded : Ryujinx.Common.Configuration.VSyncMode.Switch;
} }
if ((currentHotkeyState.HasFlag(KeyboardHotkeyState.Screenshot) && if ((currentHotkeyState.HasFlag(KeyboardHotkeyState.Screenshot) &&
@ -757,7 +758,7 @@ namespace Ryujinx.UI
{ {
KeyboardHotkeyState state = KeyboardHotkeyState.None; 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.ToggleVSync;
} }

View file

@ -4,7 +4,7 @@ namespace Ryujinx.UI
{ {
public class StatusUpdatedEventArgs : EventArgs public class StatusUpdatedEventArgs : EventArgs
{ {
public bool VSyncEnabled; public string VSyncMode;
public float Volume; public float Volume;
public string DockedMode; public string DockedMode;
public string AspectRatio; public string AspectRatio;
@ -13,9 +13,9 @@ namespace Ryujinx.UI
public string GpuName; public string GpuName;
public string GpuBackend; public string GpuBackend;
public StatusUpdatedEventArgs(bool vSyncEnabled, float volume, string gpuBackend, string dockedMode, string aspectRatio, string gameStatus, string fifoStatus, string gpuName) public StatusUpdatedEventArgs(string vSyncMode, float volume, string gpuBackend, string dockedMode, string aspectRatio, string gameStatus, string fifoStatus, string gpuName)
{ {
VSyncEnabled = vSyncEnabled; VSyncMode = vSyncMode;
Volume = volume; Volume = volume;
GpuBackend = gpuBackend; GpuBackend = gpuBackend;
DockedMode = dockedMode; DockedMode = dockedMode;

View file

@ -243,7 +243,7 @@ namespace Ryujinx.UI.Windows
break; break;
} }
if (ConfigurationState.Instance.Graphics.EnableVsync) if (ConfigurationState.Instance.Graphics.VSyncMode.Value == VSyncMode.Switch)
{ {
_vSyncToggle.Click(); _vSyncToggle.Click();
} }
@ -628,7 +628,8 @@ namespace Ryujinx.UI.Windows
ConfigurationState.Instance.CheckUpdatesOnStart.Value = _checkUpdatesToggle.Active; ConfigurationState.Instance.CheckUpdatesOnStart.Value = _checkUpdatesToggle.Active;
ConfigurationState.Instance.ShowConfirmExit.Value = _showConfirmExitToggle.Active; ConfigurationState.Instance.ShowConfirmExit.Value = _showConfirmExitToggle.Active;
ConfigurationState.Instance.HideCursor.Value = hideCursor; ConfigurationState.Instance.HideCursor.Value = hideCursor;
ConfigurationState.Instance.Graphics.EnableVsync.Value = _vSyncToggle.Active; ConfigurationState.Instance.Graphics.VSyncMode.Value =
_vSyncToggle.Active ? VSyncMode.Switch : VSyncMode.Unbounded;
ConfigurationState.Instance.Graphics.EnableShaderCache.Value = _shaderCacheToggle.Active; ConfigurationState.Instance.Graphics.EnableShaderCache.Value = _shaderCacheToggle.Active;
ConfigurationState.Instance.Graphics.EnableTextureRecompression.Value = _textureRecompressionToggle.Active; ConfigurationState.Instance.Graphics.EnableTextureRecompression.Value = _textureRecompressionToggle.Active;
ConfigurationState.Instance.Graphics.EnableMacroHLE.Value = _macroHLEToggle.Active; ConfigurationState.Instance.Graphics.EnableMacroHLE.Value = _macroHLEToggle.Active;

View file

@ -9,6 +9,7 @@ using Ryujinx.HLE.HOS.Services.Account.Acc;
using Ryujinx.HLE.HOS.SystemState; using Ryujinx.HLE.HOS.SystemState;
using Ryujinx.HLE.UI; using Ryujinx.HLE.UI;
using System; using System;
using VSyncMode = Ryujinx.Common.Configuration.VSyncMode;
namespace Ryujinx.HLE namespace Ryujinx.HLE
{ {
@ -84,9 +85,14 @@ namespace Ryujinx.HLE
internal readonly RegionCode Region; internal readonly RegionCode Region;
/// <summary> /// <summary>
/// Control the initial state of the vertical sync in the SurfaceFlinger service. /// Control the initial state of the present interval in the SurfaceFlinger service (previously Vsync).
/// </summary> /// </summary>
internal readonly bool EnableVsync; internal readonly VSyncMode VSyncMode;
/// <summary>
/// Control the custom VSync interval, if enabled and active.
/// </summary>
internal readonly int CustomVSyncInterval;
/// <summary> /// <summary>
/// Control the initial state of the docked mode. /// Control the initial state of the docked mode.
@ -180,7 +186,7 @@ namespace Ryujinx.HLE
IHostUIHandler hostUIHandler, IHostUIHandler hostUIHandler,
SystemLanguage systemLanguage, SystemLanguage systemLanguage,
RegionCode region, RegionCode region,
bool enableVsync, VSyncMode vSyncMode,
bool enableDockedMode, bool enableDockedMode,
bool enablePtc, bool enablePtc,
bool enableInternetAccess, bool enableInternetAccess,
@ -194,7 +200,8 @@ namespace Ryujinx.HLE
float audioVolume, float audioVolume,
bool useHypervisor, bool useHypervisor,
string multiplayerLanInterfaceId, string multiplayerLanInterfaceId,
MultiplayerMode multiplayerMode) MultiplayerMode multiplayerMode,
int customVSyncInterval)
{ {
VirtualFileSystem = virtualFileSystem; VirtualFileSystem = virtualFileSystem;
LibHacHorizonManager = libHacHorizonManager; LibHacHorizonManager = libHacHorizonManager;
@ -207,7 +214,8 @@ namespace Ryujinx.HLE
HostUIHandler = hostUIHandler; HostUIHandler = hostUIHandler;
SystemLanguage = systemLanguage; SystemLanguage = systemLanguage;
Region = region; Region = region;
EnableVsync = enableVsync; VSyncMode = vSyncMode;
CustomVSyncInterval = customVSyncInterval;
EnableDockedMode = enableDockedMode; EnableDockedMode = enableDockedMode;
EnablePtc = enablePtc; EnablePtc = enablePtc;
EnableInternetAccess = enableInternetAccess; EnableInternetAccess = enableInternetAccess;

View file

@ -10,13 +10,12 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using VSyncMode = Ryujinx.Common.Configuration.VSyncMode;
namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
{ {
class SurfaceFlinger : IConsumerListener, IDisposable class SurfaceFlinger : IConsumerListener, IDisposable
{ {
private const int TargetFps = 60;
private readonly Switch _device; private readonly Switch _device;
private readonly Dictionary<long, Layer> _layers; private readonly Dictionary<long, Layer> _layers;
@ -32,6 +31,9 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
private readonly long _spinTicks; private readonly long _spinTicks;
private readonly long _1msTicks; private readonly long _1msTicks;
private VSyncMode _vSyncMode;
private long _targetVSyncInterval;
private int _swapInterval; private int _swapInterval;
private int _swapIntervalDelay; private int _swapIntervalDelay;
@ -88,7 +90,8 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
} }
else else
{ {
_ticksPerFrame = Stopwatch.Frequency / TargetFps; _ticksPerFrame = Stopwatch.Frequency / _device.TargetVSyncInterval;
_targetVSyncInterval = _device.TargetVSyncInterval;
} }
} }
@ -370,15 +373,20 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
if (acquireStatus == Status.Success) if (acquireStatus == Status.Success)
{ {
// If device vsync is disabled, reflect the change. if (_device.VSyncMode == VSyncMode.Unbounded)
if (!_device.EnableDeviceVsync)
{ {
if (_swapInterval != 0) if (_swapInterval != 0)
{ {
UpdateSwapInterval(0); UpdateSwapInterval(0);
_vSyncMode = _device.VSyncMode;
} }
} }
else if (item.SwapInterval != _swapInterval) else if (_device.VSyncMode != _vSyncMode)
{
UpdateSwapInterval(_device.VSyncMode == VSyncMode.Unbounded ? 0 : item.SwapInterval);
_vSyncMode = _device.VSyncMode;
}
else if (item.SwapInterval != _swapInterval || _device.TargetVSyncInterval != _targetVSyncInterval)
{ {
UpdateSwapInterval(item.SwapInterval); UpdateSwapInterval(item.SwapInterval);
} }

View file

@ -27,7 +27,11 @@ namespace Ryujinx.HLE
public TamperMachine TamperMachine { get; } public TamperMachine TamperMachine { get; }
public IHostUIHandler UIHandler { get; } public IHostUIHandler UIHandler { get; }
public bool EnableDeviceVsync { get; set; } = true; public VSyncMode VSyncMode { get; set; } = VSyncMode.Switch;
public bool CustomVSyncIntervalEnabled { get; set; } = false;
public int CustomVSyncInterval { get; set; }
public long TargetVSyncInterval { get; set; } = 60;
public bool IsFrameAvailable => Gpu.Window.IsFrameAvailable; public bool IsFrameAvailable => Gpu.Window.IsFrameAvailable;
@ -59,12 +63,14 @@ namespace Ryujinx.HLE
System.State.SetLanguage(Configuration.SystemLanguage); System.State.SetLanguage(Configuration.SystemLanguage);
System.State.SetRegion(Configuration.Region); System.State.SetRegion(Configuration.Region);
EnableDeviceVsync = Configuration.EnableVsync; VSyncMode = Configuration.VSyncMode;
CustomVSyncInterval = Configuration.CustomVSyncInterval;
System.State.DockedMode = Configuration.EnableDockedMode; System.State.DockedMode = Configuration.EnableDockedMode;
System.PerformanceState.PerformanceMode = System.State.DockedMode ? PerformanceMode.Boost : PerformanceMode.Default; System.PerformanceState.PerformanceMode = System.State.DockedMode ? PerformanceMode.Boost : PerformanceMode.Default;
System.EnablePtc = Configuration.EnablePtc; System.EnablePtc = Configuration.EnablePtc;
System.FsIntegrityCheckLevel = Configuration.FsIntegrityCheckLevel; System.FsIntegrityCheckLevel = Configuration.FsIntegrityCheckLevel;
System.GlobalAccessLogMode = Configuration.FsGlobalAccessLogMode; System.GlobalAccessLogMode = Configuration.FsGlobalAccessLogMode;
UpdateVSyncInterval();
#pragma warning restore IDE0055 #pragma warning restore IDE0055
} }
@ -115,6 +121,34 @@ namespace Ryujinx.HLE
Gpu.Window.Present(swapBuffersCallback); Gpu.Window.Present(swapBuffersCallback);
} }
public void IncrementCustomVSyncInterval()
{
CustomVSyncInterval += 1;
UpdateVSyncInterval();
}
public void DecrementCustomVSyncInterval()
{
CustomVSyncInterval -= 1;
UpdateVSyncInterval();
}
public void UpdateVSyncInterval()
{
switch (VSyncMode)
{
case VSyncMode.Custom:
TargetVSyncInterval = CustomVSyncInterval;
break;
case VSyncMode.Switch:
TargetVSyncInterval = 60;
break;
case VSyncMode.Unbounded:
TargetVSyncInterval = 1;
break;
}
}
public void SetVolume(float volume) public void SetVolume(float volume)
{ {
AudioDeviceDriver.Volume = Math.Clamp(volume, 0f, 1f); AudioDeviceDriver.Volume = Math.Clamp(volume, 0f, 1f);

View file

@ -114,8 +114,11 @@ namespace Ryujinx.Headless.SDL2
[Option("fs-global-access-log-mode", Required = false, Default = 0, HelpText = "Enables FS access log output to the console.")] [Option("fs-global-access-log-mode", Required = false, Default = 0, HelpText = "Enables FS access log output to the console.")]
public int FsGlobalAccessLogMode { get; set; } public int FsGlobalAccessLogMode { get; set; }
[Option("disable-vsync", Required = false, HelpText = "Disables Vertical Sync.")] [Option("vsync-mode", Required = false, Default = VSyncMode.Switch, HelpText = "Sets the emulated VSync mode (Switch, Unbounded, or Custom).")]
public bool DisableVSync { get; set; } public VSyncMode VSyncMode { get; set; }
[Option("custom-refresh-rate", Required = false, Default = 90, HelpText = "Sets the custom refresh rate target value (integer).")]
public int CustomVSyncInterval { get; set; }
[Option("disable-shader-cache", Required = false, HelpText = "Disables Shader cache.")] [Option("disable-shader-cache", Required = false, HelpText = "Disables Shader cache.")]
public bool DisableShaderCache { get; set; } public bool DisableShaderCache { get; set; }

View file

@ -557,7 +557,7 @@ namespace Ryujinx.Headless.SDL2
window, window,
options.SystemLanguage, options.SystemLanguage,
options.SystemRegion, options.SystemRegion,
!options.DisableVSync, options.VSyncMode,
!options.DisableDockedMode, !options.DisableDockedMode,
!options.DisablePTC, !options.DisablePTC,
options.EnableInternetAccess, options.EnableInternetAccess,
@ -571,7 +571,8 @@ namespace Ryujinx.Headless.SDL2
options.AudioVolume, options.AudioVolume,
options.UseHypervisor ?? true, options.UseHypervisor ?? true,
options.MultiplayerLanInterfaceId, options.MultiplayerLanInterfaceId,
Common.Configuration.Multiplayer.MultiplayerMode.Disabled); Common.Configuration.Multiplayer.MultiplayerMode.Disabled,
options.CustomVSyncInterval);
return new Switch(configuration); return new Switch(configuration);
} }

View file

@ -4,16 +4,16 @@ namespace Ryujinx.Headless.SDL2
{ {
class StatusUpdatedEventArgs : EventArgs class StatusUpdatedEventArgs : EventArgs
{ {
public bool VSyncEnabled; public string VSyncMode;
public string DockedMode; public string DockedMode;
public string AspectRatio; public string AspectRatio;
public string GameStatus; public string GameStatus;
public string FifoStatus; public string FifoStatus;
public string GpuName; public string GpuName;
public StatusUpdatedEventArgs(bool vSyncEnabled, string dockedMode, string aspectRatio, string gameStatus, string fifoStatus, string gpuName) public StatusUpdatedEventArgs(string vSyncMode, string dockedMode, string aspectRatio, string gameStatus, string fifoStatus, string gpuName)
{ {
VSyncEnabled = vSyncEnabled; VSyncMode = vSyncMode;
DockedMode = dockedMode; DockedMode = dockedMode;
AspectRatio = aspectRatio; AspectRatio = aspectRatio;
GameStatus = gameStatus; GameStatus = gameStatus;

View file

@ -309,7 +309,7 @@ namespace Ryujinx.Headless.SDL2
} }
StatusUpdatedEvent?.Invoke(this, new StatusUpdatedEventArgs( StatusUpdatedEvent?.Invoke(this, new StatusUpdatedEventArgs(
Device.EnableDeviceVsync, Device.VSyncMode.ToString(),
dockedMode, dockedMode,
Device.Configuration.AspectRatio.ToText(), Device.Configuration.AspectRatio.ToText(),
$"Game: {Device.Statistics.GetGameFrameRate():00.00} FPS ({Device.Statistics.GetGameFrameTime():00.00} ms)", $"Game: {Device.Statistics.GetGameFrameRate():00.00} FPS ({Device.Statistics.GetGameFrameTime():00.00} ms)",

View file

@ -1,3 +1,4 @@
using Ryujinx.Common;
using Ryujinx.Common.Configuration; using Ryujinx.Common.Configuration;
using Ryujinx.Common.Configuration.Hid; using Ryujinx.Common.Configuration.Hid;
using Ryujinx.Common.Configuration.Multiplayer; using Ryujinx.Common.Configuration.Multiplayer;
@ -15,7 +16,7 @@ namespace Ryujinx.UI.Common.Configuration
/// <summary> /// <summary>
/// The current version of the file format /// The current version of the file format
/// </summary> /// </summary>
public const int CurrentVersion = 51; public const int CurrentVersion = 52;
/// <summary> /// <summary>
/// Version of the configuration file format /// Version of the configuration file format
@ -180,8 +181,25 @@ namespace Ryujinx.UI.Common.Configuration
/// <summary> /// <summary>
/// Enables or disables Vertical Sync /// Enables or disables Vertical Sync
/// </summary> /// </summary>
/// <remarks>Kept for file format compatibility (to avoid possible failure when parsing configuration on old versions)</remarks>
/// TODO: Remove this when those older versions aren't in use anymore.
public bool EnableVsync { get; set; } public bool EnableVsync { get; set; }
/// <summary>
/// Current VSync mode; 60 (Switch), unbounded ("Vsync off"), or custom
/// </summary>
public VSyncMode VSyncMode { get; set; }
/// <summary>
/// Enables or disables the custom present interval
/// </summary>
public bool EnableCustomVSyncInterval { get; set; }
/// <summary>
/// The custom present interval value
/// </summary>
public int CustomVSyncInterval { get; set; }
/// <summary> /// <summary>
/// Enables or disables Shader cache /// Enables or disables Shader cache
/// </summary> /// </summary>

View file

@ -468,9 +468,19 @@ namespace Ryujinx.UI.Common.Configuration
public ReactiveObject<string> ShadersDumpPath { get; private set; } public ReactiveObject<string> ShadersDumpPath { get; private set; }
/// <summary> /// <summary>
/// Enables or disables Vertical Sync /// Toggles the present interval mode. Options are Switch (60Hz), Unbounded (previously Vsync off), and Custom, if enabled.
/// </summary> /// </summary>
public ReactiveObject<bool> EnableVsync { get; private set; } public ReactiveObject<VSyncMode> VSyncMode { get; private set; }
/// <summary>
/// Enables or disables the custom present interval mode.
/// </summary>
public ReactiveObject<bool> EnableCustomVSyncInterval { get; private set; }
/// <summary>
/// Changes the custom present interval.
/// </summary>
public ReactiveObject<int> CustomVSyncInterval { get; private set; }
/// <summary> /// <summary>
/// Enables or disables Shader cache /// Enables or disables Shader cache
@ -530,8 +540,12 @@ namespace Ryujinx.UI.Common.Configuration
AspectRatio = new ReactiveObject<AspectRatio>(); AspectRatio = new ReactiveObject<AspectRatio>();
AspectRatio.Event += static (sender, e) => LogValueChange(e, nameof(AspectRatio)); AspectRatio.Event += static (sender, e) => LogValueChange(e, nameof(AspectRatio));
ShadersDumpPath = new ReactiveObject<string>(); ShadersDumpPath = new ReactiveObject<string>();
EnableVsync = new ReactiveObject<bool>(); VSyncMode = new ReactiveObject<VSyncMode>();
EnableVsync.Event += static (sender, e) => LogValueChange(e, nameof(EnableVsync)); VSyncMode.Event += static (sender, e) => LogValueChange(e, nameof(VSyncMode));
EnableCustomVSyncInterval = new ReactiveObject<bool>();
EnableCustomVSyncInterval.Event += static (sender, e) => LogValueChange(e, nameof(EnableCustomVSyncInterval));
CustomVSyncInterval = new ReactiveObject<int>();
CustomVSyncInterval.Event += static (sender, e) => LogValueChange(e, nameof(CustomVSyncInterval));
EnableShaderCache = new ReactiveObject<bool>(); EnableShaderCache = new ReactiveObject<bool>();
EnableShaderCache.Event += static (sender, e) => LogValueChange(e, nameof(EnableShaderCache)); EnableShaderCache.Event += static (sender, e) => LogValueChange(e, nameof(EnableShaderCache));
EnableTextureRecompression = new ReactiveObject<bool>(); EnableTextureRecompression = new ReactiveObject<bool>();
@ -693,7 +707,9 @@ namespace Ryujinx.UI.Common.Configuration
RememberWindowState = RememberWindowState, RememberWindowState = RememberWindowState,
EnableHardwareAcceleration = EnableHardwareAcceleration, EnableHardwareAcceleration = EnableHardwareAcceleration,
HideCursor = HideCursor, HideCursor = HideCursor,
EnableVsync = Graphics.EnableVsync, VSyncMode = Graphics.VSyncMode,
EnableCustomVSyncInterval = Graphics.EnableCustomVSyncInterval,
CustomVSyncInterval = Graphics.CustomVSyncInterval,
EnableShaderCache = Graphics.EnableShaderCache, EnableShaderCache = Graphics.EnableShaderCache,
EnableTextureRecompression = Graphics.EnableTextureRecompression, EnableTextureRecompression = Graphics.EnableTextureRecompression,
EnableMacroHLE = Graphics.EnableMacroHLE, EnableMacroHLE = Graphics.EnableMacroHLE,
@ -802,7 +818,9 @@ namespace Ryujinx.UI.Common.Configuration
RememberWindowState.Value = true; RememberWindowState.Value = true;
EnableHardwareAcceleration.Value = true; EnableHardwareAcceleration.Value = true;
HideCursor.Value = HideCursorMode.OnIdle; HideCursor.Value = HideCursorMode.OnIdle;
Graphics.EnableVsync.Value = true; Graphics.VSyncMode.Value = VSyncMode.Switch;
Graphics.CustomVSyncInterval.Value = 120;
Graphics.EnableCustomVSyncInterval.Value = false;
Graphics.EnableShaderCache.Value = true; Graphics.EnableShaderCache.Value = true;
Graphics.EnableTextureRecompression.Value = false; Graphics.EnableTextureRecompression.Value = false;
Graphics.EnableMacroHLE.Value = true; Graphics.EnableMacroHLE.Value = true;
@ -861,7 +879,7 @@ namespace Ryujinx.UI.Common.Configuration
Hid.EnableMouse.Value = false; Hid.EnableMouse.Value = false;
Hid.Hotkeys.Value = new KeyboardHotkeys Hid.Hotkeys.Value = new KeyboardHotkeys
{ {
ToggleVsync = Key.F1, ToggleVSyncMode = Key.F1,
ToggleMute = Key.F2, ToggleMute = Key.F2,
Screenshot = Key.F8, Screenshot = Key.F8,
ShowUI = Key.F4, ShowUI = Key.F4,
@ -992,7 +1010,7 @@ namespace Ryujinx.UI.Common.Configuration
configurationFileFormat.Hotkeys = new KeyboardHotkeys configurationFileFormat.Hotkeys = new KeyboardHotkeys
{ {
ToggleVsync = Key.F1, ToggleVSyncMode = Key.F1,
}; };
configurationFileUpdated = true; configurationFileUpdated = true;
@ -1186,7 +1204,7 @@ namespace Ryujinx.UI.Common.Configuration
configurationFileFormat.Hotkeys = new KeyboardHotkeys configurationFileFormat.Hotkeys = new KeyboardHotkeys
{ {
ToggleVsync = Key.F1, ToggleVSyncMode = Key.F1,
Screenshot = Key.F8, Screenshot = Key.F8,
}; };
@ -1199,7 +1217,7 @@ namespace Ryujinx.UI.Common.Configuration
configurationFileFormat.Hotkeys = new KeyboardHotkeys configurationFileFormat.Hotkeys = new KeyboardHotkeys
{ {
ToggleVsync = Key.F1, ToggleVSyncMode = Key.F1,
Screenshot = Key.F8, Screenshot = Key.F8,
ShowUI = Key.F4, ShowUI = Key.F4,
}; };
@ -1242,7 +1260,7 @@ namespace Ryujinx.UI.Common.Configuration
configurationFileFormat.Hotkeys = new KeyboardHotkeys configurationFileFormat.Hotkeys = new KeyboardHotkeys
{ {
ToggleVsync = configurationFileFormat.Hotkeys.ToggleVsync, ToggleVSyncMode = Key.F1,
Screenshot = configurationFileFormat.Hotkeys.Screenshot, Screenshot = configurationFileFormat.Hotkeys.Screenshot,
ShowUI = configurationFileFormat.Hotkeys.ShowUI, ShowUI = configurationFileFormat.Hotkeys.ShowUI,
Pause = Key.F5, Pause = Key.F5,
@ -1257,7 +1275,7 @@ namespace Ryujinx.UI.Common.Configuration
configurationFileFormat.Hotkeys = new KeyboardHotkeys configurationFileFormat.Hotkeys = new KeyboardHotkeys
{ {
ToggleVsync = configurationFileFormat.Hotkeys.ToggleVsync, ToggleVSyncMode = Key.F1,
Screenshot = configurationFileFormat.Hotkeys.Screenshot, Screenshot = configurationFileFormat.Hotkeys.Screenshot,
ShowUI = configurationFileFormat.Hotkeys.ShowUI, ShowUI = configurationFileFormat.Hotkeys.ShowUI,
Pause = configurationFileFormat.Hotkeys.Pause, Pause = configurationFileFormat.Hotkeys.Pause,
@ -1331,7 +1349,7 @@ namespace Ryujinx.UI.Common.Configuration
configurationFileFormat.Hotkeys = new KeyboardHotkeys configurationFileFormat.Hotkeys = new KeyboardHotkeys
{ {
ToggleVsync = configurationFileFormat.Hotkeys.ToggleVsync, ToggleVSyncMode = Key.F1,
Screenshot = configurationFileFormat.Hotkeys.Screenshot, Screenshot = configurationFileFormat.Hotkeys.Screenshot,
ShowUI = configurationFileFormat.Hotkeys.ShowUI, ShowUI = configurationFileFormat.Hotkeys.ShowUI,
Pause = configurationFileFormat.Hotkeys.Pause, Pause = configurationFileFormat.Hotkeys.Pause,
@ -1358,7 +1376,7 @@ namespace Ryujinx.UI.Common.Configuration
configurationFileFormat.Hotkeys = new KeyboardHotkeys configurationFileFormat.Hotkeys = new KeyboardHotkeys
{ {
ToggleVsync = configurationFileFormat.Hotkeys.ToggleVsync, ToggleVSyncMode = Key.F1,
Screenshot = configurationFileFormat.Hotkeys.Screenshot, Screenshot = configurationFileFormat.Hotkeys.Screenshot,
ShowUI = configurationFileFormat.Hotkeys.ShowUI, ShowUI = configurationFileFormat.Hotkeys.ShowUI,
Pause = configurationFileFormat.Hotkeys.Pause, Pause = configurationFileFormat.Hotkeys.Pause,
@ -1476,6 +1494,34 @@ namespace Ryujinx.UI.Common.Configuration
configurationFileUpdated = true; configurationFileUpdated = true;
} }
if (configurationFileFormat.Version < 52)
{
Ryujinx.Common.Logging.Logger.Warning?.Print(LogClass.Application, $"Outdated configuration version {configurationFileFormat.Version}, migrating to version 52.");
configurationFileFormat.VSyncMode = VSyncMode.Switch;
configurationFileFormat.EnableCustomVSyncInterval = false;
configurationFileFormat.Hotkeys = new KeyboardHotkeys
{
ToggleVSyncMode = Key.F1,
Screenshot = configurationFileFormat.Hotkeys.Screenshot,
ShowUI = configurationFileFormat.Hotkeys.ShowUI,
Pause = configurationFileFormat.Hotkeys.Pause,
ToggleMute = configurationFileFormat.Hotkeys.ToggleMute,
ResScaleUp = configurationFileFormat.Hotkeys.ResScaleUp,
ResScaleDown = configurationFileFormat.Hotkeys.ResScaleDown,
VolumeUp = configurationFileFormat.Hotkeys.VolumeUp,
VolumeDown = configurationFileFormat.Hotkeys.VolumeDown,
CustomVSyncIntervalIncrement = Key.Unbound,
CustomVSyncIntervalDecrement = Key.Unbound,
};
configurationFileFormat.CustomVSyncInterval = 120;
configurationFileUpdated = true;
}
Logger.EnableFileLog.Value = configurationFileFormat.EnableFileLog; Logger.EnableFileLog.Value = configurationFileFormat.EnableFileLog;
Graphics.ResScale.Value = configurationFileFormat.ResScale; Graphics.ResScale.Value = configurationFileFormat.ResScale;
Graphics.ResScaleCustom.Value = configurationFileFormat.ResScaleCustom; Graphics.ResScaleCustom.Value = configurationFileFormat.ResScaleCustom;
@ -1509,7 +1555,9 @@ namespace Ryujinx.UI.Common.Configuration
RememberWindowState.Value = configurationFileFormat.RememberWindowState; RememberWindowState.Value = configurationFileFormat.RememberWindowState;
EnableHardwareAcceleration.Value = configurationFileFormat.EnableHardwareAcceleration; EnableHardwareAcceleration.Value = configurationFileFormat.EnableHardwareAcceleration;
HideCursor.Value = configurationFileFormat.HideCursor; HideCursor.Value = configurationFileFormat.HideCursor;
Graphics.EnableVsync.Value = configurationFileFormat.EnableVsync; Graphics.VSyncMode.Value = configurationFileFormat.VSyncMode;
Graphics.EnableCustomVSyncInterval.Value = configurationFileFormat.EnableCustomVSyncInterval;
Graphics.CustomVSyncInterval.Value = configurationFileFormat.CustomVSyncInterval;
Graphics.EnableShaderCache.Value = configurationFileFormat.EnableShaderCache; Graphics.EnableShaderCache.Value = configurationFileFormat.EnableShaderCache;
Graphics.EnableTextureRecompression.Value = configurationFileFormat.EnableTextureRecompression; Graphics.EnableTextureRecompression.Value = configurationFileFormat.EnableTextureRecompression;
Graphics.EnableMacroHLE.Value = configurationFileFormat.EnableMacroHLE; Graphics.EnableMacroHLE.Value = configurationFileFormat.EnableMacroHLE;

View file

@ -61,6 +61,7 @@ using MouseButton = Ryujinx.Input.MouseButton;
using ScalingFilter = Ryujinx.Common.Configuration.ScalingFilter; using ScalingFilter = Ryujinx.Common.Configuration.ScalingFilter;
using Size = Avalonia.Size; using Size = Avalonia.Size;
using Switch = Ryujinx.HLE.Switch; using Switch = Ryujinx.HLE.Switch;
using VSyncMode = Ryujinx.Common.Configuration.VSyncMode;
namespace Ryujinx.Ava namespace Ryujinx.Ava
{ {
@ -201,6 +202,9 @@ namespace Ryujinx.Ava
ConfigurationState.Instance.Graphics.ScalingFilter.Event += UpdateScalingFilter; ConfigurationState.Instance.Graphics.ScalingFilter.Event += UpdateScalingFilter;
ConfigurationState.Instance.Graphics.ScalingFilterLevel.Event += UpdateScalingFilterLevel; ConfigurationState.Instance.Graphics.ScalingFilterLevel.Event += UpdateScalingFilterLevel;
ConfigurationState.Instance.Graphics.EnableColorSpacePassthrough.Event += UpdateColorSpacePassthrough; 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.System.EnableInternetAccess.Event += UpdateEnableInternetAccessState;
ConfigurationState.Instance.Multiplayer.LanInterfaceId.Event += UpdateLanInterfaceIdState; ConfigurationState.Instance.Multiplayer.LanInterfaceId.Event += UpdateLanInterfaceIdState;
@ -290,6 +294,66 @@ namespace Ryujinx.Ava
_renderer.Window?.SetColorSpacePassthrough((bool)ConfigurationState.Instance.Graphics.EnableColorSpacePassthrough.Value); _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() private void ShowCursor()
{ {
Dispatcher.UIThread.Post(() => Dispatcher.UIThread.Post(() =>
@ -481,12 +545,6 @@ namespace Ryujinx.Ava
Device.Configuration.MultiplayerMode = e.NewValue; Device.Configuration.MultiplayerMode = e.NewValue;
} }
public void ToggleVSync()
{
Device.EnableDeviceVsync = !Device.EnableDeviceVsync;
_renderer.Window.ChangeVSyncMode(Device.EnableDeviceVsync);
}
public void Stop() public void Stop()
{ {
_isActive = false; _isActive = false;
@ -840,31 +898,32 @@ namespace Ryujinx.Ava
var memoryConfiguration = ConfigurationState.Instance.System.ExpandRam.Value ? MemoryConfiguration.MemoryConfiguration6GiB : MemoryConfiguration.MemoryConfiguration4GiB; var memoryConfiguration = ConfigurationState.Instance.System.ExpandRam.Value ? MemoryConfiguration.MemoryConfiguration6GiB : MemoryConfiguration.MemoryConfiguration4GiB;
HLEConfiguration configuration = new(VirtualFileSystem, HLEConfiguration configuration = new(VirtualFileSystem,
_viewModel.LibHacHorizonManager, _viewModel.LibHacHorizonManager,
ContentManager, ContentManager,
_accountManager, _accountManager,
_userChannelPersistence, _userChannelPersistence,
renderer, renderer,
InitializeAudio(), InitializeAudio(),
memoryConfiguration, memoryConfiguration,
_viewModel.UiHandler, _viewModel.UiHandler,
(SystemLanguage)ConfigurationState.Instance.System.Language.Value, (SystemLanguage)ConfigurationState.Instance.System.Language.Value,
(RegionCode)ConfigurationState.Instance.System.Region.Value, (RegionCode)ConfigurationState.Instance.System.Region.Value,
ConfigurationState.Instance.Graphics.EnableVsync, ConfigurationState.Instance.Graphics.VSyncMode,
ConfigurationState.Instance.System.EnableDockedMode, ConfigurationState.Instance.System.EnableDockedMode,
ConfigurationState.Instance.System.EnablePtc, ConfigurationState.Instance.System.EnablePtc,
ConfigurationState.Instance.System.EnableInternetAccess, ConfigurationState.Instance.System.EnableInternetAccess,
ConfigurationState.Instance.System.EnableFsIntegrityChecks ? IntegrityCheckLevel.ErrorOnInvalid : IntegrityCheckLevel.None, ConfigurationState.Instance.System.EnableFsIntegrityChecks ? IntegrityCheckLevel.ErrorOnInvalid : IntegrityCheckLevel.None,
ConfigurationState.Instance.System.FsGlobalAccessLogMode, ConfigurationState.Instance.System.FsGlobalAccessLogMode,
ConfigurationState.Instance.System.SystemTimeOffset, ConfigurationState.Instance.System.SystemTimeOffset,
ConfigurationState.Instance.System.TimeZone, ConfigurationState.Instance.System.TimeZone,
ConfigurationState.Instance.System.MemoryManagerMode, ConfigurationState.Instance.System.MemoryManagerMode,
ConfigurationState.Instance.System.IgnoreMissingServices, ConfigurationState.Instance.System.IgnoreMissingServices,
ConfigurationState.Instance.Graphics.AspectRatio, ConfigurationState.Instance.Graphics.AspectRatio,
ConfigurationState.Instance.System.AudioVolume, ConfigurationState.Instance.System.AudioVolume,
ConfigurationState.Instance.System.UseHypervisor, ConfigurationState.Instance.System.UseHypervisor,
ConfigurationState.Instance.Multiplayer.LanInterfaceId.Value, ConfigurationState.Instance.Multiplayer.LanInterfaceId.Value,
ConfigurationState.Instance.Multiplayer.Mode); ConfigurationState.Instance.Multiplayer.Mode,
ConfigurationState.Instance.Graphics.CustomVSyncInterval.Value);
Device = new Switch(configuration); Device = new Switch(configuration);
} }
@ -989,7 +1048,7 @@ namespace Ryujinx.Ava
Device.Gpu.SetGpuThread(); Device.Gpu.SetGpuThread();
Device.Gpu.InitializeShaderCache(_gpuCancellationTokenSource.Token); Device.Gpu.InitializeShaderCache(_gpuCancellationTokenSource.Token);
_renderer.Window.ChangeVSyncMode(Device.EnableDeviceVsync); _renderer.Window.ChangeVSyncMode((Ryujinx.Graphics.GAL.VSyncMode)Device.VSyncMode);
while (_isActive) while (_isActive)
{ {
@ -1050,6 +1109,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. // 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 dockedMode = ConfigurationState.Instance.System.EnableDockedMode ? LocaleManager.Instance[LocaleKeys.Docked] : LocaleManager.Instance[LocaleKeys.Handheld];
string vSyncMode = Device.VSyncMode.ToString();
if (GraphicsConfig.ResScale != 1) if (GraphicsConfig.ResScale != 1)
{ {
@ -1057,7 +1117,7 @@ namespace Ryujinx.Ava
} }
StatusUpdatedEvent?.Invoke(this, new StatusUpdatedEventArgs( StatusUpdatedEvent?.Invoke(this, new StatusUpdatedEventArgs(
Device.EnableDeviceVsync, vSyncMode,
LocaleManager.Instance[LocaleKeys.VolumeShort] + $": {(int)(Device.GetVolume() * 100)}%", LocaleManager.Instance[LocaleKeys.VolumeShort] + $": {(int)(Device.GetVolume() * 100)}%",
dockedMode, dockedMode,
ConfigurationState.Instance.Graphics.AspectRatio.Value.ToText(), ConfigurationState.Instance.Graphics.AspectRatio.Value.ToText(),
@ -1141,8 +1201,16 @@ namespace Ryujinx.Ava
{ {
switch (currentHotkeyState) switch (currentHotkeyState)
{ {
case KeyboardHotkeyState.ToggleVSync: case KeyboardHotkeyState.ToggleVSyncMode:
ToggleVSync(); VSyncModeToggle();
break;
case KeyboardHotkeyState.CustomVSyncIntervalDecrement:
Device.DecrementCustomVSyncInterval();
_viewModel.CustomVSyncInterval -= 1;
break;
case KeyboardHotkeyState.CustomVSyncIntervalIncrement:
Device.IncrementCustomVSyncInterval();
_viewModel.CustomVSyncInterval += 1;
break; break;
case KeyboardHotkeyState.Screenshot: case KeyboardHotkeyState.Screenshot:
ScreenshotRequested = true; ScreenshotRequested = true;
@ -1229,9 +1297,9 @@ namespace Ryujinx.Ava
{ {
KeyboardHotkeyState state = KeyboardHotkeyState.None; 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)) else if (_keyboardInterface.IsPressed((Key)ConfigurationState.Instance.Hid.Hotkeys.Value.Screenshot))
{ {
@ -1265,6 +1333,14 @@ namespace Ryujinx.Ava
{ {
state = KeyboardHotkeyState.VolumeDown; 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; return state;
} }

View file

@ -132,9 +132,19 @@
"SettingsTabSystemSystemLanguageLatinAmericanSpanish": "Latin American Spanish", "SettingsTabSystemSystemLanguageLatinAmericanSpanish": "Latin American Spanish",
"SettingsTabSystemSystemLanguageSimplifiedChinese": "Simplified Chinese", "SettingsTabSystemSystemLanguageSimplifiedChinese": "Simplified Chinese",
"SettingsTabSystemSystemLanguageTraditionalChinese": "Traditional Chinese", "SettingsTabSystemSystemLanguageTraditionalChinese": "Traditional Chinese",
"SettingsTabSystemSystemTimeZone": "System TimeZone:", "SettingsTabSystemSystemTimeZone": "System Time Zone:",
"SettingsTabSystemSystemTime": "System Time:", "SettingsTabSystemSystemTime": "System Time:",
"SettingsTabSystemEnableVsync": "VSync", "SettingsTabSystemVSyncMode": "VSync:",
"SettingsTabSystemEnableCustomVSyncInterval": "Enable custom refresh rate (Experimental)",
"SettingsTabSystemVSyncModeSwitch": "Switch",
"SettingsTabSystemVSyncModeUnbounded": "Unbounded",
"SettingsTabSystemVSyncModeCustom": "Custom Refresh Rate",
"SettingsTabSystemVSyncModeTooltip": "Emulated Vertical Sync. 'Switch' emulates the Switch's refresh rate of 60Hz. 'Unbounded' is an unbounded refresh rate.",
"SettingsTabSystemVSyncModeTooltipCustom": "Emulated Vertical Sync. 'Switch' emulates the Switch's refresh rate of 60Hz. 'Unbounded' is an unbounded refresh rate. 'Custom' emulates the specified custom refresh rate.",
"SettingsTabSystemEnableCustomVSyncIntervalTooltip": "Allows the user to specify an emulated refresh rate. In some titles, this may speed up or slow down the rate of gameplay logic. In other titles, it may allow for capping FPS at some multiple of the refresh rate, or lead to unpredictable behavior. This is an experimental feature, with no guarantees for how gameplay will be affected. \n\nLeave OFF if unsure.",
"SettingsTabSystemCustomVSyncIntervalValueTooltip": "The custom refresh rate target value.",
"SettingsTabSystemCustomVSyncIntervalSliderTooltip": "The custom refresh rate, as a percentage of the normal Switch refresh rate.",
"SettingsTabSystemCustomVSyncIntervalValue": "Custom Refresh Rate Value:",
"SettingsTabSystemEnablePptc": "PPTC (Profiled Persistent Translation Cache)", "SettingsTabSystemEnablePptc": "PPTC (Profiled Persistent Translation Cache)",
"SettingsTabSystemEnableFsIntegrityChecks": "FS Integrity Checks", "SettingsTabSystemEnableFsIntegrityChecks": "FS Integrity Checks",
"SettingsTabSystemAudioBackend": "Audio Backend:", "SettingsTabSystemAudioBackend": "Audio Backend:",
@ -142,6 +152,7 @@
"SettingsTabSystemAudioBackendOpenAL": "OpenAL", "SettingsTabSystemAudioBackendOpenAL": "OpenAL",
"SettingsTabSystemAudioBackendSoundIO": "SoundIO", "SettingsTabSystemAudioBackendSoundIO": "SoundIO",
"SettingsTabSystemAudioBackendSDL2": "SDL2", "SettingsTabSystemAudioBackendSDL2": "SDL2",
"SettingsTabSystemCustomVSyncInterval": "Interval",
"SettingsTabSystemHacks": "Hacks", "SettingsTabSystemHacks": "Hacks",
"SettingsTabSystemHacksNote": "May cause instability", "SettingsTabSystemHacksNote": "May cause instability",
"SettingsTabSystemExpandDramSize": "Use alternative memory layout (Developers)", "SettingsTabSystemExpandDramSize": "Use alternative memory layout (Developers)",
@ -683,11 +694,13 @@
"RyujinxUpdater": "Ryujinx Updater", "RyujinxUpdater": "Ryujinx Updater",
"SettingsTabHotkeys": "Keyboard Hotkeys", "SettingsTabHotkeys": "Keyboard Hotkeys",
"SettingsTabHotkeysHotkeys": "Keyboard Hotkeys", "SettingsTabHotkeysHotkeys": "Keyboard Hotkeys",
"SettingsTabHotkeysToggleVsyncHotkey": "Toggle VSync:", "SettingsTabHotkeysToggleVSyncModeHotkey": "Toggle VSync mode:",
"SettingsTabHotkeysScreenshotHotkey": "Screenshot:", "SettingsTabHotkeysScreenshotHotkey": "Screenshot:",
"SettingsTabHotkeysShowUiHotkey": "Show UI:", "SettingsTabHotkeysShowUiHotkey": "Show UI:",
"SettingsTabHotkeysPauseHotkey": "Pause:", "SettingsTabHotkeysPauseHotkey": "Pause:",
"SettingsTabHotkeysToggleMuteHotkey": "Mute:", "SettingsTabHotkeysToggleMuteHotkey": "Mute:",
"SettingsTabHotkeysIncrementCustomVSyncIntervalHotkey": "Raise custom refresh rate",
"SettingsTabHotkeysDecrementCustomVSyncIntervalHotkey": "Lower custom refresh rate",
"ControllerMotionTitle": "Motion Control Settings", "ControllerMotionTitle": "Motion Control Settings",
"ControllerRumbleTitle": "Rumble Settings", "ControllerRumbleTitle": "Rumble Settings",
"SettingsSelectThemeFileDialogTitle": "Select Theme File", "SettingsSelectThemeFileDialogTitle": "Select Theme File",

View file

@ -26,8 +26,9 @@
<Color x:Key="AppListBackgroundColor">#b3ffffff</Color> <Color x:Key="AppListBackgroundColor">#b3ffffff</Color>
<Color x:Key="AppListHoverBackgroundColor">#80cccccc</Color> <Color x:Key="AppListHoverBackgroundColor">#80cccccc</Color>
<Color x:Key="SecondaryTextColor">#A0000000</Color> <Color x:Key="SecondaryTextColor">#A0000000</Color>
<Color x:Key="VsyncEnabled">#FF2EEAC9</Color> <Color x:Key="Switch">#FF2EEAC9</Color>
<Color x:Key="VsyncDisabled">#FFFF4554</Color> <Color x:Key="Unbounded">#FFFF4554</Color>
<Color x:Key="Custom">#6483F5</Color>
</ResourceDictionary> </ResourceDictionary>
<ResourceDictionary x:Key="Light"> <ResourceDictionary x:Key="Light">
<SolidColorBrush x:Key="DataGridSelectionBackgroundBrush" <SolidColorBrush x:Key="DataGridSelectionBackgroundBrush"

View file

@ -3,7 +3,7 @@ namespace Ryujinx.Ava.Common
public enum KeyboardHotkeyState public enum KeyboardHotkeyState
{ {
None, None,
ToggleVSync, ToggleVSyncMode,
Screenshot, Screenshot,
ShowUI, ShowUI,
Pause, Pause,
@ -12,5 +12,7 @@ namespace Ryujinx.Ava.Common
ResScaleDown, ResScaleDown,
VolumeUp, VolumeUp,
VolumeDown, VolumeDown,
CustomVSyncIntervalIncrement,
CustomVSyncIntervalDecrement,
} }
} }

View file

@ -5,13 +5,13 @@ namespace Ryujinx.Ava.UI.Models.Input
{ {
public class HotkeyConfig : BaseModel public class HotkeyConfig : BaseModel
{ {
private Key _toggleVsync; private Key _toggleVSyncMode;
public Key ToggleVsync public Key ToggleVSyncMode
{ {
get => _toggleVsync; get => _toggleVSyncMode;
set set
{ {
_toggleVsync = value; _toggleVSyncMode = value;
OnPropertyChanged(); OnPropertyChanged();
} }
} }
@ -104,11 +104,33 @@ namespace Ryujinx.Ava.UI.Models.Input
} }
} }
private Key _customVSyncIntervalIncrement;
public Key CustomVSyncIntervalIncrement
{
get => _customVSyncIntervalIncrement;
set
{
_customVSyncIntervalIncrement = value;
OnPropertyChanged();
}
}
private Key _customVSyncIntervalDecrement;
public Key CustomVSyncIntervalDecrement
{
get => _customVSyncIntervalDecrement;
set
{
_customVSyncIntervalDecrement = value;
OnPropertyChanged();
}
}
public HotkeyConfig(KeyboardHotkeys config) public HotkeyConfig(KeyboardHotkeys config)
{ {
if (config != null) if (config != null)
{ {
ToggleVsync = config.ToggleVsync; ToggleVSyncMode = config.ToggleVSyncMode;
Screenshot = config.Screenshot; Screenshot = config.Screenshot;
ShowUI = config.ShowUI; ShowUI = config.ShowUI;
Pause = config.Pause; Pause = config.Pause;
@ -117,6 +139,8 @@ namespace Ryujinx.Ava.UI.Models.Input
ResScaleDown = config.ResScaleDown; ResScaleDown = config.ResScaleDown;
VolumeUp = config.VolumeUp; VolumeUp = config.VolumeUp;
VolumeDown = config.VolumeDown; VolumeDown = config.VolumeDown;
CustomVSyncIntervalIncrement = config.CustomVSyncIntervalIncrement;
CustomVSyncIntervalDecrement = config.CustomVSyncIntervalDecrement;
} }
} }
@ -124,7 +148,7 @@ namespace Ryujinx.Ava.UI.Models.Input
{ {
var config = new KeyboardHotkeys var config = new KeyboardHotkeys
{ {
ToggleVsync = ToggleVsync, ToggleVSyncMode = ToggleVSyncMode,
Screenshot = Screenshot, Screenshot = Screenshot,
ShowUI = ShowUI, ShowUI = ShowUI,
Pause = Pause, Pause = Pause,
@ -133,6 +157,8 @@ namespace Ryujinx.Ava.UI.Models.Input
ResScaleDown = ResScaleDown, ResScaleDown = ResScaleDown,
VolumeUp = VolumeUp, VolumeUp = VolumeUp,
VolumeDown = VolumeDown, VolumeDown = VolumeDown,
CustomVSyncIntervalIncrement = CustomVSyncIntervalIncrement,
CustomVSyncIntervalDecrement = CustomVSyncIntervalDecrement,
}; };
return config; return config;

View file

@ -4,16 +4,16 @@ namespace Ryujinx.Ava.UI.Models
{ {
internal class StatusUpdatedEventArgs : EventArgs internal class StatusUpdatedEventArgs : EventArgs
{ {
public bool VSyncEnabled { get; } public string VSyncMode { get; }
public string VolumeStatus { get; } public string VolumeStatus { get; }
public string AspectRatio { get; } public string AspectRatio { get; }
public string DockedMode { get; } public string DockedMode { get; }
public string FifoStatus { get; } public string FifoStatus { get; }
public string GameStatus { get; } public string GameStatus { get; }
public StatusUpdatedEventArgs(bool vSyncEnabled, string volumeStatus, string dockedMode, string aspectRatio, string gameStatus, string fifoStatus) public StatusUpdatedEventArgs(string vSyncMode, string volumeStatus, string dockedMode, string aspectRatio, string gameStatus, string fifoStatus)
{ {
VSyncEnabled = vSyncEnabled; VSyncMode = vSyncMode;
VolumeStatus = volumeStatus; VolumeStatus = volumeStatus;
DockedMode = dockedMode; DockedMode = dockedMode;
AspectRatio = aspectRatio; AspectRatio = aspectRatio;

View file

@ -59,6 +59,7 @@ namespace Ryujinx.Ava.UI.ViewModels
private string _searchText; private string _searchText;
private Timer _searchTimer; private Timer _searchTimer;
private string _dockedStatusText; private string _dockedStatusText;
private string _vSyncModeText;
private string _fifoStatusText; private string _fifoStatusText;
private string _gameStatusText; private string _gameStatusText;
private string _volumeStatusText; private string _volumeStatusText;
@ -74,7 +75,7 @@ namespace Ryujinx.Ava.UI.ViewModels
private bool _showStatusSeparator; private bool _showStatusSeparator;
private Brush _progressBarForegroundColor; private Brush _progressBarForegroundColor;
private Brush _progressBarBackgroundColor; private Brush _progressBarBackgroundColor;
private Brush _vsyncColor; private Brush _vSyncModeColor;
private byte[] _selectedIcon; private byte[] _selectedIcon;
private bool _isAppletMenuActive; private bool _isAppletMenuActive;
private int _statusBarProgressMaximum; private int _statusBarProgressMaximum;
@ -102,6 +103,8 @@ namespace Ryujinx.Ava.UI.ViewModels
private WindowState _windowState; private WindowState _windowState;
private double _windowWidth; private double _windowWidth;
private double _windowHeight; private double _windowHeight;
private int _customVSyncInterval;
private int _customVSyncIntervalPercentageProxy;
private bool _isActive; private bool _isActive;
private bool _isSubMenuOpen; private bool _isSubMenuOpen;
@ -129,6 +132,7 @@ namespace Ryujinx.Ava.UI.ViewModels
Volume = ConfigurationState.Instance.System.AudioVolume; Volume = ConfigurationState.Instance.System.AudioVolume;
} }
CustomVSyncInterval = ConfigurationState.Instance.Graphics.CustomVSyncInterval.Value;
} }
public void Initialize( public void Initialize(
@ -416,17 +420,87 @@ namespace Ryujinx.Ava.UI.ViewModels
} }
} }
public Brush VsyncColor public Brush VSyncModeColor
{ {
get => _vsyncColor; get => _vSyncModeColor;
set set
{ {
_vsyncColor = value; _vSyncModeColor = value;
OnPropertyChanged(); OnPropertyChanged();
} }
} }
public bool ShowCustomVSyncIntervalPicker
{
get
{
if (_isGameRunning)
{
return AppHost.Device.VSyncMode ==
VSyncMode.Custom;
}
else
{
return false;
}
}
set
{
OnPropertyChanged();
}
}
public int CustomVSyncIntervalPercentageProxy
{
get => _customVSyncIntervalPercentageProxy;
set
{
int newInterval = (int)((value / 100f) * 60);
_customVSyncInterval = newInterval;
_customVSyncIntervalPercentageProxy = value;
if (_isGameRunning)
{
AppHost.Device.CustomVSyncInterval = newInterval;
AppHost.Device.UpdateVSyncInterval();
}
OnPropertyChanged((nameof(CustomVSyncInterval)));
OnPropertyChanged((nameof(CustomVSyncIntervalPercentageText)));
}
}
public string CustomVSyncIntervalPercentageText
{
get
{
string text = CustomVSyncIntervalPercentageProxy.ToString() + "%";
return text;
}
set
{
}
}
public int CustomVSyncInterval
{
get => _customVSyncInterval;
set
{
_customVSyncInterval = value;
int newPercent = (int)((value / 60f) * 100);
_customVSyncIntervalPercentageProxy = newPercent;
if (_isGameRunning)
{
AppHost.Device.CustomVSyncInterval = value;
AppHost.Device.UpdateVSyncInterval();
}
OnPropertyChanged(nameof(CustomVSyncIntervalPercentageProxy));
OnPropertyChanged(nameof(CustomVSyncIntervalPercentageText));
OnPropertyChanged();
}
}
public byte[] SelectedIcon public byte[] SelectedIcon
{ {
get => _selectedIcon; get => _selectedIcon;
@ -515,6 +589,17 @@ namespace Ryujinx.Ava.UI.ViewModels
} }
} }
public string VSyncModeText
{
get => _vSyncModeText;
set
{
_vSyncModeText = value;
OnPropertyChanged();
}
}
public string DockedStatusText public string DockedStatusText
{ {
get => _dockedStatusText; get => _dockedStatusText;
@ -1229,17 +1314,18 @@ namespace Ryujinx.Ava.UI.ViewModels
{ {
Dispatcher.UIThread.InvokeAsync(() => Dispatcher.UIThread.InvokeAsync(() =>
{ {
Application.Current.Styles.TryGetResource(args.VSyncEnabled Application.Current.Styles.TryGetResource(args.VSyncMode,
? "VsyncEnabled" Avalonia.Application.Current.ActualThemeVariant,
: "VsyncDisabled",
Application.Current.ActualThemeVariant,
out object color); out object color);
if (color is not null) if (color is not null)
{ {
VsyncColor = new SolidColorBrush((Color)color); VSyncModeColor = new SolidColorBrush((Color)color);
} }
VSyncModeText = args.VSyncMode == "Custom" ? "Custom" : "VSync";
ShowCustomVSyncIntervalPicker =
args.VSyncMode == VSyncMode.Custom.ToString();
DockedStatusText = args.DockedMode; DockedStatusText = args.DockedMode;
AspectRatioStatusText = args.AspectRatio; AspectRatioStatusText = args.AspectRatio;
GameStatusText = args.GameStatus; GameStatusText = args.GameStatus;
@ -1396,6 +1482,27 @@ namespace Ryujinx.Ava.UI.ViewModels
} }
} }
public void ToggleVSyncMode()
{
AppHost.VSyncModeToggle();
OnPropertyChanged(nameof(ShowCustomVSyncIntervalPicker));
}
public void VSyncModeSettingChanged()
{
if (_isGameRunning)
{
AppHost.Device.CustomVSyncInterval = ConfigurationState.Instance.Graphics.CustomVSyncInterval.Value;
AppHost.Device.UpdateVSyncInterval();
}
CustomVSyncInterval = ConfigurationState.Instance.Graphics.CustomVSyncInterval.Value;
OnPropertyChanged(nameof(ShowCustomVSyncIntervalPicker));
OnPropertyChanged(nameof(CustomVSyncIntervalPercentageProxy));
OnPropertyChanged(nameof(CustomVSyncIntervalPercentageText));
OnPropertyChanged(nameof(CustomVSyncInterval));
}
public async Task ExitCurrentState() public async Task ExitCurrentState()
{ {
if (WindowState == WindowState.FullScreen) if (WindowState == WindowState.FullScreen)

View file

@ -49,6 +49,10 @@ namespace Ryujinx.Ava.UI.ViewModels
private int _graphicsBackendIndex; private int _graphicsBackendIndex;
private int _scalingFilter; private int _scalingFilter;
private int _scalingFilterLevel; private int _scalingFilterLevel;
private int _customVSyncInterval;
private bool _enableCustomVSyncInterval;
private int _customVSyncIntervalPercentageProxy;
private VSyncMode _vSyncMode;
public event Action CloseWindow; public event Action CloseWindow;
public event Action SaveSettingsEvent; public event Action SaveSettingsEvent;
@ -136,7 +140,74 @@ namespace Ryujinx.Ava.UI.ViewModels
public bool EnableDockedMode { get; set; } public bool EnableDockedMode { get; set; }
public bool EnableKeyboard { get; set; } public bool EnableKeyboard { get; set; }
public bool EnableMouse { get; set; } public bool EnableMouse { get; set; }
public bool EnableVsync { get; set; } public VSyncMode VSyncMode
{
get => _vSyncMode;
set
{
if (value == VSyncMode.Custom ||
value == VSyncMode.Switch ||
value == VSyncMode.Unbounded)
{
_vSyncMode = value;
OnPropertyChanged();
}
}
}
public int CustomVSyncIntervalPercentageProxy
{
get => _customVSyncIntervalPercentageProxy;
set
{
int newInterval = (int)((value / 100f) * 60);
_customVSyncInterval = newInterval;
_customVSyncIntervalPercentageProxy = value;
OnPropertyChanged((nameof(CustomVSyncInterval)));
OnPropertyChanged((nameof(CustomVSyncIntervalPercentageText)));
}
}
public string CustomVSyncIntervalPercentageText
{
get
{
string text = CustomVSyncIntervalPercentageProxy.ToString() + "%";
return text;
}
}
public bool EnableCustomVSyncInterval
{
get => _enableCustomVSyncInterval;
set
{
_enableCustomVSyncInterval = value;
if (_vSyncMode == VSyncMode.Custom && !value)
{
VSyncMode = VSyncMode.Switch;
}
else if (value)
{
VSyncMode = VSyncMode.Custom;
}
OnPropertyChanged();
}
}
public int CustomVSyncInterval
{
get => _customVSyncInterval;
set
{
_customVSyncInterval = value;
int newPercent = (int)((value / 60f) * 100);
_customVSyncIntervalPercentageProxy = newPercent;
OnPropertyChanged(nameof(CustomVSyncIntervalPercentageProxy));
OnPropertyChanged(nameof(CustomVSyncIntervalPercentageText));
OnPropertyChanged();
}
}
public bool EnablePptc { get; set; } public bool EnablePptc { get; set; }
public bool EnableInternetAccess { get; set; } public bool EnableInternetAccess { get; set; }
public bool EnableFsIntegrityChecks { get; set; } public bool EnableFsIntegrityChecks { get; set; }
@ -418,7 +489,9 @@ namespace Ryujinx.Ava.UI.ViewModels
CurrentDate = currentDateTime.Date; CurrentDate = currentDateTime.Date;
CurrentTime = currentDateTime.TimeOfDay; CurrentTime = currentDateTime.TimeOfDay;
EnableVsync = config.Graphics.EnableVsync; EnableCustomVSyncInterval = config.Graphics.EnableCustomVSyncInterval.Value;
CustomVSyncInterval = config.Graphics.CustomVSyncInterval;
VSyncMode = config.Graphics.VSyncMode;
EnableFsIntegrityChecks = config.System.EnableFsIntegrityChecks; EnableFsIntegrityChecks = config.System.EnableFsIntegrityChecks;
ExpandDramSize = config.System.ExpandRam; ExpandDramSize = config.System.ExpandRam;
IgnoreMissingServices = config.System.IgnoreMissingServices; IgnoreMissingServices = config.System.IgnoreMissingServices;
@ -430,7 +503,7 @@ namespace Ryujinx.Ava.UI.ViewModels
// Graphics // Graphics
GraphicsBackendIndex = (int)config.Graphics.GraphicsBackend.Value; GraphicsBackendIndex = (int)config.Graphics.GraphicsBackend.Value;
// Physical devices are queried asynchronously hence the prefered index config value is loaded in LoadAvailableGpus(). // Physical devices are queried asynchronously hence the preferred index config value is loaded in LoadAvailableGpus().
EnableShaderCache = config.Graphics.EnableShaderCache; EnableShaderCache = config.Graphics.EnableShaderCache;
EnableTextureRecompression = config.Graphics.EnableTextureRecompression; EnableTextureRecompression = config.Graphics.EnableTextureRecompression;
EnableMacroHLE = config.Graphics.EnableMacroHLE; EnableMacroHLE = config.Graphics.EnableMacroHLE;
@ -506,7 +579,9 @@ namespace Ryujinx.Ava.UI.ViewModels
} }
config.System.SystemTimeOffset.Value = Convert.ToInt64((CurrentDate.ToUnixTimeSeconds() + CurrentTime.TotalSeconds) - DateTimeOffset.Now.ToUnixTimeSeconds()); config.System.SystemTimeOffset.Value = Convert.ToInt64((CurrentDate.ToUnixTimeSeconds() + CurrentTime.TotalSeconds) - DateTimeOffset.Now.ToUnixTimeSeconds());
config.Graphics.EnableVsync.Value = EnableVsync; config.Graphics.VSyncMode.Value = VSyncMode;
config.Graphics.EnableCustomVSyncInterval.Value = EnableCustomVSyncInterval;
config.Graphics.CustomVSyncInterval.Value = CustomVSyncInterval;
config.System.EnableFsIntegrityChecks.Value = EnableFsIntegrityChecks; config.System.EnableFsIntegrityChecks.Value = EnableFsIntegrityChecks;
config.System.ExpandRam.Value = ExpandDramSize; config.System.ExpandRam.Value = ExpandDramSize;
config.System.IgnoreMissingServices.Value = IgnoreMissingServices; config.System.IgnoreMissingServices.Value = IgnoreMissingServices;
@ -572,6 +647,7 @@ namespace Ryujinx.Ava.UI.ViewModels
config.ToFileFormat().SaveConfig(Program.ConfigurationPath); config.ToFileFormat().SaveConfig(Program.ConfigurationPath);
MainWindow.UpdateGraphicsConfig(); MainWindow.UpdateGraphicsConfig();
MainWindow.MainWindowViewModel.VSyncModeSettingChanged();
SaveSettingsEvent?.Invoke(); SaveSettingsEvent?.Invoke();

View file

@ -1,4 +1,4 @@
<UserControl <UserControl
xmlns="https://github.com/avaloniaui" xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
@ -80,15 +80,69 @@
MaxHeight="18" MaxHeight="18"
Orientation="Horizontal"> Orientation="Horizontal">
<TextBlock <TextBlock
Name="VsyncStatus" Name="VSyncMode"
Margin="5,0,5,0" Margin="5,0,5,0"
HorizontalAlignment="Left" HorizontalAlignment="Left"
VerticalAlignment="Center" VerticalAlignment="Center"
Foreground="{Binding VsyncColor}" Foreground="{Binding VSyncModeColor}"
IsVisible="{Binding !ShowLoadProgress}" IsVisible="{Binding !ShowLoadProgress}"
PointerReleased="VsyncStatus_PointerReleased" PointerReleased="VSyncMode_PointerReleased"
Text="VSync" Text="{Binding VSyncModeText}"
TextAlignment="Start" /> TextAlignment="Start"/>
<Button MinWidth="0"
Width="20"
IsVisible="{Binding ShowCustomVSyncIntervalPicker}"
Margin="-5,0,5,0"
Background="Transparent"
BorderThickness="0">
<ui:SymbolIcon Symbol="Settings"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
Width="14"
Height="14"/>
<Button.Styles>
<Style Selector=":checked">
<Style Selector="^:checked ContentPresenter">
<Setter Property="Foreground" Value="{DynamicResource ThemeForegroundColor}" />
</Style>
</Style>
<Style Selector="Border#SeparatorBorder">
<Setter Property="Opacity" Value="0" />
</Style>
</Button.Styles>
<Button.Flyout>
<Flyout Placement="Top" ShowMode="TransientWithDismissOnPointerMoveAway">
<StackPanel Margin="0,0,0,10"
Orientation="Horizontal">
<ui:NumberBox ToolTip.Tip="{locale:Locale SettingsTabSystemCustomVSyncIntervalValueTooltip}"
Value="{Binding CustomVSyncInterval}"
Width="175"
SmallChange="1.0"
LargeChange="10"
SimpleNumberFormat="F0"
SpinButtonPlacementMode="Hidden"
Minimum="10"
Maximum="1000" />
<Slider Value="{Binding CustomVSyncIntervalPercentageProxy}"
ToolTip.Tip="{locale:Locale SettingsTabSystemCustomVSyncIntervalSliderTooltip}"
MinWidth="175"
Margin="10,-3,0,0"
Height="32"
Padding="0,-5"
TickFrequency="1"
IsSnapToTickEnabled="True"
LargeChange="10"
SmallChange="1"
VerticalAlignment="Center"
Minimum="10"
Maximum="400" />
<TextBlock Margin="5,0"
Width="40"
Text="{Binding CustomVSyncIntervalPercentageText}"/>
</StackPanel>
</Flyout>
</Button.Flyout>
</Button>
<Border <Border
Width="2" Width="2"
Height="12" Height="12"

View file

@ -31,11 +31,10 @@ namespace Ryujinx.Ava.UI.Views.Main
DataContext = Window.ViewModel; DataContext = Window.ViewModel;
} }
private void VsyncStatus_PointerReleased(object sender, PointerReleasedEventArgs e) private void VSyncMode_PointerReleased(object sender, PointerReleasedEventArgs e)
{ {
Window.ViewModel.AppHost.ToggleVSync(); Window.ViewModel.ToggleVSyncMode();
Logger.Info?.Print(LogClass.Application, $"VSync Mode toggled to: {Window.ViewModel.AppHost.Device.VSyncMode}");
Logger.Info?.Print(LogClass.Application, $"VSync toggled to: {Window.ViewModel.AppHost.Device.EnableDeviceVsync}");
} }
private void DockedStatus_PointerReleased(object sender, PointerReleasedEventArgs e) private void DockedStatus_PointerReleased(object sender, PointerReleasedEventArgs e)

View file

@ -1,4 +1,4 @@
<UserControl <UserControl
x:Class="Ryujinx.Ava.UI.Views.Settings.SettingsHotkeysView" x:Class="Ryujinx.Ava.UI.Views.Settings.SettingsHotkeysView"
xmlns="https://github.com/avaloniaui" xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
@ -50,9 +50,9 @@
Classes="h1" Classes="h1"
Text="{locale:Locale SettingsTabHotkeysHotkeys}" /> Text="{locale:Locale SettingsTabHotkeysHotkeys}" />
<StackPanel> <StackPanel>
<TextBlock Text="{locale:Locale SettingsTabHotkeysToggleVsyncHotkey}" /> <TextBlock Text="{locale:Locale SettingsTabHotkeysToggleVSyncModeHotkey}" />
<ToggleButton Name="ToggleVsync"> <ToggleButton Name="ToggleVSyncMode">
<TextBlock Text="{Binding KeyboardHotkey.ToggleVsync, Converter={StaticResource Key}}" /> <TextBlock Text="{Binding KeyboardHotkey.ToggleVSyncMode, Converter={StaticResource Key}}" />
</ToggleButton> </ToggleButton>
</StackPanel> </StackPanel>
<StackPanel> <StackPanel>
@ -103,6 +103,18 @@
<TextBlock Text="{Binding KeyboardHotkey.VolumeDown, Converter={StaticResource Key}}" /> <TextBlock Text="{Binding KeyboardHotkey.VolumeDown, Converter={StaticResource Key}}" />
</ToggleButton> </ToggleButton>
</StackPanel> </StackPanel>
<StackPanel Margin="10,0,0,0" Orientation="Horizontal">
<TextBlock Text="{locale:Locale SettingsTabHotkeysIncrementCustomVSyncIntervalHotkey}" />
<ToggleButton Name="CustomVSyncIntervalIncrement">
<TextBlock Text="{Binding KeyboardHotkey.CustomVSyncIntervalIncrement, Converter={StaticResource Key}}" />
</ToggleButton>
</StackPanel>
<StackPanel Margin="10,0,0,0" Orientation="Horizontal">
<TextBlock Text="{locale:Locale SettingsTabHotkeysDecrementCustomVSyncIntervalHotkey}" />
<ToggleButton Name="CustomVSyncIntervalDecrement">
<TextBlock Text="{Binding KeyboardHotkey.CustomVSyncIntervalDecrement, Converter={StaticResource Key}}" />
</ToggleButton>
</StackPanel>
</StackPanel> </StackPanel>
</Border> </Border>
</ScrollViewer> </ScrollViewer>

View file

@ -82,8 +82,8 @@ namespace Ryujinx.Ava.UI.Views.Settings
switch (button.Name) switch (button.Name)
{ {
case "ToggleVsync": case "ToggleVSyncMode":
viewModel.KeyboardHotkey.ToggleVsync = buttonValue.AsHidType<Key>(); viewModel.KeyboardHotkey.ToggleVSyncMode = buttonValue.AsHidType<Key>();
break; break;
case "Screenshot": case "Screenshot":
viewModel.KeyboardHotkey.Screenshot = buttonValue.AsHidType<Key>(); viewModel.KeyboardHotkey.Screenshot = buttonValue.AsHidType<Key>();
@ -109,6 +109,12 @@ namespace Ryujinx.Ava.UI.Views.Settings
case "VolumeDown": case "VolumeDown":
viewModel.KeyboardHotkey.VolumeDown = buttonValue.AsHidType<Key>(); viewModel.KeyboardHotkey.VolumeDown = buttonValue.AsHidType<Key>();
break; break;
case "CustomVSyncIntervalIncrement":
viewModel.KeyboardHotkey.CustomVSyncIntervalIncrement = buttonValue.AsHidType<Key>();
break;
case "CustomVSyncIntervalDecrement":
viewModel.KeyboardHotkey.CustomVSyncIntervalDecrement = buttonValue.AsHidType<Key>();
break;
} }
} }
}; };

View file

@ -4,6 +4,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
xmlns:locale="clr-namespace:Ryujinx.Ava.Common.Locale" xmlns:locale="clr-namespace:Ryujinx.Ava.Common.Locale"
xmlns:viewModels="clr-namespace:Ryujinx.Ava.UI.ViewModels" xmlns:viewModels="clr-namespace:Ryujinx.Ava.UI.ViewModels"
xmlns:helpers="clr-namespace:Ryujinx.Ava.UI.Helpers" xmlns:helpers="clr-namespace:Ryujinx.Ava.UI.Helpers"
@ -181,11 +182,78 @@
Width="350" Width="350"
ToolTip.Tip="{locale:Locale TimeTooltip}" /> ToolTip.Tip="{locale:Locale TimeTooltip}" />
</StackPanel> </StackPanel>
<CheckBox IsChecked="{Binding EnableVsync}"> <StackPanel Margin="0,0,0,10"
Orientation="Horizontal">
<TextBlock <TextBlock
Text="{locale:Locale SettingsTabSystemEnableVsync}" VerticalAlignment="Center"
ToolTip.Tip="{locale:Locale VSyncToggleTooltip}" /> Text="{locale:Locale SettingsTabSystemVSyncMode}"
</CheckBox> ToolTip.Tip="{locale:Locale SettingsTabSystemVSyncModeTooltip}"
Width="250" />
<ComboBox
IsVisible="{Binding EnableCustomVSyncInterval}"
SelectedIndex="{Binding VSyncMode}"
ToolTip.Tip="{locale:Locale SettingsTabSystemVSyncModeTooltipCustom}"
HorizontalContentAlignment="Left"
Width="350">
<ComboBoxItem>
<TextBlock Text="{locale:Locale SettingsTabSystemVSyncModeSwitch}" />
</ComboBoxItem>
<ComboBoxItem>
<TextBlock Text="{locale:Locale SettingsTabSystemVSyncModeUnbounded}" />
</ComboBoxItem>
<ComboBoxItem>
<TextBlock Text="{locale:Locale SettingsTabSystemVSyncModeCustom}" />
</ComboBoxItem>
</ComboBox>
<ComboBox
IsVisible="{Binding !EnableCustomVSyncInterval}"
SelectedIndex="{Binding VSyncMode}"
ToolTip.Tip="{locale:Locale SettingsTabSystemVSyncModeTooltip}"
HorizontalContentAlignment="Left"
Width="350">
<ComboBoxItem>
<TextBlock Text="{locale:Locale SettingsTabSystemVSyncModeSwitch}" />
</ComboBoxItem>
<ComboBoxItem>
<TextBlock Text="{locale:Locale SettingsTabSystemVSyncModeUnbounded}" />
</ComboBoxItem>
</ComboBox>
</StackPanel>
<StackPanel IsVisible="{Binding EnableCustomVSyncInterval}"
Margin="0,0,0,10"
Orientation="Horizontal">
<TextBlock
VerticalAlignment="Center"
Text="{locale:Locale SettingsTabSystemCustomVSyncIntervalValue}"
ToolTip.Tip="{locale:Locale SettingsTabSystemCustomVSyncIntervalValueTooltip}"
Width="250" />
<ui:NumberBox IsVisible="{Binding EnableCustomVSyncInterval}"
ToolTip.Tip="{locale:Locale SettingsTabSystemCustomVSyncIntervalValueTooltip}"
Value="{Binding CustomVSyncInterval}"
Width="165"
SmallChange="1.0"
LargeChange="10"
SimpleNumberFormat="F0"
SpinButtonPlacementMode="Hidden"
Minimum="6"
Maximum="1000" />
<Slider Value="{Binding CustomVSyncIntervalPercentageProxy}"
ToolTip.Tip="{locale:Locale SettingsTabSystemCustomVSyncIntervalSliderTooltip}"
MinWidth="175"
Margin="10,-3,0,0"
Height="32"
Padding="0,-5"
TickFrequency="1"
IsSnapToTickEnabled="True"
LargeChange="10"
SmallChange="1"
VerticalAlignment="Center"
Minimum="10"
Maximum="400" />
<TextBlock Margin="5,0"
Width="40"
Text="{Binding CustomVSyncIntervalPercentageText}"/>
</StackPanel>
<CheckBox IsChecked="{Binding EnableFsIntegrityChecks}"> <CheckBox IsChecked="{Binding EnableFsIntegrityChecks}">
<TextBlock <TextBlock
Text="{locale:Locale SettingsTabSystemEnableFsIntegrityChecks}" Text="{locale:Locale SettingsTabSystemEnableFsIntegrityChecks}"
@ -217,6 +285,11 @@
ToolTip.Tip="{locale:Locale IgnoreMissingServicesTooltip}"> ToolTip.Tip="{locale:Locale IgnoreMissingServicesTooltip}">
<TextBlock Text="{locale:Locale SettingsTabSystemIgnoreMissingServices}" /> <TextBlock Text="{locale:Locale SettingsTabSystemIgnoreMissingServices}" />
</CheckBox> </CheckBox>
<CheckBox
IsChecked="{Binding EnableCustomVSyncInterval}"
ToolTip.Tip="{locale:Locale SettingsTabSystemEnableCustomVSyncIntervalTooltip}">
<TextBlock Text="{locale:Locale SettingsTabSystemEnableCustomVSyncInterval}" />
</CheckBox>
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
</Border> </Border>