From 36172ab43b97b35aa2f7fd78de953be489d38c54 Mon Sep 17 00:00:00 2001 From: riperiperi Date: Sun, 11 Sep 2022 16:58:15 +0100 Subject: [PATCH] Scale SamplesPassed counter by RT scale on report (#3680) * Scale SamplesPassed counter by RT scale on report Adds a scale factor for samples passed counter report based on the render target scale at the time. This ensures that when a game reads this counter, it appears similar to the result at 1x. This doesn't cover cases where the the render target scale changes during the queried draws, though that might be better to handle along with other scope related issues in a future rework of counters. Games generally don't count for occlusion queries over render target changes anyways. Fixes an issue in the Splatoon games where the special charge would scale too quickly at high res, points at the end of the game would be broken (but still provide a correct winner), and playing at a low res would make it impossible to swim in ink. May also affect LOD scaling in The Witcher 3. * Update Ryujinx.Graphics.Gpu/Engine/Threed/SemaphoreUpdater.cs Co-authored-by: gdkchan Co-authored-by: gdkchan --- .../Engine/Threed/SemaphoreUpdater.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Ryujinx.Graphics.Gpu/Engine/Threed/SemaphoreUpdater.cs b/Ryujinx.Graphics.Gpu/Engine/Threed/SemaphoreUpdater.cs index 6fc931f7..f52f9f81 100644 --- a/Ryujinx.Graphics.Gpu/Engine/Threed/SemaphoreUpdater.cs +++ b/Ryujinx.Graphics.Gpu/Engine/Threed/SemaphoreUpdater.cs @@ -1,4 +1,5 @@ using Ryujinx.Graphics.GAL; +using System; namespace Ryujinx.Graphics.Gpu.Engine.Threed { @@ -151,10 +152,21 @@ namespace Ryujinx.Graphics.Gpu.Engine.Threed ulong ticks = _context.GetTimestamp(); + float divisor = type switch + { + ReportCounterType.SamplesPassed => _channel.TextureManager.RenderTargetScale * _channel.TextureManager.RenderTargetScale, + _ => 1f + }; + ICounterEvent counter = null; void resultHandler(object evt, ulong result) { + if (divisor != 1f) + { + result = (ulong)MathF.Ceiling(result / divisor); + } + CounterData counterData = new CounterData { Counter = result,