GS/SW: Get rid of extra pointers to perfmon

This commit is contained in:
Connor McLaughlin 2022-04-22 20:33:23 +10:00 committed by refractionpcsx2
parent 14398da51f
commit 4f44e3fc46
3 changed files with 13 additions and 17 deletions

View File

@ -40,9 +40,8 @@ static int compute_best_thread_height(int threads)
return 4; return 4;
} }
GSRasterizer::GSRasterizer(IDrawScanline* ds, int id, int threads, GSPerfMon* perfmon) GSRasterizer::GSRasterizer(IDrawScanline* ds, int id, int threads)
: m_perfmon(perfmon) : m_ds(ds)
, m_ds(ds)
, m_id(id) , m_id(id)
, m_threads(threads) , m_threads(threads)
, m_scanmsk_value(0) , 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) GSRasterizerList::GSRasterizerList(int threads)
: m_perfmon(perfmon)
{ {
m_thread_height = compute_best_thread_height(threads); m_thread_height = compute_best_thread_height(threads);
int rows = (2048 >> m_thread_height) + 16; const int rows = (2048 >> m_thread_height) + 16;
m_scanline = (u8*)_aligned_malloc(rows, 64); m_scanline = static_cast<u8*>(_aligned_malloc(rows, 64));
for (int i = 0; i < rows; i++) for (int i = 0; i < rows; i++)
{ {
@ -1237,7 +1235,7 @@ void GSRasterizerList::Sync()
m_workers[i]->Wait(); m_workers[i]->Wait();
} }
m_perfmon->Put(GSPerfMon::SyncPoint, 1); g_perfmon.Put(GSPerfMon::SyncPoint, 1);
} }
} }

View File

@ -128,7 +128,6 @@ public:
class alignas(32) GSRasterizer : public IRasterizer class alignas(32) GSRasterizer : public IRasterizer
{ {
protected: protected:
GSPerfMon* m_perfmon;
IDrawScanline* m_ds; IDrawScanline* m_ds;
int m_id; int m_id;
int m_threads; int m_threads;
@ -165,7 +164,7 @@ protected:
__forceinline void DrawEdge(int pixels, int left, int top, const GSVertexSW& scan); __forceinline void DrawEdge(int pixels, int left, int top, const GSVertexSW& scan);
public: public:
GSRasterizer(IDrawScanline* ds, int id, int threads, GSPerfMon* perfmon); GSRasterizer(IDrawScanline* ds, int id, int threads);
virtual ~GSRasterizer(); virtual ~GSRasterizer();
__forceinline bool IsOneOfMyScanlines(int top) const; __forceinline bool IsOneOfMyScanlines(int top) const;
@ -188,14 +187,13 @@ class GSRasterizerList : public IRasterizer
protected: protected:
using GSWorker = GSJobQueue<GSRingHeap::SharedPtr<GSRasterizerData>, 65536>; using GSWorker = GSJobQueue<GSRingHeap::SharedPtr<GSRasterizerData>, 65536>;
GSPerfMon* m_perfmon;
// Worker threads depend on the rasterizers, so don't change the order. // Worker threads depend on the rasterizers, so don't change the order.
std::vector<std::unique_ptr<GSRasterizer>> m_r; std::vector<std::unique_ptr<GSRasterizer>> m_r;
std::vector<std::unique_ptr<GSWorker>> m_workers; std::vector<std::unique_ptr<GSWorker>> m_workers;
u8* m_scanline; u8* m_scanline;
int m_thread_height; int m_thread_height;
GSRasterizerList(int threads, GSPerfMon* perfmon); GSRasterizerList(int threads);
static void OnWorkerStartup(int i); static void OnWorkerStartup(int i);
static void OnWorkerShutdown(int i); static void OnWorkerShutdown(int i);
@ -204,20 +202,20 @@ public:
virtual ~GSRasterizerList(); virtual ~GSRasterizerList();
template <class DS> template <class DS>
static IRasterizer* Create(int threads, GSPerfMon* perfmon) static IRasterizer* Create(int threads)
{ {
threads = std::max<int>(threads, 0); threads = std::max<int>(threads, 0);
if (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++) for (int i = 0; i < threads; i++)
{ {
rl->m_r.push_back(std::unique_ptr<GSRasterizer>(new GSRasterizer(new DS(), i, threads, perfmon))); rl->m_r.push_back(std::unique_ptr<GSRasterizer>(new GSRasterizer(new DS(), i, threads)));
auto& r = *rl->m_r[i]; auto& r = *rl->m_r[i];
rl->m_workers.push_back(std::unique_ptr<GSWorker>(new GSWorker( rl->m_workers.push_back(std::unique_ptr<GSWorker>(new GSWorker(
[rl, i]() { rl->OnWorkerStartup(i); }, [rl, i]() { rl->OnWorkerStartup(i); },

View File

@ -35,7 +35,7 @@ GSRendererSW::GSRendererSW(int threads)
memset(m_texture, 0, sizeof(m_texture)); memset(m_texture, 0, sizeof(m_texture));
m_rl = GSRasterizerList::Create<GSDrawScanline>(threads, &g_perfmon); m_rl = GSRasterizerList::Create<GSDrawScanline>(threads);
m_output = (u8*)_aligned_malloc(1024 * 1024 * sizeof(u32), 32); m_output = (u8*)_aligned_malloc(1024 * 1024 * sizeof(u32), 32);