From 06057a99a653b83389447a9c56d926c463317b47 Mon Sep 17 00:00:00 2001 From: riperiperi Date: Fri, 11 Dec 2020 23:31:39 +0000 Subject: [PATCH] End empty gl queries before returning them to the pool. (#1806) --- Ryujinx.Graphics.OpenGL/Queries/BufferedQuery.cs | 11 +++++++---- Ryujinx.Graphics.OpenGL/Queries/CounterQueue.cs | 3 ++- Ryujinx.Graphics.OpenGL/Queries/CounterQueueEvent.cs | 4 ++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Ryujinx.Graphics.OpenGL/Queries/BufferedQuery.cs b/Ryujinx.Graphics.OpenGL/Queries/BufferedQuery.cs index b4c5259c10..a87655bec6 100644 --- a/Ryujinx.Graphics.OpenGL/Queries/BufferedQuery.cs +++ b/Ryujinx.Graphics.OpenGL/Queries/BufferedQuery.cs @@ -44,14 +44,17 @@ namespace Ryujinx.Graphics.OpenGL.Queries GL.BeginQuery(_type, Query); } - public unsafe void End() + public unsafe void End(bool withResult) { GL.EndQuery(_type); - GL.BindBuffer(BufferTarget.QueryBuffer, _buffer); + if (withResult) + { + GL.BindBuffer(BufferTarget.QueryBuffer, _buffer); - Marshal.WriteInt64(_bufferMap, -1L); - GL.GetQueryObject(Query, GetQueryObjectParam.QueryResult, (long*)0); + Marshal.WriteInt64(_bufferMap, -1L); + GL.GetQueryObject(Query, GetQueryObjectParam.QueryResult, (long*)0); + } } public bool TryGetResult(out long result) diff --git a/Ryujinx.Graphics.OpenGL/Queries/CounterQueue.cs b/Ryujinx.Graphics.OpenGL/Queries/CounterQueue.cs index a864a20037..5984a7ca04 100644 --- a/Ryujinx.Graphics.OpenGL/Queries/CounterQueue.cs +++ b/Ryujinx.Graphics.OpenGL/Queries/CounterQueue.cs @@ -107,13 +107,14 @@ namespace Ryujinx.Graphics.OpenGL.Queries if (draws > 0) { - _current.Complete(); + _current.Complete(true); _events.Enqueue(_current); _current.OnResult += resultHandler; } else { + _current.Complete(false); _current.Dispose(); resultHandler(_current, 0); } diff --git a/Ryujinx.Graphics.OpenGL/Queries/CounterQueueEvent.cs b/Ryujinx.Graphics.OpenGL/Queries/CounterQueueEvent.cs index e21ce55d24..0e1025afd4 100644 --- a/Ryujinx.Graphics.OpenGL/Queries/CounterQueueEvent.cs +++ b/Ryujinx.Graphics.OpenGL/Queries/CounterQueueEvent.cs @@ -41,9 +41,9 @@ namespace Ryujinx.Graphics.OpenGL.Queries ClearCounter = true; } - internal void Complete() + internal void Complete(bool withResult) { - _counter.End(); + _counter.End(withResult); } internal bool TryConsume(ref ulong result, bool block, AutoResetEvent wakeSignal = null)