Skip to content

Commit

Permalink
GSdx: the promised index buffer update, needed a lot of changes, expe…
Browse files Browse the repository at this point in the history
…ct bugs in the next dozen revisions.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5045 96395faa-99c1-11dd-bbfe-3dabce05a288
  • Loading branch information
gabest11 committed Jan 5, 2012
1 parent bffde4f commit f68f007
Show file tree
Hide file tree
Showing 55 changed files with 3,206 additions and 2,959 deletions.
32 changes: 18 additions & 14 deletions plugins/GSdx/GPURendererSW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,22 +114,26 @@ void GPURendererSW::Draw()

gd.vm = m_mem.GetPixelAddress(0, 0);

data->vertices = (GSVertexSW*)_aligned_malloc(sizeof(GSVertexSW) * m_count, 16);
memcpy(data->vertices, m_vertices, sizeof(GSVertexSW) * m_count);
data->count = m_count;

data->frame = m_perfmon.GetFrame();

data->scissor.left = (int)m_env.DRAREATL.X << m_scale.x;
data->scissor.top = (int)m_env.DRAREATL.Y << m_scale.y;
data->scissor.right = min((int)(m_env.DRAREABR.X + 1) << m_scale.x, m_mem.GetWidth());
data->scissor.bottom = min((int)(m_env.DRAREABR.Y + 1) << m_scale.y, m_mem.GetHeight());

data->buff = (uint8*)_aligned_malloc(sizeof(GSVertexSW) * m_count, 16);
data->vertex = (GSVertexSW*)data->buff;
data->vertex_count = m_count;

memcpy(data->vertex, m_vertices, sizeof(GSVertexSW) * m_count);

data->frame = m_perfmon.GetFrame();

int prims = 0;

switch(env.PRIM.TYPE)
{
case GPU_POLYGON: data->primclass = GS_TRIANGLE_CLASS; break;
case GPU_LINE: data->primclass = GS_LINE_CLASS; break;
case GPU_SPRITE: data->primclass = GS_SPRITE_CLASS; break;
case GPU_POLYGON: data->primclass = GS_TRIANGLE_CLASS; prims = data->vertex_count / 3; break;
case GPU_LINE: data->primclass = GS_LINE_CLASS; prims = data->vertex_count / 2; break;
case GPU_SPRITE: data->primclass = GS_SPRITE_CLASS; prims = data->vertex_count / 2; break;
default: __assume(0);
}

Expand All @@ -138,9 +142,9 @@ void GPURendererSW::Draw()
GSVector4 tl(+1e10f);
GSVector4 br(-1e10f);

GSVertexSW* v = data->vertices;
GSVertexSW* v = data->vertex;

for(int i = 0, j = m_count; i < j; i++)
for(int i = 0, j = data->vertex_count; i < j; i++)
{
GSVector4 p = v[i].p;

Expand All @@ -163,9 +167,9 @@ void GPURendererSW::Draw()

m_rl->Sync();

// TODO: m_perfmon.Put(GSPerfMon::Draw, 1);
// TODO: m_perfmon.Put(GSPerfMon::Prim, stats.prims);
// TODO: m_perfmon.Put(GSPerfMon::Fillrate, stats.pixels);
m_perfmon.Put(GSPerfMon::Draw, 1);
m_perfmon.Put(GSPerfMon::Prim, prims);
m_perfmon.Put(GSPerfMon::Fillrate, data->pixels);
}

void GPURendererSW::VertexKick()
Expand Down
121 changes: 119 additions & 2 deletions plugins/GSdx/GS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -735,8 +735,6 @@ EXPORT_C GSReplay(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow)

::SetPriorityClass(::GetCurrentProcess(), HIGH_PRIORITY_CLASS);

vector<uint8> buff;

