diff --git a/Ryujinx.HLE/HOS/Services/Vi/NvFlinger.cs b/Ryujinx.HLE/HOS/Services/Vi/NvFlinger.cs index 6085369b35..f8ed90fbf8 100644 --- a/Ryujinx.HLE/HOS/Services/Vi/NvFlinger.cs +++ b/Ryujinx.HLE/HOS/Services/Vi/NvFlinger.cs @@ -166,11 +166,9 @@ namespace Ryujinx.HLE.HOS.Services.Android { Context.Device.Statistics.RecordGameFrameTime(); - if (Context.Ns.EnableVsync) + if (Context.Device.EnableVsync) { - Context.Ns.Os.VsyncEvent.WaitEvent.WaitOne(); - - Context.Ns.Os.VsyncEvent.WaitEvent.Reset(); + Context.Device.VsyncEvent.WaitOne(); } //TODO: Errors. diff --git a/Ryujinx.HLE/Switch.cs b/Ryujinx.HLE/Switch.cs index f44b3085a5..a8c7a5b2b1 100644 --- a/Ryujinx.HLE/Switch.cs +++ b/Ryujinx.HLE/Switch.cs @@ -6,6 +6,7 @@ using Ryujinx.HLE.Input; using Ryujinx.HLE.Logging; using Ryujinx.HLE.Memory; using System; +using System.Threading; namespace Ryujinx.HLE { @@ -27,9 +28,9 @@ namespace Ryujinx.HLE public Hid Hid { get; private set; } - public bool LimitSpeed { get; set; } + public bool EnableVsync { get; set; } = true; - public bool EnableVsync { get; set; } + public AutoResetEvent VsyncEvent { get; private set; } public event EventHandler Finish; @@ -60,6 +61,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) @@ -114,6 +117,8 @@ namespace Ryujinx.HLE if (Disposing) { System.Dispose(); + + VsyncEvent.Dispose(); } } } diff --git a/Ryujinx/Ui/GLScreen.cs b/Ryujinx/Ui/GLScreen.cs index 203b99b2e9..0b2df42129 100644 --- a/Ryujinx/Ui/GLScreen.cs +++ b/Ryujinx/Ui/GLScreen.cs @@ -82,7 +82,7 @@ namespace Ryujinx if (Ticks >= TicksPerFrame) { - Ns.Os.SignalVsync(); + Device.VsyncEvent.Set(); RenderFrame(); @@ -261,7 +261,7 @@ namespace Ryujinx double GameFps = Device.Statistics.GetGameFrameRate(); NewTitle = $"Ryujinx | Host FPS: {HostFps:0.0} | Game FPS: {GameFps:0.0} | Game Vsync: " + - (Ns.EnableVsync ? "On" : "Off"); + (Device.EnableVsync ? "On" : "Off"); TitleEvent = true; @@ -315,7 +315,7 @@ namespace Ryujinx Keyboard = e.Keyboard; if (e.Key == Key.Tab) - Ns.EnableVsync = !Ns.EnableVsync; + Device.EnableVsync = !Device.EnableVsync; } protected override void OnMouseDown(MouseButtonEventArgs e)