aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Graphics.Gpu/Window.cs
diff options
context:
space:
mode:
authorriperiperi <rhy3756547@hotmail.com>2020-12-17 18:39:52 +0000
committerGitHub <noreply@github.com>2020-12-17 19:39:52 +0100
commit10aa11ce13291cf2ea2aeb751838c65c45fdc0ba (patch)
tree3ace1ad77af0fdbfc37ffdee86c24afb5fec97c8 /Ryujinx.Graphics.Gpu/Window.cs
parenteae39f80e7ca9ab220e9884c2457c934c2488e00 (diff)
Interrupt GPU command processing when a frame's fence is reached. (#1741)
* Interrupt GPU command processing when a frame's fence is reached. * Accumulate times rather than %s * Accurate timer for vsync Spin wait for the last .667ms of a frame. Avoids issues caused by signalling 16ms vsync. (periodic stutters in smo) * Use event wait for better timing. * Fix lazy wait Windows doesn't seem to want to do 1ms consistently, so force a spin if we're less than 2ms. * A bit more efficiency on frame waits. Should now wait the remainder 0.6667 instead of 1.6667 sometimes (odd waits above 1ms are reliable, unlike 1ms waits) * Better swap interval 0 solution 737 fps without breaking a sweat. Downside: Vsync can no longer be disabled on games that use the event heavily (link's awakening - which is ok since it breaks anyways) * Fix comment. * Address Comments.
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Window.cs')
-rw-r--r--Ryujinx.Graphics.Gpu/Window.cs27
1 files changed, 27 insertions, 0 deletions
diff --git a/Ryujinx.Graphics.Gpu/Window.cs b/Ryujinx.Graphics.Gpu/Window.cs
index cf5c01ef..9d269356 100644
--- a/Ryujinx.Graphics.Gpu/Window.cs
+++ b/Ryujinx.Graphics.Gpu/Window.cs
@@ -2,6 +2,7 @@ using Ryujinx.Graphics.GAL;
using Ryujinx.Graphics.Gpu.Image;
using System;
using System.Collections.Concurrent;
+using System.Threading;
namespace Ryujinx.Graphics.Gpu
{
@@ -69,6 +70,8 @@ namespace Ryujinx.Graphics.Gpu
private readonly ConcurrentQueue<PresentationTexture> _frameQueue;
+ private int _framesAvailable;
+
/// <summary>
/// Creates a new instance of the GPU presentation window.
/// </summary>
@@ -157,5 +160,29 @@ namespace Ryujinx.Graphics.Gpu
pt.ReleaseCallback(pt.UserObj);
}
}
+
+ /// <summary>
+ /// Indicate that a frame on the queue is ready to be acquired.
+ /// </summary>
+ public void SignalFrameReady()
+ {
+ Interlocked.Increment(ref _framesAvailable);
+ }
+
+ /// <summary>
+ /// Determine if any frames are available, and decrement the available count if there are.
+ /// </summary>
+ /// <returns>True if a frame is available, false otherwise</returns>
+ public bool ConsumeFrameAvailable()
+ {
+ if (Interlocked.CompareExchange(ref _framesAvailable, 0, 0) != 0)
+ {
+ Interlocked.Decrement(ref _framesAvailable);
+
+ return true;
+ }
+
+ return false;
+ }
}
} \ No newline at end of file