From 5d64a2b88975584ac393228de568243b2c661877 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Thu, 15 Jun 2023 01:10:02 +1000 Subject: [PATCH] GS/SW: Replace __rdtsc() with GetCPUTicks() --- pcsx2/GS/Renderers/Common/GSFunctionMap.h | 4 ++-- pcsx2/GS/Renderers/SW/GSRasterizer.cpp | 7 +++++-- pcsx2/GS/Renderers/SW/GSRendererSW.cpp | 6 +++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/pcsx2/GS/Renderers/Common/GSFunctionMap.h b/pcsx2/GS/Renderers/Common/GSFunctionMap.h index e7ffd75aa1..1d86be1e0c 100644 --- a/pcsx2/GS/Renderers/Common/GSFunctionMap.h +++ b/pcsx2/GS/Renderers/Common/GSFunctionMap.h @@ -96,7 +96,7 @@ public: } } - virtual void PrintStats() + void PrintStats() { u64 totalTicks = 0; @@ -106,7 +106,7 @@ public: totalTicks += p->ticks; } - double tick_us = 1.0 / x86capabilities::CachedMHz(); + double tick_us = 1.0 / GetTickFrequency(); double tick_ms = tick_us / 1000; double tick_ns = tick_us * 1000; diff --git a/pcsx2/GS/Renderers/SW/GSRasterizer.cpp b/pcsx2/GS/Renderers/SW/GSRasterizer.cpp index c07b2a710d..bda2e9e169 100644 --- a/pcsx2/GS/Renderers/SW/GSRasterizer.cpp +++ b/pcsx2/GS/Renderers/SW/GSRasterizer.cpp @@ -21,6 +21,7 @@ #include "GS/GSExtra.h" #include "PerformanceMetrics.h" #include "common/AlignedMalloc.h" +#include "common/General.h" #include "common/StringUtil.h" #include "VMManager.h" @@ -144,7 +145,7 @@ void GSRasterizer::Draw(GSRasterizerData& data) m_primcount = 0; if constexpr (ENABLE_DRAW_STATS) - data.start = __rdtsc(); + data.start = GetCPUTicks(); m_setup_prim = data.setup_prim; m_draw_scanline = data.draw_scanline; @@ -257,7 +258,7 @@ void GSRasterizer::Draw(GSRasterizerData& data) m_pixels.sum += m_pixels.actual; if constexpr (ENABLE_DRAW_STATS) - m_ds->UpdateDrawStats(data.frame, __rdtsc() - data.start, m_pixels.actual, m_pixels.total, m_primcount); + m_ds->UpdateDrawStats(data.frame, GetCPUTicks() - data.start, m_pixels.actual, m_pixels.total, m_primcount); } template @@ -1192,7 +1193,9 @@ int GSSingleRasterizer::GetPixels(bool reset /*= true*/) void GSSingleRasterizer::PrintStats() { +#ifdef ENABLE_DRAW_STATS m_ds.PrintStats(); +#endif } // diff --git a/pcsx2/GS/Renderers/SW/GSRendererSW.cpp b/pcsx2/GS/Renderers/SW/GSRendererSW.cpp index 85af860c4a..b73b62e62b 100644 --- a/pcsx2/GS/Renderers/SW/GSRendererSW.cpp +++ b/pcsx2/GS/Renderers/SW/GSRendererSW.cpp @@ -580,7 +580,7 @@ void GSRendererSW::Sync(int reason) { //printf("sync %d\n", reason); - u64 t = LOG ? __rdtsc() : 0; + u64 t = LOG ? GetCPUTicks() : 0; m_rl->Sync(); @@ -603,7 +603,7 @@ void GSRendererSW::Sync(int reason) } } - t = LOG ? (__rdtsc() - t) : 0; + t = LOG ? (GetCPUTicks() - t) : 0; int pixels = m_rl->GetPixels(); @@ -1457,7 +1457,7 @@ GSRendererSW::SharedData::~SharedData() { fprintf(s_fp, "[%d] done t=%lld p=%d | %d %d %d | %08x_%08x\n", counter, - __rdtsc() - start, pixels, + GetCPUTicks() - start, pixels, primclass, vertex_count, index_count, global.sel.hi, global.sel.lo); fflush(s_fp);