From a46b1bd88c5248be756a7fafc57e41e8e1eacf0b Mon Sep 17 00:00:00 2001 From: riperiperi Date: Thu, 15 Feb 2024 19:14:19 +0000 Subject: [PATCH] When batching, don't place barriers between every copy --- src/Ryujinx.Graphics.OpenGL/Queries/BufferedQuery.cs | 10 +++++++--- src/Ryujinx.Graphics.OpenGL/Queries/Counters.cs | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Ryujinx.Graphics.OpenGL/Queries/BufferedQuery.cs b/src/Ryujinx.Graphics.OpenGL/Queries/BufferedQuery.cs index d9add25cd..09f71aa02 100644 --- a/src/Ryujinx.Graphics.OpenGL/Queries/BufferedQuery.cs +++ b/src/Ryujinx.Graphics.OpenGL/Queries/BufferedQuery.cs @@ -49,11 +49,15 @@ namespace Ryujinx.Graphics.OpenGL.Queries GL.BeginQuery(_type, Query); } - public unsafe void CopyQueryResult() + public unsafe void CopyQueryResult(bool withBarrier) { GL.BindBuffer(BufferTarget.QueryBuffer, _buffer); GL.GetQueryObject(Query, GetQueryObjectParam.QueryResult, (long*)0); - GL.MemoryBarrier(MemoryBarrierFlags.QueryBufferBarrierBit | MemoryBarrierFlags.ClientMappedBufferBarrierBit); + + if (withBarrier) + { + GL.MemoryBarrier(MemoryBarrierFlags.QueryBufferBarrierBit | MemoryBarrierFlags.ClientMappedBufferBarrierBit); + } } public void End(bool withResult) @@ -64,7 +68,7 @@ namespace Ryujinx.Graphics.OpenGL.Queries { if (!_parent.QueueCopy(this)) { - CopyQueryResult(); + CopyQueryResult(true); } } else diff --git a/src/Ryujinx.Graphics.OpenGL/Queries/Counters.cs b/src/Ryujinx.Graphics.OpenGL/Queries/Counters.cs index ba64b84cc..0191a7e86 100644 --- a/src/Ryujinx.Graphics.OpenGL/Queries/Counters.cs +++ b/src/Ryujinx.Graphics.OpenGL/Queries/Counters.cs @@ -66,9 +66,10 @@ namespace Ryujinx.Graphics.OpenGL.Queries { if (_queuedCopies.Count > 0) { + int i = 0; foreach (BufferedQuery query in _queuedCopies) { - query.CopyQueryResult(); + query.CopyQueryResult(_queuedCopies.Count == ++i); } _queuedCopies.Clear();