if(FILE* fp = fopen(lpszCmdLine, "rb"))
{
Console console("GSdx", true);
Expand Down Expand Up @@ -769,10 +767,127 @@ EXPORT_C GSReplay(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow)

GSvsync(1);

struct Packet {uint8 type, param; uint32 size, addr; vector<uint8> buff;};

list<Packet*> packets;
vector<uint8> buff;
int type;

while((type = fgetc(fp)) != EOF)
{
Packet* p = new Packet();

p->type = (uint8)type;

switch(type)
{
case 0:

p->param = (uint8)fgetc(fp);

fread(&p->size, 4, 1, fp);

switch(p->param)
{
case 0:
p->buff.resize(0x4000);
p->addr = 0x4000 - p->size;
fread(&p->buff[p->addr], p->size, 1, fp);
break;
case 1:
case 2:
case 3:
p->buff.resize(p->size);
fread(&p->buff[0], p->size, 1, fp);
break;
}

break;

case 1:

p->param = (uint8)fgetc(fp);

break;

case 2:

fread(&p->size, 4, 1, fp);

break;

case 3:

p->buff.resize(0x2000);

fread(&p->buff[0], 0x2000, 1, fp);

break;
}

packets.push_back(p);
}

Sleep(100);

while(IsWindowVisible(hWnd))
{
for(list<Packet*>::iterator i = packets.begin(); i != packets.end(); i++)
{
Packet* p = *i;

switch(p->type)
{
case 0:

switch(p->param)
{
case 0: GSgifTransfer1(&p->buff[0], p->addr); break;
case 1: GSgifTransfer2(&p->buff[0], p->size / 16); break;
case 2: GSgifTransfer3(&p->buff[0], p->size / 16); break;
case 3: GSgifTransfer(&p->buff[0], p->size / 16); break;
}

break;

case 1:

GSvsync(p->param);

break;

case 2:

if(buff.size() < p->size) buff.resize(p->size);

GSreadFIFO2(&buff[0], p->size / 16);

break;

case 3:

memcpy(regs, &p->buff[0], 0x2000);

break;
}
}
}

for(list<Packet*>::iterator i = packets.begin(); i != packets.end(); i++)
{
delete *i;
}

packets.clear();

Sleep(100);


/*
bool exit = false;
int round = 0;
while(!exit)
{
uint32 index;
Expand All @@ -786,6 +901,7 @@ EXPORT_C GSReplay(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow)
case EOF:
fseek(fp, start, 0);
exit = !IsWindowVisible(hWnd);
//exit = ++round == 60;
break;
case 0:
Expand Down Expand Up @@ -838,6 +954,7 @@ EXPORT_C GSReplay(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow)
break;
}
}
*/

GSclose();
GSshutdown();
Expand Down
12 changes: 8 additions & 4 deletions plugins/GSdx/GS.h
Original file line number Diff line number Diff line change
Expand Up @@ -638,8 +638,8 @@ REG64_(GIFReg, FINISH)
REG_END

REG64_(GIFReg, FOG)
uint8 _PAD1[4+3];
uint8 F:8;
uint8 _PAD1[7];
uint8 F;
REG_END

REG64_(GIFReg, FOGCOL)
Expand Down Expand Up @@ -1030,7 +1030,9 @@ REG128_(GIFPacked, XYZF2)
uint32 _PAD6:3;
uint32 ADC:1;
uint32 _PAD7:16;
REG_END
REG_END2
uint32 Skip() const {return u32[3] & 0x8000;}
REG_END2

REG128_(GIFPacked, XYZ2)
uint16 X;
Expand All @@ -1041,7 +1043,9 @@ REG128_(GIFPacked, XYZ2)
uint32 _PAD3:15;
uint32 ADC:1;
uint32 _PAD4:16;
REG_END
REG_END2
uint32 Skip() const {return u32[3] & 0x8000;}
REG_END2

REG128_(GIFPacked, FOG)
uint32 _PAD1;
Expand Down
9 changes: 6 additions & 3 deletions plugins/GSdx/GSDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ GSDevice::GSDevice()
, m_1x1(NULL)
, m_frame(0)
{
memset(&m_vertices, 0, sizeof(m_vertices));
memset(&m_vertex, 0, sizeof(m_vertex));
memset(&m_index, 0, sizeof(m_index));
}

GSDevice::~GSDevice()
Expand Down Expand Up @@ -135,8 +136,10 @@ GSTexture* GSDevice::FetchSurface(int type, int w, int h, bool msaa, int format)

void GSDevice::EndScene()
{
m_vertices.start += m_vertices.count;
m_vertices.count = 0;
m_vertex.start += m_vertex.count;
m_vertex.count = 0;
m_index.start += m_index.count;
m_index.count = 0;
}

void GSDevice::Recycle(GSTexture* t)
Expand Down
4 changes: 3 additions & 1 deletion plugins/GSdx/GSDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ class GSDevice : public GSAlignedClass<32>
GSTexture* m_fxaa;
GSTexture* m_1x1;
GSTexture* m_current;
struct {size_t stride, start, count, limit;} m_vertices;
struct {size_t stride, start, count, limit;} m_vertex;
struct {size_t start, count, limit;} m_index;
unsigned int m_frame; // for ageing the pool

virtual GSTexture* CreateSurface(int type, int w, int h, bool msaa, int format) = 0;
Expand Down Expand Up @@ -101,6 +102,7 @@ class GSDevice : public GSAlignedClass<32>

virtual void BeginScene() {}
virtual void DrawPrimitive() {};
virtual void DrawIndexedPrimitive() {}
virtual void EndScene();

virtual void ClearRenderTarget(GSTexture* t, const GSVector4& c) {}
Expand Down

0 comments on commit f68f007

Please sign in to comment.