mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-11-10 06:11:45 +00:00
Dummy out gl queries with 0 draws, remove glFlush call (#1773)
This commit is contained in:
parent
2c39a4f15d
commit
c00d39b675
6 changed files with 31 additions and 11 deletions
|
@ -10,6 +10,8 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
{
|
||||
class Pipeline : IPipeline, IDisposable
|
||||
{
|
||||
internal ulong DrawCount { get; private set; }
|
||||
|
||||
private Program _program;
|
||||
|
||||
private bool _rasterizerDiscard;
|
||||
|
@ -1196,6 +1198,8 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
|
||||
private void PreDraw()
|
||||
{
|
||||
DrawCount++;
|
||||
|
||||
_vertexArray.Validate();
|
||||
|
||||
if (_unit0Texture != null)
|
||||
|
|
|
@ -46,7 +46,6 @@ namespace Ryujinx.Graphics.OpenGL.Queries
|
|||
|
||||
public unsafe void End()
|
||||
{
|
||||
GL.Flush();
|
||||
GL.EndQuery(_type);
|
||||
|
||||
GL.BindBuffer(BufferTarget.QueryBuffer, _buffer);
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace Ryujinx.Graphics.OpenGL.Queries
|
|||
_queryPool.Enqueue(new BufferedQuery(glType));
|
||||
}
|
||||
|
||||
_current = new CounterQueueEvent(this, glType);
|
||||
_current = new CounterQueueEvent(this, glType, 0);
|
||||
|
||||
_consumerThread = new Thread(EventConsumer);
|
||||
_consumerThread.Start();
|
||||
|
@ -95,19 +95,32 @@ namespace Ryujinx.Graphics.OpenGL.Queries
|
|||
}
|
||||
}
|
||||
|
||||
public CounterQueueEvent QueueReport(EventHandler<ulong> resultHandler)
|
||||
public CounterQueueEvent QueueReport(EventHandler<ulong> resultHandler, ulong lastDrawIndex)
|
||||
{
|
||||
CounterQueueEvent result;
|
||||
ulong draws = lastDrawIndex - _current.DrawIndex;
|
||||
|
||||
lock (_lock)
|
||||
{
|
||||
_current.Complete();
|
||||
_events.Enqueue(_current);
|
||||
// A query's result only matters if more than one draw was performed during it.
|
||||
// Otherwise, dummy it out and return 0 immediately.
|
||||
|
||||
if (draws > 0)
|
||||
{
|
||||
_current.Complete();
|
||||
_events.Enqueue(_current);
|
||||
|
||||
_current.OnResult += resultHandler;
|
||||
}
|
||||
else
|
||||
{
|
||||
_current.Dispose();
|
||||
resultHandler(_current, 0);
|
||||
}
|
||||
|
||||
result = _current;
|
||||
result.OnResult += resultHandler;
|
||||
|
||||
_current = new CounterQueueEvent(this, GetTarget(Type));
|
||||
_current = new CounterQueueEvent(this, GetTarget(Type), lastDrawIndex);
|
||||
}
|
||||
|
||||
_queuedEvent.Set();
|
||||
|
|
|
@ -16,18 +16,22 @@ namespace Ryujinx.Graphics.OpenGL.Queries
|
|||
public bool Disposed { get; private set; }
|
||||
public bool Invalid { get; set; }
|
||||
|
||||
public ulong DrawIndex { get; }
|
||||
|
||||
private CounterQueue _queue;
|
||||
private BufferedQuery _counter;
|
||||
|
||||
private object _lock = new object();
|
||||
|
||||
public CounterQueueEvent(CounterQueue queue, QueryTarget type)
|
||||
public CounterQueueEvent(CounterQueue queue, QueryTarget type, ulong drawIndex)
|
||||
{
|
||||
_queue = queue;
|
||||
|
||||
_counter = queue.GetQueryObject();
|
||||
Type = type;
|
||||
|
||||
DrawIndex = drawIndex;
|
||||
|
||||
_counter.Begin();
|
||||
}
|
||||
|
||||
|
|
|
@ -23,9 +23,9 @@ namespace Ryujinx.Graphics.OpenGL.Queries
|
|||
}
|
||||
}
|
||||
|
||||
public CounterQueueEvent QueueReport(CounterType type, EventHandler<ulong> resultHandler)
|
||||
public CounterQueueEvent QueueReport(CounterType type, EventHandler<ulong> resultHandler, ulong lastDrawIndex)
|
||||
{
|
||||
return _counterQueues[(int)type].QueueReport(resultHandler);
|
||||
return _counterQueues[(int)type].QueueReport(resultHandler, lastDrawIndex);
|
||||
}
|
||||
|
||||
public void QueueReset(CounterType type)
|
||||
|
|
|
@ -113,7 +113,7 @@ namespace Ryujinx.Graphics.OpenGL
|
|||
|
||||
public ICounterEvent ReportCounter(CounterType type, EventHandler<ulong> resultHandler)
|
||||
{
|
||||
return _counters.QueueReport(type, resultHandler);
|
||||
return _counters.QueueReport(type, resultHandler, _pipeline.DrawCount);
|
||||
}
|
||||
|
||||
public void Initialize(GraphicsDebugLevel glLogLevel)
|
||||
|
|
Loading…
Reference in a new issue