From 4f44e3fc4624d72d4dadb7e83f23131c48a760b9 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Fri, 22 Apr 2022 20:33:23 +1000 Subject: [PATCH] GS/SW: Get rid of extra pointers to perfmon --- pcsx2/GS/Renderers/SW/GSRasterizer.cpp | 14 ++++++-------- pcsx2/GS/Renderers/SW/GSRasterizer.h | 14 ++++++-------- pcsx2/GS/Renderers/SW/GSRendererSW.cpp | 2 +- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/pcsx2/GS/Renderers/SW/GSRasterizer.cpp b/pcsx2/GS/Renderers/SW/GSRasterizer.cpp index 5e2aa0167e..e3c5c2cacd 100644 --- a/pcsx2/GS/Renderers/SW/GSRasterizer.cpp +++ b/pcsx2/GS/Renderers/SW/GSRasterizer.cpp @@ -40,9 +40,8 @@ static int compute_best_thread_height(int threads) return 4; } -GSRasterizer::GSRasterizer(IDrawScanline* ds, int id, int threads, GSPerfMon* perfmon) - : m_perfmon(perfmon) - , m_ds(ds) +GSRasterizer::GSRasterizer(IDrawScanline* ds, int id, int threads) + : m_ds(ds) , m_id(id) , m_threads(threads) , m_scanmsk_value(0) @@ -1181,13 +1180,12 @@ void GSRasterizer::DrawEdge(int pixels, int left, int top, const GSVertexSW& sca // -GSRasterizerList::GSRasterizerList(int threads, GSPerfMon* perfmon) - : m_perfmon(perfmon) +GSRasterizerList::GSRasterizerList(int threads) { m_thread_height = compute_best_thread_height(threads); - int rows = (2048 >> m_thread_height) + 16; - m_scanline = (u8*)_aligned_malloc(rows, 64); + const int rows = (2048 >> m_thread_height) + 16; + m_scanline = static_cast(_aligned_malloc(rows, 64)); for (int i = 0; i < rows; i++) { @@ -1237,7 +1235,7 @@ void GSRasterizerList::Sync() m_workers[i]->Wait(); } - m_perfmon->Put(GSPerfMon::SyncPoint, 1); + g_perfmon.Put(GSPerfMon::SyncPoint, 1); } } diff --git a/pcsx2/GS/Renderers/SW/GSRasterizer.h b/pcsx2/GS/Renderers/SW/GSRasterizer.h index b2059010cb..dcab70d41e 100644 --- a/pcsx2/GS/Renderers/SW/GSRasterizer.h +++ b/pcsx2/GS/Renderers/SW/GSRasterizer.h @@ -128,7 +128,6 @@ public: class alignas(32) GSRasterizer : public IRasterizer { protected: - GSPerfMon* m_perfmon; IDrawScanline* m_ds; int m_id; int m_threads; @@ -165,7 +164,7 @@ protected: __forceinline void DrawEdge(int pixels, int left, int top, const GSVertexSW& scan); public: - GSRasterizer(IDrawScanline* ds, int id, int threads, GSPerfMon* perfmon); + GSRasterizer(IDrawScanline* ds, int id, int threads); virtual ~GSRasterizer(); __forceinline bool IsOneOfMyScanlines(int top) const; @@ -188,14 +187,13 @@ class GSRasterizerList : public IRasterizer protected: using GSWorker = GSJobQueue, 65536>; - GSPerfMon* m_perfmon; // Worker threads depend on the rasterizers, so don't change the order. std::vector> m_r; std::vector> m_workers; u8* m_scanline; int m_thread_height; - GSRasterizerList(int threads, GSPerfMon* perfmon); + GSRasterizerList(int threads); static void OnWorkerStartup(int i); static void OnWorkerShutdown(int i); @@ -204,20 +202,20 @@ public: virtual ~GSRasterizerList(); template - static IRasterizer* Create(int threads, GSPerfMon* perfmon) + static IRasterizer* Create(int threads) { threads = std::max(threads, 0); if (threads == 0) { - return new GSRasterizer(new DS(), 0, 1, perfmon); + return new GSRasterizer(new DS(), 0, 1); } - GSRasterizerList* rl = new GSRasterizerList(threads, perfmon); + GSRasterizerList* rl = new GSRasterizerList(threads); for (int i = 0; i < threads; i++) { - rl->m_r.push_back(std::unique_ptr(new GSRasterizer(new DS(), i, threads, perfmon))); + rl->m_r.push_back(std::unique_ptr(new GSRasterizer(new DS(), i, threads))); auto& r = *rl->m_r[i]; rl->m_workers.push_back(std::unique_ptr(new GSWorker( [rl, i]() { rl->OnWorkerStartup(i); }, diff --git a/pcsx2/GS/Renderers/SW/GSRendererSW.cpp b/pcsx2/GS/Renderers/SW/GSRendererSW.cpp index baee1be8bd..f81a3295d5 100644 --- a/pcsx2/GS/Renderers/SW/GSRendererSW.cpp +++ b/pcsx2/GS/Renderers/SW/GSRendererSW.cpp @@ -35,7 +35,7 @@ GSRendererSW::GSRendererSW(int threads) memset(m_texture, 0, sizeof(m_texture)); - m_rl = GSRasterizerList::Create(threads, &g_perfmon); + m_rl = GSRasterizerList::Create(threads); m_output = (u8*)_aligned_malloc(1024 * 1024 * sizeof(u32), 32);