diff options
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Window.cs')
| -rw-r--r-- | Ryujinx.Graphics.Gpu/Window.cs | 27 |
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 |
