mirror of https://github.com/PCSX2/pcsx2.git
GS: Alloc sw renderer things on custom heap
This commit is contained in:
parent
342170b077
commit
6d4713e069
|
@ -33,6 +33,11 @@ public:
|
|||
_aligned_free(p);
|
||||
}
|
||||
|
||||
void* operator new(size_t size, void* ptr)
|
||||
{
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void* operator new[](size_t size)
|
||||
{
|
||||
return _aligned_malloc(size, i);
|
||||
|
|
|
@ -113,7 +113,7 @@ int GSRasterizer::FindMyNextScanline(int top) const
|
|||
return top;
|
||||
}
|
||||
|
||||
void GSRasterizer::Queue(const std::shared_ptr<GSRasterizerData>& data)
|
||||
void GSRasterizer::Queue(const GSRingHeap::SharedPtr<GSRasterizerData>& data)
|
||||
{
|
||||
Draw(data.get());
|
||||
}
|
||||
|
@ -1203,7 +1203,7 @@ GSRasterizerList::~GSRasterizerList()
|
|||
_aligned_free(m_scanline);
|
||||
}
|
||||
|
||||
void GSRasterizerList::Queue(const std::shared_ptr<GSRasterizerData>& data)
|
||||
void GSRasterizerList::Queue(const GSRingHeap::SharedPtr<GSRasterizerData>& data)
|
||||
{
|
||||
GSVector4i r = data->bbox.rintersect(data->scissor);
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "GS/GSAlignedClass.h"
|
||||
#include "GS/GSPerfMon.h"
|
||||
#include "GS/GSThread_CXX11.h"
|
||||
#include "GS/GSRingHeap.h"
|
||||
|
||||
class alignas(32) GSRasterizerData : public GSAlignedClass<32>
|
||||
{
|
||||
|
@ -43,7 +44,7 @@ public:
|
|||
: scissor(GSVector4i::zero())
|
||||
, bbox(GSVector4i::zero())
|
||||
, primclass(GS_INVALID_CLASS)
|
||||
, buff(NULL)
|
||||
, buff(nullptr)
|
||||
, vertex(NULL)
|
||||
, vertex_count(0)
|
||||
, index(NULL)
|
||||
|
@ -58,7 +59,7 @@ public:
|
|||
virtual ~GSRasterizerData()
|
||||
{
|
||||
if (buff != NULL)
|
||||
_aligned_free(buff);
|
||||
GSRingHeap::free(buff);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -115,7 +116,7 @@ class IRasterizer : public GSAlignedClass<32>
|
|||
public:
|
||||
virtual ~IRasterizer() {}
|
||||
|
||||
virtual void Queue(const std::shared_ptr<GSRasterizerData>& data) = 0;
|
||||
virtual void Queue(const GSRingHeap::SharedPtr<GSRasterizerData>& data) = 0;
|
||||
virtual void Sync() = 0;
|
||||
virtual bool IsSynced() const = 0;
|
||||
virtual int GetPixels(bool reset = true) = 0;
|
||||
|
@ -172,7 +173,7 @@ public:
|
|||
|
||||
// IRasterizer
|
||||
|
||||
void Queue(const std::shared_ptr<GSRasterizerData>& data);
|
||||
void Queue(const GSRingHeap::SharedPtr<GSRasterizerData>& data);
|
||||
void Sync() {}
|
||||
bool IsSynced() const { return true; }
|
||||
int GetPixels(bool reset);
|
||||
|
@ -182,7 +183,7 @@ public:
|
|||
class GSRasterizerList : public IRasterizer
|
||||
{
|
||||
protected:
|
||||
using GSWorker = GSJobQueue<std::shared_ptr<GSRasterizerData>, 65536>;
|
||||
using GSWorker = GSJobQueue<GSRingHeap::SharedPtr<GSRasterizerData>, 65536>;
|
||||
|
||||
GSPerfMon* m_perfmon;
|
||||
// Worker threads depend on the rasterizers, so don't change the order.
|
||||
|
@ -213,7 +214,7 @@ public:
|
|||
rl->m_r.push_back(std::unique_ptr<GSRasterizer>(new GSRasterizer(new DS(), i, threads, perfmon)));
|
||||
auto& r = *rl->m_r[i];
|
||||
rl->m_workers.push_back(std::unique_ptr<GSWorker>(new GSWorker(
|
||||
[&r](std::shared_ptr<GSRasterizerData>& item) { r.Draw(item.get()); })));
|
||||
[&r](GSRingHeap::SharedPtr<GSRasterizerData>& item) { r.Draw(item.get()); })));
|
||||
}
|
||||
|
||||
return rl;
|
||||
|
@ -221,7 +222,7 @@ public:
|
|||
|
||||
// IRasterizer
|
||||
|
||||
void Queue(const std::shared_ptr<GSRasterizerData>& data);
|
||||
void Queue(const GSRingHeap::SharedPtr<GSRasterizerData>& data);
|
||||
void Sync();
|
||||
bool IsSynced() const;
|
||||
int GetPixels(bool reset);
|
||||
|
|
|
@ -335,12 +335,11 @@ void GSRendererSW::Draw()
|
|||
{
|
||||
const GSDrawingContext* context = m_context;
|
||||
|
||||
SharedData* sd = new SharedData(this);
|
||||
|
||||
std::shared_ptr<GSRasterizerData> data(sd);
|
||||
auto data = m_vertex_heap.make_shared<SharedData>(this).cast<GSRasterizerData>();
|
||||
SharedData* sd = static_cast<SharedData*>(data.get());
|
||||
|
||||
sd->primclass = m_vt.m_primclass;
|
||||
sd->buff = (u8*)_aligned_malloc(sizeof(GSVertexSW) * ((m_vertex.next + 1) & ~1) + sizeof(u32) * m_index.tail, 64);
|
||||
sd->buff = (u8*)m_vertex_heap.alloc(sizeof(GSVertexSW) * ((m_vertex.next + 1) & ~1) + sizeof(u32) * m_index.tail, 64);
|
||||
sd->vertex = (GSVertexSW*)sd->buff;
|
||||
sd->vertex_count = m_vertex.next;
|
||||
sd->index = (u32*)(sd->buff + sizeof(GSVertexSW) * ((m_vertex.next + 1) & ~1));
|
||||
|
@ -540,7 +539,7 @@ void GSRendererSW::Draw()
|
|||
*/
|
||||
}
|
||||
|
||||
void GSRendererSW::Queue(std::shared_ptr<GSRasterizerData>& item)
|
||||
void GSRendererSW::Queue(GSRingHeap::SharedPtr<GSRasterizerData>& item)
|
||||
{
|
||||
SharedData* sd = (SharedData*)item.get();
|
||||
|
||||
|
@ -1050,7 +1049,7 @@ bool GSRendererSW::GetScanlineGlobalData(SharedData* data)
|
|||
{
|
||||
gd.sel.tlu = 1;
|
||||
|
||||
gd.clut = (u32*)_aligned_malloc(sizeof(u32) * 256, 32); // FIXME: might address uninitialized data of the texture (0xCD) that is not in 0-15 range for 4-bpp formats
|
||||
gd.clut = (u32*)m_vertex_heap.alloc(sizeof(u32) * 256, 32); // FIXME: might address uninitialized data of the texture (0xCD) that is not in 0-15 range for 4-bpp formats
|
||||
|
||||
memcpy(gd.clut, (const u32*)m_mem.m_clut, sizeof(u32) * GSLocalMemory::m_psm[context->TEX0.PSM].pal);
|
||||
}
|
||||
|
@ -1327,7 +1326,7 @@ bool GSRendererSW::GetScanlineGlobalData(SharedData* data)
|
|||
{
|
||||
gd.sel.dthe = 1;
|
||||
|
||||
gd.dimx = (GSVector4i*)_aligned_malloc(sizeof(env.dimx), 32);
|
||||
gd.dimx = (GSVector4i*)m_vertex_heap.alloc(sizeof(env.dimx), 32);
|
||||
|
||||
memcpy(gd.dimx, env.dimx, sizeof(env.dimx));
|
||||
}
|
||||
|
@ -1444,9 +1443,9 @@ GSRendererSW::SharedData::~SharedData()
|
|||
ReleasePages();
|
||||
|
||||
if (global.clut)
|
||||
_aligned_free(global.clut);
|
||||
GSRingHeap::free(global.clut);
|
||||
if (global.dimx)
|
||||
_aligned_free(global.dimx);
|
||||
GSRingHeap::free(global.dimx);
|
||||
|
||||
if (LOG)
|
||||
{
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include "GSTextureCacheSW.h"
|
||||
#include "GSDrawScanline.h"
|
||||
#include "GS/GSRingHeap.h"
|
||||
|
||||
class GSRendererSW : public GSRenderer
|
||||
{
|
||||
|
@ -68,6 +69,7 @@ class GSRendererSW : public GSRenderer
|
|||
|
||||
protected:
|
||||
IRasterizer* m_rl;
|
||||
GSRingHeap m_vertex_heap;
|
||||
GSTextureCacheSW* m_tc;
|
||||
GSTexture* m_texture[2];
|
||||
u8* m_output;
|
||||
|
@ -84,7 +86,7 @@ protected:
|
|||
GSTexture* GetFeedbackOutput();
|
||||
|
||||
void Draw();
|
||||
void Queue(std::shared_ptr<GSRasterizerData>& item);
|
||||
void Queue(GSRingHeap::SharedPtr<GSRasterizerData>& item);
|
||||
void Sync(int reason);
|
||||
void InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r);
|
||||
void InvalidateLocalMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r, bool clut = false);
|
||||
|
|
Loading…
Reference in New Issue