diff options
author | riperiperi <rhy3756547@hotmail.com> | 2023-03-12 17:01:15 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-12 18:01:15 +0100 |
commit | 6e9bd4de138e6ddedef3d38d711d161a0e400d5c (patch) | |
tree | d8df41e79eae9ae9fe333f95fc15c2f43e4e0584 /Ryujinx.Graphics.Vulkan/Queries/CounterQueueEvent.cs | |
parent | 05a41b31bc4d2b973662ac370458697c0bf712a9 (diff) |
GPU: Scale counter results before addition (#4471)1.1.662
* GPU: Scale counter results before addition
Counter results were being scaled on ReportCounter, which meant that the _total_ value of the counter was being scaled. Not only could this result in very large numbers and weird overflows if the game doesn't clear the counter, but it also caused the result to change drastically.
This PR changes scaling to be done when the value is added to the counter on the backend. This should evaluate the scale at the same time as before, on report counter, but avoiding the issue with scaling the total.
Fixes scaling in Warioware, at least in the demo, where it seems to compare old/new counters and broke down when scaling was enabled.
* Fix issues when result is partially uploaded.
Drivers tend to write the low half first, then the high half. Retry if the high half is FFFFFFFF.
Diffstat (limited to 'Ryujinx.Graphics.Vulkan/Queries/CounterQueueEvent.cs')
-rw-r--r-- | Ryujinx.Graphics.Vulkan/Queries/CounterQueueEvent.cs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Ryujinx.Graphics.Vulkan/Queries/CounterQueueEvent.cs b/Ryujinx.Graphics.Vulkan/Queries/CounterQueueEvent.cs index 6b780ba3..d3aedb2f 100644 --- a/Ryujinx.Graphics.Vulkan/Queries/CounterQueueEvent.cs +++ b/Ryujinx.Graphics.Vulkan/Queries/CounterQueueEvent.cs @@ -24,6 +24,7 @@ namespace Ryujinx.Graphics.Vulkan.Queries private object _lock = new object(); private ulong _result = ulong.MaxValue; + private double _divisor = 1f; public CounterQueueEvent(CounterQueue queue, CounterType type, ulong drawIndex) { @@ -52,9 +53,11 @@ namespace Ryujinx.Graphics.Vulkan.Queries ClearCounter = true; } - internal void Complete(bool withResult) + internal void Complete(bool withResult, double divisor) { _counter.End(withResult); + + _divisor = divisor; } internal bool TryConsume(ref ulong result, bool block, AutoResetEvent wakeSignal = null) @@ -85,7 +88,7 @@ namespace Ryujinx.Graphics.Vulkan.Queries } } - result += (ulong)queryResult; + result += _divisor == 1 ? (ulong)queryResult : (ulong)Math.Ceiling(queryResult / _divisor); _result = result; |