mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-07-03 10:16:26 +02:00
Add custom refresh rate mode to VSync option (#238)
Rebased @jcm93's refreshinterval branch: https://github.com/jcm93/Ryujinx/tree/refreshinterval The option is placed under System/Hacks. Disabled, it's the default Ryujinx behavior. Enabled, the behavior is shown in the attached screenshots. If a framerate is too high or low, you can adjust the value where you normally toggle VSync on and off. It will also cycle through the default on/off toggles. Also, in order to reduce clutter, I made an adjustment to remove the target FPS and only show the percentage. --------- Co-authored-by: jcm <6864788+jcm93@users.noreply.github.com>
This commit is contained in:
parent
7e16fccfc1
commit
2e6794e69b
34 changed files with 678 additions and 110 deletions
|
@ -10,13 +10,12 @@ using System.Collections.Generic;
|
|||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using VSyncMode = Ryujinx.Common.Configuration.VSyncMode;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
||||
{
|
||||
class SurfaceFlinger : IConsumerListener, IDisposable
|
||||
{
|
||||
private const int TargetFps = 60;
|
||||
|
||||
private readonly Switch _device;
|
||||
|
||||
private readonly Dictionary<long, Layer> _layers;
|
||||
|
@ -32,6 +31,9 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
|||
private readonly long _spinTicks;
|
||||
private readonly long _1msTicks;
|
||||
|
||||
private VSyncMode _vSyncMode;
|
||||
private long _targetVSyncInterval;
|
||||
|
||||
private int _swapInterval;
|
||||
private int _swapIntervalDelay;
|
||||
|
||||
|
@ -88,7 +90,8 @@ namespace Ryujinx.HLE.HOS.Services.SurfaceFlinger
|
|||
}
|
||||
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 device vsync is disabled, reflect the change.
|
||||
if (!_device.EnableDeviceVsync)
|
||||
if (_device.VSyncMode == VSyncMode.Unbounded)
|
||||
{
|
||||
if (_swapInterval != 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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue