diff options
author | riperiperi <rhy3756547@hotmail.com> | 2020-05-04 03:24:59 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-04 12:24:59 +1000 |
commit | cd48576f5846aa89a36bfc833e9de5dde9627aed (patch) | |
tree | 5bf04a43725cf7fdc098cde59856798a67b839e0 /Ryujinx.Graphics.Gpu/Memory/CounterCache.cs | |
parent | 651a07c6c2a3e89c059d56e916c45e1881d56abc (diff) |
Implement Counter Queue and Partial Host Conditional Rendering (#1167)
* Implementation of query queue and host conditional rendering
* Resolve some comments.
* Use overloads instead of passing object.
* Wake the consumer threads when incrementing syncpoints.
Also, do a busy loop when awaiting the counter for a blocking flush, rather than potentially sleeping the thread.
* Ensure there's a command between begin and end query.
Diffstat (limited to 'Ryujinx.Graphics.Gpu/Memory/CounterCache.cs')
-rw-r--r-- | Ryujinx.Graphics.Gpu/Memory/CounterCache.cs | 59 |
1 files changed, 55 insertions, 4 deletions
diff --git a/Ryujinx.Graphics.Gpu/Memory/CounterCache.cs b/Ryujinx.Graphics.Gpu/Memory/CounterCache.cs index 3110cdcc..90b9187b 100644 --- a/Ryujinx.Graphics.Gpu/Memory/CounterCache.cs +++ b/Ryujinx.Graphics.Gpu/Memory/CounterCache.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using Ryujinx.Graphics.GAL; +using System.Collections.Generic; namespace Ryujinx.Graphics.Gpu.Memory { @@ -10,10 +11,12 @@ namespace Ryujinx.Graphics.Gpu.Memory private struct CounterEntry { public ulong Address { get; } + public ICounterEvent Event { get; } - public CounterEntry(ulong address) + public CounterEntry(ulong address, ICounterEvent evt) { Address = address; + Event = evt; } } @@ -31,11 +34,11 @@ namespace Ryujinx.Graphics.Gpu.Memory /// Adds a new counter to the counter cache, or updates a existing one. /// </summary> /// <param name="gpuVa">GPU virtual address where the counter will be written in memory</param> - public void AddOrUpdate(ulong gpuVa) + public void AddOrUpdate(ulong gpuVa, ICounterEvent evt) { int index = BinarySearch(gpuVa); - CounterEntry entry = new CounterEntry(gpuVa); + CounterEntry entry = new CounterEntry(gpuVa, evt); if (index < 0) { @@ -76,6 +79,16 @@ namespace Ryujinx.Graphics.Gpu.Memory count++; } + // Notify the removed counter events that their result should no longer be written out. + for (int i = 0; i < count; i++) + { + ICounterEvent evt = _items[index + i].Event; + if (evt != null) + { + evt.Invalid = true; + } + } + _items.RemoveRange(index, count); } @@ -102,6 +115,44 @@ namespace Ryujinx.Graphics.Gpu.Memory } /// <summary> + /// Flush any counter value written to the specified GPU virtual memory address. + /// </summary> + /// <param name="gpuVa">GPU virtual address</param> + /// <returns>True if any counter value was written on the specified address, false otherwise</returns> + public bool FindAndFlush(ulong gpuVa) + { + int index = BinarySearch(gpuVa); + if (index > 0) + { + _items[index].Event?.Flush(); + + return true; + } + else + { + return false; + } + } + + /// <summary> + /// Find any counter event that would write to the specified GPU virtual memory address. + /// </summary> + /// <param name="gpuVa">GPU virtual address</param> + /// <returns>The counter event, or null if not present</returns> + public ICounterEvent FindEvent(ulong gpuVa) + { + int index = BinarySearch(gpuVa); + if (index > 0) + { + return _items[index].Event; + } + else + { + return null; + } + } + + /// <summary> /// Performs binary search of an address on the list. /// </summary> /// <param name="address">Address to search</param> |