From cb4b58052f325864ece956898cdd64373edf896a Mon Sep 17 00:00:00 2001 From: OpaqueReptile <1337paf92@gmail.com> Date: Wed, 17 May 2023 13:38:59 -0500 Subject: [PATCH] Start GPU performance counter at 0 instead of host GPU value (#4992) * Start performance counter at 0 instead of host perf counter value * whitespace * init _firstTimestamp in constructer per feedback * change comment * punctuation * address feedback * revise comment --- src/Ryujinx.Graphics.Gpu/GpuContext.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Ryujinx.Graphics.Gpu/GpuContext.cs b/src/Ryujinx.Graphics.Gpu/GpuContext.cs index ccaabf70f..0fe6a28ff 100644 --- a/src/Ryujinx.Graphics.Gpu/GpuContext.cs +++ b/src/Ryujinx.Graphics.Gpu/GpuContext.cs @@ -99,6 +99,7 @@ namespace Ryujinx.Graphics.Gpu private bool _pendingSync; private long _modifiedSequence; + private ulong _firstTimestamp; /// /// Creates a new instance of the GPU emulation context. @@ -123,6 +124,8 @@ namespace Ryujinx.Graphics.Gpu DeferredActions = new Queue(); PhysicalMemoryRegistry = new ConcurrentDictionary(); + + _firstTimestamp = ConvertNanosecondsToTicks((ulong)PerformanceCounter.ElapsedNanoseconds); } /// @@ -217,7 +220,8 @@ namespace Ryujinx.Graphics.Gpu /// The current GPU timestamp public ulong GetTimestamp() { - ulong ticks = ConvertNanosecondsToTicks((ulong)PerformanceCounter.ElapsedNanoseconds); + // Guest timestamp will start at 0, instead of host value. + ulong ticks = ConvertNanosecondsToTicks((ulong)PerformanceCounter.ElapsedNanoseconds) - _firstTimestamp; if (GraphicsConfig.FastGpuTime) {