mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2024-12-26 18:43:04 +00:00
Fix host reserved counter
This commit is contained in:
parent
711360f775
commit
71901a54b8
12 changed files with 22 additions and 22 deletions
|
@ -45,7 +45,7 @@ namespace Ryujinx.Graphics.GAL
|
||||||
|
|
||||||
void PreFrame();
|
void PreFrame();
|
||||||
|
|
||||||
ICounterEvent ReportCounter(CounterType type, EventHandler<ulong> resultHandler, float divisor, bool hostReserved);
|
ICounterEvent ReportCounter(CounterType type, EventHandler<ulong> resultHandler, float divisor, int hostReserved);
|
||||||
|
|
||||||
void ResetCounter(CounterType type);
|
void ResetCounter(CounterType type);
|
||||||
|
|
||||||
|
|
|
@ -11,9 +11,9 @@ namespace Ryujinx.Graphics.GAL.Multithreading.Commands.Renderer
|
||||||
private CounterType _type;
|
private CounterType _type;
|
||||||
private TableRef<EventHandler<ulong>> _resultHandler;
|
private TableRef<EventHandler<ulong>> _resultHandler;
|
||||||
private float _divisor;
|
private float _divisor;
|
||||||
private bool _hostReserved;
|
private int _hostReserved;
|
||||||
|
|
||||||
public void Set(TableRef<ThreadedCounterEvent> evt, CounterType type, TableRef<EventHandler<ulong>> resultHandler, float divisor, bool hostReserved)
|
public void Set(TableRef<ThreadedCounterEvent> evt, CounterType type, TableRef<EventHandler<ulong>> resultHandler, float divisor, int hostReserved)
|
||||||
{
|
{
|
||||||
_event = evt;
|
_event = evt;
|
||||||
_type = type;
|
_type = type;
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace Ryujinx.Graphics.GAL.Multithreading.Resources
|
||||||
public CounterType Type { get; }
|
public CounterType Type { get; }
|
||||||
public bool ClearCounter { get; }
|
public bool ClearCounter { get; }
|
||||||
|
|
||||||
private bool _reserved;
|
private int _reserved;
|
||||||
private int _createLock;
|
private int _createLock;
|
||||||
|
|
||||||
public ThreadedCounterEvent(ThreadedRenderer renderer, CounterType type, bool clearCounter)
|
public ThreadedCounterEvent(ThreadedRenderer renderer, CounterType type, bool clearCounter)
|
||||||
|
@ -61,7 +61,7 @@ namespace Ryujinx.Graphics.GAL.Multithreading.Resources
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_reserved = true;
|
Interlocked.Increment(ref _reserved);
|
||||||
}
|
}
|
||||||
|
|
||||||
Volatile.Write(ref _createLock, 0);
|
Volatile.Write(ref _createLock, 0);
|
||||||
|
@ -70,10 +70,10 @@ namespace Ryujinx.Graphics.GAL.Multithreading.Resources
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Create(IRenderer renderer, CounterType type, System.EventHandler<ulong> eventHandler, float divisor, bool hostReserved)
|
public void Create(IRenderer renderer, CounterType type, System.EventHandler<ulong> eventHandler, float divisor, int hostReserved)
|
||||||
{
|
{
|
||||||
ThreadedHelpers.SpinUntilExchange(ref _createLock, 1, 0);
|
ThreadedHelpers.SpinUntilExchange(ref _createLock, 1, 0);
|
||||||
Base = renderer.ReportCounter(type, eventHandler, divisor, hostReserved || _reserved);
|
Base = renderer.ReportCounter(type, eventHandler, divisor, hostReserved + _reserved);
|
||||||
Volatile.Write(ref _createLock, 0);
|
Volatile.Write(ref _createLock, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -419,7 +419,7 @@ namespace Ryujinx.Graphics.GAL.Multithreading
|
||||||
QueueCommand();
|
QueueCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICounterEvent ReportCounter(CounterType type, EventHandler<ulong> resultHandler, float divisor, bool hostReserved)
|
public ICounterEvent ReportCounter(CounterType type, EventHandler<ulong> resultHandler, float divisor, int hostReserved)
|
||||||
{
|
{
|
||||||
ThreadedCounterEvent evt = new(this, type, _lastSampleCounterClear);
|
ThreadedCounterEvent evt = new(this, type, _lastSampleCounterClear);
|
||||||
New<ReportCounterCommand>().Set(Ref(evt), type, Ref(resultHandler), divisor, hostReserved);
|
New<ReportCounterCommand>().Set(Ref(evt), type, Ref(resultHandler), divisor, hostReserved);
|
||||||
|
|
|
@ -179,13 +179,13 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed
|
||||||
case ReportCounterType.SamplesPassed:
|
case ReportCounterType.SamplesPassed:
|
||||||
float scale = _channel.TextureManager.RenderTargetScale;
|
float scale = _channel.TextureManager.RenderTargetScale;
|
||||||
float divisor = scale * scale;
|
float divisor = scale * scale;
|
||||||
counter = _context.Renderer.ReportCounter(CounterType.SamplesPassed, resultHandler, divisor, false);
|
counter = _context.Renderer.ReportCounter(CounterType.SamplesPassed, resultHandler, divisor, 0);
|
||||||
break;
|
break;
|
||||||
case ReportCounterType.PrimitivesGenerated:
|
case ReportCounterType.PrimitivesGenerated:
|
||||||
counter = _context.Renderer.ReportCounter(CounterType.PrimitivesGenerated, resultHandler, 1f, false);
|
counter = _context.Renderer.ReportCounter(CounterType.PrimitivesGenerated, resultHandler, 1f, 0);
|
||||||
break;
|
break;
|
||||||
case ReportCounterType.TransformFeedbackPrimitivesWritten:
|
case ReportCounterType.TransformFeedbackPrimitivesWritten:
|
||||||
counter = _context.Renderer.ReportCounter(CounterType.TransformFeedbackPrimitivesWritten, resultHandler, 1f, false);
|
counter = _context.Renderer.ReportCounter(CounterType.TransformFeedbackPrimitivesWritten, resultHandler, 1f, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -205,7 +205,7 @@ namespace Ryujinx.Graphics.OpenGL
|
||||||
ResourcePool.Tick();
|
ResourcePool.Tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICounterEvent ReportCounter(CounterType type, EventHandler<ulong> resultHandler, float divisor, bool hostReserved)
|
public ICounterEvent ReportCounter(CounterType type, EventHandler<ulong> resultHandler, float divisor, int hostReserved)
|
||||||
{
|
{
|
||||||
return _counters.QueueReport(type, resultHandler, divisor, _pipeline.DrawCount, hostReserved);
|
return _counters.QueueReport(type, resultHandler, divisor, _pipeline.DrawCount, hostReserved);
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,7 +106,7 @@ namespace Ryujinx.Graphics.OpenGL.Queries
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CounterQueueEvent QueueReport(EventHandler<ulong> resultHandler, float divisor, ulong lastDrawIndex, bool hostReserved)
|
public CounterQueueEvent QueueReport(EventHandler<ulong> resultHandler, float divisor, ulong lastDrawIndex, int hostReserved)
|
||||||
{
|
{
|
||||||
CounterQueueEvent result;
|
CounterQueueEvent result;
|
||||||
ulong draws = lastDrawIndex - _current.DrawIndex;
|
ulong draws = lastDrawIndex - _current.DrawIndex;
|
||||||
|
@ -116,9 +116,9 @@ namespace Ryujinx.Graphics.OpenGL.Queries
|
||||||
// A query's result only matters if more than one draw was performed during it.
|
// A query's result only matters if more than one draw was performed during it.
|
||||||
// Otherwise, dummy it out and return 0 immediately.
|
// Otherwise, dummy it out and return 0 immediately.
|
||||||
|
|
||||||
if (hostReserved)
|
while (hostReserved-- > 0)
|
||||||
{
|
{
|
||||||
// This counter event is guaranteed to be available for host conditional rendering.
|
// This counter event is guaranteed to be available for host conditional rendering for the given number of uses.
|
||||||
_current.ReserveForHostAccess();
|
_current.ReserveForHostAccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,7 @@ namespace Ryujinx.Graphics.OpenGL.Queries
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_hostAccessReserved = Interlocked.Increment(ref _hostAccessReserved);
|
Interlocked.Increment(ref _hostAccessReserved);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace Ryujinx.Graphics.OpenGL.Queries
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CounterQueueEvent QueueReport(CounterType type, EventHandler<ulong> resultHandler, float divisor, ulong lastDrawIndex, bool hostReserved)
|
public CounterQueueEvent QueueReport(CounterType type, EventHandler<ulong> resultHandler, float divisor, ulong lastDrawIndex, int hostReserved)
|
||||||
{
|
{
|
||||||
return _counterQueues[(int)type].QueueReport(resultHandler, divisor, lastDrawIndex, hostReserved);
|
return _counterQueues[(int)type].QueueReport(resultHandler, divisor, lastDrawIndex, hostReserved);
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,7 +139,7 @@ namespace Ryujinx.Graphics.Vulkan.Queries
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CounterQueueEvent QueueReport(EventHandler<ulong> resultHandler, float divisor, ulong lastDrawIndex, bool hostReserved)
|
public CounterQueueEvent QueueReport(EventHandler<ulong> resultHandler, float divisor, ulong lastDrawIndex, int hostReserved)
|
||||||
{
|
{
|
||||||
CounterQueueEvent result;
|
CounterQueueEvent result;
|
||||||
ulong draws = lastDrawIndex - _current.DrawIndex;
|
ulong draws = lastDrawIndex - _current.DrawIndex;
|
||||||
|
@ -149,9 +149,9 @@ namespace Ryujinx.Graphics.Vulkan.Queries
|
||||||
// A query's result only matters if more than one draw was performed during it.
|
// A query's result only matters if more than one draw was performed during it.
|
||||||
// Otherwise, dummy it out and return 0 immediately.
|
// Otherwise, dummy it out and return 0 immediately.
|
||||||
|
|
||||||
if (hostReserved)
|
while (hostReserved-- > 0)
|
||||||
{
|
{
|
||||||
// This counter event is guaranteed to be available for host conditional rendering.
|
// This counter event is guaranteed to be available for host conditional rendering for the given number of uses.
|
||||||
_current.ReserveForHostAccess();
|
_current.ReserveForHostAccess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace Ryujinx.Graphics.Vulkan.Queries
|
||||||
_counterQueues[(int)CounterType.SamplesPassed].ResetFutureCounters(cmd, count);
|
_counterQueues[(int)CounterType.SamplesPassed].ResetFutureCounters(cmd, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CounterQueueEvent QueueReport(CounterType type, EventHandler<ulong> resultHandler, float divisor, bool hostReserved)
|
public CounterQueueEvent QueueReport(CounterType type, EventHandler<ulong> resultHandler, float divisor, int hostReserved)
|
||||||
{
|
{
|
||||||
return _counterQueues[(int)type].QueueReport(resultHandler, divisor, _pipeline.DrawCount, hostReserved);
|
return _counterQueues[(int)type].QueueReport(resultHandler, divisor, _pipeline.DrawCount, hostReserved);
|
||||||
}
|
}
|
||||||
|
|
|
@ -832,7 +832,7 @@ namespace Ryujinx.Graphics.Vulkan
|
||||||
SyncManager.Cleanup();
|
SyncManager.Cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICounterEvent ReportCounter(CounterType type, EventHandler<ulong> resultHandler, float divisor, bool hostReserved)
|
public ICounterEvent ReportCounter(CounterType type, EventHandler<ulong> resultHandler, float divisor, int hostReserved)
|
||||||
{
|
{
|
||||||
return _counters.QueueReport(type, resultHandler, divisor, hostReserved);
|
return _counters.QueueReport(type, resultHandler, divisor, hostReserved);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue