aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremmauss <emmausssss@gmail.com>2018-09-10 02:38:56 +0300
committerThomas Guillemard <thog@protonmail.com>2018-09-10 01:38:56 +0200
commitdb1a759c5927f2df9ddd9a08fd691f99bf10e6f8 (patch)
tree5f11107dd4b3672a6c2e4627154ca27f7f15083e
parentfc77b089a6ab600ac6f954cb193d26239008975f (diff)
Lock GbpQueueBuffer till Vsync is signalled (#367)
* Initial Framerate limit implementation * use seperate event for limiter * check for vsync signal after queue up framebuffer * removed ingame toggle * fix nits
-rw-r--r--Ryujinx.HLE/HOS/Services/Vi/NvFlinger.cs5
-rw-r--r--Ryujinx.HLE/Switch.cs11
-rw-r--r--Ryujinx/Config.cs2
-rw-r--r--Ryujinx/Ryujinx.conf3
-rw-r--r--Ryujinx/Ui/GLScreen.cs5
5 files changed, 25 insertions, 1 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Vi/NvFlinger.cs b/Ryujinx.HLE/HOS/Services/Vi/NvFlinger.cs
index 8f541fbf..2a6918c4 100644
--- a/Ryujinx.HLE/HOS/Services/Vi/NvFlinger.cs
+++ b/Ryujinx.HLE/HOS/Services/Vi/NvFlinger.cs
@@ -199,6 +199,11 @@ namespace Ryujinx.HLE.HOS.Services.Android
SendFrameBuffer(Context, Slot);
+ if (Context.Device.EnableDeviceVsync)
+ {
+ Context.Device.VsyncEvent.WaitOne();
+ }
+
return MakeReplyParcel(Context, 1280, 720, 0, 0, 0);
}
diff --git a/Ryujinx.HLE/Switch.cs b/Ryujinx.HLE/Switch.cs
index 70bd7060..a3f874ee 100644
--- a/Ryujinx.HLE/Switch.cs
+++ b/Ryujinx.HLE/Switch.cs
@@ -7,6 +7,7 @@ using Ryujinx.HLE.Input;
using Ryujinx.HLE.Logging;
using Ryujinx.HLE.Memory;
using System;
+using System.Threading;
namespace Ryujinx.HLE
{
@@ -28,6 +29,12 @@ namespace Ryujinx.HLE
public Hid Hid { get; private set; }
+ public bool EnableDeviceVsync { get; set; } = true;
+
+ public AutoResetEvent VsyncEvent { get; private set; }
+
+ public event EventHandler Finish;
+
public Switch(IGalRenderer Renderer, IAalOutput AudioOut)
{
if (Renderer == null)
@@ -55,6 +62,8 @@ namespace Ryujinx.HLE
Statistics = new PerformanceStatistics();
Hid = new Hid(this, System.HidSharedMem.PA);
+
+ VsyncEvent = new AutoResetEvent(true);
}
public void LoadCart(string ExeFsDir, string RomFsFile = null)
@@ -109,6 +118,8 @@ namespace Ryujinx.HLE
if (Disposing)
{
System.Dispose();
+
+ VsyncEvent.Dispose();
}
}
}
diff --git a/Ryujinx/Config.cs b/Ryujinx/Config.cs
index 2c02c50f..748d1dbf 100644
--- a/Ryujinx/Config.cs
+++ b/Ryujinx/Config.cs
@@ -33,6 +33,8 @@ namespace Ryujinx
Device.System.State.DockedMode = Convert.ToBoolean(Parser.Value("Docked_Mode"));
+ Device.EnableDeviceVsync = Convert.ToBoolean(Parser.Value("Enable_Vsync"));
+
string[] FilteredLogClasses = Parser.Value("Logging_Filtered_Classes").Split(',', StringSplitOptions.RemoveEmptyEntries);
//When the classes are specified on the list, we only
diff --git a/Ryujinx/Ryujinx.conf b/Ryujinx/Ryujinx.conf
index 6e15a6ac..c497c081 100644
--- a/Ryujinx/Ryujinx.conf
+++ b/Ryujinx/Ryujinx.conf
@@ -25,6 +25,9 @@ Logging_Filtered_Classes =
#Enable or Disable Docked Mode
Docked_Mode = false
+#Enable Game Vsync
+Enable_Vsync = true
+
#Controller Device Index
GamePad_Index = 0
diff --git a/Ryujinx/Ui/GLScreen.cs b/Ryujinx/Ui/GLScreen.cs
index e7eb2613..8adff9c0 100644
--- a/Ryujinx/Ui/GLScreen.cs
+++ b/Ryujinx/Ui/GLScreen.cs
@@ -258,13 +258,16 @@ namespace Ryujinx
double HostFps = Device.Statistics.GetSystemFrameRate();
double GameFps = Device.Statistics.GetGameFrameRate();
- NewTitle = $"Ryujinx | Host FPS: {HostFps:0.0} | Game FPS: {GameFps:0.0}";
+ NewTitle = $"Ryujinx | Host FPS: {HostFps:0.0} | Game FPS: {GameFps:0.0} | Game Vsync: " +
+ (Device.EnableDeviceVsync ? "On" : "Off");
TitleEvent = true;
SwapBuffers();
Device.System.SignalVsync();
+
+ Device.VsyncEvent.Set();
}
protected override void OnUnload(EventArgs e)