From e4292a5cdc78600445bdf9fbb9e045725e57a207 Mon Sep 17 00:00:00 2001 From: emmaus Date: Wed, 15 Aug 2018 20:12:23 +0000 Subject: [PATCH] Initial Framerate limit implementation --- Ryujinx.HLE/HOS/Services/Vi/NvFlinger.cs | 7 +++++++ Ryujinx.HLE/Switch.cs | 6 ++++++ Ryujinx/Ui/GLScreen.cs | 8 +++++++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Ryujinx.HLE/HOS/Services/Vi/NvFlinger.cs b/Ryujinx.HLE/HOS/Services/Vi/NvFlinger.cs index 8f541fbf45..6085369b35 100644 --- a/Ryujinx.HLE/HOS/Services/Vi/NvFlinger.cs +++ b/Ryujinx.HLE/HOS/Services/Vi/NvFlinger.cs @@ -166,6 +166,13 @@ namespace Ryujinx.HLE.HOS.Services.Android { Context.Device.Statistics.RecordGameFrameTime(); + if (Context.Ns.EnableVsync) + { + Context.Ns.Os.VsyncEvent.WaitEvent.WaitOne(); + + Context.Ns.Os.VsyncEvent.WaitEvent.Reset(); + } + //TODO: Errors. int Slot = ParcelReader.ReadInt32(); int Unknown4 = ParcelReader.ReadInt32(); diff --git a/Ryujinx.HLE/Switch.cs b/Ryujinx.HLE/Switch.cs index 090aae111e..f44b3085a5 100644 --- a/Ryujinx.HLE/Switch.cs +++ b/Ryujinx.HLE/Switch.cs @@ -27,6 +27,12 @@ namespace Ryujinx.HLE public Hid Hid { get; private set; } + public bool LimitSpeed { get; set; } + + public bool EnableVsync { get; set; } + + public event EventHandler Finish; + public Switch(IGalRenderer Renderer, IAalOutput AudioOut) { if (Renderer == null) diff --git a/Ryujinx/Ui/GLScreen.cs b/Ryujinx/Ui/GLScreen.cs index e7eb26137b..203b99b2e9 100644 --- a/Ryujinx/Ui/GLScreen.cs +++ b/Ryujinx/Ui/GLScreen.cs @@ -82,6 +82,8 @@ namespace Ryujinx if (Ticks >= TicksPerFrame) { + Ns.Os.SignalVsync(); + RenderFrame(); //Queue max. 1 vsync @@ -258,7 +260,8 @@ 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: " + + (Ns.EnableVsync ? "On" : "Off"); TitleEvent = true; @@ -310,6 +313,9 @@ namespace Ryujinx protected override void OnKeyUp(KeyboardKeyEventArgs e) { Keyboard = e.Keyboard; + + if (e.Key == Key.Tab) + Ns.EnableVsync = !Ns.EnableVsync; } protected override void OnMouseDown(MouseButtonEventArgs e)