GSdx: more refactoring (aka search and replace)

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1179 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
gabest11 2009-05-14 16:41:52 +00:00
parent 40447aabc1
commit 5648d07b96
96 changed files with 4863 additions and 5676 deletions

View File

@ -32,7 +32,7 @@
static HRESULT s_hr = E_FAIL;
static GPURendererBase* s_gpu = NULL;
EXPORT_C_(UINT32) PSEgetLibType()
EXPORT_C_(uint32) PSEgetLibType()
{
return PSE_LT_GPU;
}
@ -42,15 +42,15 @@ EXPORT_C_(char*) PSEgetLibName()
return GSUtil::GetLibName();
}
EXPORT_C_(UINT32) PSEgetLibVersion()
EXPORT_C_(uint32) PSEgetLibVersion()
{
static const UINT32 version = 1;
static const UINT32 revision = 1;
static const uint32 version = 1;
static const uint32 revision = 1;
return version << 16 | revision << 8 | PLUGIN_VERSION;
}
EXPORT_C_(INT32) GPUinit()
EXPORT_C_(int32) GPUinit()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
@ -59,7 +59,7 @@ EXPORT_C_(INT32) GPUinit()
return 0;
}
EXPORT_C_(INT32) GPUshutdown()
EXPORT_C_(int32) GPUshutdown()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
@ -68,7 +68,7 @@ EXPORT_C_(INT32) GPUshutdown()
return 0;
}
EXPORT_C_(INT32) GPUclose()
EXPORT_C_(int32) GPUclose()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
@ -86,7 +86,7 @@ EXPORT_C_(INT32) GPUclose()
return 0;
}
EXPORT_C_(INT32) GPUopen(HWND hWnd)
EXPORT_C_(int32) GPUopen(HWND hWnd)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
@ -103,8 +103,8 @@ EXPORT_C_(INT32) GPUopen(HWND hWnd)
rs.m_dither = AfxGetApp()->GetProfileInt(_T("GPUSettings"), _T("dithering"), 1);
rs.m_aspectratio = AfxGetApp()->GetProfileInt(_T("GPUSettings"), _T("AspectRatio"), 1);
rs.m_vsync = !!AfxGetApp()->GetProfileInt(_T("GPUSettings"), _T("vsync"), FALSE);
rs.m_scale.cx = AfxGetApp()->GetProfileInt(_T("GPUSettings"), _T("scale_x"), 0);
rs.m_scale.cy = AfxGetApp()->GetProfileInt(_T("GPUSettings"), _T("scale_y"), 0);
rs.m_scale.x = AfxGetApp()->GetProfileInt(_T("GPUSettings"), _T("scale_x"), 0);
rs.m_scale.y = AfxGetApp()->GetProfileInt(_T("GPUSettings"), _T("scale_y"), 0);
int threads = AfxGetApp()->GetProfileInt(_T("GPUSettings"), _T("swthreads"), 1);
@ -131,7 +131,7 @@ EXPORT_C_(INT32) GPUopen(HWND hWnd)
return 0;
}
EXPORT_C_(INT32) GPUconfigure()
EXPORT_C_(int32) GPUconfigure()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
@ -146,7 +146,7 @@ EXPORT_C_(INT32) GPUconfigure()
return 0;
}
EXPORT_C_(INT32) GPUtest()
EXPORT_C_(int32) GPUtest()
{
// TODO
@ -158,76 +158,79 @@ EXPORT_C GPUabout()
// TODO
}
EXPORT_C GPUwriteDataMem(const BYTE* mem, UINT32 size)
EXPORT_C GPUwriteDataMem(const uint8* mem, uint32 size)
{
s_gpu->WriteData(mem, size);
}
EXPORT_C GPUwriteData(UINT32 data)
EXPORT_C GPUwriteData(uint32 data)
{
s_gpu->WriteData((BYTE*)&data, 1);
s_gpu->WriteData((uint8*)&data, 1);
}
EXPORT_C GPUreadDataMem(BYTE* mem, UINT32 size)
EXPORT_C GPUreadDataMem(uint8* mem, uint32 size)
{
s_gpu->ReadData(mem, size);
}
EXPORT_C_(UINT32) GPUreadData()
EXPORT_C_(uint32) GPUreadData()
{
UINT32 data = 0;
uint32 data = 0;
s_gpu->ReadData((BYTE*)&data, 1);
s_gpu->ReadData((uint8*)&data, 1);
return data;
}
EXPORT_C GPUwriteStatus(UINT32 status)
EXPORT_C GPUwriteStatus(uint32 status)
{
s_gpu->WriteStatus(status);
}
EXPORT_C_(UINT32) GPUreadStatus()
EXPORT_C_(uint32) GPUreadStatus()
{
return s_gpu->ReadStatus();
}
EXPORT_C_(UINT32) GPUdmaChain(const BYTE* mem, UINT32 addr)
EXPORT_C_(uint32) GPUdmaChain(const uint8* mem, uint32 addr)
{
// TODO
UINT32 last[3];
uint32 last[3];
memset(last, 0xff, sizeof(last));
do
{
if(addr == last[1] || addr == last[2]) break;
if(addr == last[1] || addr == last[2])
{
break;
}
(addr < last[0] ? last[1] : last[2]) = addr;
last[0] = addr;
BYTE size = mem[addr + 3];
uint8 size = mem[addr + 3];
if(size > 0)
{
s_gpu->WriteData(&mem[addr + 4], size);
}
addr = *(UINT32*)&mem[addr] & 0xffffff;
addr = *(uint32*)&mem[addr] & 0xffffff;
}
while(addr != 0xffffff);
return 0;
}
EXPORT_C_(UINT32) GPUgetMode()
EXPORT_C_(uint32) GPUgetMode()
{
// TODO
return 0;
}
EXPORT_C GPUsetMode(UINT32)
EXPORT_C GPUsetMode(uint32 mode)
{
// TODO
}
@ -239,7 +242,7 @@ EXPORT_C GPUupdateLace()
EXPORT_C GPUmakeSnapshot()
{
s_gpu->MakeSnapshot("c:\\"); // TODO
s_gpu->MakeSnapshot("c:/"); // TODO
}
EXPORT_C GPUdisplayText(char* text)
@ -247,12 +250,12 @@ EXPORT_C GPUdisplayText(char* text)
// TODO
}
EXPORT_C GPUdisplayFlags(UINT32 flags)
EXPORT_C GPUdisplayFlags(uint32 flags)
{
// TODO
}
EXPORT_C_(INT32) GPUfreeze(UINT32 type, GPUFreezeData* data)
EXPORT_C_(int32) GPUfreeze(uint32 type, GPUFreezeData* data)
{
if(!data || data->version != 1)
{
@ -288,12 +291,12 @@ EXPORT_C_(INT32) GPUfreeze(UINT32 type, GPUFreezeData* data)
return 0;
}
EXPORT_C GPUgetScreenPic(BYTE* mem)
EXPORT_C GPUgetScreenPic(uint8* mem)
{
// TODO
}
EXPORT_C GPUshowScreenPic(BYTE* mem)
EXPORT_C GPUshowScreenPic(uint8* mem)
{
// TODO
}

View File

@ -33,209 +33,209 @@ enum
};
REG32_(GPUReg, STATUS)
UINT32 TX:4;
UINT32 TY:1;
UINT32 ABR:2;
UINT32 TP:2;
UINT32 DTD:1;
UINT32 DFE:1;
UINT32 MD:1;
UINT32 ME:1;
UINT32 _PAD0:3;
UINT32 WIDTH1:1;
UINT32 WIDTH0:2;
UINT32 HEIGHT:1;
UINT32 ISPAL:1;
UINT32 ISRGB24:1;
UINT32 ISINTER:1;
UINT32 DEN:1;
UINT32 _PAD1:2;
UINT32 IDLE:1;
UINT32 IMG:1;
UINT32 COM:1;
UINT32 DMA:2;
UINT32 LCF:1;
uint32 TX:4;
uint32 TY:1;
uint32 ABR:2;
uint32 TP:2;
uint32 DTD:1;
uint32 DFE:1;
uint32 MD:1;
uint32 ME:1;
uint32 _PAD0:3;
uint32 WIDTH1:1;
uint32 WIDTH0:2;
uint32 HEIGHT:1;
uint32 ISPAL:1;
uint32 ISRGB24:1;
uint32 ISINTER:1;
uint32 DEN:1;
uint32 _PAD1:2;
uint32 IDLE:1;
uint32 IMG:1;
uint32 COM:1;
uint32 DMA:2;
uint32 LCF:1;
/*
UINT32 TX:4;
UINT32 TY:1;
UINT32 ABR:2;
UINT32 TP:2;
UINT32 DTD:1;
UINT32 DFE:1;
UINT32 PBW:1;
UINT32 PBC:1;
UINT32 _PAD0:3;
UINT32 HRES2:1;
UINT32 HRES1:2;
UINT32 VRES:1;
UINT32 ISPAL:1;
UINT32 ISRGB24:1;
UINT32 ISINTER:1;
UINT32 ISSTOP:1;
UINT32 _PAD1:1;
UINT32 DMARDY:1;
UINT32 IDIDLE:1;
UINT32 DATARDY:1;
UINT32 ISEMPTY:1;
UINT32 TMODE:2;
UINT32 ODE:1;
uint32 TX:4;
uint32 TY:1;
uint32 ABR:2;
uint32 TP:2;
uint32 DTD:1;
uint32 DFE:1;
uint32 PBW:1;
uint32 PBC:1;
uint32 _PAD0:3;
uint32 HRES2:1;
uint32 HRES1:2;
uint32 VRES:1;
uint32 ISPAL:1;
uint32 ISRGB24:1;
uint32 ISINTER:1;
uint32 ISSTOP:1;
uint32 _PAD1:1;
uint32 DMARDY:1;
uint32 IDIDLE:1;
uint32 DATARDY:1;
uint32 ISEMPTY:1;
uint32 TMODE:2;
uint32 ODE:1;
*/
REG_END
REG32_(GPUReg, PACKET)
UINT32 _PAD:24;
UINT32 OPTION:5;
UINT32 TYPE:3;
uint32 _PAD:24;
uint32 OPTION:5;
uint32 TYPE:3;
REG_END
REG32_(GPUReg, PRIM)
UINT32 VTX:24;
UINT32 TGE:1;
UINT32 ABE:1;
UINT32 TME:1;
UINT32 _PAD2:1;
UINT32 IIP:1;
UINT32 TYPE:3;
uint32 VTX:24;
uint32 TGE:1;
uint32 ABE:1;
uint32 TME:1;
uint32 _PAD2:1;
uint32 IIP:1;
uint32 TYPE:3;
REG_END
REG32_(GPUReg, POLYGON)
UINT32 _PAD:24;
UINT32 TGE:1;
UINT32 ABE:1;
UINT32 TME:1;
UINT32 VTX:1;
UINT32 IIP:1;
UINT32 TYPE:3;
uint32 _PAD:24;
uint32 TGE:1;
uint32 ABE:1;
uint32 TME:1;
uint32 VTX:1;
uint32 IIP:1;
uint32 TYPE:3;
REG_END
REG32_(GPUReg, LINE)
UINT32 _PAD:24;
UINT32 ZERO1:1;
UINT32 ABE:1;
UINT32 ZERO2:1;
UINT32 PLL:1;
UINT32 IIP:1;
UINT32 TYPE:3;
uint32 _PAD:24;
uint32 ZERO1:1;
uint32 ABE:1;
uint32 ZERO2:1;
uint32 PLL:1;
uint32 IIP:1;
uint32 TYPE:3;
REG_END
REG32_(GPUReg, SPRITE)
UINT32 _PAD:24;
UINT32 ZERO:1;
UINT32 ABE:1;
UINT32 TME:1;
UINT32 SIZE:2;
UINT32 TYPE:3;
uint32 _PAD:24;
uint32 ZERO:1;
uint32 ABE:1;
uint32 TME:1;
uint32 SIZE:2;
uint32 TYPE:3;
REG_END
REG32_(GPUReg, RESET)
UINT32 _PAD:32;
uint32 _PAD:32;
REG_END
REG32_(GPUReg, DEN)
UINT32 DEN:1;
UINT32 _PAD:31;
uint32 DEN:1;
uint32 _PAD:31;
REG_END
REG32_(GPUReg, DMA)
UINT32 DMA:2;
UINT32 _PAD:30;
uint32 DMA:2;
uint32 _PAD:30;
REG_END
REG32_(GPUReg, DAREA)
UINT32 X:10;
UINT32 Y:9;
UINT32 _PAD:13;
uint32 X:10;
uint32 Y:9;
uint32 _PAD:13;
REG_END
REG32_(GPUReg, DHRANGE)
UINT32 X1:12;
UINT32 X2:12;
UINT32 _PAD:8;
uint32 X1:12;
uint32 X2:12;
uint32 _PAD:8;
REG_END
REG32_(GPUReg, DVRANGE)
UINT32 Y1:10;
UINT32 Y2:11;
UINT32 _PAD:11;
uint32 Y1:10;
uint32 Y2:11;
uint32 _PAD:11;
REG_END
REG32_(GPUReg, DMODE)
UINT32 WIDTH0:2;
UINT32 HEIGHT:1;
UINT32 ISPAL:1;
UINT32 ISRGB24:1;
UINT32 ISINTER:1;
UINT32 WIDTH1:1;
UINT32 REVERSE:1;
UINT32 _PAD:24;
uint32 WIDTH0:2;
uint32 HEIGHT:1;
uint32 ISPAL:1;
uint32 ISRGB24:1;
uint32 ISINTER:1;
uint32 WIDTH1:1;
uint32 REVERSE:1;
uint32 _PAD:24;
REG_END
REG32_(GPUReg, GPUINFO)
UINT32 PARAM:24;
UINT32 _PAD:8;
uint32 PARAM:24;
uint32 _PAD:8;
REG_END
REG32_(GPUReg, MODE)
UINT32 TX:4;
UINT32 TY:1;
UINT32 ABR:2;
UINT32 TP:2;
UINT32 DTD:1;
UINT32 DFE:1;
UINT32 _PAD:21;
uint32 TX:4;
uint32 TY:1;
uint32 ABR:2;
uint32 TP:2;
uint32 DTD:1;
uint32 DFE:1;
uint32 _PAD:21;
REG_END
REG32_(GPUReg, MASK)
UINT32 MD:1;
UINT32 ME:1;
UINT32 _PAD:30;
uint32 MD:1;
uint32 ME:1;
uint32 _PAD:30;
REG_END
REG32_(GPUReg, DRAREA)
UINT32 X:10;
UINT32 Y:10;
UINT32 _PAD:12;
uint32 X:10;
uint32 Y:10;
uint32 _PAD:12;
REG_END
REG32_(GPUReg, DROFF)
INT32 X:11;
INT32 Y:11;
INT32 _PAD:10;
int32 X:11;
int32 Y:11;
int32 _PAD:10;
REG_END
REG32_(GPUReg, RGB)
UINT32 R:8;
UINT32 G:8;
UINT32 B:8;
UINT32 _PAD:8;
uint32 R:8;
uint32 G:8;
uint32 B:8;
uint32 _PAD:8;
REG_END
REG32_(GPUReg, XY)
INT32 X:11;
INT32 _PAD1:5;
INT32 Y:11;
INT32 _PAD2:5;
int32 X:11;
int32 _PAD1:5;
int32 Y:11;
int32 _PAD2:5;
REG_END
REG32_(GPUReg, UV)
UINT32 U:8;
UINT32 V:8;
UINT32 _PAD:16;
uint32 U:8;
uint32 V:8;
uint32 _PAD:16;
REG_END
REG32_(GPUReg, TWIN)
UINT32 TWW:5;
UINT32 TWH:5;
UINT32 TWX:5;
UINT32 TWY:5;
UINT32 _PAD:12;
uint32 TWW:5;
uint32 TWH:5;
uint32 TWX:5;
uint32 TWY:5;
uint32 _PAD:12;
REG_END
REG32_(GPUReg, CLUT)
UINT32 _PAD1:16;
UINT32 X:6;
UINT32 Y:9;
UINT32 _PAD2:1;
uint32 _PAD1:16;
uint32 X:6;
uint32 Y:9;
uint32 _PAD2:1;
REG_END
REG32_SET(GPUReg)
@ -266,10 +266,10 @@ REG_SET_END
struct GPUFreezeData
{
UINT32 version; // == 1
UINT32 status;
UINT32 control[256];
UINT16 vram[1024 * 1024];
uint32 version; // == 1
uint32 status;
uint32 control[256];
uint16 vram[1024 * 1024];
};
#pragma pack(pop)

View File

@ -51,7 +51,7 @@ void GPUDrawScanline::BeginDraw(const GSRasterizerData* data, Functions* f)
if(m_env.sel.twin)
{
DWORD u, v;
uint32 u, v;
u = ~(env.TWIN.TWW << 3) & 0xff;
v = ~(env.TWIN.TWH << 3) & 0xff;
@ -100,7 +100,7 @@ GPUDrawScanline::GPUSetupPrimMap::GPUSetupPrimMap(GPUScanlineEnvironment& env)
{
}
GPUSetupPrimCodeGenerator* GPUDrawScanline::GPUSetupPrimMap::Create(DWORD key, void* ptr, size_t maxsize)
GPUSetupPrimCodeGenerator* GPUDrawScanline::GPUSetupPrimMap::Create(uint32 key, void* ptr, size_t maxsize)
{
return new GPUSetupPrimCodeGenerator(m_env, ptr, maxsize);
}
@ -113,7 +113,7 @@ GPUDrawScanline::GPUDrawScanlineMap::GPUDrawScanlineMap(GPUScanlineEnvironment&
{
}
GPUDrawScanlineCodeGenerator* GPUDrawScanline::GPUDrawScanlineMap::Create(DWORD key, void* ptr, size_t maxsize)
GPUDrawScanlineCodeGenerator* GPUDrawScanline::GPUDrawScanlineMap::Create(uint32 key, void* ptr, size_t maxsize)
{
return new GPUDrawScanlineCodeGenerator(m_env, ptr, maxsize);
}

View File

@ -34,24 +34,24 @@ class GPUDrawScanline : public GSAlignedClass<16>, public IDrawScanline
//
class GPUSetupPrimMap : public GSCodeGeneratorFunctionMap<GPUSetupPrimCodeGenerator, DWORD, SetupPrimStaticPtr>
class GPUSetupPrimMap : public GSCodeGeneratorFunctionMap<GPUSetupPrimCodeGenerator, uint32, SetupPrimStaticPtr>
{
GPUScanlineEnvironment& m_env;
public:
GPUSetupPrimMap(GPUScanlineEnvironment& env);
GPUSetupPrimCodeGenerator* Create(DWORD key, void* ptr, size_t maxsize);
GPUSetupPrimCodeGenerator* Create(uint32 key, void* ptr, size_t maxsize);
} m_sp;
//
class GPUDrawScanlineMap : public GSCodeGeneratorFunctionMap<GPUDrawScanlineCodeGenerator, DWORD, DrawScanlineStaticPtr>
class GPUDrawScanlineMap : public GSCodeGeneratorFunctionMap<GPUDrawScanlineCodeGenerator, uint32, DrawScanlineStaticPtr>
{
GPUScanlineEnvironment& m_env;
public:
GPUDrawScanlineMap(GPUScanlineEnvironment& env);
GPUDrawScanlineCodeGenerator* Create(DWORD key, void* ptr, size_t maxsize);
GPUDrawScanlineCodeGenerator* Create(uint32 key, void* ptr, size_t maxsize);
} m_ds;
protected:

View File

@ -119,7 +119,7 @@ void GPUDrawScanlineCodeGenerator::Init(int params)
mov(eax, dword[esp + _top]);
// WORD* fb = &m_env.vm[(top << (10 + m_env.sel.scalex)) + left];
// uint16* fb = &m_env.vm[(top << (10 + m_env.sel.scalex)) + left];
mov(edi, eax);
shl(edi, 10 + m_env.sel.scalex);
@ -222,7 +222,7 @@ void GPUDrawScanlineCodeGenerator::Step()
// fb += 8;
add(edi, 8 * sizeof(WORD));
add(edi, 8 * sizeof(uint16));
if(m_env.sel.tme)
{
@ -1020,7 +1020,7 @@ const GSVector4i GPUDrawScanlineCodeGenerator::m_test[8] =
GSVector4i::zero(),
};
__declspec(align(16)) const WORD GPUDrawScanlineCodeGenerator::m_dither[4][16] =
__declspec(align(16)) const uint16 GPUDrawScanlineCodeGenerator::m_dither[4][16] =
{
{7, 0, 6, 1, 7, 0, 6, 1, 7, 0, 6, 1, 7, 0, 6, 1},
{2, 5, 3, 4, 2, 5, 3, 4, 2, 5, 3, 4, 2, 5, 3, 4},

View File

@ -32,7 +32,7 @@ class GPUDrawScanlineCodeGenerator : public CodeGenerator
void operator = (const GPUDrawScanlineCodeGenerator&);
static const GSVector4i m_test[8];
static const WORD m_dither[4][16];
static const uint16 m_dither[4][16];
util::Cpu m_cpu;

View File

@ -55,21 +55,19 @@ public:
DVRANGE.Y2 = 256;
}
CRect GetDisplayRect()
GSVector4i GetDisplayRect()
{
static int s_width[] = {256, 320, 512, 640, 368, 384, 512, 640};
static int s_height[] = {240, 480};
CRect r;
GSVector4i r;
r.left = DAREA.X & ~7; // FIXME
r.top = DAREA.Y;
r.right = r.left + s_width[(STATUS.WIDTH1 << 2) | STATUS.WIDTH0];
r.bottom = r.top + (DVRANGE.Y2 - DVRANGE.Y1) * s_height[STATUS.HEIGHT] / 240;
r &= CRect(0, 0, 1024, 512);
return r;
return r.rintersect(GSVector4i(0, 0, 1024, 512));
}
int GetFPS()

View File

@ -27,16 +27,16 @@ const GSVector4i GPULocalMemory::m_xxbx(0x00007c00);
const GSVector4i GPULocalMemory::m_xgxx(0x000003e0);
const GSVector4i GPULocalMemory::m_rxxx(0x0000001f);
GPULocalMemory::GPULocalMemory(const CSize& scale)
GPULocalMemory::GPULocalMemory(const GSVector2i& scale)
{
m_scale.cx = min(max(scale.cx, 0), 2);
m_scale.cy = min(max(scale.cy, 0), 2);
m_scale.x = min(max(scale.x, 0), 2);
m_scale.y = min(max(scale.y, 0), 2);
//
int size = (1 << (12 + 11)) * sizeof(WORD);
int size = (1 << (12 + 11)) * sizeof(uint16);
m_vm = (WORD*)VirtualAlloc(NULL, size * 2, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
m_vm = (uint16*)VirtualAlloc(NULL, size * 2, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
memset(m_vm, 0, size);
@ -49,7 +49,7 @@ GPULocalMemory::GPULocalMemory(const CSize& scale)
size = 256 * 256 * (1 + 1 + 4) * 32;
m_texture.buff[0] = (BYTE*)VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
m_texture.buff[0] = (uint8*)VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
m_texture.buff[1] = m_texture.buff[0] + 256 * 256 * 32;
m_texture.buff[2] = m_texture.buff[1] + 256 * 256 * 32;
@ -61,8 +61,8 @@ GPULocalMemory::GPULocalMemory(const CSize& scale)
{
for(int x = 0; x < 16; x++, offset += 256 * 256)
{
m_texture.page[0][y][x] = &((BYTE*)m_texture.buff[0])[offset];
m_texture.page[1][y][x] = &((BYTE*)m_texture.buff[1])[offset];
m_texture.page[0][y][x] = &((uint8*)m_texture.buff[0])[offset];
m_texture.page[1][y][x] = &((uint8*)m_texture.buff[1])[offset];
}
}
@ -70,7 +70,7 @@ GPULocalMemory::GPULocalMemory(const CSize& scale)
{
for(int x = 0; x < 16; x++, offset += 256 * 256)
{
m_texture.page[2][y][x] = &((DWORD*)m_texture.buff[2])[offset];
m_texture.page[2][y][x] = &((uint32*)m_texture.buff[2])[offset];
}
}
}
@ -82,18 +82,18 @@ GPULocalMemory::~GPULocalMemory()
VirtualFree(m_texture.buff[0], 0, MEM_RELEASE);
}
const WORD* GPULocalMemory::GetCLUT(int tp, int cx, int cy)
const uint16* GPULocalMemory::GetCLUT(int tp, int cx, int cy)
{
if(m_clut.dirty || m_clut.tp != tp || m_clut.cx != cx || m_clut.cy != cy)
{
WORD* src = GetPixelAddressScaled(cx << 4, cy);
WORD* dst = m_clut.buff;
uint16* src = GetPixelAddressScaled(cx << 4, cy);
uint16* dst = m_clut.buff;
if(m_scale.cx == 0)
if(m_scale.x == 0)
{
memcpy(dst, src, (tp == 0 ? 16 : 256) * 2);
}
else if(m_scale.cx == 1)
else if(m_scale.x == 1)
{
if(tp == 0)
{
@ -110,7 +110,7 @@ const WORD* GPULocalMemory::GetCLUT(int tp, int cx, int cy)
}
}
}
else if(m_scale.cx == 2)
else if(m_scale.x == 2)
{
if(tp == 0)
{
@ -152,7 +152,7 @@ const void* GPULocalMemory::GetTexture(int tp, int tx, int ty)
void* buff = m_texture.page[tp][ty][tx];
UINT32 flag = 1 << tx;
uint32 flag = 1 << tx;
if((m_texture.valid[tp][ty] & flag) == 0)
{
@ -161,16 +161,16 @@ const void* GPULocalMemory::GetTexture(int tp, int tx, int ty)
switch(tp)
{
case 0:
ReadPage4(tx, ty, (BYTE*)buff);
ReadPage4(tx, ty, (uint8*)buff);
bpp = 4;
break;
case 1:
ReadPage8(tx, ty, (BYTE*)buff);
ReadPage8(tx, ty, (uint8*)buff);
bpp = 8;
break;
case 2:
case 3:
ReadPage16(tx, ty, (WORD*)buff);
ReadPage16(tx, ty, (uint16*)buff);
bpp = 16;
default:
// FIXME: __assume(0); // vc9 generates bogus code in release mode
@ -185,7 +185,7 @@ const void* GPULocalMemory::GetTexture(int tp, int tx, int ty)
return buff;
}
void GPULocalMemory::Invalidate(const CRect& r)
void GPULocalMemory::Invalidate(const GSVector4i& r)
{
if(!m_clut.dirty)
{
@ -207,7 +207,7 @@ void GPULocalMemory::Invalidate(const CRect& r)
for(int x = 0, xe = min(r.right, 1024), i = 0; x < xe; x += 64, i++)
{
DWORD flag = 1 << i;
uint32 flag = 1 << i;
if(r.left >= x + 256) continue;
@ -224,14 +224,14 @@ void GPULocalMemory::Invalidate(const CRect& r)
}
}
void GPULocalMemory::FillRect(const CRect& r, WORD c)
void GPULocalMemory::FillRect(const GSVector4i& r, uint16 c)
{
Invalidate(r);
WORD* RESTRICT dst = GetPixelAddressScaled(r.left, r.top);
uint16* RESTRICT dst = GetPixelAddressScaled(r.left, r.top);
int w = r.Width() << m_scale.cx;
int h = r.Height() << m_scale.cy;
int w = r.width() << m_scale.x;
int h = r.height() << m_scale.y;
int pitch = GetWidth();
@ -244,32 +244,32 @@ void GPULocalMemory::FillRect(const CRect& r, WORD c)
}
}
void GPULocalMemory::WriteRect(const CRect& r, const WORD* RESTRICT src)
void GPULocalMemory::WriteRect(const GSVector4i& r, const uint16* RESTRICT src)
{
Invalidate(r);
WORD* RESTRICT dst = GetPixelAddressScaled(r.left, r.top);
uint16* RESTRICT dst = GetPixelAddressScaled(r.left, r.top);
int w = r.Width();
int h = r.Height();
int w = r.width();
int h = r.height();
int pitch = GetWidth();
if(m_scale.cx == 0)
if(m_scale.x == 0)
{
for(int j = 0; j < h; j++, src += w)
{
for(int k = 1 << m_scale.cy; k >= 1; k--, dst += pitch)
for(int k = 1 << m_scale.y; k >= 1; k--, dst += pitch)
{
memcpy(dst, src, w * 2);
}
}
}
else if(m_scale.cx == 1)
else if(m_scale.x == 1)
{
for(int j = 0; j < h; j++, src += w)
{
for(int k = 1 << m_scale.cy; k >= 1; k--, dst += pitch)
for(int k = 1 << m_scale.y; k >= 1; k--, dst += pitch)
{
for(int i = 0; i < w; i++)
{
@ -279,11 +279,11 @@ void GPULocalMemory::WriteRect(const CRect& r, const WORD* RESTRICT src)
}
}
}
else if(m_scale.cx == 2)
else if(m_scale.x == 2)
{
for(int j = 0; j < h; j++, src += w)
{
for(int k = 1 << m_scale.cy; k >= 1; k--, dst += pitch)
for(int k = 1 << m_scale.y; k >= 1; k--, dst += pitch)
{
for(int i = 0; i < w; i++)
{
@ -301,23 +301,23 @@ void GPULocalMemory::WriteRect(const CRect& r, const WORD* RESTRICT src)
}
}
void GPULocalMemory::ReadRect(const CRect& r, WORD* RESTRICT dst)
void GPULocalMemory::ReadRect(const GSVector4i& r, uint16* RESTRICT dst)
{
WORD* RESTRICT src = GetPixelAddressScaled(r.left, r.top);
uint16* RESTRICT src = GetPixelAddressScaled(r.left, r.top);
int w = r.Width();
int h = r.Height();
int w = r.width();
int h = r.height();
int pitch = GetWidth() << m_scale.cy;
int pitch = GetWidth() << m_scale.y;
if(m_scale.cx == 0)
if(m_scale.x == 0)
{
for(int j = 0; j < h; j++, src += pitch, dst += w)
{
memcpy(dst, src, w * 2);
}
}
else if(m_scale.cx == 1)
else if(m_scale.x == 1)
{
for(int j = 0; j < h; j++, src += pitch, dst += w)
{
@ -327,7 +327,7 @@ void GPULocalMemory::ReadRect(const CRect& r, WORD* RESTRICT dst)
}
}
}
else if(m_scale.cx == 2)
else if(m_scale.x == 2)
{
for(int j = 0; j < h; j++, src += pitch, dst += w)
{
@ -343,31 +343,31 @@ void GPULocalMemory::ReadRect(const CRect& r, WORD* RESTRICT dst)
}
}
void GPULocalMemory::MoveRect(const CPoint& src, const CPoint& dst, int w, int h)
void GPULocalMemory::MoveRect(int sx, int sy, int dx, int dy, int w, int h)
{
Invalidate(CRect(dst, CSize(w, h)));
Invalidate(GSVector4i(dx, dy, dx + w, dy + h));
WORD* s = GetPixelAddressScaled(src.x, src.y);
WORD* d = GetPixelAddressScaled(dst.x, dst.y);
uint16* s = GetPixelAddressScaled(sx, sy);
uint16* d = GetPixelAddressScaled(dx, dy);
w <<= m_scale.cx;
h <<= m_scale.cy;
w <<= m_scale.x;
h <<= m_scale.y;
int pitch = GetWidth();
for(int i = 0; i < h; i++, s += pitch, d += pitch)
{
memcpy(d, s, w * sizeof(WORD));
memcpy(d, s, w * sizeof(uint16));
}
}
void GPULocalMemory::ReadPage4(int tx, int ty, BYTE* RESTRICT dst)
void GPULocalMemory::ReadPage4(int tx, int ty, uint8* RESTRICT dst)
{
WORD* src = GetPixelAddressScaled(tx << 6, ty << 8);
uint16* src = GetPixelAddressScaled(tx << 6, ty << 8);
int pitch = GetWidth() << m_scale.cy;
int pitch = GetWidth() << m_scale.y;
if(m_scale.cx == 0)
if(m_scale.x == 0)
{
for(int j = 0; j < 256; j++, src += pitch, dst += 256)
{
@ -380,7 +380,7 @@ void GPULocalMemory::ReadPage4(int tx, int ty, BYTE* RESTRICT dst)
}
}
}
else if(m_scale.cx == 1)
else if(m_scale.x == 1)
{
for(int j = 0; j < 256; j++, src += pitch, dst += 256)
{
@ -393,7 +393,7 @@ void GPULocalMemory::ReadPage4(int tx, int ty, BYTE* RESTRICT dst)
}
}
}
else if(m_scale.cx == 2)
else if(m_scale.x == 2)
{
for(int j = 0; j < 256; j++, src += pitch, dst += 256)
{
@ -412,36 +412,36 @@ void GPULocalMemory::ReadPage4(int tx, int ty, BYTE* RESTRICT dst)
}
}
void GPULocalMemory::ReadPage8(int tx, int ty, BYTE* RESTRICT dst)
void GPULocalMemory::ReadPage8(int tx, int ty, uint8* RESTRICT dst)
{
WORD* src = GetPixelAddressScaled(tx << 6, ty << 8);
uint16* src = GetPixelAddressScaled(tx << 6, ty << 8);
int pitch = GetWidth() << m_scale.cy;
int pitch = GetWidth() << m_scale.y;
if(m_scale.cx == 0)
if(m_scale.x == 0)
{
for(int j = 0; j < 256; j++, src += pitch, dst += 256)
{
memcpy(dst, src, 256);
}
}
else if(m_scale.cx == 1)
else if(m_scale.x == 1)
{
for(int j = 0; j < 256; j++, src += pitch, dst += 256)
{
for(int i = 0; i < 128; i++)
{
((WORD*)dst)[i] = src[i * 2];
((uint16*)dst)[i] = src[i * 2];
}
}
}
else if(m_scale.cx == 2)
else if(m_scale.x == 2)
{
for(int j = 0; j < 256; j++, src += pitch, dst += 256)
{
for(int i = 0; i < 128; i++)
{
((WORD*)dst)[i] = src[i * 4];
((uint16*)dst)[i] = src[i * 4];
}
}
}
@ -451,20 +451,20 @@ void GPULocalMemory::ReadPage8(int tx, int ty, BYTE* RESTRICT dst)
}
}
void GPULocalMemory::ReadPage16(int tx, int ty, WORD* RESTRICT dst)
void GPULocalMemory::ReadPage16(int tx, int ty, uint16* RESTRICT dst)
{
WORD* src = GetPixelAddressScaled(tx << 6, ty << 8);
uint16* src = GetPixelAddressScaled(tx << 6, ty << 8);
int pitch = GetWidth() << m_scale.cy;
int pitch = GetWidth() << m_scale.y;
if(m_scale.cx == 0)
if(m_scale.x == 0)
{
for(int j = 0; j < 256; j++, src += pitch, dst += 256)
{
memcpy(dst, src, 512);
}
}
else if(m_scale.cx == 1)
else if(m_scale.x == 1)
{
for(int j = 0; j < 256; j++, src += pitch, dst += 256)
{
@ -474,7 +474,7 @@ void GPULocalMemory::ReadPage16(int tx, int ty, WORD* RESTRICT dst)
}
}
}
else if(m_scale.cx == 2)
else if(m_scale.x == 2)
{
for(int j = 0; j < 256; j++, src += pitch, dst += 256)
{
@ -490,9 +490,9 @@ void GPULocalMemory::ReadPage16(int tx, int ty, WORD* RESTRICT dst)
}
}
void GPULocalMemory::ReadFrame32(const CRect& r, DWORD* RESTRICT dst, bool rgb24)
void GPULocalMemory::ReadFrame32(const GSVector4i& r, uint32* RESTRICT dst, bool rgb24)
{
WORD* src = GetPixelAddress(r.left, r.top);
uint16* src = GetPixelAddress(r.left, r.top);
int pitch = GetWidth();
@ -500,19 +500,19 @@ void GPULocalMemory::ReadFrame32(const CRect& r, DWORD* RESTRICT dst, bool rgb24
{
for(int i = r.top; i < r.bottom; i++, src += pitch, dst += pitch)
{
Expand24(src, dst, r.Width());
Expand24(src, dst, r.width());
}
}
else
{
for(int i = r.top; i < r.bottom; i++, src += pitch, dst += pitch)
{
Expand16(src, dst, r.Width());
Expand16(src, dst, r.width());
}
}
}
void GPULocalMemory::Expand16(const WORD* RESTRICT src, DWORD* RESTRICT dst, int pixels)
void GPULocalMemory::Expand16(const uint16* RESTRICT src, uint32* RESTRICT dst, int pixels)
{
GSVector4i rm = m_rxxx;
GSVector4i gm = m_xgxx;
@ -534,11 +534,11 @@ void GPULocalMemory::Expand16(const WORD* RESTRICT src, DWORD* RESTRICT dst, int
}
}
void GPULocalMemory::Expand24(const WORD* RESTRICT src, DWORD* RESTRICT dst, int pixels)
void GPULocalMemory::Expand24(const uint16* RESTRICT src, uint32* RESTRICT dst, int pixels)
{
BYTE* s = (BYTE*)src;
uint8* s = (uint8*)src;
if(m_scale.cx == 0)
if(m_scale.x == 0)
{
for(int i = 0; i < pixels; i += 2, s += 6)
{
@ -546,7 +546,7 @@ void GPULocalMemory::Expand24(const WORD* RESTRICT src, DWORD* RESTRICT dst, int
dst[i + 1] = (s[5] << 16) | (s[4] << 8) | s[3];
}
}
else if(m_scale.cx == 1)
else if(m_scale.x == 1)
{
for(int i = 0; i < pixels; i += 4, s += 12)
{
@ -554,7 +554,7 @@ void GPULocalMemory::Expand24(const WORD* RESTRICT src, DWORD* RESTRICT dst, int
dst[i + 2] = dst[i + 3] = (s[9] << 16) | (s[8] << 8) | s[5];
}
}
else if(m_scale.cx == 2)
else if(m_scale.x == 2)
{
for(int i = 0; i < pixels; i += 8, s += 24)
{
@ -568,12 +568,14 @@ void GPULocalMemory::Expand24(const WORD* RESTRICT src, DWORD* RESTRICT dst, int
}
}
void GPULocalMemory::SaveBMP(const string& path, CRect r, int tp, int cx, int cy)
void GPULocalMemory::SaveBMP(const string& path, const GSVector4i& r2, int tp, int cx, int cy)
{
r.left <<= m_scale.cx;
r.top <<= m_scale.cy;
r.right <<= m_scale.cx;
r.bottom <<= m_scale.cy;
GSVector4i r;
r.left = r2.left << m_scale.x;
r.top = r2.top << m_scale.y;
r.right = r2.right << m_scale.x;
r.bottom = r2.bottom << m_scale.y;
r.left &= ~1;
r.right &= ~1;
@ -583,8 +585,8 @@ void GPULocalMemory::SaveBMP(const string& path, CRect r, int tp, int cx, int cy
BITMAPINFOHEADER bih;
memset(&bih, 0, sizeof(bih));
bih.biSize = sizeof(bih);
bih.biWidth = r.Width();
bih.biHeight = r.Height();
bih.biWidth = r.width();
bih.biHeight = r.height();
bih.biPlanes = 1;
bih.biBitCount = 32;
bih.biCompression = BI_RGB;
@ -602,10 +604,10 @@ void GPULocalMemory::SaveBMP(const string& path, CRect r, int tp, int cx, int cy
int pitch = GetWidth();
WORD* buff = (WORD*)_aligned_malloc(pitch * sizeof(WORD), 16);
DWORD* buff32 = (DWORD*)_aligned_malloc(pitch * sizeof(DWORD), 16);
WORD* src = GetPixelAddress(r.left, r.bottom - 1);
const WORD* clut = GetCLUT(tp, cx, cy);
uint16* buff = (uint16*)_aligned_malloc(pitch * sizeof(WORD), 16);
uint32* buff32 = (uint32*)_aligned_malloc(pitch * sizeof(uint32), 16);
uint16* src = GetPixelAddress(r.left, r.bottom - 1);
const uint16* clut = GetCLUT(tp, cx, cy);
for(int j = r.bottom - 1; j >= r.top; j--, src -= pitch)
{
@ -613,26 +615,26 @@ void GPULocalMemory::SaveBMP(const string& path, CRect r, int tp, int cx, int cy
{
case 0: // 4 bpp
for(int i = 0, k = r.Width() / 2; i < k; i++)
for(int i = 0, k = r.width() / 2; i < k; i++)
{
buff[i * 2 + 0] = clut[((BYTE*)src)[i] & 0xf];
buff[i * 2 + 1] = clut[((BYTE*)src)[i] >> 4];
buff[i * 2 + 0] = clut[((uint8*)src)[i] & 0xf];
buff[i * 2 + 1] = clut[((uint8*)src)[i] >> 4];
}
break;
case 1: // 8 bpp
for(int i = 0, k = r.Width(); i < k; i++)
for(int i = 0, k = r.width(); i < k; i++)
{
buff[i] = clut[((BYTE*)src)[i]];
buff[i] = clut[((uint8*)src)[i]];
}
break;
case 2: // 16 bpp;
for(int i = 0, k = r.Width(); i < k; i++)
for(int i = 0, k = r.width(); i < k; i++)
{
buff[i] = src[i];
}
@ -646,14 +648,14 @@ void GPULocalMemory::SaveBMP(const string& path, CRect r, int tp, int cx, int cy
break;
}
Expand16(buff, buff32, r.Width());
Expand16(buff, buff32, r.width());
for(int i = 0, k = r.Width(); i < k; i++)
for(int i = 0, k = r.width(); i < k; i++)
{
buff32[i] = (buff32[i] & 0xff00ff00) | ((buff32[i] & 0x00ff0000) >> 16) | ((buff32[i] & 0x000000ff) << 16);
}
fwrite(buff32, 1, r.Width() * 4, fp);
fwrite(buff32, 1, r.width() * 4, fp);
}
_aligned_free(buff);

View File

@ -31,55 +31,56 @@ class GPULocalMemory
static const GSVector4i m_xgxx;
static const GSVector4i m_rxxx;
WORD* m_vm;
uint16* m_vm;
struct
{
WORD* buff;
uint16* buff;
int tp, cx, cy;
bool dirty;
} m_clut;
struct
{
BYTE* buff[3];
uint8* buff[3];
void* page[3][2][16];
WORD valid[3][2];
uint16 valid[3][2];
} m_texture;
CSize m_scale;
GSVector2i m_scale;
public:
GPULocalMemory(const CSize& scale);
GPULocalMemory(const GSVector2i& scale);
virtual ~GPULocalMemory();
CSize GetScale() {return m_scale;}
int GetWidth() {return 1 << (10 + m_scale.cx);}
int GetHeight() {return 1 << (9 + m_scale.cy);}
GSVector2i GetScale() {return m_scale;}
WORD* GetPixelAddress(int x, int y) const {return &m_vm[(y << (10 + m_scale.cx)) + x];}
WORD* GetPixelAddressScaled(int x, int y) const {return &m_vm[((y << m_scale.cy) << (10 + m_scale.cx)) + (x << m_scale.cx)];}
int GetWidth() {return 1 << (10 + m_scale.x);}
int GetHeight() {return 1 << (9 + m_scale.y);}
const WORD* GetCLUT(int tp, int cx, int cy);
uint16* GetPixelAddress(int x, int y) const {return &m_vm[(y << (10 + m_scale.x)) + x];}
uint16* GetPixelAddressScaled(int x, int y) const {return &m_vm[((y << m_scale.y) << (10 + m_scale.x)) + (x << m_scale.x)];}
const uint16* GetCLUT(int tp, int cx, int cy);
const void* GetTexture(int tp, int tx, int ty);
void Invalidate(const CRect& r);
void Invalidate(const GSVector4i& r);
void FillRect(const CRect& r, WORD c);
void WriteRect(const CRect& r, const WORD* RESTRICT src);
void ReadRect(const CRect& r, WORD* RESTRICT dst);
void MoveRect(const CPoint& src, const CPoint& dst, int w, int h);
void FillRect(const GSVector4i& r, uint16 c);
void WriteRect(const GSVector4i& r, const uint16* RESTRICT src);
void ReadRect(const GSVector4i& r, uint16* RESTRICT dst);
void MoveRect(int sx, int sy, int dx, int dy, int w, int h);
void ReadPage4(int tx, int ty, BYTE* RESTRICT dst);
void ReadPage8(int tx, int ty, BYTE* RESTRICT dst);
void ReadPage16(int tx, int ty, WORD* RESTRICT dst);
void ReadPage4(int tx, int ty, uint8* RESTRICT dst);
void ReadPage8(int tx, int ty, uint8* RESTRICT dst);
void ReadPage16(int tx, int ty, uint16* RESTRICT dst);
void ReadFrame32(const CRect& r, DWORD* RESTRICT dst, bool rgb24);
void ReadFrame32(const GSVector4i& r, uint32* RESTRICT dst, bool rgb24);
void Expand16(const WORD* RESTRICT src, DWORD* RESTRICT dst, int pixels);
void Expand24(const WORD* RESTRICT src, DWORD* RESTRICT dst, int pixels);
void Expand16(const uint16* RESTRICT src, uint32* RESTRICT dst, int pixels);
void Expand24(const uint16* RESTRICT src, uint32* RESTRICT dst, int pixels);
void SaveBMP(const string& path, CRect r, int tp, int cx, int cy);
void SaveBMP(const string& path, const GSVector4i& r, int tp, int cx, int cy);
};
#pragma warning(default: 4244)

View File

@ -30,7 +30,7 @@ struct GPURendererSettings
int m_dither;
int m_aspectratio;
bool m_vsync;
CSize m_scale;
GSVector2i m_scale;
};
class GPURendererBase : public GPUState, protected GPURendererSettings
@ -142,7 +142,7 @@ protected:
void VertexKick()
{
if(m_vl.GetCount() < m_env.PRIM.VTX)
if(m_vl.GetCount() < (int)m_env.PRIM.VTX)
{
return;
}
@ -214,7 +214,7 @@ protected:
if(m_env.PRIM.TME)
{
CRect r;
GSVector4i r;
r.left = m_env.STATUS.TX << 6;
r.top = m_env.STATUS.TY << 8;
@ -246,11 +246,8 @@ protected:
return false;
}
CSize s;
GSVector2i s = st[0].GetSize();
s.cx = st[0].GetWidth();
s.cy = st[0].GetHeight();
GSVector4 sr[2];
sr[0].x = 0;
@ -262,8 +259,8 @@ protected:
dr[0].x = 0;
dr[0].y = 0;
dr[0].z = (float)s.cx;
dr[0].w = (float)s.cy;
dr[0].z = (float)s.x;
dr[0].w = (float)s.y;
GSVector4 c(0, 0, 0, 1);
@ -345,10 +342,10 @@ public:
double fps = 1000.0f / m_perfmon.Get(GSPerfMon::Frame);
CRect r = m_env.GetDisplayRect();
GSVector4i r = m_env.GetDisplayRect();
int w = r.Width() << m_scale.cx;
int h = r.Height() << m_scale.cy;
int w = r.width() << m_scale.x;
int h = r.height() << m_scale.y;
s_stats = format(
"%I64d | %d x %d | %.2f fps (%d%%) | %d/%d | %d%% CPU | %.2f | %.2f",
@ -375,13 +372,11 @@ public:
ResetDevice();
}
CRect r;
GSVector4i r;
GetClientRect(m_hWnd, &r);
GetClientRect(m_hWnd, r);
GSUtil::FitRect(r, m_aspectratio);
m_dev.Present(r);
m_dev.Present(r.fit(m_aspectratio));
}
virtual bool MakeSnapshot(const string& path)

View File

@ -38,31 +38,32 @@ protected:
bool GetOutput(Texture& t)
{
CRect r = m_env.GetDisplayRect();
GSVector4i r = m_env.GetDisplayRect();
r.left <<= m_scale.cx;
r.top <<= m_scale.cy;
r.right <<= m_scale.cx;
r.bottom <<= m_scale.cy;
r.left <<= m_scale.x;
r.top <<= m_scale.y;
r.right <<= m_scale.x;
r.bottom <<= m_scale.y;
// TODO
static DWORD* buff = (DWORD*)_aligned_malloc(m_mem.GetWidth() * m_mem.GetHeight() * sizeof(DWORD), 16);
static uint32* buff = (uint32*)_aligned_malloc(m_mem.GetWidth() * m_mem.GetHeight() * sizeof(uint32), 16);
m_mem.ReadFrame32(r, buff, !!m_env.STATUS.ISRGB24);
r.OffsetRect(-r.TopLeft());
int w = r.width();
int h = r.height();
if(m_texture.GetWidth() != r.Width() || m_texture.GetHeight() != r.Height())
if(m_texture.GetWidth() != w || m_texture.GetHeight() != h)
{
m_texture = Texture();
}
if(!m_texture && !m_dev.CreateTexture(m_texture, r.Width(), r.Height()))
if(!m_texture && !m_dev.CreateTexture(m_texture, w, h))
{
return false;
}
m_texture.Update(r, buff, m_mem.GetWidth() * sizeof(DWORD));
m_texture.Update(GSVector4i(0, 0, w, h), buff, m_mem.GetWidth() * sizeof(uint32));
t = m_texture;
@ -75,8 +76,8 @@ protected:
// TODO: x/y + off.x/y should wrap around at +/-1024
int x = (int)(m_v.XY.X + m_env.DROFF.X) << m_scale.cx;
int y = (int)(m_v.XY.Y + m_env.DROFF.Y) << m_scale.cy;
int x = (int)(m_v.XY.X + m_env.DROFF.X) << m_scale.x;
int y = (int)(m_v.XY.Y + m_env.DROFF.Y) << m_scale.y;
int s = m_v.UV.X;
int t = m_v.UV.Y;
@ -85,7 +86,7 @@ protected:
v.p = pt.xyxy(GSVector4::zero());
v.t = (pt.zwzw(GSVector4::zero()) + GSVector4(0.125f)) * 256.0f;
v.c = GSVector4((DWORD)m_v.RGB.ai32) * 128.0f;
v.c = GSVector4(m_v.RGB.u32) * 128.0f;
__super::VertexKick();
}
@ -107,14 +108,14 @@ protected:
GSVector4i GetScissor()
{
GSVector4i v;
GSVector4i r;
v.x = (int)m_env.DRAREATL.X << m_scale.cx;
v.y = (int)m_env.DRAREATL.Y << m_scale.cy;
v.z = min((int)(m_env.DRAREABR.X + 1) << m_scale.cx, m_mem.GetWidth());
v.w = min((int)(m_env.DRAREABR.Y + 1) << m_scale.cy, m_mem.GetHeight());
r.left = (int)m_env.DRAREATL.X << m_scale.x;
r.top = (int)m_env.DRAREATL.Y << m_scale.y;
r.right = min((int)(m_env.DRAREABR.X + 1) << m_scale.x, m_mem.GetWidth());
r.bottom = min((int)(m_env.DRAREABR.Y + 1) << m_scale.y, m_mem.GetHeight());
return v;
return r;
}
void Draw()
@ -141,7 +142,7 @@ protected:
{
p.sel.tme = env.PRIM.TME;
p.sel.tlu = env.STATUS.TP < 2;
p.sel.twin = (env.TWIN.ai32 & 0xfffff) != 0;
p.sel.twin = (env.TWIN.u32 & 0xfffff) != 0;
p.sel.ltf = m_filter == 1 && env.PRIM.TYPE == GPU_POLYGON || m_filter == 2 ? 1 : 0;
const void* t = m_mem.GetTexture(env.STATUS.TP, env.STATUS.TX, env.STATUS.TY);
@ -155,7 +156,7 @@ protected:
p.sel.dtd = m_dither ? env.STATUS.DTD : 0;
p.sel.md = env.STATUS.MD;
p.sel.sprite = env.PRIM.TYPE == GPU_SPRITE;
p.sel.scalex = m_mem.GetScale().cx;
p.sel.scalex = m_mem.GetScale().x;
//
@ -198,14 +199,12 @@ protected:
br = br.maxv(p);
}
GSVector4i scissor = data.scissor;
GSVector4i r = GSVector4i(tl.xyxy(br)).rintersect(data.scissor);
CRect r;
r.left = max(scissor.x, min(scissor.z, (int)tl.x)) >> m_scale.cx;
r.top = max(scissor.y, min(scissor.w, (int)tl.y)) >> m_scale.cy;
r.right = max(scissor.x, min(scissor.z, (int)br.x)) >> m_scale.cx;
r.bottom = max(scissor.y, min(scissor.w, (int)br.y)) >> m_scale.cy;
r.left >>= m_scale.x;
r.top >>= m_scale.y;
r.right >>= m_scale.x;
r.bottom >>= m_scale.y;
Invalidate(r);
}

View File

@ -28,32 +28,32 @@ union GPUScanlineSelector
{
struct
{
DWORD iip:1; // 0
DWORD me:1; // 1
DWORD abe:1; // 2
DWORD abr:2; // 3
DWORD tge:1; // 5
DWORD tme:1; // 6
DWORD twin:1; // 7
DWORD tlu:1; // 8
DWORD dtd:1; // 9
DWORD ltf:1; // 10
DWORD md:1; // 11
DWORD sprite:1; // 12
DWORD scalex:2; // 13
uint32 iip:1; // 0
uint32 me:1; // 1
uint32 abe:1; // 2
uint32 abr:2; // 3
uint32 tge:1; // 5
uint32 tme:1; // 6
uint32 twin:1; // 7
uint32 tlu:1; // 8
uint32 dtd:1; // 9
uint32 ltf:1; // 10
uint32 md:1; // 11
uint32 sprite:1; // 12
uint32 scalex:2; // 13
};
struct
{
DWORD _pad1:1; // 0
DWORD rfb:2; // 1
DWORD _pad2:2; // 3
DWORD tfx:2; // 5
uint32 _pad1:1; // 0
uint32 rfb:2; // 1
uint32 _pad2:2; // 3
uint32 tfx:2; // 5
};
DWORD key;
uint32 key;
operator DWORD() {return key;}
operator uint32() {return key;}
};
__declspec(align(16)) struct GPUScanlineParam
@ -61,17 +61,16 @@ __declspec(align(16)) struct GPUScanlineParam
GPUScanlineSelector sel;
const void* tex;
const WORD* clut;
const uint16* clut;
};
__declspec(align(16)) struct GPUScanlineEnvironment
{
GPUScanlineSelector sel;
// GPULocalMemory* mem; // TODO: obsolite
void* vm;
const void* tex;
const WORD* clut;
const uint16* clut;
// GSVector4i md; // similar to gs fba

View File

@ -154,13 +154,13 @@ BOOL GPUSettingsDlg::OnInitDialog()
if(CComPtr<IDirect3D9> d3d = Direct3DCreate9(D3D_SDK_VERSION))
{
UINT ModeWidth = pApp->GetProfileInt(_T("Settings"), _T("ModeWidth"), 0);
UINT ModeHeight = pApp->GetProfileInt(_T("Settings"), _T("ModeHeight"), 0);
UINT ModeRefreshRate = pApp->GetProfileInt(_T("Settings"), _T("ModeRefreshRate"), 0);
uint32 ModeWidth = pApp->GetProfileInt(_T("Settings"), _T("ModeWidth"), 0);
uint32 ModeHeight = pApp->GetProfileInt(_T("Settings"), _T("ModeHeight"), 0);
uint32 ModeRefreshRate = pApp->GetProfileInt(_T("Settings"), _T("ModeRefreshRate"), 0);
UINT nModes = d3d->GetAdapterModeCount(D3DADAPTER_DEFAULT, D3DFMT_X8R8G8B8);
uint32 nModes = d3d->GetAdapterModeCount(D3DADAPTER_DEFAULT, D3DFMT_X8R8G8B8);
for(UINT i = 0; i < nModes; i++)
for(uint32 i = 0; i < nModes; i++)
{
D3DDISPLAYMODE mode;

View File

@ -22,7 +22,7 @@
#include "stdafx.h"
#include "GPUState.h"
GPUState::GPUState(const CSize& scale)
GPUState::GPUState(const GSVector2i& scale)
: m_mem(scale)
, s_n(0)
{
@ -64,7 +64,7 @@ void GPUState::Reset()
{
m_env.Reset();
m_mem.Invalidate(CRect(0, 0, 1024, 512));
m_mem.Invalidate(GSVector4i(0, 0, 1024, 512));
memset(&m_v, 0, sizeof(m_v));
}
@ -88,18 +88,18 @@ void GPUState::SetPrim(GPUReg* r)
switch(r->PRIM.TYPE)
{
case GPU_POLYGON:
PRIM.ai32 = (r->PRIM.ai32 & 0xF7000000) | 3; // TYPE IIP TME ABE TGE
PRIM.u32 = (r->PRIM.u32 & 0xF7000000) | 3; // TYPE IIP TME ABE TGE
break;
case GPU_LINE:
PRIM.ai32 = (r->PRIM.ai32 & 0xF2000000) | 2; // TYPE IIP ABE
PRIM.u32 = (r->PRIM.u32 & 0xF2000000) | 2; // TYPE IIP ABE
PRIM.TGE = 1; // ?
break;
case GPU_SPRITE:
PRIM.ai32 = (r->PRIM.ai32 & 0xE7000000) | 2; // TYPE TME ABE TGE
PRIM.u32 = (r->PRIM.u32 & 0xE7000000) | 2; // TYPE TME ABE TGE
break;
}
if(m_env.PRIM.ai32 != PRIM.ai32)
if(m_env.PRIM.u32 != PRIM.u32)
{
Flush();
@ -109,38 +109,38 @@ void GPUState::SetPrim(GPUReg* r)
void GPUState::SetCLUT(GPUReg* r)
{
UINT32 mask = 0xFFFF0000; // X Y
uint32 mask = 0xFFFF0000; // X Y
UINT32 value = (m_env.CLUT.ai32 & ~mask) | (r->ai32 & mask);
uint32 value = (m_env.CLUT.u32 & ~mask) | (r->u32 & mask);
if(m_env.CLUT.ai32 != value)
if(m_env.CLUT.u32 != value)
{
Flush();
m_env.CLUT.ai32 = value;
m_env.CLUT.u32 = value;
}
}
void GPUState::SetTPAGE(GPUReg* r)
{
UINT32 mask = 0x000001FF; // TP ABR TY TX
uint32 mask = 0x000001FF; // TP ABR TY TX
UINT32 value = (m_env.STATUS.ai32 & ~mask) | ((r->ai32 >> 16) & mask);
uint32 value = (m_env.STATUS.u32 & ~mask) | ((r->u32 >> 16) & mask);
if(m_env.STATUS.ai32 != value)
if(m_env.STATUS.u32 != value)
{
Flush();
m_env.STATUS.ai32 = value;
m_env.STATUS.u32 = value;
}
}
void GPUState::Invalidate(const CRect& r)
void GPUState::Invalidate(const GSVector4i& r)
{
m_mem.Invalidate(r);
}
void GPUState::WriteData(const BYTE* mem, UINT32 size)
void GPUState::WriteData(const uint8* mem, uint32 size)
{
GSPerfMonAutoTimer pmat(m_perfmon);
@ -164,7 +164,7 @@ void GPUState::WriteData(const BYTE* mem, UINT32 size)
m_write.Remove(i);
}
void GPUState::ReadData(BYTE* mem, UINT32 size)
void GPUState::ReadData(uint8* mem, uint32 size)
{
GSPerfMonAutoTimer pmat(m_perfmon);
@ -193,38 +193,38 @@ void GPUState::ReadData(BYTE* mem, UINT32 size)
}
}
void GPUState::WriteStatus(UINT32 status)
void GPUState::WriteStatus(uint32 status)
{
GSPerfMonAutoTimer pmat(m_perfmon);
UINT32 b = status >> 24;
uint32 b = status >> 24;
m_status[b] = status;
(this->*m_fpGPUStatusCommandHandlers[b])((GPUReg*)&status);
}
UINT32 GPUState::ReadStatus()
uint32 GPUState::ReadStatus()
{
GSPerfMonAutoTimer pmat(m_perfmon);
m_env.STATUS.LCF = ~m_env.STATUS.LCF; // ?
return m_env.STATUS.ai32;
return m_env.STATUS.u32;
}
void GPUState::Freeze(GPUFreezeData* data)
{
data->status = m_env.STATUS.ai32;
data->status = m_env.STATUS.u32;
memcpy(data->control, m_status, 256 * 4);
m_mem.ReadRect(CRect(0, 0, 1024, 512), data->vram);
m_mem.ReadRect(GSVector4i(0, 0, 1024, 512), data->vram);
}
void GPUState::Defrost(const GPUFreezeData* data)
{
m_env.STATUS.ai32 = data->status;
m_env.STATUS.u32 = data->status;
memcpy(m_status, data->control, 256 * 4);
m_mem.WriteRect(CRect(0, 0, 1024, 512), data->vram);
m_mem.WriteRect(GSVector4i(0, 0, 1024, 512), data->vram);
for(int i = 0; i <= 8; i++)
{
@ -289,24 +289,24 @@ void GPUState::SCH_DisplayMode(GPUReg* r)
void GPUState::SCH_GPUInfo(GPUReg* r)
{
UINT32 value = 0;
uint32 value = 0;
switch(r->GPUINFO.PARAM)
{
case 0x2:
value = m_env.TWIN.ai32;
value = m_env.TWIN.u32;
break;
case 0x0:
case 0x1:
case 0x3:
value = m_env.DRAREATL.ai32;
value = m_env.DRAREATL.u32;
break;
case 0x4:
value = m_env.DRAREABR.ai32;
value = m_env.DRAREABR.u32;
break;
case 0x5:
case 0x6:
value = m_env.DROFF.ai32;
value = m_env.DROFF.u32;
break;
case 0x7:
value = 2;
@ -321,7 +321,7 @@ void GPUState::SCH_GPUInfo(GPUReg* r)
}
m_read.RemoveAll();
m_read.Append((BYTE*)&value, 4);
m_read.Append((uint8*)&value, 4);
m_read.cur = 0;
}
@ -343,14 +343,14 @@ int GPUState::PH_Command(GPUReg* r, int size)
Flush();
CRect r2;
GSVector4i r2;
r2.left = r[1].XY.X;
r2.top = r[1].XY.Y;
r2.right = r2.left + r[2].XY.X;
r2.bottom = r2.top + r[2].XY.Y;
WORD c = (WORD)(((r[0].RGB.R >> 3) << 10) | ((r[0].RGB.R >> 3) << 5) | (r[0].RGB.R >> 3));
uint16 c = (uint16)(((r[0].RGB.R >> 3) << 10) | ((r[0].RGB.R >> 3) << 5) | (r[0].RGB.R >> 3));
m_mem.FillRect(r2, c);
@ -439,7 +439,7 @@ int GPUState::PH_Line(GPUReg* r, int size)
for(int i = 1; i < size; i++)
{
if(r[i].ai32 == 0x55555555)
if(r[i].u32 == 0x55555555)
{
vertices = i - 1;
}
@ -553,20 +553,18 @@ int GPUState::PH_Move(GPUReg* r, int size)
Flush();
CPoint src, dst;
int sx = r[1].XY.X;
int sy = r[1].XY.Y;
src.x = r[1].XY.X;
src.y = r[1].XY.Y;
dst.x = r[2].XY.X;
dst.y = r[2].XY.Y;
int dx = r[2].XY.X;
int dy = r[2].XY.Y;
int w = r[3].XY.X;
int h = r[3].XY.Y;
m_mem.MoveRect(src, dst, w, h);
m_mem.MoveRect(sx, sy, dx, dy, w, h);
Invalidate(CRect(dst, CSize(w, h)));
Invalidate(GSVector4i(dx, dy, dx + w, dy + h));
// Dump("m");
@ -586,14 +584,14 @@ int GPUState::PH_Write(GPUReg* r, int size)
Flush();
CRect r2;
GSVector4i r2;
r2.left = r[1].XY.X;
r2.top = r[1].XY.Y;
r2.right = r2.left + w;
r2.bottom = r2.top + h;
m_mem.WriteRect(r2, (const WORD*)&r[3]);
m_mem.WriteRect(r2, (const uint16*)&r[3]);
Invalidate(r2);
@ -613,7 +611,7 @@ int GPUState::PH_Read(GPUReg* r, int size)
int w = r[2].XY.X;
int h = r[2].XY.Y;
CRect r2;
GSVector4i r2;
r2.left = r[1].XY.X;
r2.top = r[1].XY.Y;
@ -624,7 +622,7 @@ int GPUState::PH_Read(GPUReg* r, int size)
m_read.cur = 0;
m_read.Reserve(m_read.bytes);
m_mem.ReadRect(r2, (WORD*)m_read.buff);
m_mem.ReadRect(r2, (uint16*)m_read.buff);
Dump("r");
@ -693,7 +691,7 @@ GPUState::Buffer::Buffer()
{
bytes = 0;
maxbytes = 4096;
buff = (BYTE*)_aligned_malloc(maxbytes, 16);
buff = (uint8*)_aligned_malloc(maxbytes, 16);
cur = 0;
}
@ -708,11 +706,11 @@ void GPUState::Buffer::Reserve(int size)
{
maxbytes = (maxbytes + size + 1023) & ~1023;
buff = (BYTE*)_aligned_realloc(buff, maxbytes, 16);
buff = (uint8*)_aligned_realloc(buff, maxbytes, 16);
}
}
void GPUState::Buffer::Append(const BYTE* src, int size)
void GPUState::Buffer::Append(const uint8* src, int size)
{
Reserve(bytes + (int)size);

View File

@ -65,14 +65,14 @@ class GPUState : public GSAlignedClass<16>
public:
int bytes;
int maxbytes;
BYTE* buff;
uint8* buff;
int cur;
public:
Buffer();
~Buffer();
void Reserve(int size);
void Append(const BYTE* src, int size);
void Append(const uint8* src, int size);
void Remove(int size);
void RemoveAll();
};
@ -88,10 +88,10 @@ protected:
int s_n;
void Dump(const string& s, UINT32 TP, const CRect& r, int inc = true)
void Dump(const string& s, uint32 TP, const GSVector4i& r, int inc = true)
{
//if(m_perfmon.GetFrame() < 1000)
//if((m_env.TWIN.ai32 & 0xfffff) == 0)
//if((m_env.TWIN.u32 & 0xfffff) == 0)
//if(!m_env.STATUS.ME && !m_env.STATUS.MD)
return;
@ -108,7 +108,7 @@ protected:
void Dump(const string& s, int inc = true)
{
Dump(s, 2, CRect(0, 0, 1024, 512), inc);
Dump(s, 2, GSVector4i(0, 0, 1024, 512), inc);
}
public:
@ -116,10 +116,10 @@ public:
GPULocalMemory m_mem;
GPUVertex m_v;
GSPerfMon m_perfmon;
UINT32 m_status[256];
uint32 m_status[256];
public:
GPUState(const CSize& scale);
GPUState(const GSVector2i& scale);
virtual ~GPUState();
virtual void Reset();
@ -127,13 +127,13 @@ public:
virtual void FlushPrim() = 0;
virtual void ResetPrim() = 0;
virtual void VertexKick() = 0;
virtual void Invalidate(const CRect& r);
virtual void Invalidate(const GSVector4i& r);
void WriteData(const BYTE* mem, UINT32 size);
void ReadData(BYTE* mem, UINT32 size);
void WriteData(const uint8* mem, uint32 size);
void ReadData(uint8* mem, uint32 size);
void WriteStatus(UINT32 status);
UINT32 ReadStatus();
void WriteStatus(uint32 status);
uint32 ReadStatus();
void Freeze(GPUFreezeData* data);
void Defrost(const GPUFreezeData* data);

View File

@ -35,9 +35,9 @@
static HRESULT s_hr = E_FAIL;
static GSRendererBase* s_gs = NULL;
static void (*s_irq)() = NULL;
static BYTE* s_basemem = NULL;
static uint8* s_basemem = NULL;
EXPORT_C_(UINT32) PS2EgetLibType()
EXPORT_C_(uint32) PS2EgetLibType()
{
return PS2E_LT_GS;
}
@ -47,15 +47,15 @@ EXPORT_C_(char*) PS2EgetLibName()
return GSUtil::GetLibName();
}
EXPORT_C_(UINT32) PS2EgetLibVersion2(UINT32 type)
EXPORT_C_(uint32) PS2EgetLibVersion2(uint32 type)
{
const UINT32 revision = 0;
const UINT32 build = 1;
const uint32 revision = 0;
const uint32 build = 1;
return (build << 0) | (revision << 8) | (PS2E_GS_VERSION << 16) | (PLUGIN_VERSION << 24);
}
EXPORT_C_(UINT32) PS2EgetCpuPlatform()
EXPORT_C_(uint32) PS2EgetCpuPlatform()
{
#if _M_AMD64
return PS2E_X86_64;
@ -64,7 +64,7 @@ EXPORT_C_(UINT32) PS2EgetCpuPlatform()
#endif
}
EXPORT_C GSsetBaseMem(BYTE* mem)
EXPORT_C GSsetBaseMem(uint8* mem)
{
s_basemem = mem - 0x12000000;
}
@ -175,37 +175,37 @@ EXPORT_C GSreset()
s_gs->Reset();
}
EXPORT_C GSgifSoftReset(int mask)
EXPORT_C GSgifSoftReset(uint32 mask)
{
s_gs->SoftReset((BYTE)mask);
s_gs->SoftReset(mask);
}
EXPORT_C GSwriteCSR(UINT32 csr)
EXPORT_C GSwriteCSR(uint32 csr)
{
s_gs->WriteCSR(csr);
}
EXPORT_C GSreadFIFO(BYTE* mem)
EXPORT_C GSreadFIFO(uint8* mem)
{
s_gs->ReadFIFO(mem, 1);
}
EXPORT_C GSreadFIFO2(BYTE* mem, UINT32 size)
EXPORT_C GSreadFIFO2(uint8* mem, uint32 size)
{
s_gs->ReadFIFO(mem, size);
}
EXPORT_C GSgifTransfer1(BYTE* mem, UINT32 addr)
EXPORT_C GSgifTransfer1(uint8* mem, uint32 addr)
{
s_gs->Transfer<0>(mem + addr, (0x4000 - addr) / 16);
}
EXPORT_C GSgifTransfer2(BYTE* mem, UINT32 size)
EXPORT_C GSgifTransfer2(uint8* mem, uint32 size)
{
s_gs->Transfer<1>(mem, size);
}
EXPORT_C GSgifTransfer3(BYTE* mem, UINT32 size)
EXPORT_C GSgifTransfer3(uint8* mem, uint32 size)
{
s_gs->Transfer<2>(mem, size);
}
@ -215,7 +215,7 @@ EXPORT_C GSvsync(int field)
s_gs->VSync(field);
}
EXPORT_C_(UINT32) GSmakeSnapshot(char* path)
EXPORT_C_(uint32) GSmakeSnapshot(char* path)
{
return s_gs->MakeSnapshot(string(path) + "gsdx");
}
@ -224,7 +224,7 @@ EXPORT_C GSkeyEvent(keyEvent* ev)
{
}
EXPORT_C_(INT32) GSfreeze(int mode, GSFreezeData* data)
EXPORT_C_(int) GSfreeze(int mode, GSFreezeData* data)
{
if(mode == FREEZE_SAVE)
{
@ -279,12 +279,12 @@ EXPORT_C GSirqCallback(void (*irq)())
s_irq = irq;
}
EXPORT_C GSsetGameCRC(DWORD crc, int options)
EXPORT_C GSsetGameCRC(uint32 crc, int options)
{
s_gs->SetGameCRC(crc, options);
}
EXPORT_C GSgetLastTag(UINT32* tag)
EXPORT_C GSgetLastTag(uint32* tag)
{
s_gs->GetLastTag(tag);
}
@ -309,25 +309,25 @@ EXPORT_C GSReplay(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow)
::SetPriorityClass(::GetCurrentProcess(), HIGH_PRIORITY_CLASS);
vector<BYTE> buff;
vector<uint8> buff;
if(FILE* fp = fopen(lpszCmdLine, "rb"))
{
GSinit();
BYTE regs[0x2000];
uint8 regs[0x2000];
GSsetBaseMem(regs);
HWND hWnd = NULL;
GSopen(&hWnd, "", true, renderer);
DWORD crc;
uint32 crc;
fread(&crc, 4, 1, fp);
GSsetGameCRC(crc, 0);
GSFreezeData fd;
fread(&fd.size, 4, 1, fp);
fd.data = new BYTE[fd.size];
fd.data = new uint8[fd.size];
fread(fd.data, fd.size, 1, fp);
GSfreeze(FREEZE_LOAD, &fd);
delete [] fd.data;
@ -425,9 +425,9 @@ EXPORT_C GSBenchmark(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow
{PSM_PSMZ16S, "16ZS"},
};
BYTE* ptr = (BYTE*)_aligned_malloc(1024 * 1024 * 4, 16);
uint8* ptr = (uint8*)_aligned_malloc(1024 * 1024 * 4, 16);
for(int i = 0; i < 1024 * 1024 * 4; i++) ptr[i] = (BYTE)i;
for(int i = 0; i < 1024 * 1024 * 4; i++) ptr[i] = (uint8)i;
//
@ -470,7 +470,7 @@ EXPORT_C GSBenchmark(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow
TRXREG.RRW = w;
TRXREG.RRH = h;
CRect r(0, 0, w, h);
GSVector4i r(0, 0, w, h);
GIFRegTEX0 TEX0;
@ -560,9 +560,9 @@ EXPORT_C GSBenchmark(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow
{
GSLocalMemory mem;
BYTE* ptr = (BYTE*)_aligned_malloc(1024 * 1024 * 4, 16);
uint8* ptr = (uint8*)_aligned_malloc(1024 * 1024 * 4, 16);
for(int i = 0; i < 1024 * 1024 * 4; i++) ptr[i] = (BYTE)i;
for(int i = 0; i < 1024 * 1024 * 4; i++) ptr[i] = (uint8)i;
const GSLocalMemory::psm_t& psm = GSLocalMemory::m_psm[PSM_PSMCT32];

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -46,24 +46,24 @@ class __declspec(uuid("F8BB6F4F-0965-4ED4-BA74-C6A01E6E6C77"))
#endif
GSSource : public CBaseFilter, private CCritSec, public IGSSource
{
CSize m_size;
GSVector2i m_size;
REFERENCE_TIME m_atpf;
REFERENCE_TIME m_now;
STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv)
{
return
QI(IGSSource)
riid == __uuidof(IGSSource) ? GetInterface((IGSSource*)this, ppv) :
__super::NonDelegatingQueryInterface(riid, ppv);
}
class GSSourceOutputPin : public CBaseOutputPin
{
CSize m_size;
GSVector2i m_size;
vector<CMediaType> m_mts;
public:
GSSourceOutputPin(CSize size, REFERENCE_TIME atpf, CBaseFilter* pFilter, CCritSec* pLock, HRESULT& hr)
GSSourceOutputPin(const GSVector2i& size, REFERENCE_TIME atpf, CBaseFilter* pFilter, CCritSec* pLock, HRESULT& hr)
: CBaseOutputPin("GSSourceOutputPin", pFilter, pLock, &hr, L"Output")
, m_size(size)
{
@ -75,36 +75,32 @@ GSSource : public CBaseFilter, private CCritSec, public IGSSource
memset(&vih, 0, sizeof(vih));
vih.AvgTimePerFrame = atpf;
vih.bmiHeader.biSize = sizeof(vih.bmiHeader);
vih.bmiHeader.biWidth = m_size.cx;
vih.bmiHeader.biHeight = m_size.cy;
#if _M_SSE >= 0x200
vih.bmiHeader.biWidth = m_size.x;
vih.bmiHeader.biHeight = m_size.y;
// YUY2
mt.subtype = MEDIASUBTYPE_YUY2;
mt.lSampleSize = m_size.cx * m_size.cy * 2;
mt.lSampleSize = m_size.x * m_size.y * 2;
vih.bmiHeader.biCompression = '2YUY';
vih.bmiHeader.biPlanes = 1;
vih.bmiHeader.biBitCount = 16;
vih.bmiHeader.biSizeImage = m_size.cx * m_size.cy * 2;
mt.SetFormat((BYTE*)&vih, sizeof(vih));
vih.bmiHeader.biSizeImage = m_size.x * m_size.y * 2;
mt.SetFormat((uint8*)&vih, sizeof(vih));
m_mts.push_back(mt);
#endif
// RGB32
mt.subtype = MEDIASUBTYPE_RGB32;
mt.lSampleSize = m_size.cx * m_size.cy * 4;
mt.lSampleSize = m_size.x * m_size.y * 4;
vih.bmiHeader.biCompression = BI_RGB;
vih.bmiHeader.biPlanes = 1;
vih.bmiHeader.biBitCount = 32;
vih.bmiHeader.biSizeImage = m_size.cx * m_size.cy * 4;
mt.SetFormat((BYTE*)&vih, sizeof(vih));
vih.bmiHeader.biSizeImage = m_size.x * m_size.y * 4;
mt.SetFormat((uint8*)&vih, sizeof(vih));
m_mts.push_back(mt);
}
@ -231,17 +227,15 @@ public:
const CMediaType& mt = m_output->CurrentMediaType();
BYTE* src = (BYTE*)bits;
uint8* src = (uint8*)bits;
uint8* dst = NULL;
BYTE* dst = NULL;
sample->GetPointer(&dst);
int w = m_size.cx;
int h = m_size.cy;
int w = m_size.x;
int h = m_size.y;
int srcpitch = pitch;
#if _M_SSE >= 0x200
if(mt.subtype == MEDIASUBTYPE_YUY2)
{
int dstpitch = ((VIDEOINFOHEADER*)mt.Format())->bmiHeader.biWidth * 2;
@ -255,8 +249,8 @@ public:
{
for(int j = 0; j < h; j++, dst += dstpitch, src += srcpitch)
{
DWORD* s = (DWORD*)src;
WORD* d = (WORD*)dst;
uint32* s = (uint32*)src;
uint16* d = (uint16*)dst;
for(int i = 0; i < w; i += 2)
{
@ -269,7 +263,7 @@ public:
GSVector4 c = lo.hadd(hi) + offset;
*((DWORD*)&d[i]) = GSVector4i(c).rgba32();
*((uint32*)&d[i]) = GSVector4i(c).rgba32();
}
}
}
@ -277,8 +271,8 @@ public:
{
for(int j = 0; j < h; j++, dst += dstpitch, src += srcpitch)
{
DWORD* s = (DWORD*)src;
WORD* d = (WORD*)dst;
uint32* s = (uint32*)src;
uint16* d = (uint16*)dst;
for(int i = 0; i < w; i += 2)
{
@ -291,16 +285,12 @@ public:
GSVector4 c = lo.hadd(hi) + offset;
*((DWORD*)&d[i]) = GSVector4i(c).rgba32();
*((uint32*)&d[i]) = GSVector4i(c).rgba32();
}
}
}
}
else
#endif
if(mt.subtype == MEDIASUBTYPE_RGB32)
else if(mt.subtype == MEDIASUBTYPE_RGB32)
{
int dstpitch = ((VIDEOINFOHEADER*)mt.Format())->bmiHeader.biWidth * 4;
@ -323,7 +313,7 @@ public:
d[i] = s[i].shuffle8(mask);
}
#elif _M_SSE >= 0x200
#else
GSVector4i* s = (GSVector4i*)src;
GSVector4i* d = (GSVector4i*)dst;
@ -333,16 +323,6 @@ public:
d[i] = ((s[i] & 0x00ff0000) >> 16) | ((s[i] & 0x000000ff) << 16) | (s[i] & 0x0000ff00);
}
#else
DWORD* s = (DWORD*)src;
DWORD* d = (DWORD*)dst;
for(int i = 0; i < w; i++)
{
d[i] = ((s[i] & 0x00ff0000) >> 16) | ((s[i] & 0x000000ff) << 16) | (s[i] & 0x0000ff00);
}
#endif
}
else
@ -429,8 +409,8 @@ bool GSCapture::BeginCapture(int fps)
if(IDOK != dlg.DoModal()) return false;
m_size.cx = (dlg.m_width + 7) & ~7;
m_size.cy = (dlg.m_height + 7) & ~7;
m_size.x = (dlg.m_width + 7) & ~7;
m_size.y = (dlg.m_height + 7) & ~7;
//
@ -447,7 +427,7 @@ bool GSCapture::BeginCapture(int fps)
return false;
}
m_src = new GSSource(m_size.cx, m_size.cy, fps, NULL, hr);
m_src = new GSSource(m_size.x, m_size.y, fps, NULL, hr);
if(FAILED(hr = m_graph->AddFilter(m_src, L"Source"))
|| FAILED(hr = m_graph->AddFilter(dlg.m_enc, L"Encoder")))

View File

@ -22,11 +22,12 @@
#pragma once
#include "GSCaptureDlg.h"
#include "GSVector.h"
class GSCapture : protected CCritSec
{
bool m_capturing;
CSize m_size;
GSVector2i m_size;
CComPtr<IGraphBuilder> m_graph;
CComPtr<IBaseFilter> m_src;
@ -39,5 +40,5 @@ public:
bool EndCapture();
bool IsCapturing() {return m_capturing;}
CSize GetSize() {return m_size;}
GSVector2i GetSize() {return m_size;}
};

View File

@ -26,11 +26,11 @@
GSClut::GSClut(const GSLocalMemory* mem)
: m_mem(mem)
{
BYTE* p = (BYTE*)VirtualAlloc(NULL, 2 * 4096, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
uint8* p = (uint8*)VirtualAlloc(NULL, 2 * 4096, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
m_clut = (WORD*)&p[0]; // 1k + 1k for buffer overruns (sfex: PSM == PSM_PSMT8, CPSM == PSM_PSMCT32, CSA != 0)
m_buff32 = (DWORD*)&p[2048]; // 1k
m_buff64 = (UINT64*)&p[4096]; // 2k
m_clut = (uint16*)&p[0]; // 1k + 1k for buffer overruns (sfex: PSM == PSM_PSMT8, CPSM == PSM_PSMCT32, CSA != 0)
m_buff32 = (uint32*)&p[2048]; // 1k
m_buff64 = (uint64*)&p[4096]; // 2k
m_write.dirty = true;
m_read.dirty = true;
@ -128,7 +128,7 @@ void GSClut::WriteCLUT32_I8_CSM1(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TE
{
ASSERT(TEX0.CSA == 0);
WriteCLUT_T32_I8_CSM1((DWORD*)m_mem->BlockPtr32(0, 0, TEX0.CBP, 1), m_clut + (TEX0.CSA << 4));
WriteCLUT_T32_I8_CSM1((uint32*)m_mem->BlockPtr32(0, 0, TEX0.CBP, 1), m_clut + (TEX0.CSA << 4));
}
void GSClut::WriteCLUT32_I4_CSM1(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT)
@ -137,72 +137,72 @@ void GSClut::WriteCLUT32_I4_CSM1(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TE
GSVector4i dummy; // this just forces stack alignment and enables inlining the next call
WriteCLUT_T32_I4_CSM1((DWORD*)m_mem->BlockPtr32(0, 0, TEX0.CBP, 1), m_clut + (TEX0.CSA << 4));
WriteCLUT_T32_I4_CSM1((uint32*)m_mem->BlockPtr32(0, 0, TEX0.CBP, 1), m_clut + (TEX0.CSA << 4));
}
void GSClut::WriteCLUT16_I8_CSM1(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT)
{
ASSERT(TEX0.CSA < 16);
WriteCLUT_T16_I8_CSM1((WORD*)m_mem->BlockPtr16(0, 0, TEX0.CBP, 1), m_clut + (TEX0.CSA << 4));
WriteCLUT_T16_I8_CSM1((uint16*)m_mem->BlockPtr16(0, 0, TEX0.CBP, 1), m_clut + (TEX0.CSA << 4));
}
void GSClut::WriteCLUT16_I4_CSM1(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT)
{
ASSERT(TEX0.CSA < 32);
WriteCLUT_T16_I4_CSM1((WORD*)m_mem->BlockPtr16(0, 0, TEX0.CBP, 1), m_clut + (TEX0.CSA << 4));
WriteCLUT_T16_I4_CSM1((uint16*)m_mem->BlockPtr16(0, 0, TEX0.CBP, 1), m_clut + (TEX0.CSA << 4));
}
void GSClut::WriteCLUT16S_I8_CSM1(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT)
{
WriteCLUT_T16_I8_CSM1((WORD*)m_mem->BlockPtr16S(0, 0, TEX0.CBP, 1), m_clut + (TEX0.CSA << 4));
WriteCLUT_T16_I8_CSM1((uint16*)m_mem->BlockPtr16S(0, 0, TEX0.CBP, 1), m_clut + (TEX0.CSA << 4));
}
void GSClut::WriteCLUT16S_I4_CSM1(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT)
{
WriteCLUT_T16_I4_CSM1((WORD*)m_mem->BlockPtr16S(0, 0, TEX0.CBP, 1), m_clut + (TEX0.CSA << 4));
WriteCLUT_T16_I4_CSM1((uint16*)m_mem->BlockPtr16S(0, 0, TEX0.CBP, 1), m_clut + (TEX0.CSA << 4));
}
template<int n> void GSClut::WriteCLUT32_CSM2(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT)
{
WORD* RESTRICT clut = m_clut + (TEX0.CSA << 4);
uint16* RESTRICT clut = m_clut + (TEX0.CSA << 4);
DWORD base = m_mem->PixelAddress32(0, TEXCLUT.COV, TEX0.CBP, TEXCLUT.CBW);
uint32 base = m_mem->PixelAddress32(0, TEXCLUT.COV, TEX0.CBP, TEXCLUT.CBW);
int* offset = &m_mem->rowOffset32[TEXCLUT.COU << 4];
for(int i = 0; i < n; i++)
{
DWORD c = m_mem->ReadPixel32(base + offset[i]);
uint32 c = m_mem->ReadPixel32(base + offset[i]);
clut[i] = (WORD)(c & 0xffff);
clut[i + 256] = (WORD)(c >> 16);
clut[i] = (uint16)(c & 0xffff);
clut[i + 256] = (uint16)(c >> 16);
}
}
template<int n> void GSClut::WriteCLUT16_CSM2(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT)
{
WORD* RESTRICT clut = m_clut + (TEX0.CSA << 4);
uint16* RESTRICT clut = m_clut + (TEX0.CSA << 4);
DWORD base = m_mem->PixelAddress16(0, TEXCLUT.COV, TEX0.CBP, TEXCLUT.CBW);
uint32 base = m_mem->PixelAddress16(0, TEXCLUT.COV, TEX0.CBP, TEXCLUT.CBW);
int* offset = &m_mem->rowOffset16[TEXCLUT.COU << 4];
for(int i = 0; i < n; i++)
{
clut[i] = (WORD)m_mem->ReadPixel16(base + offset[i]);
clut[i] = (uint16)m_mem->ReadPixel16(base + offset[i]);
}
}
template<int n> void GSClut::WriteCLUT16S_CSM2(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT)
{
WORD* RESTRICT clut = m_clut + (TEX0.CSA << 4);
uint16* RESTRICT clut = m_clut + (TEX0.CSA << 4);
DWORD base = m_mem->PixelAddress16S(0, TEXCLUT.COV, TEX0.CBP, TEXCLUT.CBW);
uint32 base = m_mem->PixelAddress16S(0, TEXCLUT.COV, TEX0.CBP, TEXCLUT.CBW);
int* offset = &m_mem->rowOffset16S[TEXCLUT.COU << 4];
for(int i = 0; i < n; i++)
{
clut[i] = (WORD)m_mem->ReadPixel16(base + offset[i]);
clut[i] = (uint16)m_mem->ReadPixel16(base + offset[i]);
}
}
@ -213,7 +213,7 @@ void GSClut::Read(const GIFRegTEX0& TEX0)
m_read.TEX0 = TEX0;
m_read.dirty = false;
WORD* clut = m_clut + (TEX0.CSA << 4);
uint16* clut = m_clut + (TEX0.CSA << 4);
if(TEX0.CPSM == PSM_PSMCT32 || TEX0.CPSM == PSM_PSMCT24)
{
@ -257,7 +257,7 @@ void GSClut::Read32(const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA)
m_read.dirty = false;
m_read.adirty = true;
WORD* clut = m_clut + (TEX0.CSA << 4);
uint16* clut = m_clut + (TEX0.CSA << 4);
if(TEX0.CPSM == PSM_PSMCT32 || TEX0.CPSM == PSM_PSMCT24)
{
@ -272,7 +272,7 @@ void GSClut::Read32(const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA)
case PSM_PSMT4HH:
// TODO: merge these functions
ReadCLUT_T32_I4(clut, m_buff32);
ExpandCLUT64_T32_I8(m_buff32, (UINT64*)m_buff64); // sw renderer does not need m_buff64 anymore
ExpandCLUT64_T32_I8(m_buff32, (uint64*)m_buff64); // sw renderer does not need m_buff64 anymore
break;
}
}
@ -289,7 +289,7 @@ void GSClut::Read32(const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA)
case PSM_PSMT4HH:
// TODO: merge these functions
Expand16(clut, m_buff32, 16, TEXA);
ExpandCLUT64_T32_I8(m_buff32, (UINT64*)m_buff64); // sw renderer does not need m_buff64 anymore
ExpandCLUT64_T32_I8(m_buff32, (uint64*)m_buff64); // sw renderer does not need m_buff64 anymore
break;
}
}
@ -306,9 +306,9 @@ void GSClut::GetAlphaMinMax32(int& amin, int& amax)
{
m_read.adirty = false;
// DWORD bpp = GSLocalMemory::m_psm[m_read.TEX0.PSM].trbpp;
DWORD cbpp = GSLocalMemory::m_psm[m_read.TEX0.CPSM].trbpp;
DWORD pal = GSLocalMemory::m_psm[m_read.TEX0.PSM].pal;
// uint32 bpp = GSLocalMemory::m_psm[m_read.TEX0.PSM].trbpp;
uint32 cbpp = GSLocalMemory::m_psm[m_read.TEX0.CPSM].trbpp;
uint32 pal = GSLocalMemory::m_psm[m_read.TEX0.PSM].pal;
if(cbpp == 24 && m_read.TEXA.AEM == 0)
{
@ -352,10 +352,8 @@ void GSClut::GetAlphaMinMax32(int& amin, int& amax)
//
void GSClut::WriteCLUT_T32_I8_CSM1(const DWORD* RESTRICT src, WORD* RESTRICT clut)
void GSClut::WriteCLUT_T32_I8_CSM1(const uint32* RESTRICT src, uint16* RESTRICT clut)
{
#if _M_SSE >= 0x200
for(int i = 0; i < 64; i += 16)
{
WriteCLUT_T32_I4_CSM1(&src[i + 0], &clut[i * 2 + 0]);
@ -363,26 +361,10 @@ void GSClut::WriteCLUT_T32_I8_CSM1(const DWORD* RESTRICT src, WORD* RESTRICT clu
WriteCLUT_T32_I4_CSM1(&src[i + 128], &clut[i * 2 + 128]);
WriteCLUT_T32_I4_CSM1(&src[i + 192], &clut[i * 2 + 144]);
}
#else
for(int j = 0; j < 2; j++, src += 128, clut += 128)
{
for(int i = 0; i < 128; i++)
{
DWORD c = src[clutTableT32I8[i]];
clut[i] = (WORD)(c & 0xffff);
clut[i + 256] = (WORD)(c >> 16);
}
}
#endif
}
__forceinline void GSClut::WriteCLUT_T32_I4_CSM1(const DWORD* RESTRICT src, WORD* RESTRICT clut)
__forceinline void GSClut::WriteCLUT_T32_I4_CSM1(const uint32* RESTRICT src, uint16* RESTRICT clut)
{
#if _M_SSE >= 0x200
GSVector4i* s = (GSVector4i*)src;
GSVector4i* d = (GSVector4i*)clut;
@ -400,23 +382,10 @@ __forceinline void GSClut::WriteCLUT_T32_I4_CSM1(const DWORD* RESTRICT src, WORD
d[1] = v1;
d[32] = v2;
d[33] = v3;
#else
for(int i = 0; i < 16; i++)
{
DWORD c = src[clutTableT32I4[i]];
clut[i] = (WORD)(c & 0xffff);
clut[i + 256] = (WORD)(c >> 16);
}
#endif
}
void GSClut::WriteCLUT_T16_I8_CSM1(const WORD* RESTRICT src, WORD* RESTRICT clut)
void GSClut::WriteCLUT_T16_I8_CSM1(const uint16* RESTRICT src, uint16* RESTRICT clut)
{
#if _M_SSE >= 0x200
GSVector4i* s = (GSVector4i*)src;
GSVector4i* d = (GSVector4i*)clut;
@ -436,21 +405,9 @@ void GSClut::WriteCLUT_T16_I8_CSM1(const WORD* RESTRICT src, WORD* RESTRICT clut
d[i + 2] = v1;
d[i + 3] = v3;
}
#else
for(int j = 0; j < 8; j++, src += 32, clut += 32)
{
for(int i = 0; i < 32; i++)
{
clut[i] = src[clutTableT16I8[i]];
}
}
#endif
}
__forceinline void GSClut::WriteCLUT_T16_I4_CSM1(const WORD* RESTRICT src, WORD* RESTRICT clut)
__forceinline void GSClut::WriteCLUT_T16_I4_CSM1(const uint16* RESTRICT src, uint16* RESTRICT clut)
{
for(int i = 0; i < 16; i++)
{
@ -458,29 +415,16 @@ __forceinline void GSClut::WriteCLUT_T16_I4_CSM1(const WORD* RESTRICT src, WORD*
}
}
void GSClut::ReadCLUT_T32_I8(const WORD* RESTRICT clut, DWORD* RESTRICT dst)
void GSClut::ReadCLUT_T32_I8(const uint16* RESTRICT clut, uint32* RESTRICT dst)
{
#if _M_SSE >= 0x200
for(int i = 0; i < 256; i += 16)
{
ReadCLUT_T32_I4(&clut[i], &dst[i]);
}
#else
for(int i = 0; i < 256; i++)
{
dst[i] = ((DWORD)clut[i + 256] << 16) | clut[i];
}
#endif
}
__forceinline void GSClut::ReadCLUT_T32_I4(const WORD* RESTRICT clut, DWORD* RESTRICT dst)
__forceinline void GSClut::ReadCLUT_T32_I4(const uint16* RESTRICT clut, uint32* RESTRICT dst)
{
#if _M_SSE >= 0x200
GSVector4i* s = (GSVector4i*)clut;
GSVector4i* d = (GSVector4i*)dst;
@ -495,21 +439,10 @@ __forceinline void GSClut::ReadCLUT_T32_I4(const WORD* RESTRICT clut, DWORD* RES
d[1] = v1;
d[2] = v2;
d[3] = v3;
#else
for(int i = 0; i < 16; i++)
{
dst[i] = ((DWORD)clut[i + 256] << 16) | clut[i];
}
#endif
}
__forceinline void GSClut::ReadCLUT_T32_I4(const WORD* RESTRICT clut, DWORD* RESTRICT dst32, UINT64* RESTRICT dst64)
__forceinline void GSClut::ReadCLUT_T32_I4(const uint16* RESTRICT clut, uint32* RESTRICT dst32, uint64* RESTRICT dst64)
{
#if _M_SSE >= 0x200
GSVector4i* s = (GSVector4i*)clut;
GSVector4i* d32 = (GSVector4i*)dst32;
GSVector4i* d64 = (GSVector4i*)dst64;
@ -530,53 +463,18 @@ __forceinline void GSClut::ReadCLUT_T32_I4(const WORD* RESTRICT clut, DWORD* RES
ExpandCLUT64_T32(s1, s0, s1, s2, s3, &d64[32]);
ExpandCLUT64_T32(s2, s0, s1, s2, s3, &d64[64]);
ExpandCLUT64_T32(s3, s0, s1, s2, s3, &d64[96]);
#else
for(int i = 0; i < 16; i++)
{
dst[i] = ((DWORD)clut[i + 256] << 16) | clut[i];
}
DWORD* d = (DWORD*)dst64;
for(int j = 0; j < 16; j++, d += 32)
{
DWORD hi = dst32[j];
for(int i = 0; i < 16; i++)
{
d[i * 2 + 0] = dst32[i];
d[i * 2 + 1] = hi;
}
}
#endif
}
void GSClut::ReadCLUT_T16_I8(const WORD* RESTRICT clut, DWORD* RESTRICT dst)
void GSClut::ReadCLUT_T16_I8(const uint16* RESTRICT clut, uint32* RESTRICT dst)
{
#if _M_SSE >= 0x200
for(int i = 0; i < 256; i += 16)
{
ReadCLUT_T16_I4(&clut[i], &dst[i]);
}
#else
for(int i = 0; i < 256; i++)
{
dst[i] = (DWORD)clut[i];
}
#endif
}
__forceinline void GSClut::ReadCLUT_T16_I4(const WORD* RESTRICT clut, DWORD* RESTRICT dst)
__forceinline void GSClut::ReadCLUT_T16_I4(const uint16* RESTRICT clut, uint32* RESTRICT dst)
{
#if _M_SSE >= 0x200
GSVector4i* s = (GSVector4i*)clut;
GSVector4i* d = (GSVector4i*)dst;
@ -587,21 +485,10 @@ __forceinline void GSClut::ReadCLUT_T16_I4(const WORD* RESTRICT clut, DWORD* RES
d[1] = v0.uph16();
d[2] = v1.upl16();
d[3] = v1.uph16();
#else
for(int i = 0; i < 16; i++)
{
dst[i] = (DWORD)clut[i];
}
#endif
}
__forceinline void GSClut::ReadCLUT_T16_I4(const WORD* RESTRICT clut, DWORD* RESTRICT dst32, UINT64* RESTRICT dst64)
__forceinline void GSClut::ReadCLUT_T16_I4(const uint16* RESTRICT clut, uint32* RESTRICT dst32, uint64* RESTRICT dst64)
{
#if _M_SSE >= 0x200
GSVector4i* s = (GSVector4i*)clut;
GSVector4i* d32 = (GSVector4i*)dst32;
GSVector4i* d64 = (GSVector4i*)dst64;
@ -623,33 +510,10 @@ __forceinline void GSClut::ReadCLUT_T16_I4(const WORD* RESTRICT clut, DWORD* RES
ExpandCLUT64_T16(s1, s0, s1, s2, s3, &d64[32]);
ExpandCLUT64_T16(s2, s0, s1, s2, s3, &d64[64]);
ExpandCLUT64_T16(s3, s0, s1, s2, s3, &d64[96]);
#else
for(int i = 0; i < 16; i++)
{
dst32[i] = (DWORD)clut[i];
}
DWORD* d = (DWORD*)dst64;
for(int j = 0; j < 16; j++, d += 32)
{
DWORD hi = dst32[j] << 16;
for(int i = 0; i < 16; i++)
{
d[i * 2 + 0] = hi | (dst32[i] & 0xffff);
}
}
#endif
}
void GSClut::ExpandCLUT64_T32_I8(const DWORD* RESTRICT src, UINT64* RESTRICT dst)
void GSClut::ExpandCLUT64_T32_I8(const uint32* RESTRICT src, uint64* RESTRICT dst)
{
#if _M_SSE >= 0x200
GSVector4i* s = (GSVector4i*)src;
GSVector4i* d = (GSVector4i*)dst;
@ -662,23 +526,6 @@ void GSClut::ExpandCLUT64_T32_I8(const DWORD* RESTRICT src, UINT64* RESTRICT dst
ExpandCLUT64_T32(s1, s0, s1, s2, s3, &d[32]);
ExpandCLUT64_T32(s2, s0, s1, s2, s3, &d[64]);
ExpandCLUT64_T32(s3, s0, s1, s2, s3, &d[96]);
#else
DWORD* d = (DWORD*)dst;
for(int j = 0; j < 16; j++, d += 32)
{
DWORD hi = src[j];
for(int i = 0; i < 16; i++)
{
d[i * 2 + 0] = src[i];
d[i * 2 + 1] = hi;
}
}
#endif
}
__forceinline void GSClut::ExpandCLUT64_T32(const GSVector4i& hi, const GSVector4i& lo0, const GSVector4i& lo1, const GSVector4i& lo2, const GSVector4i& lo3, GSVector4i* dst)
@ -707,10 +554,8 @@ __forceinline void GSClut::ExpandCLUT64_T32(const GSVector4i& hi, const GSVector
dst[1] = lo.uph32(hi);
}
void GSClut::ExpandCLUT64_T16_I8(const DWORD* RESTRICT src, UINT64* RESTRICT dst)
void GSClut::ExpandCLUT64_T16_I8(const uint32* RESTRICT src, uint64* RESTRICT dst)
{
#if _M_SSE >= 0x200
GSVector4i* s = (GSVector4i*)src;
GSVector4i* d = (GSVector4i*)dst;
@ -723,22 +568,6 @@ void GSClut::ExpandCLUT64_T16_I8(const DWORD* RESTRICT src, UINT64* RESTRICT dst
ExpandCLUT64_T16(s1, s0, s1, s2, s3, &d[32]);
ExpandCLUT64_T16(s2, s0, s1, s2, s3, &d[64]);
ExpandCLUT64_T16(s3, s0, s1, s2, s3, &d[96]);
#else
DWORD* d = (DWORD*)dst;
for(int j = 0; j < 16; j++, d += 32)
{
DWORD hi = src[j] << 16;
for(int i = 0; i < 16; i++)
{
d[i * 2 + 0] = hi | (src[i] & 0xffff);
}
}
#endif
}
__forceinline void GSClut::ExpandCLUT64_T16(const GSVector4i& hi, const GSVector4i& lo0, const GSVector4i& lo1, const GSVector4i& lo2, const GSVector4i& lo3, GSVector4i* dst)
@ -774,10 +603,8 @@ static const GSVector4i s_bm(0x00007c00);
static const GSVector4i s_gm(0x000003e0);
static const GSVector4i s_rm(0x0000001f);
void GSClut::Expand16(const WORD* RESTRICT src, DWORD* RESTRICT dst, int w, const GIFRegTEXA& TEXA)
void GSClut::Expand16(const uint16* RESTRICT src, uint32* RESTRICT dst, int w, const GIFRegTEXA& TEXA)
{
#if _M_SSE >= 0x200
ASSERT((w & 7) == 0);
const GSVector4i rm = s_rm;
@ -827,43 +654,21 @@ void GSClut::Expand16(const WORD* RESTRICT src, DWORD* RESTRICT dst, int w, cons
d[i * 2 + 1] = ((ch & rm) << 3) | ((ch & gm) << 6) | ((ch & bm) << 9) | TA0.blend8(TA1, ch.sra16(15)).andnot(ch == GSVector4i::zero());
}
}
#else
DWORD TA0 = (DWORD)TEXA.TA0 << 24;
DWORD TA1 = (DWORD)TEXA.TA1 << 24;
if(!TEXA.AEM)
{
for(int i = 0; i < w; i++)
{
dst[i] = ((src[i] & 0x8000) ? TA1 : TA0) | ((src[i] & 0x7c00) << 9) | ((src[i] & 0x03e0) << 6) | ((src[i] & 0x001f) << 3);
}
}
else
{
for(int i = 0; i < w; i++)
{
dst[i] = ((src[i] & 0x8000) ? TA1 : src[i] ? TA0 : 0) | ((src[i] & 0x7c00) << 9) | ((src[i] & 0x03e0) << 6) | ((src[i] & 0x001f) << 3);
}
}
#endif
}
//
bool GSClut::WriteState::IsDirty(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT)
{
return dirty || !(GSVector4i::load<true>(this) == GSVector4i::load(&TEX0, &TEXCLUT)).alltrue();
return dirty || !GSVector4i::load<true>(this).eq(GSVector4i::load(&TEX0, &TEXCLUT));
}
bool GSClut::ReadState::IsDirty(const GIFRegTEX0& TEX0)
{
return dirty || !(GSVector4i::load<true>(this) == GSVector4i::load(&TEX0, &this->TEXA)).alltrue();
return dirty || !GSVector4i::load<true>(this).eq(GSVector4i::load(&TEX0, &this->TEXA));
}
bool GSClut::ReadState::IsDirty(const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA)
{
return dirty || !(GSVector4i::load<true>(this) == GSVector4i::load(&TEX0, &TEXA)).alltrue();
return dirty || !GSVector4i::load<true>(this).eq(GSVector4i::load(&TEX0, &TEXA));
}

View File

@ -32,10 +32,10 @@ __declspec(align(16)) class GSClut : public GSAlignedClass<16>
{
const GSLocalMemory* m_mem;
DWORD m_CBP[2];
WORD* m_clut;
DWORD* m_buff32;
UINT64* m_buff64;
uint32 m_CBP[2];
uint16* m_clut;
uint32* m_buff32;
uint64* m_buff64;
__declspec(align(16)) struct WriteState
{
@ -73,24 +73,24 @@ __declspec(align(16)) class GSClut : public GSAlignedClass<16>
void WriteCLUT_NULL(const GIFRegTEX0& TEX0, const GIFRegTEXCLUT& TEXCLUT) {}
static void WriteCLUT_T32_I8_CSM1(const DWORD* RESTRICT src, WORD* RESTRICT clut);
static void WriteCLUT_T32_I4_CSM1(const DWORD* RESTRICT src, WORD* RESTRICT clut);
static void WriteCLUT_T16_I8_CSM1(const WORD* RESTRICT src, WORD* RESTRICT clut);
static void WriteCLUT_T16_I4_CSM1(const WORD* RESTRICT src, WORD* RESTRICT clut);
static void ReadCLUT_T32_I8(const WORD* RESTRICT clut, DWORD* RESTRICT dst);
static void ReadCLUT_T32_I4(const WORD* RESTRICT clut, DWORD* RESTRICT dst);
static void ReadCLUT_T32_I4(const WORD* RESTRICT clut, DWORD* RESTRICT dst32, UINT64* RESTRICT dst64);
static void ReadCLUT_T16_I8(const WORD* RESTRICT clut, DWORD* RESTRICT dst);
static void ReadCLUT_T16_I4(const WORD* RESTRICT clut, DWORD* RESTRICT dst);
static void ReadCLUT_T16_I4(const WORD* RESTRICT clut, DWORD* RESTRICT dst32, UINT64* RESTRICT dst64);
static void ExpandCLUT64_T32_I8(const DWORD* RESTRICT src, UINT64* RESTRICT dst);
static void WriteCLUT_T32_I8_CSM1(const uint32* RESTRICT src, uint16* RESTRICT clut);
static void WriteCLUT_T32_I4_CSM1(const uint32* RESTRICT src, uint16* RESTRICT clut);
static void WriteCLUT_T16_I8_CSM1(const uint16* RESTRICT src, uint16* RESTRICT clut);
static void WriteCLUT_T16_I4_CSM1(const uint16* RESTRICT src, uint16* RESTRICT clut);
static void ReadCLUT_T32_I8(const uint16* RESTRICT clut, uint32* RESTRICT dst);
static void ReadCLUT_T32_I4(const uint16* RESTRICT clut, uint32* RESTRICT dst);
static void ReadCLUT_T32_I4(const uint16* RESTRICT clut, uint32* RESTRICT dst32, uint64* RESTRICT dst64);
static void ReadCLUT_T16_I8(const uint16* RESTRICT clut, uint32* RESTRICT dst);
static void ReadCLUT_T16_I4(const uint16* RESTRICT clut, uint32* RESTRICT dst);
static void ReadCLUT_T16_I4(const uint16* RESTRICT clut, uint32* RESTRICT dst32, uint64* RESTRICT dst64);
static void ExpandCLUT64_T32_I8(const uint32* RESTRICT src, uint64* RESTRICT dst);
static void ExpandCLUT64_T32(const GSVector4i& hi, const GSVector4i& lo0, const GSVector4i& lo1, const GSVector4i& lo2, const GSVector4i& lo3, GSVector4i* dst);
static void ExpandCLUT64_T32(const GSVector4i& hi, const GSVector4i& lo, GSVector4i* dst);
static void ExpandCLUT64_T16_I8(const DWORD* RESTRICT src, UINT64* RESTRICT dst);
static void ExpandCLUT64_T16_I8(const uint32* RESTRICT src, uint64* RESTRICT dst);
static void ExpandCLUT64_T16(const GSVector4i& hi, const GSVector4i& lo0, const GSVector4i& lo1, const GSVector4i& lo2, const GSVector4i& lo3, GSVector4i* dst);
static void ExpandCLUT64_T16(const GSVector4i& hi, const GSVector4i& lo, GSVector4i* dst);
static void Expand16(const WORD* RESTRICT src, DWORD* RESTRICT dst, int w, const GIFRegTEXA& TEXA);
static void Expand16(const uint16* RESTRICT src, uint32* RESTRICT dst, int w, const GIFRegTEXA& TEXA);
public:
GSClut(const GSLocalMemory* mem);
@ -103,8 +103,8 @@ public:
void Read32(const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA);
void GetAlphaMinMax32(int& amin, int& amax);
DWORD operator [] (size_t i) const {return m_buff32[i];}
uint32 operator [] (size_t i) const {return m_buff32[i];}
operator const DWORD*() const {return m_buff32;}
operator const UINT64*() const {return m_buff64;}
operator const uint32*() const {return m_buff32;}
operator const uint64*() const {return m_buff64;}
};

View File

@ -47,14 +47,14 @@ void* GSCodeBuffer::GetBuffer(size_t size)
if(m_ptr == NULL || m_pos + size > m_blocksize)
{
m_ptr = (BYTE*)VirtualAlloc(NULL, m_blocksize, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
m_ptr = (uint8*)VirtualAlloc(NULL, m_blocksize, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE);
m_pos = 0;
m_buffers.push_back(m_ptr);
}
BYTE* ptr = &m_ptr[m_pos];
uint8* ptr = &m_ptr[m_pos];
m_reserved = size;

View File

@ -26,7 +26,7 @@ class GSCodeBuffer
list<void*> m_buffers;
size_t m_blocksize;
size_t m_pos, m_reserved;
BYTE* m_ptr;
uint8* m_ptr;
public:
GSCodeBuffer(size_t blocksize = 4096 * 64); // 256k

View File

@ -131,9 +131,9 @@ CRC::Game CRC::m_games[] =
{0xFB236A46, SonicUnleashed, US},
};
hash_map<DWORD, CRC::Game*> CRC::m_map;
hash_map<uint32, CRC::Game*> CRC::m_map;
CRC::Game CRC::Lookup(DWORD crc)
CRC::Game CRC::Lookup(uint32 crc)
{
if(m_map.empty())
{
@ -143,7 +143,7 @@ CRC::Game CRC::Lookup(DWORD crc)
}
}
hash_map<DWORD, Game*>::iterator i = m_map.find(crc);
hash_map<uint32, Game*>::iterator i = m_map.find(crc);
if(i != m_map.end())
{

View File

@ -84,15 +84,15 @@ public:
struct Game
{
DWORD crc;
uint32 crc;
Title title;
Region region;
};
private:
static Game m_games[];
static hash_map<DWORD, Game*> m_map;
static hash_map<uint32, Game*> m_map;
public:
static Game Lookup(DWORD crc);
static Game Lookup(uint32 crc);
};

View File

@ -115,7 +115,7 @@ public:
virtual bool IsLost() = 0;
virtual void Present(const CRect& r) = 0;
virtual void Present(const GSVector4i& r) = 0;
virtual void BeginScene() = 0;
@ -127,11 +127,11 @@ public:
virtual void ClearRenderTarget(Texture& t, const GSVector4& c) = 0;
virtual void ClearRenderTarget(Texture& t, DWORD c) = 0;
virtual void ClearRenderTarget(Texture& t, uint32 c) = 0;
virtual void ClearDepth(Texture& t, float c) = 0;
virtual void ClearStencil(Texture& t, BYTE c) = 0;
virtual void ClearStencil(Texture& t, uint8 c) = 0;
virtual bool CreateRenderTarget(Texture& t, int w, int h, int format = 0)
{
@ -178,11 +178,11 @@ public:
t = m_current;
}
void Merge(Texture* st, GSVector4* sr, GSVector4* dr, CSize fs, bool slbg, bool mmod, GSVector4& c)
void Merge(Texture* st, GSVector4* sr, GSVector4* dr, const GSVector2i& fs, bool slbg, bool mmod, GSVector4& c)
{
if(!m_merge || m_merge.GetWidth() != fs.cx || m_merge.GetHeight() != fs.cy)
if(!m_merge || m_merge.GetWidth() != fs.x || m_merge.GetHeight() != fs.y)
{
CreateRenderTarget(m_merge, fs.cx, fs.cy);
CreateRenderTarget(m_merge, fs.x, fs.y);
}
// TODO: m_1x1
@ -192,11 +192,11 @@ public:
m_current = m_merge;
}
bool Interlace(CSize ds, int field, int mode, float yoffset)
bool Interlace(const GSVector2i& ds, int field, int mode, float yoffset)
{
if(!m_weavebob || m_weavebob.GetWidth() != ds.cx || m_weavebob.GetHeight() != ds.cy)
if(!m_weavebob || m_weavebob.GetWidth() != ds.x || m_weavebob.GetHeight() != ds.y)
{
CreateRenderTarget(m_weavebob, ds.cx, ds.cy);
CreateRenderTarget(m_weavebob, ds.x, ds.y);
}
if(mode == 0 || mode == 2) // weave or blend
@ -209,9 +209,9 @@ public:
{
// blend
if(!m_blend || m_blend.GetWidth() != ds.cx || m_blend.GetHeight() != ds.cy)
if(!m_blend || m_blend.GetWidth() != ds.x || m_blend.GetHeight() != ds.y)
{
CreateRenderTarget(m_blend, ds.cx, ds.cy);
CreateRenderTarget(m_blend, ds.x, ds.y);
}
DoInterlace(m_weavebob, m_blend, 2, false, 0);

View File

@ -80,7 +80,7 @@ bool GSDevice10::Create(HWND hWnd, bool vsync)
scd.SampleDesc.Quality = 0;
scd.Windowed = TRUE;
UINT flags = 0;
uint32 flags = 0;
#ifdef DEBUG
flags |= D3D10_CREATE_DEVICE_DEBUG;
@ -256,15 +256,15 @@ bool GSDevice10::Reset(int w, int h, bool fs)
return true;
}
void GSDevice10::Present(const CRect& r)
void GSDevice10::Present(const GSVector4i& r)
{
CRect cr;
GSVector4i cr;
GetClientRect(m_hWnd, &cr);
GetClientRect(m_hWnd, cr);
if(m_backbuffer.GetWidth() != cr.Width() || m_backbuffer.GetHeight() != cr.Height())
if(m_backbuffer.GetWidth() != cr.width() || m_backbuffer.GetHeight() != cr.height())
{
Reset(cr.Width(), cr.Height(), false);
Reset(cr.width(), cr.height(), false);
}
float color[4] = {0, 0, 0, 0};
@ -306,13 +306,13 @@ void GSDevice10::Draw(const string& s)
OMSetRenderTargets(m_backbuffer, NULL);
CRect r(0, 0, m_backbuffer.GetWidth(), m_backbuffer.GetHeight());
GSVector4i r(0, 0, m_backbuffer.GetWidth(), m_backbuffer.GetHeight());
D3DCOLOR c = D3DCOLOR_ARGB(255, 0, 255, 0);
if(m_font->DrawText(NULL, str, -1, &r, DT_CALCRECT|DT_LEFT|DT_WORDBREAK, c))
if(m_font->DrawText(NULL, str, -1, r, DT_CALCRECT|DT_LEFT|DT_WORDBREAK, c))
{
m_font->DrawText(NULL, str, -1, &r, DT_LEFT|DT_WORDBREAK, c);
m_font->DrawText(NULL, str, -1, r, DT_LEFT|DT_WORDBREAK, c);
}
EndScene();
@ -360,7 +360,7 @@ void GSDevice10::ClearRenderTarget(Texture& t, const GSVector4& c)
m_dev->ClearRenderTargetView(t, c.v);
}
void GSDevice10::ClearRenderTarget(Texture& t, DWORD c)
void GSDevice10::ClearRenderTarget(Texture& t, uint32 c)
{
GSVector4 color = GSVector4(c) * (1.0f / 255);
@ -372,7 +372,7 @@ void GSDevice10::ClearDepth(Texture& t, float c)
m_dev->ClearDepthStencilView(t, D3D10_CLEAR_DEPTH, c, 0);
}
void GSDevice10::ClearStencil(Texture& t, BYTE c)
void GSDevice10::ClearStencil(Texture& t, uint8 c)
{
m_dev->ClearDepthStencilView(t, D3D10_CLEAR_STENCIL, 0, c);
}
@ -487,11 +487,11 @@ void GSDevice10::DoInterlace(Texture& st, Texture& dt, int shader, bool linear,
StretchRect(st, sr, dt, dr, m_interlace.ps[shader], m_interlace.cb, linear);
}
void GSDevice10::IASetVertexBuffer(ID3D10Buffer* vb, UINT stride)
void GSDevice10::IASetVertexBuffer(ID3D10Buffer* vb, size_t stride)
{
if(m_vb != vb || m_vb_stride != stride)
{
UINT offset = 0;
uint32 offset = 0;
m_dev->IASetVertexBuffers(0, 1, &vb, &stride, &offset);
@ -590,9 +590,9 @@ void GSDevice10::PSSetSamplerState(ID3D10SamplerState* ss0, ID3D10SamplerState*
}
}
void GSDevice10::RSSet(int width, int height, const RECT* scissor)
void GSDevice10::RSSet(int width, int height, const GSVector4i* scissor)
{
if(m_viewport.cx != width || m_viewport.cy != height)
if(m_viewport.x != width || m_viewport.y != height)
{
D3D10_VIEWPORT vp;
@ -607,20 +607,20 @@ void GSDevice10::RSSet(int width, int height, const RECT* scissor)
m_dev->RSSetViewports(1, &vp);
m_viewport = CSize(width, height);
m_viewport = GSVector2i(width, height);
}
CRect r = scissor ? *scissor : CRect(0, 0, width, height);
GSVector4i r = scissor ? *scissor : GSVector4i(0, 0, width, height);
if(m_scissor != r)
if(!m_scissor.eq(r))
{
m_dev->RSSetScissorRects(1, &r);
m_dev->RSSetScissorRects(1, r);
m_scissor = r;
}
}
void GSDevice10::OMSetDepthStencilState(ID3D10DepthStencilState* dss, UINT sref)
void GSDevice10::OMSetDepthStencilState(ID3D10DepthStencilState* dss, uint8 sref)
{
if(m_dss != dss || m_sref != sref)
{
@ -655,7 +655,7 @@ void GSDevice10::OMSetRenderTargets(ID3D10RenderTargetView* rtv, ID3D10DepthSten
}
}
void GSDevice10::DrawPrimitive(UINT count, UINT start)
void GSDevice10::DrawPrimitive(uint32 count, uint32 start)
{
m_dev->Draw(count, start);
}
@ -735,7 +735,7 @@ void GSDevice10::StretchRect(Texture& st, const GSVector4& sr, Texture& dt, cons
EndScene();
}
HRESULT GSDevice10::CompileShader(UINT id, const string& entry, D3D10_SHADER_MACRO* macro, ID3D10VertexShader** ps, D3D10_INPUT_ELEMENT_DESC* layout, int count, ID3D10InputLayout** il)
HRESULT GSDevice10::CompileShader(uint32 id, const string& entry, D3D10_SHADER_MACRO* macro, ID3D10VertexShader** ps, D3D10_INPUT_ELEMENT_DESC* layout, int count, ID3D10InputLayout** il)
{
HRESULT hr;
@ -753,7 +753,7 @@ HRESULT GSDevice10::CompileShader(UINT id, const string& entry, D3D10_SHADER_MAC
return hr;
}
hr = m_dev->CreateVertexShader((DWORD*)shader->GetBufferPointer(), shader->GetBufferSize(), ps);
hr = m_dev->CreateVertexShader((void*)shader->GetBufferPointer(), shader->GetBufferSize(), ps);
if(FAILED(hr))
{
@ -770,7 +770,7 @@ HRESULT GSDevice10::CompileShader(UINT id, const string& entry, D3D10_SHADER_MAC
return hr;
}
HRESULT GSDevice10::CompileShader(UINT id, const string& entry, D3D10_SHADER_MACRO* macro, ID3D10GeometryShader** gs)
HRESULT GSDevice10::CompileShader(uint32 id, const string& entry, D3D10_SHADER_MACRO* macro, ID3D10GeometryShader** gs)
{
HRESULT hr;
@ -788,7 +788,7 @@ HRESULT GSDevice10::CompileShader(UINT id, const string& entry, D3D10_SHADER_MAC
return hr;
}
hr = m_dev->CreateGeometryShader((DWORD*)shader->GetBufferPointer(), shader->GetBufferSize(), gs);
hr = m_dev->CreateGeometryShader((void*)shader->GetBufferPointer(), shader->GetBufferSize(), gs);
if(FAILED(hr))
{
@ -798,7 +798,7 @@ HRESULT GSDevice10::CompileShader(UINT id, const string& entry, D3D10_SHADER_MAC
return hr;
}
HRESULT GSDevice10::CompileShader(UINT id, const string& entry, D3D10_SHADER_MACRO* macro, ID3D10PixelShader** ps)
HRESULT GSDevice10::CompileShader(uint32 id, const string& entry, D3D10_SHADER_MACRO* macro, ID3D10PixelShader** ps)
{
HRESULT hr;
@ -816,7 +816,7 @@ HRESULT GSDevice10::CompileShader(UINT id, const string& entry, D3D10_SHADER_MAC
return hr;
}
hr = m_dev->CreatePixelShader((DWORD*)shader->GetBufferPointer(), shader->GetBufferSize(), ps);
hr = m_dev->CreatePixelShader((void*)shader->GetBufferPointer(), shader->GetBufferSize(), ps);
if(FAILED(hr))
{

View File

@ -33,8 +33,8 @@ private:
// state cache
ID3D10Buffer* m_vb;
UINT m_vb_count;
UINT m_vb_stride;
int m_vb_count;
size_t m_vb_stride;
ID3D10InputLayout* m_layout;
D3D10_PRIMITIVE_TOPOLOGY m_topology;
ID3D10VertexShader* m_vs;
@ -44,10 +44,10 @@ private:
ID3D10PixelShader* m_ps;
ID3D10Buffer* m_ps_cb;
ID3D10SamplerState* m_ps_ss[2];
CSize m_viewport;
CRect m_scissor;
GSVector2i m_viewport;
GSVector4i m_scissor;
ID3D10DepthStencilState* m_dss;
UINT m_sref;
uint8 m_sref;
ID3D10BlendState* m_bs;
float m_bf;
ID3D10RenderTargetView* m_rtv;
@ -100,16 +100,16 @@ public:
bool Create(HWND hWnd, bool vsync);
bool Reset(int w, int h, bool fs);
bool IsLost() {return false;}
void Present(const CRect& r);
void Present(const GSVector4i& r);
void BeginScene();
void EndScene();
void Draw(const string& s);
bool CopyOffscreen(Texture& src, const GSVector4& sr, Texture& dst, int w, int h, int format = 0);
void ClearRenderTarget(Texture& t, const GSVector4& c);
void ClearRenderTarget(Texture& t, DWORD c);
void ClearRenderTarget(Texture& t, uint32 c);
void ClearDepth(Texture& t, float c);
void ClearStencil(Texture& t, BYTE c);
void ClearStencil(Texture& t, uint8 c);
bool CreateRenderTarget(Texture& t, int w, int h, int format = 0);
bool CreateDepthStencil(Texture& t, int w, int h, int format = 0);
@ -119,7 +119,7 @@ public:
ID3D10Device* operator->() {return m_dev;}
operator ID3D10Device*() {return m_dev;}
void IASetVertexBuffer(ID3D10Buffer* vb, UINT stride);
void IASetVertexBuffer(ID3D10Buffer* vb, size_t stride);
void IASetInputLayout(ID3D10InputLayout* layout);
void IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY topology);
void VSSetShader(ID3D10VertexShader* vs, ID3D10Buffer* vs_cb);
@ -127,18 +127,18 @@ public:
void PSSetShaderResources(ID3D10ShaderResourceView* srv0, ID3D10ShaderResourceView* srv1);
void PSSetShader(ID3D10PixelShader* ps, ID3D10Buffer* ps_cb);
void PSSetSamplerState(ID3D10SamplerState* ss0, ID3D10SamplerState* ss1);
void RSSet(int width, int height, const RECT* scissor = NULL);
void OMSetDepthStencilState(ID3D10DepthStencilState* dss, UINT sref);
void RSSet(int width, int height, const GSVector4i* scissor = NULL);
void OMSetDepthStencilState(ID3D10DepthStencilState* dss, uint8 sref);
void OMSetBlendState(ID3D10BlendState* bs, float bf);
void OMSetRenderTargets(ID3D10RenderTargetView* rtv, ID3D10DepthStencilView* dsv);
void DrawPrimitive(UINT count, UINT start = 0);
void DrawPrimitive(uint32 count, uint32 start = 0);
void StretchRect(Texture& st, Texture& dt, const GSVector4& dr, bool linear = true);
void StretchRect(Texture& st, const GSVector4& sr, Texture& dt, const GSVector4& dr, bool linear = true);
void StretchRect(Texture& st, const GSVector4& sr, Texture& dt, const GSVector4& dr, ID3D10PixelShader* ps, ID3D10Buffer* ps_cb, bool linear = true);
void StretchRect(Texture& st, const GSVector4& sr, Texture& dt, const GSVector4& dr, ID3D10PixelShader* ps, ID3D10Buffer* ps_cb, ID3D10BlendState* bs, bool linear = true);
HRESULT CompileShader(UINT id, const string& entry, D3D10_SHADER_MACRO* macro, ID3D10VertexShader** vs, D3D10_INPUT_ELEMENT_DESC* layout, int count, ID3D10InputLayout** il);
HRESULT CompileShader(UINT id, const string& entry, D3D10_SHADER_MACRO* macro, ID3D10GeometryShader** gs);
HRESULT CompileShader(UINT id, const string& entry, D3D10_SHADER_MACRO* macro, ID3D10PixelShader** ps);
HRESULT CompileShader(uint32 id, const string& entry, D3D10_SHADER_MACRO* macro, ID3D10VertexShader** vs, D3D10_INPUT_ELEMENT_DESC* layout, int count, ID3D10InputLayout** il);
HRESULT CompileShader(uint32 id, const string& entry, D3D10_SHADER_MACRO* macro, ID3D10GeometryShader** gs);
HRESULT CompileShader(uint32 id, const string& entry, D3D10_SHADER_MACRO* macro, ID3D10PixelShader** ps);
};

View File

@ -112,7 +112,7 @@ bool GSDevice7::Reset(int w, int h, bool fs)
HRGN hrgn = CreateRectRgn(0, 0, w, h);
BYTE buff[1024];
uint8 buff[1024];
GetRegionData(hrgn, sizeof(buff), (RGNDATA*)buff);
@ -129,12 +129,13 @@ bool GSDevice7::Reset(int w, int h, bool fs)
return true;
}
void GSDevice7::Present(const CRect& r)
void GSDevice7::Present(const GSVector4i& r)
{
HRESULT hr;
CRect cr;
GetClientRect(m_hWnd, &cr);
GSVector4i cr;
GetClientRect(m_hWnd, cr);
DDSURFACEDESC2 desc;
memset(&desc, 0, sizeof(desc));
@ -142,9 +143,9 @@ void GSDevice7::Present(const CRect& r)
hr = m_backbuffer->GetSurfaceDesc(&desc);
if(desc.dwWidth != cr.Width() || desc.dwHeight != cr.Height())
if(desc.dwWidth != cr.width() || desc.dwHeight != cr.height())
{
Reset(cr.Width(), cr.Height(), false);
Reset(cr.width(), cr.height(), false);
}
DDBLTFX fx;
@ -156,9 +157,9 @@ void GSDevice7::Present(const CRect& r)
hr = m_backbuffer->Blt(NULL, NULL, NULL, DDBLT_WAIT | DDBLT_COLORFILL, &fx);
CRect r2 = r;
GSVector4i r2 = r;
hr = m_backbuffer->Blt(&r2, m_merge, NULL, DDBLT_WAIT, NULL);
hr = m_backbuffer->Blt(r2, m_merge, NULL, DDBLT_WAIT, NULL);
r2 = cr;
@ -169,7 +170,7 @@ void GSDevice7::Present(const CRect& r)
hr = m_dd->WaitForVerticalBlank(DDWAITVB_BLOCKBEGIN, NULL);
}
hr = m_primary->Blt(&r2, m_backbuffer, &cr, DDBLT_WAIT, NULL);
hr = m_primary->Blt(r2, m_backbuffer, cr, DDBLT_WAIT, NULL);
if(hr == DDERR_SURFACELOST)
{

View File

@ -45,14 +45,14 @@ public:
bool Create(HWND hWnd, bool vsync);
bool Reset(int w, int h, bool fs);
bool IsLost() {return false;}
void Present(const CRect& r);
void Present(const GSVector4i& r);
void BeginScene() {}
void EndScene() {}
void Draw(const string& s) {}
bool CopyOffscreen(Texture& src, const GSVector4& sr, Texture& dst, int w, int h, int format = 0) {return false;}
void ClearRenderTarget(Texture& t, const GSVector4& c) {}
void ClearRenderTarget(Texture& t, DWORD c) {}
void ClearRenderTarget(Texture& t, uint32 c) {}
void ClearDepth(Texture& t, float c) {}
void ClearStencil(Texture& t, BYTE c) {}
void ClearStencil(Texture& t, uint8 c) {}
};

View File

@ -237,7 +237,7 @@ bool GSDevice9::Reset(int w, int h, bool fs)
m_ps_cb = NULL;
m_ps_cb_len = 0;
m_ps_ss = NULL;
m_scissor = CRect(0, 0, 0, 0);
m_scissor = GSVector4i::zero();
m_dss = NULL;
m_sref = 0;
m_bs = NULL;
@ -280,7 +280,7 @@ bool GSDevice9::Reset(int w, int h, bool fs)
if(!m_dev)
{
UINT flags = D3DCREATE_MULTITHREADED | (m_d3dcaps.VertexProcessingCaps ? D3DCREATE_HARDWARE_VERTEXPROCESSING : D3DCREATE_SOFTWARE_VERTEXPROCESSING);
uint32 flags = D3DCREATE_MULTITHREADED | (m_d3dcaps.VertexProcessingCaps ? D3DCREATE_HARDWARE_VERTEXPROCESSING : D3DCREATE_SOFTWARE_VERTEXPROCESSING);
hr = m_d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, m_hWnd, flags, &m_pp, &m_dev);
@ -347,15 +347,15 @@ bool GSDevice9::IsLost()
return hr == D3DERR_DEVICELOST || hr == D3DERR_DEVICENOTRESET;
}
void GSDevice9::Present(const CRect& r)
void GSDevice9::Present(const GSVector4i& r)
{
CRect cr;
GSVector4i cr;
GetClientRect(m_hWnd, &cr);
GetClientRect(m_hWnd, cr);
if(m_backbuffer.GetWidth() != cr.Width() || m_backbuffer.GetHeight() != cr.Height())
if(m_backbuffer.GetWidth() != cr.width() || m_backbuffer.GetHeight() != cr.height())
{
Reset(cr.Width(), cr.Height(), false);
Reset(cr.width(), cr.height(), false);
}
OMSetRenderTargets(m_backbuffer, NULL);
@ -396,13 +396,13 @@ void GSDevice9::Draw(const string& s)
OMSetRenderTargets(m_backbuffer, NULL);
CRect r(0, 0, m_backbuffer.GetWidth(), m_backbuffer.GetHeight());
GSVector4i r(0, 0, m_backbuffer.GetWidth(), m_backbuffer.GetHeight());
D3DCOLOR c = D3DCOLOR_ARGB(255, 0, 255, 0);
if(m_font->DrawText(NULL, str, -1, &r, DT_CALCRECT|DT_LEFT|DT_WORDBREAK, c))
if(m_font->DrawText(NULL, str, -1, r, DT_CALCRECT|DT_LEFT|DT_WORDBREAK, c))
{
m_font->DrawText(NULL, str, -1, &r, DT_LEFT|DT_WORDBREAK, c);
m_font->DrawText(NULL, str, -1, r, DT_LEFT|DT_WORDBREAK, c);
}
EndScene();
@ -447,10 +447,10 @@ bool GSDevice9::CopyOffscreen(Texture& src, const GSVector4& sr, Texture& dst, i
void GSDevice9::ClearRenderTarget(Texture& t, const GSVector4& c)
{
ClearRenderTarget(t, D3DCOLOR_RGBA((BYTE)(c.r * 255 + 0.5f), (BYTE)(c.g * 255 + 0.5f), (BYTE)(c.b * 255 + 0.5f), (BYTE)(c.a * 255 + 0.5f)));
ClearRenderTarget(t, (c * 255 + 0.5f).zyxw().rgba32());
}
void GSDevice9::ClearRenderTarget(Texture& t, DWORD c)
void GSDevice9::ClearRenderTarget(Texture& t, uint32 c)
{
CComPtr<IDirect3DSurface9> surface;
m_dev->GetRenderTarget(0, &surface);
@ -468,7 +468,7 @@ void GSDevice9::ClearDepth(Texture& t, float c)
m_dev->SetDepthStencilSurface(surface);
}
void GSDevice9::ClearStencil(Texture& t, BYTE c)
void GSDevice9::ClearStencil(Texture& t, uint8 c)
{
CComPtr<IDirect3DSurface9> surface;
m_dev->GetDepthStencilSurface(&surface);
@ -580,7 +580,7 @@ void GSDevice9::DoInterlace(Texture& st, Texture& dt, int shader, bool linear, f
StretchRect(st, sr, dt, dr, m_interlace.ps[shader], (const float*)&cb, 1, linear);
}
/*
void GSDevice9::IASetVertexBuffer(IDirect3DVertexBuffer9* vb, UINT count, const void* vertices, UINT stride)
void GSDevice9::IASetVertexBuffer(IDirect3DVertexBuffer9* vb, uint32 count, const void* vertices, size_t stride)
{
void* data = NULL;
@ -600,7 +600,7 @@ void GSDevice9::IASetVertexBuffer(IDirect3DVertexBuffer9* vb, UINT count, const
}
}
*/
void GSDevice9::IASetVertexBuffer(UINT count, const void* vertices, UINT stride)
void GSDevice9::IASetVertexBuffer(int count, const void* vertices, size_t stride)
{
m_vb_count = count;
m_vb_vertices = vertices;
@ -728,19 +728,19 @@ void GSDevice9::PSSetSamplerState(Direct3DSamplerState9* ss)
}
}
void GSDevice9::RSSet(int width, int height, const RECT* scissor)
void GSDevice9::RSSet(int width, int height, const GSVector4i* scissor)
{
CRect r = scissor ? *scissor : CRect(0, 0, width, height);
GSVector4i r = scissor ? *scissor : GSVector4i(0, 0, width, height);
if(m_scissor != r)
if(!m_scissor.eq(r))
{
m_dev->SetScissorRect(&r);
m_dev->SetScissorRect(r);
m_scissor = r;
}
}
void GSDevice9::OMSetDepthStencilState(Direct3DDepthStencilState9* dss, UINT sref)
void GSDevice9::OMSetDepthStencilState(Direct3DDepthStencilState9* dss, uint32 sref)
{
if(m_dss != dss || m_sref != sref)
{
@ -770,7 +770,7 @@ void GSDevice9::OMSetDepthStencilState(Direct3DDepthStencilState9* dss, UINT sre
}
}
void GSDevice9::OMSetBlendState(Direct3DBlendState9* bs, DWORD bf)
void GSDevice9::OMSetBlendState(Direct3DBlendState9* bs, uint32 bf)
{
if(m_bs != bs || m_bf != bf)
{
@ -914,7 +914,7 @@ void GSDevice9::StretchRect(Texture& st, const GSVector4& sr, Texture& dt, const
// FIXME: D3DXCompileShaderFromResource of d3dx9 v37 (march 2008) calls GetFullPathName on id for some reason and then crashes
static HRESULT LoadShader(UINT id, LPCSTR& data, DWORD& size)
static HRESULT LoadShader(uint32 id, LPCSTR& data, uint32& size)
{
CComPtr<ID3DXBuffer> shader, error;
@ -935,7 +935,7 @@ static HRESULT LoadShader(UINT id, LPCSTR& data, DWORD& size)
return S_OK;
}
HRESULT GSDevice9::CompileShader(UINT id, const string& entry, const D3DXMACRO* macro, IDirect3DVertexShader9** vs, const D3DVERTEXELEMENT9* layout, int count, IDirect3DVertexDeclaration9** il)
HRESULT GSDevice9::CompileShader(uint32 id, const string& entry, const D3DXMACRO* macro, IDirect3DVertexShader9** vs, const D3DVERTEXELEMENT9* layout, int count, IDirect3DVertexDeclaration9** il)
{
const char* target;
@ -959,7 +959,7 @@ HRESULT GSDevice9::CompileShader(UINT id, const string& entry, const D3DXMACRO*
// FIXME: hr = D3DXCompileShaderFromResource(AfxGetResourceHandle(), MAKEINTRESOURCE(id), macro, NULL, entry.c_str(), target, 0, &shader, &error, NULL);
LPCSTR data;
DWORD size;
uint32 size;
hr = LoadShader(id, data, size);
@ -995,10 +995,10 @@ HRESULT GSDevice9::CompileShader(UINT id, const string& entry, const D3DXMACRO*
return S_OK;
}
HRESULT GSDevice9::CompileShader(UINT id, const string& entry, const D3DXMACRO* macro, IDirect3DPixelShader9** ps)
HRESULT GSDevice9::CompileShader(uint32 id, const string& entry, const D3DXMACRO* macro, IDirect3DPixelShader9** ps)
{
const char* target = NULL;
UINT flags = 0;
uint32 flags = 0;
if(m_d3dcaps.PixelShaderVersion >= D3DPS_VERSION(3, 0))
{
@ -1021,7 +1021,7 @@ HRESULT GSDevice9::CompileShader(UINT id, const string& entry, const D3DXMACRO*
// FIXME: hr = D3DXCompileShaderFromResource(AfxGetResourceHandle(), MAKEINTRESOURCE(id), macro, NULL, entry.c_str(), target, flags, &shader, &error, NULL);
LPCSTR data;
DWORD size;
uint32 size;
hr = LoadShader(id, data, size);

View File

@ -67,9 +67,9 @@ private:
// state cache
IDirect3DVertexBuffer9* m_vb;
UINT m_vb_count;
int m_vb_count;
const void* m_vb_vertices;
UINT m_vb_stride;
size_t m_vb_stride;
IDirect3DVertexDeclaration9* m_layout;
D3DPRIMITIVETYPE m_topology;
IDirect3DVertexShader9* m_vs;
@ -80,11 +80,11 @@ private:
float* m_ps_cb;
int m_ps_cb_len;
Direct3DSamplerState9* m_ps_ss;
CRect m_scissor;
GSVector4i m_scissor;
Direct3DDepthStencilState9* m_dss;
UINT m_sref;
uint32 m_sref;
Direct3DBlendState9* m_bs;
DWORD m_bf;
uint32 m_bf;
IDirect3DSurface9* m_rtv;
IDirect3DSurface9* m_dsv;
@ -136,16 +136,16 @@ public:
bool Create(HWND hWnd, bool vsync);
bool Reset(int w, int h, bool fs);
bool IsLost();
void Present(const CRect& r);
void Present(const GSVector4i& r);
void BeginScene();
void EndScene();
void Draw(const string& s);
bool CopyOffscreen(Texture& src, const GSVector4& sr, Texture& dst, int w, int h, int format = 0);
void ClearRenderTarget(Texture& t, const GSVector4& c);
void ClearRenderTarget(Texture& t, DWORD c);
void ClearRenderTarget(Texture& t, uint32 c);
void ClearDepth(Texture& t, float c);
void ClearStencil(Texture& t, BYTE c);
void ClearStencil(Texture& t, uint8 c);
bool CreateRenderTarget(Texture& t, int w, int h, int format = 0);
bool CreateDepthStencil(Texture& t, int w, int h, int format = 0);
@ -155,21 +155,21 @@ public:
IDirect3DDevice9* operator->() {return m_dev;}
operator IDirect3DDevice9*() {return m_dev;}
// TODO: void IASetVertexBuffer(IDirect3DVertexBuffer9* vb, UINT count, const void* vertices, UINT stride);
void IASetVertexBuffer(UINT count, const void* vertices, UINT stride);
// TODO: void IASetVertexBuffer(IDirect3DVertexBuffer9* vb, uint32 count, const void* vertices, size_t stride);
void IASetVertexBuffer(int count, const void* vertices, size_t stride);
void IASetInputLayout(IDirect3DVertexDeclaration9* layout);
void IASetPrimitiveTopology(D3DPRIMITIVETYPE topology);
void VSSetShader(IDirect3DVertexShader9* vs, const float* vs_cb, int vs_cb_len);
void PSSetShaderResources(IDirect3DTexture9* srv0, IDirect3DTexture9* srv1);
void PSSetShader(IDirect3DPixelShader9* ps, const float* ps_cb, int ps_cb_len);
void PSSetSamplerState(Direct3DSamplerState9* ss);
void RSSet(int width, int height, const RECT* scissor = NULL);
void OMSetDepthStencilState(Direct3DDepthStencilState9* dss, UINT sref);
void OMSetBlendState(Direct3DBlendState9* bs, DWORD bf);
void RSSet(int width, int height, const GSVector4i* scissor = NULL);
void OMSetDepthStencilState(Direct3DDepthStencilState9* dss, uint32 sref);
void OMSetBlendState(Direct3DBlendState9* bs, uint32 bf);
void OMSetRenderTargets(IDirect3DSurface9* rtv, IDirect3DSurface9* dsv);
void DrawPrimitive();
template<class T> void IASetVertexBuffer(UINT count, T* vertices)
template<class T> void IASetVertexBuffer(int count, T* vertices)
{
IASetVertexBuffer(count, vertices, sizeof(T));
}
@ -179,8 +179,8 @@ public:
void StretchRect(Texture& st, const GSVector4& sr, Texture& dt, const GSVector4& dr, IDirect3DPixelShader9* ps, const float* ps_cb, int ps_cb_len, bool linear = true);
void StretchRect(Texture& st, const GSVector4& sr, Texture& dt, const GSVector4& dr, IDirect3DPixelShader9* ps, const float* ps_cb, int ps_cb_len, Direct3DBlendState9* bs, bool linear = true);
HRESULT CompileShader(UINT id, const string& entry, const D3DXMACRO* macro, IDirect3DVertexShader9** vs, const D3DVERTEXELEMENT9* layout, int count, IDirect3DVertexDeclaration9** il);
HRESULT CompileShader(UINT id, const string& entry, const D3DXMACRO* macro, IDirect3DPixelShader9** ps);
HRESULT CompileShader(uint32 id, const string& entry, const D3DXMACRO* macro, IDirect3DVertexShader9** vs, const D3DVERTEXELEMENT9* layout, int count, IDirect3DVertexDeclaration9** il);
HRESULT CompileShader(uint32 id, const string& entry, const D3DXMACRO* macro, IDirect3DPixelShader9** ps);
virtual bool IsCurrentRGBA()
{

View File

@ -40,14 +40,14 @@ public:
bool Create(HWND hWnd, bool vsync);
bool Reset(int w, int h, bool fs);
bool IsLost() {return false;}
void Present(const CRect& r) {}
void Present(const GSVector4i& r) {}
void BeginScene() {}
void EndScene() {}
void Draw(const string& s) {}
bool CopyOffscreen(Texture& src, const GSVector4& sr, Texture& dst, int w, int h, int format = 0) {return false;}
void ClearRenderTarget(Texture& t, const GSVector4& c) {}
void ClearRenderTarget(Texture& t, DWORD c) {}
void ClearRenderTarget(Texture& t, uint32 c) {}
void ClearDepth(Texture& t, float c) {}
void ClearStencil(Texture& t, BYTE c) {}
void ClearStencil(Texture& t, uint8 c) {}
};

View File

@ -23,36 +23,41 @@
#include "GSDirtyRect.h"
GSDirtyRect::GSDirtyRect()
: m_psm(PSM_PSMCT32)
, m_rect(0, 0, 0, 0)
: psm(PSM_PSMCT32)
{
left = top = right = bottom = 0;
}
GSDirtyRect::GSDirtyRect(DWORD psm, CRect rect)
GSDirtyRect::GSDirtyRect(const GSVector4i& r, uint32 psm)
: psm(psm)
{
m_psm = psm;
m_rect = rect;
left = r.left;
top = r.top;
right = r.right;
bottom = r.bottom;
}
CRect GSDirtyRect::GetDirtyRect(const GIFRegTEX0& TEX0)
GSVector4i GSDirtyRect::GetDirtyRect(const GIFRegTEX0& TEX0)
{
CRect r = m_rect;
GSVector4i r;
CSize src = GSLocalMemory::m_psm[m_psm].bs;
GSVector2i src = GSLocalMemory::m_psm[psm].bs;
r.left = (r.left) & ~(src.cx-1);
r.right = (r.right + (src.cx-1) /* + 1 */) & ~(src.cx-1);
r.top = (r.top) & ~(src.cy-1);
r.bottom = (r.bottom + (src.cy-1) /* + 1 */) & ~(src.cy-1);
if(m_psm != TEX0.PSM)
if(psm != TEX0.PSM)
{
CSize dst = GSLocalMemory::m_psm[TEX0.PSM].bs;
GSVector2i dst = GSLocalMemory::m_psm[TEX0.PSM].bs;
r.left = MulDiv(m_rect.left, dst.cx, src.cx);
r.right = MulDiv(m_rect.right, dst.cx, src.cx);
r.top = MulDiv(m_rect.top, dst.cy, src.cy);
r.bottom = MulDiv(m_rect.bottom, dst.cy, src.cy);
r.left = MulDiv(left, dst.x, src.x);
r.right = MulDiv(right, dst.x, src.x);
r.top = MulDiv(top, dst.y, src.y);
r.bottom = MulDiv(bottom, dst.y, src.y);
}
else
{
r.left = left & ~(src.x - 1);
r.right = (right + (src.x - 1) /* + 1 */) & ~(src.x - 1);
r.top = top & ~(src.y - 1);
r.bottom = (bottom + (src.y - 1) /* + 1 */) & ~(src.y - 1);
}
return r;
@ -60,19 +65,21 @@ CRect GSDirtyRect::GetDirtyRect(const GIFRegTEX0& TEX0)
//
CRect GSDirtyRectList::GetDirtyRect(const GIFRegTEX0& TEX0, CSize size)
GSVector4i GSDirtyRectList::GetDirtyRectAndClear(const GIFRegTEX0& TEX0, const GSVector2i& size)
{
if(empty())
if(!empty())
{
return CRect(0, 0, 0, 0);
}
CRect r(INT_MAX, INT_MAX, 0, 0);
GSVector4i r(INT_MAX, INT_MAX, 0, 0);
for(list<GSDirtyRect>::iterator i = begin(); i != end(); i++)
{
r |= i->GetDirtyRect(TEX0);
for(list<GSDirtyRect>::iterator i = begin(); i != end(); i++)
{
r = r.runion(i->GetDirtyRect(TEX0));
}
clear();
return r.rintersect(GSVector4i(0, 0, size.x, size.y));
}
return r & CRect(0, 0, size.cx, size.cy);
return GSVector4i::zero();
}

View File

@ -25,18 +25,22 @@
class GSDirtyRect
{
DWORD m_psm;
CRect m_rect;
int left;
int top;
int right;
int bottom;
uint32 psm;
public:
GSDirtyRect();
GSDirtyRect(DWORD psm, CRect rect);
CRect GetDirtyRect(const GIFRegTEX0& TEX0);
GSDirtyRect(const GSVector4i& r, uint32 psm);
GSVector4i GetDirtyRect(const GIFRegTEX0& TEX0);
};
class GSDirtyRectList : public list<GSDirtyRect>
{
public:
GSDirtyRectList() {}
CRect GetDirtyRect(const GIFRegTEX0& TEX0, CSize size);
GSVector4i GetDirtyRectAndClear(const GIFRegTEX0& TEX0, const GSVector2i& size);
};

View File

@ -56,8 +56,8 @@ void GSDrawScanline::BeginDraw(const GSRasterizerData* data, Functions* f)
m_env.zm = GSVector4i(p->zm);
m_env.aref = GSVector4i((int)context->TEST.AREF);
m_env.afix = GSVector4i((int)context->ALPHA.FIX << 7).xxzzlh();
m_env.frb = GSVector4i((int)env.FOGCOL.ai32[0] & 0x00ff00ff);
m_env.fga = GSVector4i((int)(env.FOGCOL.ai32[0] >> 8) & 0x00ff00ff);
m_env.frb = GSVector4i((int)env.FOGCOL.u32[0] & 0x00ff00ff);
m_env.fga = GSVector4i((int)(env.FOGCOL.u32[0] >> 8) & 0x00ff00ff);
m_env.dimx = env.dimx;
if(m_sel.fpsm == 1)
@ -212,34 +212,34 @@ void GSDrawScanline::DrawSolidRect(const GSVector4i& r, const GSVertexSW& v)
// FIXME: sometimes the frame and z buffer may overlap, the outcome is undefined
DWORD m;
uint32 m;
m = m_env.zm.u32[0];
if(m != 0xffffffff)
{
DWORD z = (DWORD)(float)v.p.z;
uint32 z = (uint32)v.p.z;
if(m_sel.zpsm != 2)
{
if(m == 0)
{
DrawSolidRectT<DWORD, false>(m_env.zbr, m_env.zbc[0], r, z, m);
DrawSolidRectT<uint32, false>(m_env.zbr, m_env.zbc[0], r, z, m);
}
else
{
DrawSolidRectT<DWORD, true>(m_env.zbr, m_env.zbc[0], r, z, m);
DrawSolidRectT<uint32, true>(m_env.zbr, m_env.zbc[0], r, z, m);
}
}
else
{
if(m == 0)
{
DrawSolidRectT<WORD, false>(m_env.zbr, m_env.zbc[0], r, z, m);
DrawSolidRectT<uint16, false>(m_env.zbr, m_env.zbc[0], r, z, m);
}
else
{
DrawSolidRectT<WORD, true>(m_env.zbr, m_env.zbc[0], r, z, m);
DrawSolidRectT<uint16, true>(m_env.zbr, m_env.zbc[0], r, z, m);
}
}
}
@ -248,7 +248,7 @@ void GSDrawScanline::DrawSolidRect(const GSVector4i& r, const GSVertexSW& v)
if(m != 0xffffffff)
{
DWORD c = (GSVector4i(v.c) >> 7).rgba32();
uint32 c = (GSVector4i(v.c) >> 7).rgba32();
if(m_state->m_context->FBA.FBA)
{
@ -259,11 +259,11 @@ void GSDrawScanline::DrawSolidRect(const GSVector4i& r, const GSVertexSW& v)
{
if(m == 0)
{
DrawSolidRectT<DWORD, false>(m_env.fbr, m_env.fbc[0], r, c, m);
DrawSolidRectT<uint32, false>(m_env.fbr, m_env.fbc[0], r, c, m);
}
else
{
DrawSolidRectT<DWORD, true>(m_env.fbr, m_env.fbc[0], r, c, m);
DrawSolidRectT<uint32, true>(m_env.fbr, m_env.fbc[0], r, c, m);
}
}
else
@ -272,25 +272,25 @@ void GSDrawScanline::DrawSolidRect(const GSVector4i& r, const GSVertexSW& v)
if(m == 0)
{
DrawSolidRectT<WORD, false>(m_env.fbr, m_env.fbc[0], r, c, m);
DrawSolidRectT<uint16, false>(m_env.fbr, m_env.fbc[0], r, c, m);
}
else
{
DrawSolidRectT<WORD, true>(m_env.fbr, m_env.fbc[0], r, c, m);
DrawSolidRectT<uint16, true>(m_env.fbr, m_env.fbc[0], r, c, m);
}
}
}
}
template<class T, bool masked>
void GSDrawScanline::DrawSolidRectT(const GSVector4i* row, int* col, const GSVector4i& r, DWORD c, DWORD m)
void GSDrawScanline::DrawSolidRectT(const GSVector4i* row, int* col, const GSVector4i& r, uint32 c, uint32 m)
{
if(m == 0xffffffff) return;
GSVector4i color((int)c);
GSVector4i mask((int)m);
if(sizeof(T) == sizeof(WORD))
if(sizeof(T) == sizeof(uint16))
{
color = color.xxzzlh();
mask = mask.xxzzlh();
@ -314,13 +314,13 @@ void GSDrawScanline::DrawSolidRectT(const GSVector4i* row, int* col, const GSVec
}
template<class T, bool masked>
void GSDrawScanline::FillRect(const GSVector4i* row, int* col, const GSVector4i& r, DWORD c, DWORD m)
void GSDrawScanline::FillRect(const GSVector4i* row, int* col, const GSVector4i& r, uint32 c, uint32 m)
{
if(r.x >= r.z) return;
for(int y = r.y; y < r.w; y++)
{
DWORD base = row[y].x;
uint32 base = row[y].x;
for(int x = r.x; x < r.z; x++)
{
@ -338,7 +338,7 @@ void GSDrawScanline::FillBlock(const GSVector4i* row, int* col, const GSVector4i
for(int y = r.y; y < r.w; y += 8)
{
DWORD base = row[y].x;
uint32 base = row[y].x;
for(int x = r.x; x < r.z; x += 8 * 4 / sizeof(T))
{
@ -363,7 +363,7 @@ GSDrawScanline::GSSetupPrimMap::GSSetupPrimMap(GSScanlineEnvironment& env)
{
}
GSSetupPrimCodeGenerator* GSDrawScanline::GSSetupPrimMap::Create(UINT64 key, void* ptr, size_t maxsize)
GSSetupPrimCodeGenerator* GSDrawScanline::GSSetupPrimMap::Create(uint64 key, void* ptr, size_t maxsize)
{
return new GSSetupPrimCodeGenerator(m_env, key, ptr, maxsize);
}
@ -376,7 +376,7 @@ GSDrawScanline::GSDrawScanlineMap::GSDrawScanlineMap(GSScanlineEnvironment& env)
{
}
GSDrawScanlineCodeGenerator* GSDrawScanline::GSDrawScanlineMap::Create(UINT64 key, void* ptr, size_t maxsize)
GSDrawScanlineCodeGenerator* GSDrawScanline::GSDrawScanlineMap::Create(uint64 key, void* ptr, size_t maxsize)
{
return new GSDrawScanlineCodeGenerator(m_env, key, ptr, maxsize);
}

View File

@ -35,24 +35,24 @@ class GSDrawScanline : public GSAlignedClass<16>, public IDrawScanline
//
class GSSetupPrimMap : public GSCodeGeneratorFunctionMap<GSSetupPrimCodeGenerator, UINT64, SetupPrimStaticPtr>
class GSSetupPrimMap : public GSCodeGeneratorFunctionMap<GSSetupPrimCodeGenerator, uint64, SetupPrimStaticPtr>
{
GSScanlineEnvironment& m_env;
public:
GSSetupPrimMap(GSScanlineEnvironment& env);
GSSetupPrimCodeGenerator* Create(UINT64 key, void* ptr, size_t maxsize);
GSSetupPrimCodeGenerator* Create(uint64 key, void* ptr, size_t maxsize);
} m_sp;
//
class GSDrawScanlineMap : public GSCodeGeneratorFunctionMap<GSDrawScanlineCodeGenerator, UINT64, DrawScanlineStaticPtr>
class GSDrawScanlineMap : public GSCodeGeneratorFunctionMap<GSDrawScanlineCodeGenerator, uint64, DrawScanlineStaticPtr>
{
GSScanlineEnvironment& m_env;
public:
GSDrawScanlineMap(GSScanlineEnvironment& env);
GSDrawScanlineCodeGenerator* Create(UINT64 key, void* ptr, size_t maxsize);
GSDrawScanlineCodeGenerator* Create(uint64 key, void* ptr, size_t maxsize);
} m_ds;
//
@ -60,10 +60,10 @@ class GSDrawScanline : public GSAlignedClass<16>, public IDrawScanline
void DrawSolidRect(const GSVector4i& r, const GSVertexSW& v);
template<class T, bool masked>
void DrawSolidRectT(const GSVector4i* row, int* col, const GSVector4i& r, DWORD c, DWORD m);
void DrawSolidRectT(const GSVector4i* row, int* col, const GSVector4i& r, uint32 c, uint32 m);
template<class T, bool masked>
__forceinline void FillRect(const GSVector4i* row, int* col, const GSVector4i& r, DWORD c, DWORD m);
__forceinline void FillRect(const GSVector4i* row, int* col, const GSVector4i& r, uint32 c, uint32 m);
template<class T, bool masked>
__forceinline void FillBlock(const GSVector4i* row, int* col, const GSVector4i& r, const GSVector4i& c, const GSVector4i& m);

View File

@ -875,10 +875,10 @@ void GSDrawScanlineCodeGenerator::SampleTexture()
// xmm1, xmm4, xmm6 = free
// xmm7 = used
// c00 = addr00.gather32_32((const DWORD/BYTE*)tex[, clut]);
// c01 = addr01.gather32_32((const DWORD/BYTE*)tex[, clut]);
// c10 = addr10.gather32_32((const DWORD/BYTE*)tex[, clut]);
// c11 = addr11.gather32_32((const DWORD/BYTE*)tex[, clut]);
// c00 = addr00.gather32_32((const uint32/uint8*)tex[, clut]);
// c01 = addr01.gather32_32((const uint32/uint8*)tex[, clut]);
// c10 = addr10.gather32_32((const uint32/uint8*)tex[, clut]);
// c11 = addr11.gather32_32((const uint32/uint8*)tex[, clut]);
ReadTexel(xmm6, xmm5, xmm1, xmm4);
@ -994,7 +994,7 @@ void GSDrawScanlineCodeGenerator::SampleTexture()
paddd(xmm2, xmm4);
// c00 = addr00.gather32_32((const DWORD/BYTE*)tex[, clut]);
// c00 = addr00.gather32_32((const uint32/uint8*)tex[, clut]);
ReadTexel(xmm5, xmm2, xmm0, xmm1);

View File

@ -36,7 +36,7 @@ GSDump::~GSDump()
Close();
}
void GSDump::Open(const string& fn, DWORD crc, const GSFreezeData& fd, const GSPrivRegSet* regs)
void GSDump::Open(const string& fn, uint32 crc, const GSFreezeData& fd, const GSPrivRegSet* regs)
{
m_gs = fopen((fn + ".gs").c_str(), "wb");
m_obj = fopen((fn + ".obj").c_str(), "wt");
@ -60,7 +60,7 @@ void GSDump::Close()
if(m_obj) {fclose(m_obj); m_obj = NULL;}
}
void GSDump::Transfer(int index, BYTE* mem, size_t size)
void GSDump::Transfer(int index, uint8* mem, size_t size)
{
if(m_gs && size > 0)
{
@ -71,7 +71,7 @@ void GSDump::Transfer(int index, BYTE* mem, size_t size)
}
}
void GSDump::ReadFIFO(UINT32 size)
void GSDump::ReadFIFO(uint32 size)
{
if(m_gs && size > 0)
{

View File

@ -55,10 +55,10 @@ public:
GSDump();
virtual ~GSDump();
void Open(const string& fn, DWORD crc, const GSFreezeData& fd, const GSPrivRegSet* regs);
void Open(const string& fn, uint32 crc, const GSFreezeData& fd, const GSPrivRegSet* regs);
void Close();
void ReadFIFO(UINT32 size);
void Transfer(int index, BYTE* mem, size_t size);
void ReadFIFO(uint32 size);
void Transfer(int index, uint8* mem, size_t size);
void VSync(int field, bool last, const GSPrivRegSet* regs);
void Object(GSVertexSW* vertices, int count, GS_PRIM_CLASS primclass);
operator bool() {return m_gs != NULL;}

View File

@ -158,9 +158,9 @@ public:
template<class CG, class KEY, class VALUE>
class GSCodeGeneratorFunctionMap : public GSFunctionMap<KEY, VALUE>
{
DWORD m_id;
uint32 m_id;
string m_name;
hash_map<UINT64, CG*> m_cgmap;
hash_map<uint64, CG*> m_cgmap;
GSCodeBuffer m_cb;
enum {MAX_SIZE = 4096};
@ -177,7 +177,7 @@ public:
virtual ~GSCodeGeneratorFunctionMap()
{
for(hash_map<UINT64, CG*>::iterator i = m_cgmap.begin(); i != m_cgmap.end(); i++)
for(hash_map<uint64, CG*>::iterator i = m_cgmap.begin(); i != m_cgmap.end(); i++)
{
delete (*i).second;
}
@ -207,7 +207,7 @@ public:
// vtune method registration
string name = format("%s<%016I64x>()", m_name.c_str(), (UINT64)key);
string name = format("%s<%016I64x>()", m_name.c_str(), (uint64)key);
iJIT_Method_Load ml;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -94,7 +94,7 @@ void GSRasterizer::DrawPoint(const GSVertexSW* v, const GSVector4i& scissor)
GSVector4i p(v->p);
if(scissor.x <= p.x && p.x < scissor.z && scissor.y <= p.y && p.y < scissor.w)
if(scissor.left <= p.x && p.x < scissor.right && scissor.top <= p.y && p.y < scissor.bottom)
{
if((p.y % m_threads) == m_id)
{
@ -153,7 +153,7 @@ void GSRasterizer::DrawLine(const GSVertexSW* v, const GSVector4i& scissor)
GSVector4i p(l.p);
if(scissor.y <= p.y && p.y < scissor.w)
if(scissor.top <= p.y && p.y < scissor.bottom)
{
GSVertexSW dscan = dv / dv.p.xxxx();
@ -546,29 +546,9 @@ void GSRasterizer::DrawSprite(const GSVertexSW* vertices, const GSVector4i& scis
GSVector4i r(v[0].p.xyxy(v[1].p).ceil());
int& top = r.y;
int& bottom = r.w;
int& left = r.x;
int& right = r.z;
#if _M_SSE >= 0x401
r = r.sat_i32(scissor);
r = r.rintersect(scissor);
if((r < r.zwzw()).mask() != 0x00ff) return;
#else
if(top < scissor.y) top = scissor.y;
if(bottom > scissor.w) bottom = scissor.w;
if(top >= bottom) return;
if(left < scissor.x) left = scissor.x;
if(right > scissor.z) right = scissor.z;
if(left >= right) return;
#endif
if(r.rempty()) return;
GSVertexSW scan = v[0];
@ -578,7 +558,7 @@ void GSRasterizer::DrawSprite(const GSVertexSW* vertices, const GSVector4i& scis
{
(m_ds->*m_dsf.sr)(r, scan);
m_stats.pixels += (r.z - r.x) * (r.w - r.y);
m_stats.pixels += r.width() * r.height();
}
return;
@ -599,18 +579,18 @@ void GSRasterizer::DrawSprite(const GSVertexSW* vertices, const GSVector4i& scis
dedge.t = (dv.t / dv.p.yyyy()).xyxy(zero).wyww();
dscan.t = (dv.t / dv.p.xxxx()).xyxy(zero).xwww();
if(scan.p.y < (float)top) scan.t += dedge.t * ((float)top - scan.p.y);
if(scan.p.x < (float)left) scan.t += dscan.t * ((float)left - scan.p.x);
if(scan.p.y < (float)r.top) scan.t += dedge.t * ((float)r.top - scan.p.y);
if(scan.p.x < (float)r.left) scan.t += dscan.t * ((float)r.left - scan.p.x);
m_dsf.ssp(v, dscan);
for(; top < bottom; top++, scan.t += dedge.t)
for(; r.top < r.bottom; r.top++, scan.t += dedge.t)
{
if((top % m_threads) == m_id)
if((r.top % m_threads) == m_id)
{
m_dsf.ssl(right, left, top, scan);
m_dsf.ssl(r.right, r.left, r.top, scan);
m_stats.pixels += right - left;
m_stats.pixels += r.width();
}
}
}
@ -681,7 +661,7 @@ void GSRasterizer::DrawEdge(const GSVertexSW& v0, const GSVertexSW& v1, const GS
int xi = x >> 16;
int xf = x & 0xffff;
if(scissor.x <= xi && xi < scissor.z && (xi % m_threads) == m_id)
if(scissor.left <= xi && xi < scissor.right && (xi % m_threads) == m_id)
{
m_stats.pixels++;
@ -709,7 +689,7 @@ void GSRasterizer::DrawEdge(const GSVertexSW& v0, const GSVertexSW& v1, const GS
int xi = (x >> 16) + 1;
int xf = x & 0xffff;
if(scissor.x <= xi && xi < scissor.z && (xi % m_threads) == m_id)
if(scissor.left <= xi && xi < scissor.right && (xi % m_threads) == m_id)
{
m_stats.pixels++;
@ -779,7 +759,7 @@ void GSRasterizer::DrawEdge(const GSVertexSW& v0, const GSVertexSW& v1, const GS
int yi = y >> 16;
int yf = y & 0xffff;
if(scissor.y <= yi && yi < scissor.w && (yi % m_threads) == m_id)
if(scissor.top <= yi && yi < scissor.bottom && (yi % m_threads) == m_id)
{
m_stats.pixels++;
@ -807,7 +787,7 @@ void GSRasterizer::DrawEdge(const GSVertexSW& v0, const GSVertexSW& v1, const GS
int yi = (y >> 16) + 1;
int yf = y & 0xffff;
if(scissor.y <= yi && yi < scissor.w && (yi % m_threads) == m_id)
if(scissor.top <= yi && yi < scissor.bottom && (yi % m_threads) == m_id)
{
m_stats.pixels++;
@ -835,29 +815,17 @@ GSRasterizerMT::GSRasterizerMT(IDrawScanline* ds, int id, int threads, long* syn
: GSRasterizer(ds, id, threads)
, m_sync(sync)
, m_exit(false)
, m_ThreadId(0)
, m_hThread(NULL)
, m_data(NULL)
{
if(id > 0)
{
m_hThread = CreateThread(NULL, 0, StaticThreadProc, (LPVOID)this, 0, &m_ThreadId);
CreateThread();
}
}
GSRasterizerMT::~GSRasterizerMT()
{
if(m_hThread != NULL)
{
m_exit = true;
if(WaitForSingleObject(m_hThread, 5000) != WAIT_OBJECT_0)
{
TerminateThread(m_hThread, 1);
}
CloseHandle(m_hThread);
}
m_exit = true;
}
void GSRasterizerMT::Draw(const GSRasterizerData* data)
@ -870,16 +838,11 @@ void GSRasterizerMT::Draw(const GSRasterizerData* data)
{
m_data = data;
InterlockedBitTestAndSet(m_sync, m_id);
_interlockedbittestandset(m_sync, m_id);
}
}
DWORD WINAPI GSRasterizerMT::StaticThreadProc(LPVOID lpParam)
{
return ((GSRasterizerMT*)lpParam)->ThreadProc();
}
DWORD GSRasterizerMT::ThreadProc()
void GSRasterizerMT::ThreadProc()
{
// _mm_setcsr(MXCSR);
@ -889,15 +852,13 @@ DWORD GSRasterizerMT::ThreadProc()
{
__super::Draw(m_data);
InterlockedBitTestAndReset(m_sync, m_id);
_interlockedbittestandreset(m_sync, m_id);
}
else
{
_mm_pause();
}
}
return 0;
}
//

View File

@ -24,6 +24,7 @@
#include "GS.h"
#include "GSVertexSW.h"
#include "GSFunctionMap.h"
#include "GSThread.h"
__declspec(align(16)) class GSRasterizerData
{
@ -102,17 +103,13 @@ public:
void PrintStats() {m_ds->PrintStats();}
};
class GSRasterizerMT : public GSRasterizer
class GSRasterizerMT : public GSRasterizer, private GSThread
{
long* m_sync;
bool m_exit;
DWORD m_ThreadId;
HANDLE m_hThread;
const GSRasterizerData* m_data;
static DWORD WINAPI StaticThreadProc(LPVOID lpParam);
DWORD ThreadProc();
void ThreadProc();
public:
GSRasterizerMT(IDrawScanline* ds, int id, int threads, long* sync);

View File

@ -95,7 +95,7 @@ public:
GSWnd m_wnd;
public:
GSRendererBase(BYTE* base, bool mt, void (*irq)(), const GSRendererSettings& rs)
GSRendererBase(uint8* base, bool mt, void (*irq)(), const GSRendererSettings& rs)
: GSState(base, mt, irq)
, m_osd(true)
{
@ -125,8 +125,8 @@ protected:
{
bool en[2];
CRect fr[2];
CRect dr[2];
GSVector4i fr[2];
GSVector4i dr[2];
int baseline = INT_MAX;
@ -164,8 +164,8 @@ protected:
if(samesrc && m_regs->PMODE.SLBG == 0 && m_regs->PMODE.MMOD == 1 && m_regs->PMODE.ALP == 0x80)
{
if(fr[0] == fr[1] + CRect(0, 1, 0, 0) && dr[0] == dr[1] + CRect(0, 0, 0, 1)
|| fr[1] == fr[0] + CRect(0, 1, 0, 0) && dr[1] == dr[0] + CRect(0, 0, 0, 1))
if(fr[0].eq(fr[1] + GSVector4i(0, 1, 0, 0)) && dr[0].eq(dr[1] + GSVector4i(0, 0, 0, 1))
|| fr[1].eq(fr[0] + GSVector4i(0, 1, 0, 0)) && dr[1].eq(dr[0] + GSVector4i(0, 0, 0, 1)))
{
// persona 4:
//
@ -195,7 +195,7 @@ protected:
blurdetected = true;
}
else if(dr[0] == dr[1] && (fr[0] == fr[1] + CPoint(0, 1) || fr[1] == fr[0] + CPoint(0, 1)))
else if(dr[0].eq(dr[1]) && (fr[0].eq(fr[1] + GSVector4i(0, 1, 0, 1)) || fr[1].eq(fr[0] + GSVector4i(0, 1, 0, 1))))
{
// dq5:
//
@ -214,8 +214,8 @@ protected:
}
}
CSize fs(0, 0);
CSize ds(0, 0);
GSVector2i fs(0, 0);
GSVector2i ds(0, 0);
Texture tex[2];
@ -238,13 +238,13 @@ protected:
{
if(!en[i] || !tex[i]) continue;
CRect r = fr[i];
GSVector4i r = fr[i];
// overscan hack
if(dr[i].Height() > 512) // hmm
if(dr[i].height() > 512) // hmm
{
int y = GetDeviceSize(i).cy;
int y = GetDeviceRect(i).height();
if(m_regs->SMODE2.INT && m_regs->SMODE2.FFMD) y /= 2;
r.bottom = r.top + y;
}
@ -280,17 +280,16 @@ protected:
dst[i].x = o.x;
dst[i].y = o.y;
dst[i].z = o.x + tex[i].m_scale.x * r.Width();
dst[i].w = o.y + tex[i].m_scale.y * r.Height();
dst[i].z = o.x + tex[i].m_scale.x * r.width();
dst[i].w = o.y + tex[i].m_scale.y * r.height();
fs.cx = max(fs.cx, (int)(dst[i].z + 0.5f));
fs.cy = max(fs.cy, (int)(dst[i].w + 0.5f));
fs.x = max(fs.x, (int)(dst[i].z + 0.5f));
fs.y = max(fs.y, (int)(dst[i].w + 0.5f));
}
ds.cx = fs.cx;
ds.cy = fs.cy;
ds = fs;
if(m_regs->SMODE2.INT && m_regs->SMODE2.FFMD) ds.cy *= 2;
if(m_regs->SMODE2.INT && m_regs->SMODE2.FFMD) ds.y *= 2;
bool slbg = m_regs->PMODE.SLBG;
bool mmod = m_regs->PMODE.MMOD;
@ -331,7 +330,7 @@ protected:
fd.size = 0;
fd.data = NULL;
Freeze(&fd, true);
fd.data = new BYTE[fd.size];
fd.data = new uint8[fd.size];
Freeze(&fd, false);
m_dump.Open(m_snapshot, m_crc, fd, m_regs);
@ -359,7 +358,7 @@ protected:
return;
}
CSize size = m_capture.GetSize();
GSVector2i size = m_capture.GetSize();
Texture current;
@ -367,9 +366,9 @@ protected:
Texture offscreen;
if(m_dev.CopyOffscreen(current, GSVector4(0, 0, 1, 1), offscreen, size.cx, size.cy))
if(m_dev.CopyOffscreen(current, GSVector4(0, 0, 1, 1), offscreen, size.x, size.y))
{
BYTE* bits = NULL;
uint8* bits = NULL;
int pitch = 0;
if(offscreen.Map(&bits, pitch))
@ -412,7 +411,7 @@ public:
GSCapture m_capture;
public:
GSRenderer(BYTE* base, bool mt, void (*irq)(), const GSRendererSettings& rs, bool psrr)
GSRenderer(uint8* base, bool mt, void (*irq)(), const GSRendererSettings& rs, bool psrr)
: GSRendererBase(base, mt, irq, rs)
, m_psrr(psrr)
{
@ -466,12 +465,14 @@ public:
double fps = 1000.0f / m_perfmon.Get(GSPerfMon::Frame);
string interlace = m_regs->SMODE2.INT ? (string("Interlaced ") + (m_regs->SMODE2.FFMD ? "(frame)" : "(field)")) : "Progressive";
string s = m_regs->SMODE2.INT ? (string("Interlaced ") + (m_regs->SMODE2.FFMD ? "(frame)" : "(field)")) : "Progressive";
GSVector4i r = GetDisplayRect();
s_stats = format(
"%I64d | %d x %d | %.2f fps (%d%%) | %s - %s | %s | %d/%d/%d | %d%% CPU | %.2f | %.2f",
m_perfmon.GetFrame(), GetDisplaySize().cx, GetDisplaySize().cy, fps, (int)(100.0 * fps / GetFPS()),
interlace.c_str(),
m_perfmon.GetFrame(), r.width(), r.height(), fps, (int)(100.0 * fps / GetFPS()),
s.c_str(),
GSSettingsDlg::g_interlace[m_interlace].name,
GSSettingsDlg::g_aspectratio[m_aspectratio].name,
(int)m_perfmon.Get(GSPerfMon::Quad),
@ -516,13 +517,11 @@ public:
//
CRect r;
GSVector4i r;
m_wnd.GetClientRect(&r);
m_wnd.GetClientRect(r);
GSUtil::FitRect(r, m_aspectratio);
m_dev.Present(r);
m_dev.Present(r.fit(m_aspectratio));
//
@ -541,7 +540,7 @@ public:
return true;
}
virtual void MinMaxUV(int w, int h, CRect& r) {r = CRect(0, 0, w, h);}
virtual void MinMaxUV(int w, int h, GSVector4i& r) {r = GSVector4i(0, 0, w, h);}
virtual bool CanUpscale() {return !m_nativeres;}
};
@ -603,7 +602,7 @@ protected:
m_maxcount -= 100;
}
template<DWORD prim> __forceinline Vertex* DrawingKick(bool skip, DWORD& count)
template<uint32 prim> __forceinline Vertex* DrawingKick(bool skip, int& count)
{
switch(prim)
{
@ -683,7 +682,7 @@ protected:
virtual void Draw() = 0;
public:
GSRendererT(BYTE* base, bool mt, void (*irq)(), const GSRendererSettings& rs, bool psrr = true)
GSRendererT(uint8* base, bool mt, void (*irq)(), const GSRendererSettings& rs, bool psrr = true)
: GSRenderer<Device>(base, mt, irq, rs, psrr)
, m_count(0)
, m_maxcount(0)

View File

@ -45,7 +45,7 @@ protected:
__super::Reset();
}
void MinMaxUV(int w, int h, CRect& r)
void MinMaxUV(int w, int h, GSVector4i& r)
{
int wms = m_context->CLAMP.WMS;
int wmt = m_context->CLAMP.WMT;
@ -208,18 +208,15 @@ protected:
__assume(0);
}
r = vr;
r = vr + GSVector4i(-1, -1, 1, 1); // one more pixel because of bilinear filtering
r.InflateRect(1, 1); // one more pixel because of bilinear filtering
GSVector2i bs = GSLocalMemory::m_psm[m_context->TEX0.PSM].bs;
GSVector2i bsm(bs.x - 1, bs.y - 1);
CSize bs = GSLocalMemory::m_psm[m_context->TEX0.PSM].bs;
CSize bsm(bs.cx - 1, bs.cy - 1);
r.left = max(r.left & ~bsm.cx, 0);
r.right = min((r.right + bsm.cx) & ~bsm.cx, w);
r.top = max(r.top & ~bsm.cy, 0);
r.bottom = min((r.bottom + bsm.cy) & ~bsm.cy, h);
r.left = max(r.left & ~bsm.x, 0);
r.top = max(r.top & ~bsm.y, 0);
r.right = min((r.right + bsm.x) & ~bsm.x, w);
r.bottom = min((r.bottom + bsm.y) & ~bsm.y, h);
}
void VSync(int field)
@ -275,14 +272,14 @@ protected:
return false;
}
void InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, CRect r)
void InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r)
{
TRACE(_T("[%d] InvalidateVideoMem %d,%d - %d,%d %05x (%d)\n"), (int)m_perfmon.GetFrame(), r.left, r.top, r.right, r.bottom, (int)BITBLTBUF.DBP, (int)BITBLTBUF.DPSM);
m_tc->InvalidateVideoMem(BITBLTBUF, r);
}
void InvalidateLocalMem(const GIFRegBITBLTBUF& BITBLTBUF, CRect r)
void InvalidateLocalMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r)
{
TRACE(_T("[%d] InvalidateLocalMem %d,%d - %d,%d %05x (%d)\n"), (int)m_perfmon.GetFrame(), r.left, r.top, r.right, r.bottom, (int)BITBLTBUF.SBP, (int)BITBLTBUF.SPSM);
@ -410,18 +407,18 @@ protected:
if(m_game.title == CRC::FFXII && m_game.region == CRC::EU)
{
static DWORD* video = NULL;
static uint32* video = NULL;
static bool ok = false;
if(prim == GS_POINTLIST && m_count >= 448*448 && m_count <= 448*512)
if(prim == GS_POINTLIST && m_count >= 448 * 448 && m_count <= 448 * 512)
{
// incoming pixels are stored in columns, one column is 16x512, total res 448x512 or 448x454
if(!video) video = new DWORD[512*512];
if(!video) video = new uint32[512 * 512];
for(int x = 0, i = 0, rows = m_count / 448; x < 448; x += 16)
{
DWORD* dst = &video[x];
uint32* dst = &video[x];
for(int y = 0; y < rows; y++, dst += 512)
{
@ -436,7 +433,7 @@ protected:
return false;
}
else if(prim == GS_LINELIST && m_count == 512*2 && ok)
else if(prim == GS_LINELIST && m_count == 512 * 2 && ok)
{
// normally, this step would copy the video onto screen with 512 texture mapped horizontal lines,
// but we use the stored video data to create a new texture, and replace the lines with two triangles
@ -445,7 +442,7 @@ protected:
m_dev.CreateTexture(*t, 512, 512);
t->Update(CRect(0, 0, 448, 512), video, 512*4);
t->Update(GSVector4i(0, 0, 448, 512), video, 512 * 4);
m_vertices[0] = m_vertices[0];
m_vertices[1] = m_vertices[1];
@ -467,9 +464,9 @@ protected:
if(m_game.title == CRC::FFX)
{
DWORD FBP = m_context->FRAME.Block();
DWORD ZBP = m_context->ZBUF.Block();
DWORD TBP = m_context->TEX0.TBP0;
uint32 FBP = m_context->FRAME.Block();
uint32 ZBP = m_context->ZBUF.Block();
uint32 TBP = m_context->TEX0.TBP0;
if((FBP == 0x00d00 || FBP == 0x00000) && ZBP == 0x02100 && PRIM->TME && TBP == 0x01a00 && m_context->TEX0.PSM == PSM_PSMCT16S)
{
@ -504,8 +501,8 @@ protected:
{
if(prim == GS_POINTLIST && !PRIM->TME)
{
DWORD bp = m_context->FRAME.Block();
DWORD bw = m_context->FRAME.FBW;
uint32 bp = m_context->FRAME.Block();
uint32 bw = m_context->FRAME.FBW;
if(bp >= 0x03f40 && (bp & 0x1f) == 0)
{
@ -551,9 +548,9 @@ protected:
if(m_game.title == CRC::GodOfWar2)
{
DWORD FBP = m_context->FRAME.Block();
DWORD FBW = m_context->FRAME.FBW;
DWORD FPSM = m_context->FRAME.PSM;
uint32 FBP = m_context->FRAME.Block();
uint32 FBW = m_context->FRAME.FBW;
uint32 FPSM = m_context->FRAME.PSM;
if((FBP == 0x00f00 || FBP == 0x00100) && FPSM == PSM_PSMZ24) // ntsc 0xf00, pal 0x100
{
@ -585,8 +582,8 @@ protected:
if(m_game.title == CRC::DBZBT2)
{
DWORD FBP = m_context->FRAME.Block();
DWORD TBP0 = m_context->TEX0.TBP0;
uint32 FBP = m_context->FRAME.Block();
uint32 TBP0 = m_context->TEX0.TBP0;
if(PRIM->TME && (FBP == 0x03c00 && TBP0 == 0x03c80 || FBP == 0x03ac0 && TBP0 == 0x03b40))
{
@ -596,7 +593,7 @@ protected:
BITBLTBUF.SBW = 1;
BITBLTBUF.SPSM = PSM_PSMCT32;
InvalidateLocalMem(BITBLTBUF, CRect(0, 0, 64, 64));
InvalidateLocalMem(BITBLTBUF, GSVector4i(0, 0, 64, 64));
}
}
@ -606,7 +603,7 @@ protected:
if(m_game.title == CRC::MajokkoALaMode2)
{
DWORD FBP = m_context->FRAME.Block();
uint32 FBP = m_context->FRAME.Block();
if(!PRIM->TME && FBP == 0x03f40)
{
@ -616,7 +613,7 @@ protected:
BITBLTBUF.SBW = 1;
BITBLTBUF.SPSM = PSM_PSMCT32;
InvalidateLocalMem(BITBLTBUF, CRect(0, 0, 16, 16));
InvalidateLocalMem(BITBLTBUF, GSVector4i(0, 0, 16, 16));
}
}
@ -629,7 +626,7 @@ protected:
if(m_game.title == CRC::DBZBT2)
{
DWORD FBP = m_context->FRAME.Block();
uint32 FBP = m_context->FRAME.Block();
if(FBP == 0x03c00 || FBP == 0x03ac0)
{
@ -643,7 +640,7 @@ protected:
if(m_game.title == CRC::MajokkoALaMode2)
{
DWORD FBP = m_context->FRAME.Block();
uint32 FBP = m_context->FRAME.Block();
if(FBP == 0x03f40)
{
@ -657,7 +654,7 @@ protected:
if(m_game.title == CRC::TalesOfAbyss)
{
DWORD FBP = m_context->FRAME.Block();
uint32 FBP = m_context->FRAME.Block();
if(FBP == 0x036e0 || FBP == 0x03560 || FBP == 0x038e0)
{
@ -671,7 +668,7 @@ protected:
}
public:
GSRendererHW(BYTE* base, bool mt, void (*irq)(), const GSRendererSettings& rs, bool psrr)
GSRendererHW(uint8* base, bool mt, void (*irq)(), const GSRendererSettings& rs, bool psrr)
: GSRendererT<Device, Vertex>(base, mt, irq, rs, psrr)
, m_width(1024)
, m_height(1024)
@ -692,7 +689,7 @@ public:
delete m_tc;
}
void SetGameCRC(DWORD crc, int options)
void SetGameCRC(uint32 crc, int options)
{
__super::SetGameCRC(crc, options);

View File

@ -24,7 +24,7 @@
#include "GSCrc.h"
#include "resource.h"
GSRendererHW10::GSRendererHW10(BYTE* base, bool mt, void (*irq)(), const GSRendererSettings& rs)
GSRendererHW10::GSRendererHW10(uint8* base, bool mt, void (*irq)(), const GSRendererSettings& rs)
: GSRendererHW<Device, Vertex, TextureCache>(base, mt, irq, rs, true)
{
InitVertexKick<GSRendererHW10>();
@ -70,7 +70,7 @@ bool GSRendererHW10::Create(const string& title)
return true;
}
template<DWORD prim, DWORD tme, DWORD fst>
template<uint32 prim, uint32 tme, uint32 fst>
void GSRendererHW10::VertexKick(bool skip)
{
Vertex& dst = m_vl.AddTail();
@ -83,7 +83,7 @@ void GSRendererHW10::VertexKick(bool skip)
GSVector4::storel(&dst.ST, m_v.GetUV());
}
DWORD count = 0;
int count = 0;
if(Vertex* v = DrawingKick<prim>(skip, count))
{
@ -412,7 +412,7 @@ void GSRendererHW10::Draw(int prim, Texture& rt, Texture& ds, GSTextureCache<Dev
int w = rt.GetWidth();
int h = rt.GetHeight();
CRect scissor = (CRect)GSVector4i(GSVector4(rt.m_scale).xyxy() * context->scissor.in) & CRect(0, 0, w, h);
GSVector4i scissor = GSVector4i(GSVector4(rt.m_scale).xyxy() * context->scissor.in).rintersect(GSVector4i(0, 0, w, h));
//
@ -436,7 +436,7 @@ void GSRendererHW10::Draw(int prim, Texture& rt, Texture& ds, GSTextureCache<Dev
{
ASSERT(!env.PABE.PABE);
static const DWORD iatst[] = {1, 0, 5, 6, 7, 2, 3, 4};
static const uint32 iatst[] = {1, 0, 5, 6, 7, 2, 3, 4};
ps_sel.atst = iatst[ps_sel.atst];
@ -474,7 +474,7 @@ void GSRendererHW10::Draw(int prim, Texture& rt, Texture& ds, GSTextureCache<Dev
m_dev.EndScene();
}
bool GSRendererHW10::WrapZ(DWORD maxz)
bool GSRendererHW10::WrapZ(uint32 maxz)
{
// should only run once if z values are in the z buffer range

View File

@ -32,7 +32,7 @@ class GSRendererHW10 : public GSRendererHW<GSDevice10, GSVertexHW10, GSTextureCa
typedef GSVertexHW10 Vertex;
typedef GSTextureCache10 TextureCache;
bool WrapZ(DWORD maxz);
bool WrapZ(uint32 maxz);
protected:
GSTextureFX10 m_tfx;
@ -48,9 +48,9 @@ protected:
void SetupDATE(Texture& rt, Texture& ds);
public:
GSRendererHW10(BYTE* base, bool mt, void (*irq)(), const GSRendererSettings& rs);
GSRendererHW10(uint8* base, bool mt, void (*irq)(), const GSRendererSettings& rs);
bool Create(const string& title);
template<DWORD prim, DWORD tme, DWORD fst> void VertexKick(bool skip);
template<uint32 prim, uint32 tme, uint32 fst> void VertexKick(bool skip);
};

View File

@ -24,7 +24,7 @@
#include "GSCrc.h"
#include "resource.h"
GSRendererHW9::GSRendererHW9(BYTE* base, bool mt, void (*irq)(), const GSRendererSettings& rs)
GSRendererHW9::GSRendererHW9(uint8* base, bool mt, void (*irq)(), const GSRendererSettings& rs)
: GSRendererHW<Device, Vertex, TextureCache>(base, mt, irq, rs, false)
{
m_fba.enabled = !!AfxGetApp()->GetProfileInt(_T("Settings"), _T("fba"), TRUE);
@ -74,7 +74,7 @@ bool GSRendererHW9::Create(const string& title)
return true;
}
template<DWORD prim, DWORD tme, DWORD fst>
template<uint32 prim, uint32 tme, uint32 fst>
void GSRendererHW9::VertexKick(bool skip)
{
Vertex& dst = m_vl.AddTail();
@ -83,8 +83,8 @@ void GSRendererHW9::VertexKick(bool skip)
dst.p.y = (float)(int)m_v.XYZ.Y;
dst.p.z = (float)m_v.XYZ.Z;
dst.c0 = m_v.RGBAQ.ai32[0];
dst.c1 = m_v.FOG.ai32[1];
dst.c0 = m_v.RGBAQ.u32[0];
dst.c1 = m_v.FOG.u32[1];
if(tme)
{
@ -100,7 +100,7 @@ void GSRendererHW9::VertexKick(bool skip)
}
}
DWORD count = 0;
int count = 0;
if(Vertex* v = DrawingKick<prim>(skip, count))
{
@ -234,7 +234,7 @@ void GSRendererHW9::Draw(int prim, Texture& rt, Texture& ds, GSTextureCache<Devi
om_bsel.wb = (context->FRAME.FBMSK & 0x00ff0000) != 0x00ff0000;
om_bsel.wa = (context->FRAME.FBMSK & 0xff000000) != 0xff000000;
BYTE bf = context->ALPHA.FIX >= 0x80 ? 0xff : (BYTE)(context->ALPHA.FIX * 2);
uint8 bf = context->ALPHA.FIX >= 0x80 ? 0xff : (uint8)(context->ALPHA.FIX * 2);
// vs
@ -386,7 +386,7 @@ void GSRendererHW9::Draw(int prim, Texture& rt, Texture& ds, GSTextureCache<Devi
int w = rt.GetWidth();
int h = rt.GetHeight();
CRect scissor = (CRect)GSVector4i(GSVector4(rt.m_scale).xyxy() * context->scissor.in) & CRect(0, 0, w, h);
GSVector4i scissor = GSVector4i(GSVector4(rt.m_scale).xyxy() * context->scissor.in).rintersect(GSVector4i(0, 0, w, h));
//
@ -410,7 +410,7 @@ void GSRendererHW9::Draw(int prim, Texture& rt, Texture& ds, GSTextureCache<Devi
{
ASSERT(!env.PABE.PABE);
static const DWORD iatst[] = {1, 0, 5, 6, 7, 2, 3, 4};
static const uint32 iatst[] = {1, 0, 5, 6, 7, 2, 3, 4};
ps_sel.atst = iatst[ps_sel.atst];

View File

@ -57,9 +57,9 @@ protected:
void UpdateFBA(Texture& rt);
public:
GSRendererHW9(BYTE* base, bool mt, void (*irq)(), const GSRendererSettings& rs);
GSRendererHW9(uint8* base, bool mt, void (*irq)(), const GSRendererSettings& rs);
bool Create(const string& title);
template<DWORD prim, DWORD tme, DWORD fst> void VertexKick(bool skip);
template<uint32 prim, uint32 tme, uint32 fst> void VertexKick(bool skip);
};

View File

@ -37,13 +37,13 @@ protected:
}
public:
GSRendererNull(BYTE* base, bool mt, void (*irq)(), const GSRendererSettings& rs)
GSRendererNull(uint8* base, bool mt, void (*irq)(), const GSRendererSettings& rs)
: GSRendererT<Device, GSVertexNull>(base, mt, irq, rs)
{
InitVertexKick<GSRendererNull<Device> >();
}
template<DWORD prim, DWORD tme, DWORD fst> void VertexKick(bool skip)
template<uint32 prim, uint32 tme, uint32 fst> void VertexKick(bool skip)
{
}
};

View File

@ -79,16 +79,16 @@ protected:
TEX0.TBW = DISPFB.FBW;
TEX0.PSM = DISPFB.PSM;
CRect r(0, 0, TEX0.TBW * 64, GetFrameRect(i).bottom);
GSVector4i r(0, 0, TEX0.TBW * 64, GetFrameRect(i).bottom);
// TODO: round up bottom
if(m_texture[i].GetWidth() != r.Width() || m_texture[i].GetHeight() != r.Height())
if(m_texture[i].GetWidth() != r.width() || m_texture[i].GetHeight() != r.height())
{
m_texture[i] = Texture();
}
if(!m_texture[i] && !m_dev.CreateTexture(m_texture[i], r.Width(), r.Height()))
if(!m_texture[i] && !m_dev.CreateTexture(m_texture[i], r.width(), r.height()))
{
return false;
}
@ -98,7 +98,7 @@ protected:
CLAMP.WMS = CLAMP.WMT = 1;
// TODO
static BYTE* buff = (BYTE*)_aligned_malloc(1024 * 1024 * 4, 16);
static uint8* buff = (uint8*)_aligned_malloc(1024 * 1024 * 4, 16);
static int pitch = 1024 * 4;
m_mem.ReadTexture(r, buff, pitch, TEX0, m_env.TEXA, CLAMP);
@ -134,9 +134,9 @@ protected:
if(PRIM->TME && context->TEX0.TCC)
{
DWORD bpp = GSLocalMemory::m_psm[context->TEX0.PSM].trbpp;
DWORD cbpp = GSLocalMemory::m_psm[context->TEX0.CPSM].trbpp;
DWORD pal = GSLocalMemory::m_psm[context->TEX0.PSM].pal;
uint32 bpp = GSLocalMemory::m_psm[context->TEX0.PSM].trbpp;
uint32 cbpp = GSLocalMemory::m_psm[context->TEX0.CPSM].trbpp;
uint32 pal = GSLocalMemory::m_psm[context->TEX0.PSM].pal;
if(bpp == 32)
{
@ -177,6 +177,8 @@ protected:
if(a.z > 0xff) a.z = 0xff;
break;
case TFX_HIGHLIGHT2:
a.x = a.y;
a.z = a.w;
break;
default:
__assume(0);
@ -188,7 +190,7 @@ protected:
m_vtrace.m_alpha.valid = true;
}
bool TryAlphaTest(DWORD& fm, DWORD& zm)
bool TryAlphaTest(uint32& fm, uint32& zm)
{
const GSDrawingContext* context = m_context;
@ -440,11 +442,11 @@ protected:
}
*/
CRect r;
int w = 1 << context->TEX0.TW;
int h = 1 << context->TEX0.TH;
GSVector4i r;
MinMaxUV(w, h, r, p.sel.fst);
const GSTextureCacheSW::GSTexture* t = m_tc->Lookup(context->TEX0, env.TEXA, &r);
@ -491,7 +493,7 @@ protected:
if(PRIM->ABE && !context->ALPHA.IsOpaque(amin, amax) || PRIM->AA1)
{
p.sel.abe = PRIM->ABE;
p.sel.ababcd = context->ALPHA.ai32[0];
p.sel.ababcd = context->ALPHA.u32[0];
if(env.PABE.PABE)
{
@ -572,14 +574,14 @@ protected:
{
s = format("c:\\temp1\\_%05d_f%I64d_rt0_%05x_%d.bmp", s_n, frame, m_context->FRAME.Block(), m_context->FRAME.PSM);
m_mem.SaveBMP(s, m_context->FRAME.Block(), m_context->FRAME.FBW, m_context->FRAME.PSM, GetFrameSize().cx, 512);//GetFrameSize(1).cy);
m_mem.SaveBMP(s, m_context->FRAME.Block(), m_context->FRAME.FBW, m_context->FRAME.PSM, GetFrameRect().width(), 512);//GetFrameSize(1).cy);
}
if(s_savez)
{
s = format("c:\\temp1\\_%05d_f%I64d_rz0_%05x_%d.bmp", s_n, frame, m_context->ZBUF.Block(), m_context->ZBUF.PSM);
m_mem.SaveBMP(s, m_context->ZBUF.Block(), m_context->FRAME.FBW, m_context->ZBUF.PSM, GetFrameSize().cx, 512);
m_mem.SaveBMP(s, m_context->ZBUF.Block(), m_context->FRAME.FBW, m_context->ZBUF.PSM, GetFrameRect().width(), 512);
}
s_n++;
@ -604,16 +606,7 @@ protected:
m_perfmon.Put(GSPerfMon::Prim, stats.prims);
m_perfmon.Put(GSPerfMon::Fillrate, stats.pixels);
GSVector4i pos(m_vtrace.m_min.p.xyxy(m_vtrace.m_max.p));
GSVector4i scissor = data.scissor;
CRect r;
r.left = max(scissor.x, min(scissor.z, pos.x));
r.top = max(scissor.y, min(scissor.w, pos.y));
r.right = max(scissor.x, min(scissor.z, pos.z));
r.bottom = max(scissor.y, min(scissor.w, pos.w));
GSVector4i r = GSVector4i(m_vtrace.m_min.p.xyxy(m_vtrace.m_max.p)).rintersect(data.scissor);
GIFRegBITBLTBUF BITBLTBUF;
@ -645,14 +638,14 @@ protected:
{
s = format("c:\\temp1\\_%05d_f%I64d_rt1_%05x_%d.bmp", s_n, frame, m_context->FRAME.Block(), m_context->FRAME.PSM);
m_mem.SaveBMP(s, m_context->FRAME.Block(), m_context->FRAME.FBW, m_context->FRAME.PSM, GetFrameSize().cx, 512);//GetFrameSize(1).cy);
m_mem.SaveBMP(s, m_context->FRAME.Block(), m_context->FRAME.FBW, m_context->FRAME.PSM, GetFrameRect().width(), 512);//GetFrameSize(1).cy);
}
if(s_savez)
{
s = format("c:\\temp1\\_%05d_f%I64d_rz1_%05x_%d.bmp", s_n, frame, m_context->ZBUF.Block(), m_context->ZBUF.PSM);
m_mem.SaveBMP(s, m_context->ZBUF.Block(), m_context->FRAME.FBW, m_context->ZBUF.PSM, GetFrameSize().cx, 512);
m_mem.SaveBMP(s, m_context->ZBUF.Block(), m_context->FRAME.FBW, m_context->ZBUF.PSM, GetFrameRect().width(), 512);
}
s_n++;
@ -668,12 +661,12 @@ protected:
}
}
void InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, CRect r)
void InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r)
{
m_tc->InvalidateVideoMem(BITBLTBUF, r);
}
void MinMaxUV(int w, int h, CRect& r, DWORD fst)
void MinMaxUV(int w, int h, GSVector4i& r, uint32 fst)
{
const GSDrawingContext* context = m_context;
@ -778,13 +771,11 @@ protected:
}
}
r = vr;
r &= CRect(0, 0, w, h);
r = vr.rintersect(GSVector4i(0, 0, w, h));
}
public:
GSRendererSW(BYTE* base, bool mt, void (*irq)(), const GSRendererSettings& rs, int threads)
GSRendererSW(uint8* base, bool mt, void (*irq)(), const GSRendererSettings& rs, int threads)
: GSRendererT(base, mt, irq, rs)
{
m_rl.Create<GSDrawScanline>(this, threads);
@ -799,12 +790,12 @@ public:
delete m_tc;
}
template<DWORD prim, DWORD tme, DWORD fst>
template<uint32 prim, uint32 tme, uint32 fst>
void VertexKick(bool skip)
{
const GSDrawingContext* context = m_context;
GSVector4i xy = GSVector4i::load((int)m_v.XYZ.ai32[0]);
GSVector4i xy = GSVector4i::load((int)m_v.XYZ.u32[0]);
xy = xy.insert16<3>(m_v.FOG.F);
xy = xy.upl16();
@ -814,7 +805,7 @@ public:
v.p = GSVector4(xy) * g_pos_scale;
v.c = GSVector4(GSVector4i::load((int)m_v.RGBAQ.ai32[0]).u8to32() << 7);
v.c = GSVector4(GSVector4i::load((int)m_v.RGBAQ.u32[0]).u8to32() << 7);
if(tme)
{
@ -839,9 +830,9 @@ public:
dst = v;
dst.p.z = (float)min(m_v.XYZ.Z, 0xffffff00); // max value which can survive the DWORD => float => DWORD conversion
dst.p.z = (float)min(m_v.XYZ.Z, 0xffffff00); // max value which can survive the uint32 => float => uint32 conversion
DWORD count = 0;
int count = 0;
if(GSVertexSW* v = DrawingKick<prim>(skip, count))
{
@ -951,7 +942,7 @@ if(!m_dump)
m_count = 2;
UINT32 tmp = PRIM->PRIM;
uint32 tmp = PRIM->PRIM;
PRIM->PRIM = GS_SPRITE;
Flush();

View File

@ -28,63 +28,63 @@ union GSScanlineSelector
{
struct
{
DWORD fpsm:2; // 0
DWORD zpsm:2; // 2
DWORD ztst:2; // 4 (0: off, 1: write, 2: test (ge), 3: test (g))
DWORD atst:3; // 6
DWORD afail:2; // 9
DWORD iip:1; // 11
DWORD tfx:3; // 12
DWORD tcc:1; // 15
DWORD fst:1; // 16
DWORD ltf:1; // 17
DWORD tlu:1; // 18
DWORD fge:1; // 19
DWORD date:1; // 20
DWORD abe:1; // 21
DWORD aba:2; // 22
DWORD abb:2; // 24
DWORD abc:2; // 26
DWORD abd:2; // 28
DWORD pabe:1; // 30
DWORD aa1:1; // 31
uint32 fpsm:2; // 0
uint32 zpsm:2; // 2
uint32 ztst:2; // 4 (0: off, 1: write, 2: test (ge), 3: test (g))
uint32 atst:3; // 6
uint32 afail:2; // 9
uint32 iip:1; // 11
uint32 tfx:3; // 12
uint32 tcc:1; // 15
uint32 fst:1; // 16
uint32 ltf:1; // 17
uint32 tlu:1; // 18
uint32 fge:1; // 19
uint32 date:1; // 20
uint32 abe:1; // 21
uint32 aba:2; // 22
uint32 abb:2; // 24
uint32 abc:2; // 26
uint32 abd:2; // 28
uint32 pabe:1; // 30
uint32 aa1:1; // 31
DWORD fwrite:1; // 32
DWORD ftest:1; // 33
DWORD rfb:1; // 34
DWORD zwrite:1; // 35
DWORD ztest:1; // 36
DWORD zoverflow:1; // 37 (z max >= 0x80000000)
DWORD wms:2; // 38
DWORD wmt:2; // 40
DWORD datm:1; // 42
DWORD colclamp:1; // 43
DWORD fba:1; // 44
DWORD dthe:1; // 45
DWORD sprite:1; // 46
DWORD edge:1; // 47
uint32 fwrite:1; // 32
uint32 ftest:1; // 33
uint32 rfb:1; // 34
uint32 zwrite:1; // 35
uint32 ztest:1; // 36
uint32 zoverflow:1; // 37 (z max >= 0x80000000)
uint32 wms:2; // 38
uint32 wmt:2; // 40
uint32 datm:1; // 42
uint32 colclamp:1; // 43
uint32 fba:1; // 44
uint32 dthe:1; // 45
uint32 sprite:1; // 46
uint32 edge:1; // 47
};
struct
{
DWORD _pad1:22;
DWORD ababcd:8;
DWORD _pad2:2;
DWORD fb:2;
DWORD _pad3:1;
DWORD zb:2;
uint32 _pad1:22;
uint32 ababcd:8;
uint32 _pad2:2;
uint32 fb:2;
uint32 _pad3:1;
uint32 zb:2;
};
struct
{
DWORD lo;
DWORD hi;
uint32 lo;
uint32 hi;
};
UINT64 key;
uint64 key;
operator DWORD() {return lo;}
operator UINT64() {return key;}
operator uint32() {return lo;}
operator uint64() {return key;}
bool IsSolidRect()
{
@ -105,22 +105,22 @@ __declspec(align(16)) struct GSScanlineParam
void* vm;
const void* tex;
const DWORD* clut;
DWORD tw;
const uint32* clut;
uint32 tw;
GSLocalMemory::Offset* fbo;
GSLocalMemory::Offset* zbo;
GSLocalMemory::Offset4* fzbo;
DWORD fm, zm;
uint32 fm, zm;
};
__declspec(align(16)) struct GSScanlineEnvironment
{
void* vm;
const void* tex;
const DWORD* clut;
DWORD tw;
const uint32* clut;
uint32 tw;
GSVector4i* fbr;
GSVector4i* zbr;

View File

@ -165,13 +165,13 @@ BOOL GSSettingsDlg::OnInitDialog()
if(CComPtr<IDirect3D9> d3d = Direct3DCreate9(D3D_SDK_VERSION))
{
UINT ModeWidth = pApp->GetProfileInt(_T("Settings"), _T("ModeWidth"), 0);
UINT ModeHeight = pApp->GetProfileInt(_T("Settings"), _T("ModeHeight"), 0);
UINT ModeRefreshRate = pApp->GetProfileInt(_T("Settings"), _T("ModeRefreshRate"), 0);
uint32 ModeWidth = pApp->GetProfileInt(_T("Settings"), _T("ModeWidth"), 0);
uint32 ModeHeight = pApp->GetProfileInt(_T("Settings"), _T("ModeHeight"), 0);
uint32 ModeRefreshRate = pApp->GetProfileInt(_T("Settings"), _T("ModeRefreshRate"), 0);
UINT nModes = d3d->GetAdapterModeCount(D3DADAPTER_DEFAULT, D3DFMT_X8R8G8B8);
uint32 nModes = d3d->GetAdapterModeCount(D3DADAPTER_DEFAULT, D3DFMT_X8R8G8B8);
for(UINT i = 0; i < nModes; i++)
for(uint32 i = 0; i < nModes; i++)
{
D3DDISPLAYMODE mode;
@ -259,22 +259,22 @@ void GSSettingsDlg::OnOK()
if(m_renderer.GetCurSel() >= 0)
{
pApp->WriteProfileInt(_T("Settings"), _T("Renderer"), (DWORD)m_renderer.GetItemData(m_renderer.GetCurSel()));
pApp->WriteProfileInt(_T("Settings"), _T("Renderer"), (uint32)m_renderer.GetItemData(m_renderer.GetCurSel()));
}
if(m_psversion.GetCurSel() >= 0)
{
pApp->WriteProfileInt(_T("Settings"), _T("PixelShaderVersion2"), (DWORD)m_psversion.GetItemData(m_psversion.GetCurSel()));
pApp->WriteProfileInt(_T("Settings"), _T("PixelShaderVersion2"), (uint32)m_psversion.GetItemData(m_psversion.GetCurSel()));
}
if(m_interlace.GetCurSel() >= 0)
{
pApp->WriteProfileInt(_T("Settings"), _T("Interlace"), (DWORD)m_interlace.GetItemData(m_interlace.GetCurSel()));
pApp->WriteProfileInt(_T("Settings"), _T("Interlace"), (uint32)m_interlace.GetItemData(m_interlace.GetCurSel()));
}
if(m_aspectratio.GetCurSel() >= 0)
{
pApp->WriteProfileInt(_T("Settings"), _T("AspectRatio"), (DWORD)m_aspectratio.GetItemData(m_aspectratio.GetCurSel()));
pApp->WriteProfileInt(_T("Settings"), _T("AspectRatio"), (uint32)m_aspectratio.GetItemData(m_aspectratio.GetCurSel()));
}
pApp->WriteProfileInt(_T("Settings"), _T("filter"), m_filter);

View File

@ -24,7 +24,7 @@
#include "StdAfx.h"
#include "GSSetupPrimCodeGenerator.h"
GSSetupPrimCodeGenerator::GSSetupPrimCodeGenerator(GSScanlineEnvironment& env, UINT64 key, void* ptr, size_t maxsize)
GSSetupPrimCodeGenerator::GSSetupPrimCodeGenerator(GSScanlineEnvironment& env, uint64 key, void* ptr, size_t maxsize)
: CodeGenerator(maxsize, ptr)
, m_env(env)
{

View File

@ -38,7 +38,7 @@ class GSSetupPrimCodeGenerator : public CodeGenerator
GSScanlineEnvironment& m_env;
GSScanlineSelector m_sel;
struct {DWORD z:1, f:1, t:1, c:1;} m_en;
struct {uint32 z:1, f:1, t:1, c:1;} m_en;
void Generate();
@ -47,5 +47,5 @@ class GSSetupPrimCodeGenerator : public CodeGenerator
void Color();
public:
GSSetupPrimCodeGenerator(GSScanlineEnvironment& env, UINT64 key, void* ptr, size_t maxsize);
GSSetupPrimCodeGenerator(GSScanlineEnvironment& env, uint64 key, void* ptr, size_t maxsize);
};

View File

@ -22,7 +22,7 @@
#include "stdafx.h"
#include "GSState.h"
GSState::GSState(BYTE* base, bool mt, void (*irq)())
GSState::GSState(uint8* base, bool mt, void (*irq)())
: m_mt(mt)
, m_irq(irq)
, m_crc(0)
@ -202,112 +202,65 @@ void GSState::ResetHandlers()
m_fpGIFRegHandlers[GIF_A_D_REG_LABEL] = &GSState::GIFRegHandlerLABEL;
}
CPoint GSState::GetDisplayPos(int i)
GSVector4i GSState::GetDisplayRect(int i)
{
ASSERT(i >= 0 && i < 2);
if(i < 0) i = IsEnabled(1) ? 1 : 0;
CPoint p;
GSVector4i r;
p.x = m_regs->DISP[i].DISPLAY.DX / (m_regs->DISP[i].DISPLAY.MAGH + 1);
p.y = m_regs->DISP[i].DISPLAY.DY / (m_regs->DISP[i].DISPLAY.MAGV + 1);
r.left = m_regs->DISP[i].DISPLAY.DX / (m_regs->DISP[i].DISPLAY.MAGH + 1);
r.top = m_regs->DISP[i].DISPLAY.DY / (m_regs->DISP[i].DISPLAY.MAGV + 1);
r.right = r.left + (m_regs->DISP[i].DISPLAY.DW + 1) / (m_regs->DISP[i].DISPLAY.MAGH + 1);
r.bottom = r.top + (m_regs->DISP[i].DISPLAY.DH + 1) / (m_regs->DISP[i].DISPLAY.MAGV + 1);
return p;
return r;
}
CSize GSState::GetDisplaySize(int i)
GSVector4i GSState::GetFrameRect(int i)
{
ASSERT(i >= 0 && i < 2);
if(i < 0) i = IsEnabled(1) ? 1 : 0;
CSize s;
GSVector4i r = GetDisplayRect(i);
s.cx = (m_regs->DISP[i].DISPLAY.DW + 1) / (m_regs->DISP[i].DISPLAY.MAGH + 1);
s.cy = (m_regs->DISP[i].DISPLAY.DH + 1) / (m_regs->DISP[i].DISPLAY.MAGV + 1);
int w = r.width();
int h = r.height();
return s;
if(m_regs->SMODE2.INT && m_regs->SMODE2.FFMD && h > 1) h >>= 1;
r.left = m_regs->DISP[i].DISPFB.DBX;
r.top = m_regs->DISP[i].DISPFB.DBY;
r.right = r.left + w;
r.bottom = r.top + h;
return r;
}
CRect GSState::GetDisplayRect(int i)
{
return CRect(GetDisplayPos(i), GetDisplaySize(i));
}
CSize GSState::GetDisplayPos()
{
return GetDisplayPos(IsEnabled(1) ? 1 : 0);
}
CSize GSState::GetDisplaySize()
{
return GetDisplaySize(IsEnabled(1) ? 1 : 0);
}
CRect GSState::GetDisplayRect()
{
return GetDisplayRect(IsEnabled(1) ? 1 : 0);
}
CPoint GSState::GetFramePos(int i)
{
ASSERT(i >= 0 && i < 2);
return CPoint(m_regs->DISP[i].DISPFB.DBX, m_regs->DISP[i].DISPFB.DBY);
}
CSize GSState::GetFrameSize(int i)
{
CSize s = GetDisplaySize(i);
if(m_regs->SMODE2.INT && m_regs->SMODE2.FFMD && s.cy > 1) s.cy >>= 1;
return s;
}
CRect GSState::GetFrameRect(int i)
{
return CRect(GetFramePos(i), GetFrameSize(i));
}
CSize GSState::GetFramePos()
{
return GetFramePos(IsEnabled(1) ? 1 : 0);
}
CSize GSState::GetFrameSize()
{
return GetFrameSize(IsEnabled(1) ? 1 : 0);
}
CRect GSState::GetFrameRect()
{
return GetFrameRect(IsEnabled(1) ? 1 : 0);
}
CSize GSState::GetDeviceSize(int i)
GSVector4i GSState::GetDeviceRect(int i)
{
// TODO: other params of SMODE1 should affect the true device display size
// TODO2: pal games at 60Hz
CSize s = GetDisplaySize(i);
if(i < 0) i = IsEnabled(1) ? 1 : 0;
if(s.cy == 2 * 416 || s.cy == 2 * 448 || s.cy == 2 * 512)
GSVector4i r = GetDisplayRect(i);
int w = r.width();
int h = r.height();
if(h == 2 * 416 || h == 2 * 448 || h == 2 * 512)
{
s.cy /= 2;
h /= 2;
}
else
{
s.cy = (m_regs->SMODE1.CMOD & 1) ? 512 : 448;
h = (m_regs->SMODE1.CMOD & 1) ? 512 : 448;
}
return s;
return GSVector4i(0, 0, w, h);
}
CSize GSState::GetDeviceSize()
{
return GetDeviceSize(IsEnabled(1) ? 1 : 0);
}
bool GSState::IsEnabled(int i)
{
ASSERT(i >= 0 && i < 2);
@ -349,12 +302,12 @@ void GSState::GIFPackedRegHandlerRGBA(GIFPackedReg* r)
GSVector4i mask = GSVector4i::load(0x0c080400);
GSVector4i v = GSVector4i::load<false>(r).shuffle8(mask);
m_v.RGBAQ.ai32[0] = (UINT32)GSVector4i::store(v);
m_v.RGBAQ.u32[0] = (uint32)GSVector4i::store(v);
#elif _M_SSE >= 0x200
GSVector4i v = GSVector4i::load<false>(r) & GSVector4i::x000000ff();
m_v.RGBAQ.ai32[0] = v.rgba32();
m_v.RGBAQ.u32[0] = v.rgba32();
#else
@ -372,12 +325,12 @@ void GSState::GIFPackedRegHandlerSTQ(GIFPackedReg* r)
{
#if defined(_M_AMD64)
m_v.ST.i64 = r->ai64[0];
m_v.ST.u64 = r->u64[0];
#elif _M_SSE >= 0x200
GSVector4i v = GSVector4i::loadl(r);
GSVector4i::storel(&m_v.ST.i64, v);
GSVector4i::storel(&m_v.ST.u64, v);
#else
@ -394,7 +347,7 @@ void GSState::GIFPackedRegHandlerUV(GIFPackedReg* r)
#if _M_SSE >= 0x200
GSVector4i v = GSVector4i::loadl(r) & GSVector4i::x00003fff();
m_v.UV.ai32[0] = (UINT32)GSVector4i::store(v.ps32(v));
m_v.UV.u32[0] = (uint32)GSVector4i::store(v.ps32(v));
#else
@ -425,12 +378,12 @@ void GSState::GIFPackedRegHandlerXYZ2(GIFPackedReg* r)
template<int i> void GSState::GIFPackedRegHandlerTEX0(GIFPackedReg* r)
{
GIFRegHandlerTEX0<i>((GIFReg*)&r->ai64[0]);
GIFRegHandlerTEX0<i>((GIFReg*)&r->u64[0]);
}
template<int i> void GSState::GIFPackedRegHandlerCLAMP(GIFPackedReg* r)
{
GIFRegHandlerCLAMP<i>((GIFReg*)&r->ai64[0]);
GIFRegHandlerCLAMP<i>((GIFReg*)&r->u64[0]);
}
void GSState::GIFPackedRegHandlerFOG(GIFPackedReg* r)
@ -440,17 +393,17 @@ void GSState::GIFPackedRegHandlerFOG(GIFPackedReg* r)
void GSState::GIFPackedRegHandlerXYZF3(GIFPackedReg* r)
{
GIFRegHandlerXYZF3((GIFReg*)&r->ai64[0]);
GIFRegHandlerXYZF3((GIFReg*)&r->u64[0]);
}
void GSState::GIFPackedRegHandlerXYZ3(GIFPackedReg* r)
{
GIFRegHandlerXYZ3((GIFReg*)&r->ai64[0]);
GIFRegHandlerXYZ3((GIFReg*)&r->u64[0]);
}
void GSState::GIFPackedRegHandlerA_D(GIFPackedReg* r)
{
(this->*m_fpGIFRegHandlers[(BYTE)r->A_D.ADDR])(&r->r);
(this->*m_fpGIFRegHandlers[r->A_D.ADDR])(&r->r);
}
void GSState::GIFPackedRegHandlerNOP(GIFPackedReg* r)
@ -470,7 +423,7 @@ void GSState::GIFRegHandlerPRIM(GIFReg* r)
if(GSUtil::GetPrimClass(m_env.PRIM.PRIM) == GSUtil::GetPrimClass(r->PRIM.PRIM))
{
if(((m_env.PRIM.i64 ^ r->PRIM.i64) & ~7) != 0)
if(((m_env.PRIM.u64 ^ r->PRIM.u64) & ~7) != 0)
{
Flush();
}
@ -502,7 +455,7 @@ void GSState::GIFRegHandlerST(GIFReg* r)
void GSState::GIFRegHandlerUV(GIFReg* r)
{
m_v.UV.ai32[0] = r->UV.ai32[0] & 0x3fff3fff;
m_v.UV.u32[0] = r->UV.u32[0] & 0x3fff3fff;
}
void GSState::GIFRegHandlerXYZF2(GIFReg* r)
@ -513,9 +466,9 @@ void GSState::GIFRegHandlerXYZF2(GIFReg* r)
m_v.XYZ.Z = r->XYZF.Z;
m_v.FOG.F = r->XYZF.F;
*/
m_v.XYZ.ai32[0] = r->XYZF.ai32[0];
m_v.XYZ.ai32[1] = r->XYZF.ai32[1] & 0x00ffffff;
m_v.FOG.ai32[1] = r->XYZF.ai32[1] & 0xff000000;
m_v.XYZ.u32[0] = r->XYZF.u32[0];
m_v.XYZ.u32[1] = r->XYZF.u32[1] & 0x00ffffff;
m_v.FOG.u32[1] = r->XYZF.u32[1] & 0xff000000;
VertexKick(false);
}
@ -533,7 +486,7 @@ template<int i> void GSState::GIFRegHandlerTEX0(GIFReg* r)
bool wt = m_mem.m_clut.WriteTest(r->TEX0, m_env.TEXCLUT);
if(wt || PRIM->CTXT == i && !(m_env.CTXT[i].TEX0 == (GSVector4i)r->TEX0).alltrue())
if(wt || PRIM->CTXT == i && !((GSVector4i)r->TEX0).eq(m_env.CTXT[i].TEX0))
{
Flush();
}
@ -558,7 +511,7 @@ template<int i> void GSState::GIFRegHandlerTEX0(GIFReg* r)
template<int i> void GSState::GIFRegHandlerCLAMP(GIFReg* r)
{
if(PRIM->CTXT == i && !(m_env.CTXT[i].CLAMP == (GSVector4i)r->CLAMP).alltrue())
if(PRIM->CTXT == i && !((GSVector4i)r->CLAMP).eq(m_env.CTXT[i].CLAMP))
{
Flush();
}
@ -579,9 +532,9 @@ void GSState::GIFRegHandlerXYZF3(GIFReg* r)
m_v.XYZ.Z = r->XYZF.Z;
m_v.FOG.F = r->XYZF.F;
*/
m_v.XYZ.ai32[0] = r->XYZF.ai32[0];
m_v.XYZ.ai32[1] = r->XYZF.ai32[1] & 0x00ffffff;
m_v.FOG.ai32[1] = r->XYZF.ai32[1] & 0xff000000;
m_v.XYZ.u32[0] = r->XYZF.u32[0];
m_v.XYZ.u32[1] = r->XYZF.u32[1] & 0x00ffffff;
m_v.FOG.u32[1] = r->XYZF.u32[1] & 0xff000000;
VertexKick(true);
}
@ -599,7 +552,7 @@ void GSState::GIFRegHandlerNOP(GIFReg* r)
template<int i> void GSState::GIFRegHandlerTEX1(GIFReg* r)
{
if(PRIM->CTXT == i && !(m_env.CTXT[i].TEX1 == (GSVector4i)r->TEX1).alltrue())
if(PRIM->CTXT == i && !((GSVector4i)r->TEX1).eq(m_env.CTXT[i].TEX1))
{
Flush();
}
@ -613,7 +566,7 @@ template<int i> void GSState::GIFRegHandlerTEX2(GIFReg* r)
UINT64 mask = 0xFFFFFFE003F00000ui64; // TEX2 bits
r->i64 = (r->i64 & mask) | (m_env.CTXT[i].TEX0.i64 & ~mask);
r->u64 = (r->u64 & mask) | (m_env.CTXT[i].TEX0.u64 & ~mask);
GIFRegHandlerTEX0<i>(r);
}
@ -622,7 +575,7 @@ template<int i> void GSState::GIFRegHandlerXYOFFSET(GIFReg* r)
{
GSVector4i o = (GSVector4i)r->XYOFFSET & GSVector4i::x0000ffff();
if(!(m_env.CTXT[i].XYOFFSET == o).alltrue())
if(!o.eq(m_env.CTXT[i].XYOFFSET))
{
Flush();
}
@ -634,7 +587,7 @@ template<int i> void GSState::GIFRegHandlerXYOFFSET(GIFReg* r)
void GSState::GIFRegHandlerPRMODECONT(GIFReg* r)
{
if(!(m_env.PRMODECONT == (GSVector4i)r->PRMODECONT).alltrue())
if(!((GSVector4i)r->PRMODECONT).eq(m_env.PRMODECONT))
{
Flush();
}
@ -657,7 +610,7 @@ void GSState::GIFRegHandlerPRMODE(GIFReg* r)
Flush();
}
UINT32 _PRIM = m_env.PRMODE._PRIM;
uint32 _PRIM = m_env.PRMODE._PRIM;
m_env.PRMODE = (GSVector4i)r->PRMODE;
m_env.PRMODE._PRIM = _PRIM;
@ -668,7 +621,7 @@ void GSState::GIFRegHandlerPRMODE(GIFReg* r)
void GSState::GIFRegHandlerTEXCLUT(GIFReg* r)
{
if(!(m_env.TEXCLUT == (GSVector4i)r->TEXCLUT).alltrue())
if(!((GSVector4i)r->TEXCLUT).eq(m_env.TEXCLUT))
{
Flush();
}
@ -678,7 +631,7 @@ void GSState::GIFRegHandlerTEXCLUT(GIFReg* r)
void GSState::GIFRegHandlerSCANMSK(GIFReg* r)
{
if(!(m_env.SCANMSK == (GSVector4i)r->SCANMSK).alltrue())
if(!((GSVector4i)r->SCANMSK).eq(m_env.SCANMSK))
{
Flush();
}
@ -688,7 +641,7 @@ void GSState::GIFRegHandlerSCANMSK(GIFReg* r)
template<int i> void GSState::GIFRegHandlerMIPTBP1(GIFReg* r)
{
if(PRIM->CTXT == i && !(m_env.CTXT[i].MIPTBP1 == (GSVector4i)r->MIPTBP1).alltrue())
if(PRIM->CTXT == i && !((GSVector4i)r->MIPTBP1).eq(m_env.CTXT[i].MIPTBP1))
{
Flush();
}
@ -698,7 +651,7 @@ template<int i> void GSState::GIFRegHandlerMIPTBP1(GIFReg* r)
template<int i> void GSState::GIFRegHandlerMIPTBP2(GIFReg* r)
{
if(PRIM->CTXT == i && !(m_env.CTXT[i].MIPTBP2 == (GSVector4i)r->MIPTBP2).alltrue())
if(PRIM->CTXT == i && !((GSVector4i)r->MIPTBP2).eq(m_env.CTXT[i].MIPTBP2))
{
Flush();
}
@ -708,7 +661,7 @@ template<int i> void GSState::GIFRegHandlerMIPTBP2(GIFReg* r)
void GSState::GIFRegHandlerTEXA(GIFReg* r)
{
if(!(m_env.TEXA == (GSVector4i)r->TEXA).alltrue())
if(!((GSVector4i)r->TEXA).eq(m_env.TEXA))
{
Flush();
}
@ -718,7 +671,7 @@ void GSState::GIFRegHandlerTEXA(GIFReg* r)
void GSState::GIFRegHandlerFOGCOL(GIFReg* r)
{
if(!(m_env.FOGCOL == (GSVector4i)r->FOGCOL).alltrue())
if(!((GSVector4i)r->FOGCOL).eq(m_env.FOGCOL))
{
Flush();
}
@ -735,7 +688,7 @@ void GSState::GIFRegHandlerTEXFLUSH(GIFReg* r)
template<int i> void GSState::GIFRegHandlerSCISSOR(GIFReg* r)
{
if(PRIM->CTXT == i && !(m_env.CTXT[i].SCISSOR == (GSVector4i)r->SCISSOR).alltrue())
if(PRIM->CTXT == i && !((GSVector4i)r->SCISSOR).eq(m_env.CTXT[i].SCISSOR))
{
Flush();
}
@ -752,7 +705,7 @@ template<int i> void GSState::GIFRegHandlerALPHA(GIFReg* r)
ASSERT(r->ALPHA.C != 3);
ASSERT(r->ALPHA.D != 3);
if(PRIM->CTXT == i && !(m_env.CTXT[i].ALPHA == (GSVector4i)r->ALPHA).alltrue())
if(PRIM->CTXT == i && !((GSVector4i)r->ALPHA).eq(m_env.CTXT[i].ALPHA))
{
Flush();
}
@ -761,14 +714,14 @@ template<int i> void GSState::GIFRegHandlerALPHA(GIFReg* r)
// A/B/C/D == 3? => 2
m_env.CTXT[i].ALPHA.ai32[0] = ((~m_env.CTXT[i].ALPHA.ai32[0] >> 1) | 0xAA) & m_env.CTXT[i].ALPHA.ai32[0];
m_env.CTXT[i].ALPHA.u32[0] = ((~m_env.CTXT[i].ALPHA.u32[0] >> 1) | 0xAA) & m_env.CTXT[i].ALPHA.u32[0];
}
void GSState::GIFRegHandlerDIMX(GIFReg* r)
{
bool update = false;
if(!(m_env.DIMX == (GSVector4i)r->DIMX).alltrue())
if(!((GSVector4i)r->DIMX).eq(m_env.DIMX))
{
Flush();
@ -785,7 +738,7 @@ void GSState::GIFRegHandlerDIMX(GIFReg* r)
void GSState::GIFRegHandlerDTHE(GIFReg* r)
{
if(!(m_env.DTHE == (GSVector4i)r->DTHE).alltrue())
if(!((GSVector4i)r->DTHE).eq(m_env.DTHE))
{
Flush();
}
@ -795,7 +748,7 @@ void GSState::GIFRegHandlerDTHE(GIFReg* r)
void GSState::GIFRegHandlerCOLCLAMP(GIFReg* r)
{
if(!(m_env.COLCLAMP == (GSVector4i)r->COLCLAMP).alltrue())
if(!((GSVector4i)r->COLCLAMP).eq(m_env.COLCLAMP))
{
Flush();
}
@ -805,7 +758,7 @@ void GSState::GIFRegHandlerCOLCLAMP(GIFReg* r)
template<int i> void GSState::GIFRegHandlerTEST(GIFReg* r)
{
if(PRIM->CTXT == i && !(m_env.CTXT[i].TEST == (GSVector4i)r->TEST).alltrue())
if(PRIM->CTXT == i && !((GSVector4i)r->TEST).eq(m_env.CTXT[i].TEST))
{
Flush();
}
@ -815,7 +768,7 @@ template<int i> void GSState::GIFRegHandlerTEST(GIFReg* r)
void GSState::GIFRegHandlerPABE(GIFReg* r)
{
if(!(m_env.PABE == (GSVector4i)r->PABE).alltrue())
if(!((GSVector4i)r->PABE).eq(m_env.PABE))
{
Flush();
}
@ -825,7 +778,7 @@ void GSState::GIFRegHandlerPABE(GIFReg* r)
template<int i> void GSState::GIFRegHandlerFBA(GIFReg* r)
{
if(PRIM->CTXT == i && !(m_env.CTXT[i].FBA == (GSVector4i)r->FBA).alltrue())
if(PRIM->CTXT == i && !((GSVector4i)r->FBA).eq(m_env.CTXT[i].FBA))
{
Flush();
}
@ -835,7 +788,7 @@ template<int i> void GSState::GIFRegHandlerFBA(GIFReg* r)
template<int i> void GSState::GIFRegHandlerFRAME(GIFReg* r)
{
if(PRIM->CTXT == i && !(m_env.CTXT[i].FRAME == (GSVector4i)r->FRAME).alltrue())
if(PRIM->CTXT == i && !((GSVector4i)r->FRAME).eq(m_env.CTXT[i].FRAME))
{
Flush();
}
@ -845,7 +798,7 @@ template<int i> void GSState::GIFRegHandlerFRAME(GIFReg* r)
template<int i> void GSState::GIFRegHandlerZBUF(GIFReg* r)
{
if(r->ZBUF.ai32[0] == 0)
if(r->ZBUF.u32[0] == 0)
{
// during startup all regs are cleared to 0 (by the bios or something), so we mask z until this register becomes valid
@ -854,7 +807,7 @@ template<int i> void GSState::GIFRegHandlerZBUF(GIFReg* r)
r->ZBUF.PSM |= 0x30;
if(PRIM->CTXT == i && !(m_env.CTXT[i].ZBUF == (GSVector4i)r->ZBUF).alltrue())
if(PRIM->CTXT == i && !((GSVector4i)r->ZBUF).eq(m_env.CTXT[i].ZBUF))
{
Flush();
}
@ -872,7 +825,7 @@ template<int i> void GSState::GIFRegHandlerZBUF(GIFReg* r)
void GSState::GIFRegHandlerBITBLTBUF(GIFReg* r)
{
if(!(m_env.BITBLTBUF == (GSVector4i)r->BITBLTBUF).alltrue())
if(!((GSVector4i)r->BITBLTBUF).eq(m_env.BITBLTBUF))
{
FlushWrite();
}
@ -892,7 +845,7 @@ void GSState::GIFRegHandlerBITBLTBUF(GIFReg* r)
void GSState::GIFRegHandlerTRXPOS(GIFReg* r)
{
if(!(m_env.TRXPOS == (GSVector4i)r->TRXPOS).alltrue())
if(!((GSVector4i)r->TRXPOS).eq(m_env.TRXPOS))
{
FlushWrite();
}
@ -902,7 +855,7 @@ void GSState::GIFRegHandlerTRXPOS(GIFReg* r)
void GSState::GIFRegHandlerTRXREG(GIFReg* r)
{
if(!(m_env.TRXREG == (GSVector4i)r->TRXREG).alltrue())
if(!((GSVector4i)r->TRXREG).eq(m_env.TRXREG))
{
FlushWrite();
}
@ -937,7 +890,7 @@ void GSState::GIFRegHandlerHWREG(GIFReg* r)
{
ASSERT(m_env.TRXDIR.XDIR == 0); // host => local
Write((BYTE*)r, 8); // hunting ground
Write((uint8*)r, 8); // hunting ground
}
void GSState::GIFRegHandlerSIGNAL(GIFReg* r)
@ -990,7 +943,7 @@ void GSState::FlushWrite()
m_perfmon.Put(GSPerfMon::Swizzle, len);
CRect r;
GSVector4i r;
r.left = m_env.TRXPOS.DSAX;
r.top = y;
@ -1010,7 +963,7 @@ void GSState::FlushWrite()
//
void GSState::Write(BYTE* mem, int len)
void GSState::Write(uint8* mem, int len)
{
int dx = m_env.TRXPOS.DSAX;
int dy = m_env.TRXPOS.DSAY;
@ -1041,7 +994,7 @@ void GSState::Write(BYTE* mem, int len)
m_mem.m_clut.Invalidate();
}
void GSState::Read(BYTE* mem, int len)
void GSState::Read(uint8* mem, int len)
{
if(len <= 0) return;
@ -1059,7 +1012,7 @@ void GSState::Read(BYTE* mem, int len)
if(m_tr.x == sx && m_tr.y == sy)
{
InvalidateLocalMem(m_env.BITBLTBUF, CRect(CPoint(sx, sy), CSize(w, h)));
InvalidateLocalMem(m_env.BITBLTBUF, GSVector4i(sx, sy, sx + w, sy + h));
}
m_mem.ReadImageX(m_tr.x, m_tr.y, mem, len, m_env.BITBLTBUF, m_env.TRXPOS, m_env.TRXREG);
@ -1077,8 +1030,8 @@ void GSState::Move()
int w = m_env.TRXREG.RRW;
int h = m_env.TRXREG.RRH;
InvalidateLocalMem(m_env.BITBLTBUF, CRect(CPoint(sx, sy), CSize(w, h)));
InvalidateVideoMem(m_env.BITBLTBUF, CRect(CPoint(dx, dy), CSize(w, h)));
InvalidateLocalMem(m_env.BITBLTBUF, GSVector4i(sx, sy, sx + w, sy + h));
InvalidateVideoMem(m_env.BITBLTBUF, GSVector4i(dx, dy, dx + w, dy + h));
int xinc = 1;
int yinc = 1;
@ -1102,10 +1055,10 @@ void GSState::Move()
{
for(int y = 0; y < h; y++, sy += yinc, dy += yinc, sx -= xinc * w, dx -= xinc * w)
{
DWORD sbase = spsm.pa(0, sy, m_env.BITBLTBUF.SBP, m_env.BITBLTBUF.SBW);
uint32 sbase = spsm.pa(0, sy, m_env.BITBLTBUF.SBP, m_env.BITBLTBUF.SBW);
int* soffset = spsm.rowOffset[sy & 7];
DWORD dbase = dpsm.pa(0, dy, m_env.BITBLTBUF.DBP, m_env.BITBLTBUF.DBW);
uint32 dbase = dpsm.pa(0, dy, m_env.BITBLTBUF.DBP, m_env.BITBLTBUF.DBW);
int* doffset = dpsm.rowOffset[dy & 7];
for(int x = 0; x < w; x++, sx += xinc, dx += xinc)
@ -1118,10 +1071,10 @@ void GSState::Move()
{
for(int y = 0; y < h; y++, sy += yinc, dy += yinc, sx -= xinc * w, dx -= xinc * w)
{
DWORD sbase = spsm.pa(0, sy, m_env.BITBLTBUF.SBP, m_env.BITBLTBUF.SBW);
uint32 sbase = spsm.pa(0, sy, m_env.BITBLTBUF.SBP, m_env.BITBLTBUF.SBW);
int* soffset = spsm.rowOffset[sy & 7];
DWORD dbase = dpsm.pa(0, dy, m_env.BITBLTBUF.DBP, m_env.BITBLTBUF.DBW);
uint32 dbase = dpsm.pa(0, dy, m_env.BITBLTBUF.DBP, m_env.BITBLTBUF.DBW);
int* doffset = dpsm.rowOffset[dy & 7];
for(int x = 0; x < w; x++, sx += xinc, dx += xinc)
@ -1132,7 +1085,7 @@ void GSState::Move()
}
}
void GSState::SoftReset(BYTE mask)
void GSState::SoftReset(uint32 mask)
{
if(mask & 1) memset(&m_path[0], 0, sizeof(GIFPath));
if(mask & 2) memset(&m_path[1], 0, sizeof(GIFPath));
@ -1143,7 +1096,7 @@ void GSState::SoftReset(BYTE mask)
m_q = 1;
}
void GSState::ReadFIFO(BYTE* mem, int size)
void GSState::ReadFIFO(uint8* mem, int size)
{
GSPerfMonAutoTimer pmat(m_perfmon);
@ -1159,15 +1112,15 @@ void GSState::ReadFIFO(BYTE* mem, int size)
}
}
template void GSState::Transfer<0>(BYTE* mem, UINT32 size);
template void GSState::Transfer<1>(BYTE* mem, UINT32 size);
template void GSState::Transfer<2>(BYTE* mem, UINT32 size);
template void GSState::Transfer<0>(uint8* mem, uint32 size);
template void GSState::Transfer<1>(uint8* mem, uint32 size);
template void GSState::Transfer<2>(uint8* mem, uint32 size);
template<int index> void GSState::Transfer(BYTE* mem, UINT32 size)
template<int index> void GSState::Transfer(uint8* mem, uint32 size)
{
GSPerfMonAutoTimer pmat(m_perfmon);
BYTE* start = mem;
uint8* start = mem;
GIFPath& path = m_path[index];
@ -1192,7 +1145,7 @@ template<int index> void GSState::Transfer(BYTE* mem, UINT32 size)
if(path.tag.PRE && (path.tag.FLG & 2) == 0)
{
GIFReg r;
r.i64 = path.tag.PRIM;
r.u64 = path.tag.PRIM;
(this->*m_fpGIFRegHandlers[GIF_A_D_REG_PRIM])(&r);
}
}
@ -1211,7 +1164,7 @@ template<int index> void GSState::Transfer(BYTE* mem, UINT32 size)
do
{
(this->*m_fpGIFRegHandlers[(BYTE)((GIFPackedReg*)mem)->A_D.ADDR])(&((GIFPackedReg*)mem)->r);
(this->*m_fpGIFRegHandlers[((GIFPackedReg*)mem)->A_D.ADDR])(&((GIFPackedReg*)mem)->r);
mem += sizeof(GIFPackedReg);
}
@ -1221,7 +1174,7 @@ template<int index> void GSState::Transfer(BYTE* mem, UINT32 size)
{
do
{
DWORD reg = path.GetReg();
uint32 reg = path.GetReg();
switch(reg)
{
@ -1343,13 +1296,13 @@ template<int index> void GSState::Transfer(BYTE* mem, UINT32 size)
}
}
template<class T> static void WriteState(BYTE*& dst, T* src, size_t len = sizeof(T))
template<class T> static void WriteState(uint8*& dst, T* src, size_t len = sizeof(T))
{
memcpy(dst, src, len);
dst += len;
}
template<class T> static void ReadState(T* dst, BYTE*& src, size_t len = sizeof(T))
template<class T> static void ReadState(T* dst, uint8*& src, size_t len = sizeof(T))
{
memcpy(dst, src, len);
src += len;
@ -1370,7 +1323,7 @@ int GSState::Freeze(GSFreezeData* fd, bool sizeonly)
Flush();
BYTE* data = fd->data;
uint8* data = fd->data;
WriteState(data, &m_version);
WriteState(data, &m_env.PRIM);
@ -1442,7 +1395,7 @@ int GSState::Defrost(const GSFreezeData* fd)
return -1;
}
BYTE* data = fd->data;
uint8* data = fd->data;
int version;
@ -1495,7 +1448,7 @@ int GSState::Defrost(const GSFreezeData* fd)
if(version <= 4)
{
data += sizeof(DWORD) * 7; // skip
data += sizeof(uint32) * 7; // skip
}
}
@ -1536,7 +1489,7 @@ m_perfmon.SetFrame(5000);
return 0;
}
void GSState::SetGameCRC(DWORD crc, int options)
void GSState::SetGameCRC(uint32 crc, int options)
{
m_crc = crc;
m_options = options;
@ -1608,7 +1561,7 @@ GSState::GSTransferBuffer::GSTransferBuffer()
{
x = y = 0;
start = end = total = 0;
buff = (BYTE*)_aligned_malloc(1024 * 1024 * 4, 16);
buff = (uint8*)_aligned_malloc(1024 * 1024 * 4, 16);
}
GSState::GSTransferBuffer::~GSTransferBuffer()
@ -1653,12 +1606,12 @@ bool GSState::GSTransferBuffer::Update(int tw, int th, int bpp, int& len)
struct GSFrameInfo
{
DWORD FBP;
DWORD FPSM;
DWORD FBMSK;
uint32 FBP;
uint32 FPSM;
uint32 FBMSK;
uint32 TBP0;
uint32 TPSM;
bool TME;
DWORD TBP0;
DWORD TPSM;
};
typedef bool (*GetSkipCount)(const GSFrameInfo& fi, int& skip);

View File

@ -117,7 +117,7 @@ class GSState : public GSAlignedClass<16>
int x, y;
int start, end, total;
bool overflow;
BYTE* buff;
uint8* buff;
GSTransferBuffer();
virtual ~GSTransferBuffer();
@ -204,58 +204,49 @@ public:
GSDrawingContext* m_context;
GSVertex m_v;
float m_q;
DWORD m_vprim;
uint32 m_vprim;
GSPerfMon m_perfmon;
DWORD m_crc;
uint32 m_crc;
int m_options;
int m_frameskip;
CRC::Game m_game;
GSDump m_dump;
public:
GSState(BYTE* base, bool mt, void (*irq)());
GSState(uint8* base, bool mt, void (*irq)());
virtual ~GSState();
void ResetHandlers();
CPoint GetDisplayPos(int i);
CSize GetDisplaySize(int i);
CRect GetDisplayRect(int i);
CSize GetDisplayPos();
CSize GetDisplaySize();
CRect GetDisplayRect();
CPoint GetFramePos(int i);
CSize GetFrameSize(int i);
CRect GetFrameRect(int i);
CSize GetFramePos();
CSize GetFrameSize();
CRect GetFrameRect();
CSize GetDeviceSize(int i);
CSize GetDeviceSize();
GSVector4i GetDisplayRect(int i = -1);
GSVector4i GetFrameRect(int i = -1);
GSVector4i GetDeviceRect(int i = -1);
bool IsEnabled(int i);
int GetFPS();
virtual void Reset();
virtual void Flush();
virtual void FlushPrim() = 0;
virtual void ResetPrim() = 0;
virtual void InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, CRect r) {}
virtual void InvalidateLocalMem(const GIFRegBITBLTBUF& BITBLTBUF, CRect r) {}
virtual void InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r) {}
virtual void InvalidateLocalMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r) {}
virtual void InvalidateTextureCache() {}
void Move();
void Write(BYTE* mem, int len);
void Read(BYTE* mem, int len);
void Write(uint8* mem, int len);
void Read(uint8* mem, int len);
void SoftReset(BYTE mask);
void WriteCSR(UINT32 csr) {m_regs->CSR.ai32[1] = csr;}
void ReadFIFO(BYTE* mem, int size);
template<int index> void Transfer(BYTE* mem, UINT32 size);
void SoftReset(uint32 mask);
void WriteCSR(uint32 csr) {m_regs->CSR.u32[1] = csr;}
void ReadFIFO(uint8* mem, int size);
template<int index> void Transfer(uint8* mem, uint32 size);
int Freeze(GSFreezeData* fd, bool sizeonly);
int Defrost(const GSFreezeData* fd);
void GetLastTag(UINT32* tag) {*tag = m_path3hack; m_path3hack = 0;}
virtual void SetGameCRC(DWORD crc, int options);
void GetLastTag(uint32* tag) {*tag = m_path3hack; m_path3hack = 0;}
virtual void SetGameCRC(uint32 crc, int options);
void SetFrameSkip(int frameskip);
};

View File

@ -22,21 +22,21 @@
#include "StdAfx.h"
#include "GSTables.h"
const BYTE blockTable32[4][8] = {
const uint8 blockTable32[4][8] = {
{ 0, 1, 4, 5, 16, 17, 20, 21},
{ 2, 3, 6, 7, 18, 19, 22, 23},
{ 8, 9, 12, 13, 24, 25, 28, 29},
{ 10, 11, 14, 15, 26, 27, 30, 31}
};
const BYTE blockTable32Z[4][8] = {
const uint8 blockTable32Z[4][8] = {
{ 24, 25, 28, 29, 8, 9, 12, 13},
{ 26, 27, 30, 31, 10, 11, 14, 15},
{ 16, 17, 20, 21, 0, 1, 4, 5},
{ 18, 19, 22, 23, 2, 3, 6, 7}
};
const BYTE blockTable16[8][4] = {
const uint8 blockTable16[8][4] = {
{ 0, 2, 8, 10 },
{ 1, 3, 9, 11 },
{ 4, 6, 12, 14 },
@ -47,7 +47,7 @@ const BYTE blockTable16[8][4] = {
{ 21, 23, 29, 31 }
};
const BYTE blockTable16S[8][4] = {
const uint8 blockTable16S[8][4] = {
{ 0, 2, 16, 18 },
{ 1, 3, 17, 19 },
{ 8, 10, 24, 26 },
@ -58,7 +58,7 @@ const BYTE blockTable16S[8][4] = {
{ 13, 15, 29, 31 }
};
const BYTE blockTable16Z[8][4] = {
const uint8 blockTable16Z[8][4] = {
{ 24, 26, 16, 18 },
{ 25, 27, 17, 19 },
{ 28, 30, 20, 22 },
@ -69,7 +69,7 @@ const BYTE blockTable16Z[8][4] = {
{ 13, 15, 5, 7 }
};
const BYTE blockTable16SZ[8][4] = {
const uint8 blockTable16SZ[8][4] = {
{ 24, 26, 8, 10 },
{ 25, 27, 9, 11 },
{ 16, 18, 0, 2 },
@ -80,14 +80,14 @@ const BYTE blockTable16SZ[8][4] = {
{ 21, 23, 5, 7 }
};
const BYTE blockTable8[4][8] = {
const uint8 blockTable8[4][8] = {
{ 0, 1, 4, 5, 16, 17, 20, 21},
{ 2, 3, 6, 7, 18, 19, 22, 23},
{ 8, 9, 12, 13, 24, 25, 28, 29},
{ 10, 11, 14, 15, 26, 27, 30, 31}
};
const BYTE blockTable4[8][4] = {
const uint8 blockTable4[8][4] = {
{ 0, 2, 8, 10 },
{ 1, 3, 9, 11 },
{ 4, 6, 12, 14 },
@ -98,7 +98,7 @@ const BYTE blockTable4[8][4] = {
{ 21, 23, 29, 31 }
};
const BYTE columnTable32[8][8] = {
const uint8 columnTable32[8][8] = {
{ 0, 1, 4, 5, 8, 9, 12, 13 },
{ 2, 3, 6, 7, 10, 11, 14, 15 },
{ 16, 17, 20, 21, 24, 25, 28, 29 },
@ -109,7 +109,7 @@ const BYTE columnTable32[8][8] = {
{ 50, 51, 54, 55, 58, 59, 62, 63 },
};
const BYTE columnTable16[8][16] = {
const uint8 columnTable16[8][16] = {
{ 0, 2, 8, 10, 16, 18, 24, 26,
1, 3, 9, 11, 17, 19, 25, 27 },
{ 4, 6, 12, 14, 20, 22, 28, 30,
@ -128,7 +128,7 @@ const BYTE columnTable16[8][16] = {
101, 103, 109, 111, 117, 119, 125, 127 },
};
const BYTE columnTable8[16][16] = {
const uint8 columnTable8[16][16] = {
{ 0, 4, 16, 20, 32, 36, 48, 52, // column 0
2, 6, 18, 22, 34, 38, 50, 54 },
{ 8, 12, 24, 28, 40, 44, 56, 60,
@ -163,7 +163,7 @@ const BYTE columnTable8[16][16] = {
203, 207, 219, 223, 235, 239, 251, 255 },
};
const WORD columnTable4[16][32] = {
const uint16 columnTable4[16][32] = {
{ 0, 8, 32, 40, 64, 72, 96, 104, // column 0
2, 10, 34, 42, 66, 74, 98, 106,
4, 12, 36, 44, 68, 76, 100, 108,
@ -230,7 +230,7 @@ const WORD columnTable4[16][32] = {
407, 415, 439, 447, 471, 479, 503, 511 },
};
const BYTE clutTableT32I8[128] =
const uint8 clutTableT32I8[128] =
{
0, 1, 4, 5, 8, 9, 12, 13, 2, 3, 6, 7, 10, 11, 14, 15,
64, 65, 68, 69, 72, 73, 76, 77, 66, 67, 70, 71, 74, 75, 78, 79,
@ -242,13 +242,13 @@ const BYTE clutTableT32I8[128] =
112, 113, 116, 117, 120, 121, 124, 125, 114, 115, 118, 119, 122, 123, 126, 127
};
const BYTE clutTableT32I4[16] =
const uint8 clutTableT32I4[16] =
{
0, 1, 4, 5, 8, 9, 12, 13,
2, 3, 6, 7, 10, 11, 14, 15
};
const BYTE clutTableT16I8[32] =
const uint8 clutTableT16I8[32] =
{
0, 2, 8, 10, 16, 18, 24, 26,
4, 6, 12, 14, 20, 22, 28, 30,
@ -256,7 +256,7 @@ const BYTE clutTableT16I8[32] =
5, 7, 13, 15, 21, 23, 29, 31
};
const BYTE clutTableT16I4[16] =
const uint8 clutTableT16I4[16] =
{
0, 2, 8, 10, 16, 18, 24, 26,
4, 6, 12, 14, 20, 22, 28, 30

View File

@ -21,19 +21,19 @@
#pragma once
extern const BYTE blockTable32[4][8];
extern const BYTE blockTable32Z[4][8];
extern const BYTE blockTable16[8][4];
extern const BYTE blockTable16S[8][4];
extern const BYTE blockTable16Z[8][4];
extern const BYTE blockTable16SZ[8][4];
extern const BYTE blockTable8[4][8];
extern const BYTE blockTable4[8][4];
extern const BYTE columnTable32[8][8];
extern const BYTE columnTable16[8][16];
extern const BYTE columnTable8[16][16];
extern const WORD columnTable4[16][32];
extern const BYTE clutTableT32I8[128];
extern const BYTE clutTableT32I4[16];
extern const BYTE clutTableT16I8[32];
extern const BYTE clutTableT16I4[16];
extern const uint8 blockTable32[4][8];
extern const uint8 blockTable32Z[4][8];
extern const uint8 blockTable16[8][4];
extern const uint8 blockTable16S[8][4];
extern const uint8 blockTable16Z[8][4];
extern const uint8 blockTable16SZ[8][4];
extern const uint8 blockTable8[4][8];
extern const uint8 blockTable4[8][4];
extern const uint8 columnTable32[8][8];
extern const uint8 columnTable16[8][16];
extern const uint8 columnTable8[16][16];
extern const uint16 columnTable4[16][32];
extern const uint8 clutTableT32I8[128];
extern const uint8 clutTableT32I4[16];
extern const uint8 clutTableT16I8[32];
extern const uint8 clutTableT16I4[16];

View File

@ -39,10 +39,10 @@ public:
virtual int GetWidth() const = 0;
virtual int GetHeight() const = 0;
virtual int GetFormat() const = 0;
virtual bool Update(const CRect& r, const void* data, int pitch) = 0;
virtual bool Map(BYTE** bits, int& pitch, const RECT* r = NULL) = 0;
virtual bool Update(const GSVector4i& r, const void* data, int pitch) = 0;
virtual bool Map(uint8** bits, int& pitch) = 0;
virtual void Unmap() = 0;
virtual bool Save(const string& fn, bool dds = false) = 0;
CSize GetSize() {return CSize(GetWidth(), GetHeight());}
GSVector2i GetSize() {return GSVector2i(GetWidth(), GetHeight());}
};

View File

@ -69,7 +69,7 @@ int GSTexture10::GetFormat() const
return m_desc.Format;
}
bool GSTexture10::Update(const CRect& r, const void* data, int pitch)
bool GSTexture10::Update(const GSVector4i& r, const void* data, int pitch)
{
if(m_dev && m_texture)
{
@ -83,7 +83,7 @@ bool GSTexture10::Update(const CRect& r, const void* data, int pitch)
return false;
}
bool GSTexture10::Map(BYTE** bits, int& pitch, const RECT* r)
bool GSTexture10::Map(uint8** bits, int& pitch)
{
if(m_texture)
{
@ -91,7 +91,7 @@ bool GSTexture10::Map(BYTE** bits, int& pitch, const RECT* r)
if(SUCCEEDED(m_texture->Map(0, D3D10_MAP_READ_WRITE, 0, &map)))
{
*bits = (BYTE*)map.pData;
*bits = (uint8*)map.pData;
pitch = (int)map.RowPitch;
return true;
@ -143,14 +143,14 @@ bool GSTexture10::Save(const string& fn, bool dds)
hr = src->Map(0, D3D10_MAP_READ, 0, &sm);
hr = dst->Map(0, D3D10_MAP_WRITE, 0, &dm);
BYTE* s = (BYTE*)sm.pData;
BYTE* d = (BYTE*)dm.pData;
uint8* s = (uint8*)sm.pData;
uint8* d = (uint8*)dm.pData;
for(UINT y = 0; y < desc.Height; y++, s += sm.RowPitch, d += dm.RowPitch)
for(uint32 y = 0; y < desc.Height; y++, s += sm.RowPitch, d += dm.RowPitch)
{
for(UINT x = 0; x < desc.Width; x++)
for(uint32 x = 0; x < desc.Width; x++)
{
((UINT*)d)[x] = (UINT)(((float*)s)[x*2] * UINT_MAX);
((uint32*)d)[x] = (uint32)(((float*)s)[x*2] * UINT_MAX);
}
}

View File

@ -43,8 +43,8 @@ public:
int GetWidth() const;
int GetHeight() const;
int GetFormat() const;
bool Update(const CRect& r, const void* data, int pitch);
bool Map(BYTE** bits, int& pitch, const RECT* r = NULL);
bool Update(const GSVector4i& r, const void* data, int pitch);
bool Map(uint8** bits, int& pitch);
void Unmap();
bool Save(const string& fn, bool dds = false);

View File

@ -80,11 +80,11 @@ int GSTexture7::GetFormat() const
return (int)m_desc.ddpfPixelFormat.dwFourCC;
}
bool GSTexture7::Update(const CRect& r, const void* data, int pitch)
bool GSTexture7::Update(const GSVector4i& r, const void* data, int pitch)
{
HRESULT hr;
CRect r2 = r;
GSVector4i r2 = r;
DDSURFACEDESC2 desc;
@ -92,14 +92,14 @@ bool GSTexture7::Update(const CRect& r, const void* data, int pitch)
desc.dwSize = sizeof(desc);
if(SUCCEEDED(hr = m_system->Lock(&r2, &desc, DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR | DDLOCK_WRITEONLY, NULL)))
if(SUCCEEDED(hr = m_system->Lock(r2, &desc, DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR | DDLOCK_WRITEONLY, NULL)))
{
BYTE* src = (BYTE*)data;
BYTE* dst = (BYTE*)desc.lpSurface;
uint8* src = (uint8*)data;
uint8* dst = (uint8*)desc.lpSurface;
int bytes = min(pitch, desc.lPitch);
for(int i = 0, j = r.Height(); i < j; i++, src += pitch, dst += desc.lPitch)
for(int i = 0, j = r.height(); i < j; i++, src += pitch, dst += desc.lPitch)
{
// memcpy(dst, src, bytes);
@ -120,11 +120,11 @@ bool GSTexture7::Update(const CRect& r, const void* data, int pitch)
}
}
hr = m_system->Unlock(&r2);
hr = m_system->Unlock(r2);
if(m_video)
{
hr = m_video->Blt(&r2, m_system, &r2, DDBLT_WAIT, NULL);
hr = m_video->Blt(r2, m_system, r2, DDBLT_WAIT, NULL);
}
return true;
@ -133,21 +133,17 @@ bool GSTexture7::Update(const CRect& r, const void* data, int pitch)
return false;
}
bool GSTexture7::Map(BYTE** bits, int& pitch, const RECT* r)
bool GSTexture7::Map(uint8** bits, int& pitch)
{
HRESULT hr;
CRect r2 = r;
DDSURFACEDESC2 desc;
if(SUCCEEDED(hr = m_system->Lock(&r2, &desc, DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR, NULL)))
if(SUCCEEDED(hr = m_system->Lock(NULL, &desc, DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR, NULL)))
{
*bits = (BYTE*)desc.lpSurface;
*bits = (uint8*)desc.lpSurface;
pitch = (int)desc.lPitch;
m_lr = r;
return true;
}
@ -162,7 +158,7 @@ void GSTexture7::Unmap()
if(m_video)
{
hr = m_video->Blt(&m_lr, m_system, &m_lr, DDBLT_WAIT, NULL);
hr = m_video->Blt(NULL, m_system, NULL, DDBLT_WAIT, NULL);
}
}

View File

@ -30,7 +30,6 @@ class GSTexture7 : public GSTexture
CComPtr<IDirectDrawSurface7> m_system;
CComPtr<IDirectDrawSurface7> m_video;
DDSURFACEDESC2 m_desc;
CRect m_lr;
public:
GSTexture7();
@ -44,8 +43,8 @@ public:
int GetWidth() const;
int GetHeight() const;
int GetFormat() const;
bool Update(const CRect& r, const void* data, int pitch);
bool Map(BYTE** bits, int& pitch, const RECT* r = NULL);
bool Update(const GSVector4i& r, const void* data, int pitch);
bool Map(uint8** bits, int& pitch);
void Unmap();
bool Save(const string& fn, bool dds = false);

View File

@ -83,7 +83,7 @@ int GSTexture9::GetFormat() const
return m_desc.Format;
}
bool GSTexture9::Update(const CRect& r, const void* data, int pitch)
bool GSTexture9::Update(const GSVector4i& r, const void* data, int pitch)
{
if(CComPtr<IDirect3DSurface9> surface = *this)
{
@ -91,12 +91,12 @@ bool GSTexture9::Update(const CRect& r, const void* data, int pitch)
if(SUCCEEDED(surface->LockRect(&lr, r, 0)))
{
BYTE* src = (BYTE*)data;
BYTE* dst = (BYTE*)lr.pBits;
uint8* src = (uint8*)data;
uint8* dst = (uint8*)lr.pBits;
int bytes = min(pitch, lr.Pitch);
for(int i = 0, j = r.Height(); i < j; i++, src += pitch, dst += lr.Pitch)
for(int i = 0, j = r.height(); i < j; i++, src += pitch, dst += lr.Pitch)
{
memcpy(dst, src, bytes);
}
@ -110,7 +110,7 @@ bool GSTexture9::Update(const CRect& r, const void* data, int pitch)
return false;
}
bool GSTexture9::Map(BYTE** bits, int& pitch, const RECT* r)
bool GSTexture9::Map(uint8** bits, int& pitch)
{
HRESULT hr;
@ -118,9 +118,9 @@ bool GSTexture9::Map(BYTE** bits, int& pitch, const RECT* r)
{
D3DLOCKED_RECT lr;
if(SUCCEEDED(hr = surface->LockRect(&lr, r, 0)))
if(SUCCEEDED(hr = surface->LockRect(&lr, NULL, 0)))
{
*bits = (BYTE*)lr.pBits;
*bits = (uint8*)lr.pBits;
pitch = (int)lr.Pitch;
return true;
@ -160,12 +160,12 @@ bool GSTexture9::Save(const string& fn, bool dds)
hr = m_surface->LockRect(&slr, NULL, 0);
hr = surface->LockRect(&dlr, NULL, 0);
BYTE* s = (BYTE*)slr.pBits;
BYTE* d = (BYTE*)dlr.pBits;
uint8* s = (uint8*)slr.pBits;
uint8* d = (uint8*)dlr.pBits;
for(UINT y = 0; y < desc.Height; y++, s += slr.Pitch, d += dlr.Pitch)
for(uint32 y = 0; y < desc.Height; y++, s += slr.Pitch, d += dlr.Pitch)
{
for(UINT x = 0; x < desc.Width; x++)
for(uint32 x = 0; x < desc.Width; x++)
{
((float*)d)[x] = ((float*)s)[x];
}

View File

@ -42,8 +42,8 @@ public:
int GetWidth() const;
int GetHeight() const;
int GetFormat() const;
bool Update(const CRect& r, const void* data, int pitch);
bool Map(BYTE** bits, int& pitch, const RECT* r = NULL);
bool Update(const GSVector4i& r, const void* data, int pitch);
bool Map(uint8** bits, int& pitch);
void Unmap();
bool Save(const string& fn, bool dds = false);

View File

@ -28,7 +28,7 @@ template<class Device> class GSTextureCache
typedef typename Device::Texture Texture;
public:
class GSSurface
class GSSurface : public GSAlignedClass<16>
{
protected:
GSRenderer<Device>* m_renderer;
@ -48,7 +48,7 @@ public:
, m_age(0)
, m_initpalette(false)
{
m_TEX0.TBP0 = (UINT32)~0;
m_TEX0.TBP0 = (uint32)~0;
}
virtual ~GSSurface()
@ -81,7 +81,7 @@ public:
return m_renderer->m_dev.CreateRenderTarget(m_texture, w, h);
}
virtual void Read(CRect r) = 0;
virtual void Read(const GSVector4i& r) = 0;
};
class GSDepthStencil : public GSSurface
@ -107,30 +107,30 @@ public:
class GSTexture : public GSSurface
{
protected:
bool GetDirtyRect(CRect& rr)
bool GetDirtyRect(GSVector4i& rr)
{
int w = 1 << m_TEX0.TW;
int h = 1 << m_TEX0.TH;
CRect r(0, 0, w, h);
GSVector4i r(0, 0, w, h);
for(list<GSDirtyRect>::iterator i = m_dirty.begin(); i != m_dirty.end(); i++)
{
const CRect& dirty = i->GetDirtyRect(m_TEX0) & r;
const GSVector4i& dirty = i->GetDirtyRect(m_TEX0).rintersect(r);
if(!(m_valid & dirty).IsRectEmpty())
if(!m_valid.rintersect(dirty).rempty())
{
// find the rect having the largest area, outside dirty, inside m_valid
CRect left(m_valid.left, m_valid.top, min(m_valid.right, dirty.left), m_valid.bottom);
CRect top(m_valid.left, m_valid.top, m_valid.right, min(m_valid.bottom, dirty.top));
CRect right(max(m_valid.left, dirty.right), m_valid.top, m_valid.right, m_valid.bottom);
CRect bottom(m_valid.left, max(m_valid.top, dirty.bottom), m_valid.right, m_valid.bottom);
GSVector4i left(m_valid.left, m_valid.top, min(m_valid.right, dirty.left), m_valid.bottom);
GSVector4i top(m_valid.left, m_valid.top, m_valid.right, min(m_valid.bottom, dirty.top));
GSVector4i right(max(m_valid.left, dirty.right), m_valid.top, m_valid.right, m_valid.bottom);
GSVector4i bottom(m_valid.left, max(m_valid.top, dirty.bottom), m_valid.right, m_valid.bottom);
int leftsize = !left.IsRectEmpty() ? left.Width() * left.Height() : 0;
int topsize = !top.IsRectEmpty() ? top.Width() * top.Height() : 0;
int rightsize = !right.IsRectEmpty() ? right.Width() * right.Height() : 0;
int bottomsize = !bottom.IsRectEmpty() ? bottom.Width() * bottom.Height() : 0;
int leftsize = !left.rempty() ? left.width() * left.height() : 0;
int topsize = !top.rempty() ? top.width() * top.height() : 0;
int rightsize = !right.rempty() ? right.width() * right.height() : 0;
int bottomsize = !bottom.rempty() ? bottom.width() * bottom.height() : 0;
// TODO: sort
@ -139,7 +139,7 @@ public:
topsize > 0 ? top :
rightsize > 0 ? right :
bottomsize > 0 ? bottom :
CRect(0, 0, 0, 0);
GSVector4i::zero();
}
}
@ -167,10 +167,10 @@ public:
}
else
{
r |= m_valid;
r = r.runion(m_valid);
}
if(r.IsRectEmpty())
if(r.rempty())
{
return false;
}
@ -182,8 +182,8 @@ public:
public:
GIFRegCLAMP m_CLAMP;
DWORD* m_clut; // *
CRect m_valid;
uint32* m_clut; // *
GSVector4i m_valid;
int m_bpp;
int m_bpp2;
bool m_rendered;
@ -195,7 +195,7 @@ public:
, m_bpp2(0)
, m_rendered(false)
{
m_clut = (DWORD*)_aligned_malloc(256 * sizeof(DWORD), 16);
m_clut = (uint32*)_aligned_malloc(256 * sizeof(uint32), 16);
memset(m_clut, 0, sizeof(m_clut));
}
@ -205,6 +205,41 @@ public:
_aligned_free(m_clut);
}
void Update()
{
__super::Update();
if(m_rendered)
{
return;
}
GSVector4i r;
if(!GetDirtyRect(r))
{
return;
}
m_valid = m_valid.runion(r);
static uint8* bits = (uint8*)::_aligned_malloc(1024 * 1024 * 4, 16);
static int pitch = 1024 * 4;
if(m_renderer->m_psrr)
{
m_renderer->m_mem.ReadTextureNPNC(r, bits, pitch, m_renderer->m_context->TEX0, m_renderer->m_env.TEXA, m_renderer->m_context->CLAMP);
}
else
{
m_renderer->m_mem.ReadTextureNP(r, bits, pitch, m_renderer->m_context->TEX0, m_renderer->m_env.TEXA, m_renderer->m_context->CLAMP);
}
m_texture.Update(r, bits, pitch);
m_renderer->m_perfmon.Put(GSPerfMon::Unswizzle, r.width() * r.height() * m_bpp >> 3);
}
virtual bool Create() = 0;
virtual bool Create(GSRenderTarget* rt) = 0;
virtual bool Create(GSDepthStencil* ds) = 0;
@ -335,10 +370,12 @@ public:
if(m_renderer->CanUpscale())
{
int ww = (int)(m_renderer->GetFramePos().cx + rt->m_TEX0.TBW * 64);
int hh = (int)(m_renderer->GetFramePos().cy + m_renderer->GetDisplaySize().cy);
GSVector4i fr = m_renderer->GetFrameRect();
if(hh <= m_renderer->GetDeviceSize().cy / 2)
int ww = (int)(fr.left + rt->m_TEX0.TBW * 64);
int hh = (int)(fr.top + m_renderer->GetDisplayRect().height());
if(hh <= m_renderer->GetDeviceRect().height() / 2)
{
hh *= 2;
}
@ -412,7 +449,7 @@ public:
const GIFRegTEX0& TEX0 = m_renderer->m_context->TEX0;
const GIFRegCLAMP& CLAMP = m_renderer->m_context->CLAMP;
const DWORD* clut = m_renderer->m_mem.m_clut;
const uint32* clut = m_renderer->m_mem.m_clut;
const int pal = GSLocalMemory::m_psm[TEX0.PSM].pal;
if(pal > 0)
@ -480,7 +517,7 @@ public:
{
if(TEX0.PSM == t->m_TEX0.PSM && TEX0.TBW == t->m_TEX0.TBW
&& TEX0.TW == t->m_TEX0.TW && TEX0.TH == t->m_TEX0.TH
&& (m_renderer->m_psrr || (CLAMP.WMS != 3 && t->m_CLAMP.WMS != 3 && CLAMP.WMT != 3 && t->m_CLAMP.WMT != 3 || CLAMP.i64 == t->m_CLAMP.i64))
&& (m_renderer->m_psrr || (CLAMP.WMS != 3 && t->m_CLAMP.WMS != 3 && CLAMP.WMT != 3 && t->m_CLAMP.WMT != 3 || CLAMP.u64 == t->m_CLAMP.u64))
&& (pal == 0 || TEX0.CPSM == t->m_TEX0.CPSM && GSVector4i::compare(t->m_clut, clut, pal * sizeof(clut[0]))))
{
m_tex.splice(m_tex.begin(), m_tex, i);
@ -563,14 +600,14 @@ public:
if(t->m_initpalette)
{
memcpy(t->m_clut, clut, size);
t->m_palette.Update(CRect(0, 0, pal, 1), t->m_clut, size);
t->m_palette.Update(GSVector4i(0, 0, pal, 1), t->m_clut, size);
t->m_initpalette = false;
}
else
{
if(GSVector4i::update(t->m_clut, clut, size))
{
t->m_palette.Update(CRect(0, 0, pal, 1), t->m_clut, size);
t->m_palette.Update(GSVector4i(0, 0, pal, 1), t->m_clut, size);
}
}
}
@ -603,7 +640,7 @@ public:
}
}
void InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, const CRect& r)
void InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r)
{
bool found = false;
@ -617,7 +654,7 @@ public:
{
if(BITBLTBUF.DBW == t->m_TEX0.TBW && !t->m_rendered)
{
t->m_dirty.push_back(GSDirtyRect(BITBLTBUF.DPSM, r));
t->m_dirty.push_back(GSDirtyRect(r, BITBLTBUF.DPSM));
found = true;
}
@ -636,16 +673,16 @@ public:
if(rowsize > 0 && offset % rowsize == 0)
{
int y = m_renderer->m_mem.m_psm[BITBLTBUF.DPSM].pgs.cy * offset / rowsize;
int y = m_renderer->m_mem.m_psm[BITBLTBUF.DPSM].pgs.y * offset / rowsize;
CRect r2(r.left, r.top + y, r.right, r.bottom + y);
GSVector4i r2(r.left, r.top + y, r.right, r.bottom + y);
int w = 1 << t->m_TEX0.TW;
int h = 1 << t->m_TEX0.TH;
if(r2.bottom > 0 && r2.top < h && r2.right > 0 && r2.left < w)
{
t->m_dirty.push_back(GSDirtyRect(BITBLTBUF.DPSM, r2));
t->m_dirty.push_back(GSDirtyRect(r2, BITBLTBUF.DPSM));
}
}
}
@ -662,7 +699,7 @@ public:
{
if(!found && GSUtil::HasCompatibleBits(BITBLTBUF.DPSM, rt->m_TEX0.PSM))
{
rt->m_dirty.push_back(GSDirtyRect(BITBLTBUF.DPSM, r));
rt->m_dirty.push_back(GSDirtyRect(r, BITBLTBUF.DPSM));
rt->m_TEX0.TBW = BITBLTBUF.DBW;
}
else
@ -675,17 +712,17 @@ public:
if(GSUtil::HasSharedBits(BITBLTBUF.DPSM, rt->m_TEX0.PSM) && BITBLTBUF.DBP < rt->m_TEX0.TBP0)
{
DWORD rowsize = BITBLTBUF.DBW * 8192;
DWORD offset = (DWORD)((rt->m_TEX0.TBP0 - BITBLTBUF.DBP) * 256);
uint32 rowsize = BITBLTBUF.DBW * 8192;
uint32 offset = (uint32)((rt->m_TEX0.TBP0 - BITBLTBUF.DBP) * 256);
if(rowsize > 0 && offset % rowsize == 0)
{
int y = m_renderer->m_mem.m_psm[BITBLTBUF.DPSM].pgs.cy * offset / rowsize;
int y = m_renderer->m_mem.m_psm[BITBLTBUF.DPSM].pgs.y * offset / rowsize;
if(r.bottom > y)
{
// TODO: do not add this rect above too
rt->m_dirty.push_back(GSDirtyRect(BITBLTBUF.DPSM, CRect(r.left, r.top - y, r.right, r.bottom - y)));
rt->m_dirty.push_back(GSDirtyRect(GSVector4i(r.left, r.top - y, r.right, r.bottom - y), BITBLTBUF.DPSM));
rt->m_TEX0.TBW = BITBLTBUF.DBW;
continue;
}
@ -705,7 +742,7 @@ public:
{
if(!found && GSUtil::HasCompatibleBits(BITBLTBUF.DPSM, ds->m_TEX0.PSM))
{
ds->m_dirty.push_back(GSDirtyRect(BITBLTBUF.DPSM, r));
ds->m_dirty.push_back(GSDirtyRect(r, BITBLTBUF.DPSM));
ds->m_TEX0.TBW = BITBLTBUF.DBW;
}
else
@ -718,17 +755,17 @@ public:
if(GSUtil::HasSharedBits(BITBLTBUF.DPSM, ds->m_TEX0.PSM) && BITBLTBUF.DBP < ds->m_TEX0.TBP0)
{
DWORD rowsize = BITBLTBUF.DBW * 8192;
DWORD offset = (DWORD)((ds->m_TEX0.TBP0 - BITBLTBUF.DBP) * 256);
uint32 rowsize = BITBLTBUF.DBW * 8192;
uint32 offset = (uint32)((ds->m_TEX0.TBP0 - BITBLTBUF.DBP) * 256);
if(rowsize > 0 && offset % rowsize == 0)
{
int y = m_renderer->m_mem.m_psm[BITBLTBUF.DPSM].pgs.cy * offset / rowsize;
int y = m_renderer->m_mem.m_psm[BITBLTBUF.DPSM].pgs.y * offset / rowsize;
if(r.bottom > y)
{
// TODO: do not add this rect above too
ds->m_dirty.push_back(GSDirtyRect(BITBLTBUF.DPSM, CRect(r.left, r.top - y, r.right, r.bottom - y)));
ds->m_dirty.push_back(GSDirtyRect(GSVector4i(r.left, r.top - y, r.right, r.bottom - y), BITBLTBUF.DPSM));
ds->m_TEX0.TBW = BITBLTBUF.DBW;
continue;
}
@ -738,7 +775,7 @@ public:
}
}
void InvalidateLocalMem(const GIFRegBITBLTBUF& BITBLTBUF, const CRect& r)
void InvalidateLocalMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r)
{
for(list<GSRenderTarget*>::iterator i = m_rt.begin(); i != m_rt.end(); )
{
@ -757,7 +794,7 @@ public:
{
// ffx-2 riku changing to her default (shoots some reflecting glass at the end), 16-bit rt read as 32-bit
rt->Read(CRect(r.left, r.top, r.right, r.top + (r.bottom - r.top) * 2));
rt->Read(GSVector4i(r.left, r.top, r.right, r.top + (r.bottom - r.top) * 2));
return;
}
else
@ -784,12 +821,12 @@ public:
{
// ffx2 pause screen background
DWORD rowsize = BITBLTBUF.SBW * 8192;
DWORD offset = (DWORD)((BITBLTBUF.SBP - rt->m_TEX0.TBP0) * 256);
uint32 rowsize = BITBLTBUF.SBW * 8192;
uint32 offset = (uint32)((BITBLTBUF.SBP - rt->m_TEX0.TBP0) * 256);
if(rowsize > 0 && offset % rowsize == 0)
{
int y = m_renderer->m_mem.m_psm[BITBLTBUF.SPSM].pgs.cy * offset / rowsize;
int y = m_renderer->m_mem.m_psm[BITBLTBUF.SPSM].pgs.y * offset / rowsize;
if(y < ymin && y < 512)
{
@ -802,7 +839,7 @@ public:
if(rt2)
{
rt2->Read(CRect(r.left, r.top + ymin, r.right, r.bottom + ymin));
rt2->Read(GSVector4i(r.left, r.top + ymin, r.right, r.bottom + ymin));
}
// TODO: ds

View File

@ -37,16 +37,14 @@ void GSTextureCache10::GSRenderTargetHW10::Update()
// FIXME: the union of the rects may also update wrong parts of the render target (but a lot faster :)
CRect r = m_dirty.GetDirtyRect(m_TEX0, m_texture.GetSize());
GSVector4i r = m_dirty.GetDirtyRectAndClear(m_TEX0, m_texture.GetSize());
m_dirty.clear();
if(r.rempty()) return;
if(r.IsRectEmpty()) return;
int w = r.width();
int h = r.height();
int w = r.Width();
int h = r.Height();
static BYTE* buff = (BYTE*)_aligned_malloc(1024 * 1024 * 4, 16);
static uint8* buff = (uint8*)_aligned_malloc(1024 * 1024 * 4, 16);
static int pitch = 1024 * 4;
GIFRegTEXA TEXA;
@ -69,7 +67,7 @@ void GSTextureCache10::GSRenderTargetHW10::Update()
if(!m_renderer->m_dev.CreateTexture(texture, w, h))
return;
texture.Update(CRect(0, 0, w, h), buff, pitch);
texture.Update(GSVector4i(0, 0, w, h), buff, pitch);
GSVector4 dr(
m_texture.m_scale.x * r.left,
@ -82,7 +80,7 @@ void GSTextureCache10::GSRenderTargetHW10::Update()
m_renderer->m_dev.Recycle(texture);
}
void GSTextureCache10::GSRenderTargetHW10::Read(CRect r)
void GSTextureCache10::GSRenderTargetHW10::Read(const GSVector4i& r)
{
if(m_TEX0.PSM != PSM_PSMCT32
&& m_TEX0.PSM != PSM_PSMCT24
@ -102,8 +100,8 @@ void GSTextureCache10::GSRenderTargetHW10::Read(CRect r)
// m_renderer->m_perfmon.Put(GSPerfMon::ReadRT, 1);
int w = r.Width();
int h = r.Height();
int w = r.width();
int h = r.height();
GSVector4 src;
@ -119,15 +117,15 @@ void GSTextureCache10::GSRenderTargetHW10::Read(CRect r)
if(!m_renderer->m_dev.CopyOffscreen(m_texture, src, offscreen, w, h, format))
return;
BYTE* bits;
uint8* bits;
int pitch;
if(offscreen.Map(&bits, pitch))
{
// TODO: block level write
DWORD bp = m_TEX0.TBP0;
DWORD bw = m_TEX0.TBW;
uint32 bp = m_TEX0.TBP0;
uint32 bw = m_TEX0.TBW;
GSLocalMemory::pixelAddress pa = GSLocalMemory::m_psm[m_TEX0.PSM].pa;
@ -135,12 +133,12 @@ void GSTextureCache10::GSRenderTargetHW10::Read(CRect r)
{
for(int y = r.top; y < r.bottom; y++, bits += pitch)
{
DWORD addr = pa(0, y, bp, bw);
uint32 addr = pa(0, y, bp, bw);
int* offset = GSLocalMemory::m_psm[m_TEX0.PSM].rowOffset[y & 7];
for(int x = r.left, i = 0; x < r.right; x++, i++)
{
m_renderer->m_mem.WritePixel32(addr + offset[x], ((DWORD*)bits)[i]);
m_renderer->m_mem.WritePixel32(addr + offset[x], ((uint32*)bits)[i]);
}
}
}
@ -148,12 +146,12 @@ void GSTextureCache10::GSRenderTargetHW10::Read(CRect r)
{
for(int y = r.top; y < r.bottom; y++, bits += pitch)
{
DWORD addr = pa(0, y, bp, bw);
uint32 addr = pa(0, y, bp, bw);
int* offset = GSLocalMemory::m_psm[m_TEX0.PSM].rowOffset[y & 7];
for(int x = r.left, i = 0; x < r.right; x++, i++)
{
m_renderer->m_mem.WritePixel24(addr + offset[x], ((DWORD*)bits)[i]);
m_renderer->m_mem.WritePixel24(addr + offset[x], ((uint32*)bits)[i]);
}
}
}
@ -161,12 +159,12 @@ void GSTextureCache10::GSRenderTargetHW10::Read(CRect r)
{
for(int y = r.top; y < r.bottom; y++, bits += pitch)
{
DWORD addr = pa(0, y, bp, bw);
uint32 addr = pa(0, y, bp, bw);
int* offset = GSLocalMemory::m_psm[m_TEX0.PSM].rowOffset[y & 7];
for(int x = r.left, i = 0; x < r.right; x++, i++)
{
m_renderer->m_mem.WritePixel16(addr + offset[x], ((WORD*)bits)[i]);
m_renderer->m_mem.WritePixel16(addr + offset[x], ((uint16*)bits)[i]);
}
}
}
@ -199,7 +197,7 @@ bool GSTextureCache10::GSTextureHW10::Create()
m_TEX0 = m_renderer->m_context->TEX0;
m_CLAMP = m_renderer->m_context->CLAMP;
DWORD psm = m_TEX0.PSM;
uint32 psm = m_TEX0.PSM;
switch(psm)
{
@ -413,40 +411,3 @@ bool GSTextureCache10::GSTextureHW10::Create(GSDepthStencil* ds)
return false;
}
void GSTextureCache10::GSTextureHW10::Update()
{
__super::Update();
if(m_rendered)
{
return;
}
CRect r;
if(!GetDirtyRect(r))
{
return;
}
m_valid |= r;
//TRACE(_T("GSTexture::Update %d,%d - %d,%d (%08x)\n"), r.left, r.top, r.right, r.bottom, m_TEX0.TBP0);
static BYTE* bits = (BYTE*)::_aligned_malloc(1024 * 1024 * 4, 16);
int pitch = 1024 * 4;
if(m_renderer->m_psrr)
{
m_renderer->m_mem.ReadTextureNPNC(r, bits, pitch, m_renderer->m_context->TEX0, m_renderer->m_env.TEXA, m_renderer->m_context->CLAMP);
}
else
{
m_renderer->m_mem.ReadTextureNP(r, bits, pitch, m_renderer->m_context->TEX0, m_renderer->m_env.TEXA, m_renderer->m_context->CLAMP);
}
m_texture.Update(r, bits, pitch);
m_renderer->m_perfmon.Put(GSPerfMon::Unswizzle, r.Width() * r.Height() * m_bpp >> 3);
}

View File

@ -34,7 +34,7 @@ class GSTextureCache10 : public GSTextureCache<GSDevice10>
explicit GSRenderTargetHW10(GSRenderer<GSDevice10>* renderer) : GSRenderTarget(renderer) {}
void Update();
void Read(CRect r);
void Read(const GSVector4i& r);
};
class GSDepthStencilHW10 : public GSDepthStencil
@ -53,7 +53,6 @@ class GSTextureCache10 : public GSTextureCache<GSDevice10>
bool Create();
bool Create(GSRenderTarget* rt);
bool Create(GSDepthStencil* ds);
void Update();
};
protected:

View File

@ -37,21 +37,19 @@ void GSTextureCache9::GSRenderTarget9::Update()
// FIXME: the union of the rects may also update wrong parts of the render target (but a lot faster :)
CRect r = m_dirty.GetDirtyRect(m_TEX0, m_texture.GetSize());
GSVector4i r = m_dirty.GetDirtyRectAndClear(m_TEX0, m_texture.GetSize());
m_dirty.clear();
if(r.rempty()) return;
if(r.IsRectEmpty()) return;
int w = r.Width();
int h = r.Height();
int w = r.width();
int h = r.height();
Texture texture;
if(!m_renderer->m_dev.CreateTexture(texture, w, h))
return;
BYTE* bits;
uint8* bits;
int pitch;
if(texture.Map(&bits, pitch))
@ -85,7 +83,7 @@ void GSTextureCache9::GSRenderTarget9::Update()
m_renderer->m_dev.Recycle(texture);
}
void GSTextureCache9::GSRenderTarget9::Read(CRect r)
void GSTextureCache9::GSRenderTarget9::Read(const GSVector4i& r)
{
if(m_TEX0.PSM != PSM_PSMCT32
&& m_TEX0.PSM != PSM_PSMCT24
@ -105,8 +103,8 @@ void GSTextureCache9::GSRenderTarget9::Read(CRect r)
// m_renderer->m_perfmon.Put(GSPerfMon::ReadRT, 1);
int w = r.Width();
int h = r.Height();
int w = r.width();
int h = r.height();
GSVector4 src;
@ -120,15 +118,15 @@ void GSTextureCache9::GSRenderTarget9::Read(CRect r)
if(!m_renderer->m_dev.CopyOffscreen(m_texture, src, offscreen, w, h))
return;
BYTE* bits;
uint8* bits;
int pitch;
if(offscreen.Map(&bits, pitch))
{
// TODO: block level write
DWORD bp = m_TEX0.TBP0;
DWORD bw = m_TEX0.TBW;
uint32 bp = m_TEX0.TBP0;
uint32 bw = m_TEX0.TBW;
GSLocalMemory::pixelAddress pa = GSLocalMemory::m_psm[m_TEX0.PSM].pa;
@ -136,12 +134,12 @@ void GSTextureCache9::GSRenderTarget9::Read(CRect r)
{
for(int y = r.top; y < r.bottom; y++, bits += pitch)
{
DWORD addr = pa(0, y, bp, bw);
uint32 addr = pa(0, y, bp, bw);
int* offset = GSLocalMemory::m_psm[m_TEX0.PSM].rowOffset[y & 7];
for(int x = r.left, i = 0; x < r.right; x++, i++)
{
m_renderer->m_mem.WritePixel32(addr + offset[x], ((DWORD*)bits)[i]);
m_renderer->m_mem.WritePixel32(addr + offset[x], ((uint32*)bits)[i]);
}
}
}
@ -149,12 +147,12 @@ void GSTextureCache9::GSRenderTarget9::Read(CRect r)
{
for(int y = r.top; y < r.bottom; y++, bits += pitch)
{
DWORD addr = pa(0, y, bp, bw);
uint32 addr = pa(0, y, bp, bw);
int* offset = GSLocalMemory::m_psm[m_TEX0.PSM].rowOffset[y & 7];
for(int x = r.left, i = 0; x < r.right; x++, i++)
{
m_renderer->m_mem.WritePixel24(addr + offset[x], ((DWORD*)bits)[i]);
m_renderer->m_mem.WritePixel24(addr + offset[x], ((uint32*)bits)[i]);
}
}
}
@ -162,12 +160,12 @@ void GSTextureCache9::GSRenderTarget9::Read(CRect r)
{
for(int y = r.top; y < r.bottom; y++, bits += pitch)
{
DWORD addr = pa(0, y, bp, bw);
uint32 addr = pa(0, y, bp, bw);
int* offset = GSLocalMemory::m_psm[m_TEX0.PSM].rowOffset[y & 7];
for(int x = r.left, i = 0; x < r.right; x++, i++)
{
m_renderer->m_mem.WriteFrame16(addr + offset[x], ((DWORD*)bits)[i]);
m_renderer->m_mem.WriteFrame16(addr + offset[x], ((uint32*)bits)[i]);
}
}
}
@ -200,7 +198,7 @@ bool GSTextureCache9::GSTexture9::Create()
m_TEX0 = m_renderer->m_context->TEX0;
m_CLAMP = m_renderer->m_context->CLAMP;
DWORD psm = m_TEX0.PSM;
uint32 psm = m_TEX0.PSM;
switch(psm)
{
@ -358,7 +356,7 @@ bool GSTextureCache9::GSTexture9::Create(GSRenderTarget* rt)
if(src.x == dst.x && src.y == dst.y && src.z == dst.z && src.w == dst.w)
{
CRect r(0, 0, w, h);
GSVector4i r(0, 0, w, h);
m_renderer->m_dev->StretchRect(*st, r, *dt, r, D3DTEXF_POINT);
}
@ -413,41 +411,3 @@ bool GSTextureCache9::GSTexture9::Create(GSDepthStencil* ds)
return false;
}
void GSTextureCache9::GSTexture9::Update()
{
__super::Update();
if(m_rendered)
{
return;
}
CRect r;
if(!GetDirtyRect(r))
{
return;
}
m_valid |= r;
BYTE* bits;
int pitch;
if(m_texture.Map(&bits, pitch, &r))
{
if(m_renderer->m_psrr)
{
m_renderer->m_mem.ReadTextureNPNC(r, bits, pitch, m_renderer->m_context->TEX0, m_renderer->m_env.TEXA, m_renderer->m_context->CLAMP);
}
else
{
m_renderer->m_mem.ReadTextureNP(r, bits, pitch, m_renderer->m_context->TEX0, m_renderer->m_env.TEXA, m_renderer->m_context->CLAMP);
}
m_texture.Unmap();
}
m_renderer->m_perfmon.Put(GSPerfMon::Unswizzle, r.Width() * r.Height() * m_bpp >> 3);
}

View File

@ -34,7 +34,7 @@ class GSTextureCache9 : public GSTextureCache<GSDevice9>
explicit GSRenderTarget9(GSRenderer<GSDevice9>* renderer) : GSRenderTarget(renderer) {}
void Update();
void Read(CRect r);
void Read(const GSVector4i& r);
};
class GSDepthStencil9 : public GSDepthStencil
@ -53,7 +53,6 @@ class GSTextureCache9 : public GSTextureCache<GSDevice9>
bool Create();
bool Create(GSRenderTarget* rt);
bool Create(GSDepthStencil* ds);
void Update();
};
protected:

View File

@ -32,7 +32,7 @@ GSTextureCacheSW::~GSTextureCacheSW()
RemoveAll();
}
const GSTextureCacheSW::GSTexture* GSTextureCacheSW::Lookup(const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const CRect* r)
const GSTextureCacheSW::GSTexture* GSTextureCacheSW::Lookup(const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GSVector4i* r)
{
GSLocalMemory& mem = m_state->m_mem;
@ -47,12 +47,12 @@ const GSTextureCacheSW::GSTexture* GSTextureCacheSW::Lookup(const GIFRegTEX0& TE
GSTexture* t2 = (*i).first;
// if(t2->m_TEX0.TBP0 != TEX0.TBP0 || t2->m_TEX0.TBW != TEX0.TBW || t2->m_TEX0.PSM != TEX0.PSM || t2->m_TEX0.TW != TEX0.TW || t2->m_TEX0.TH != TEX0.TH)
if(((t2->m_TEX0.ai32[0] ^ TEX0.ai32[0]) | ((t2->m_TEX0.ai32[1] ^ TEX0.ai32[1]) & 3)) != 0)
if(((t2->m_TEX0.u32[0] ^ TEX0.u32[0]) | ((t2->m_TEX0.u32[1] ^ TEX0.u32[1]) & 3)) != 0)
{
continue;
}
if((psm.trbpp == 16 || psm.trbpp == 24) && (t2->m_TEX0.TCC != TEX0.TCC || TEX0.TCC && !(t2->m_TEXA == (GSVector4i)TEXA).alltrue()))
if((psm.trbpp == 16 || psm.trbpp == 24) && (t2->m_TEX0.TCC != TEX0.TCC || TEX0.TCC && !((GSVector4i)TEXA).eq(t2->m_TEXA)))
{
continue;
}
@ -73,18 +73,18 @@ const GSTextureCacheSW::GSTexture* GSTextureCacheSW::Lookup(const GIFRegTEX0& TE
int tw = 1 << TEX0.TW;
int th = 1 << TEX0.TH;
DWORD bp = TEX0.TBP0;
DWORD bw = TEX0.TBW;
uint32 bp = TEX0.TBP0;
uint32 bw = TEX0.TBW;
CSize s = (bp & 31) == 0 ? psm.pgs : psm.bs;
GSVector2i s = (bp & 31) == 0 ? psm.pgs : psm.bs;
for(int y = 0; y < th; y += s.cy)
for(int y = 0; y < th; y += s.y)
{
DWORD base = psm.bn(0, y, bp, bw);
uint32 base = psm.bn(0, y, bp, bw);
for(int x = 0; x < tw; x += s.cx)
for(int x = 0; x < tw; x += s.x)
{
DWORD page = (base + psm.blockOffset[x >> 3]) >> 5;
uint32 page = (base + psm.blockOffset[x >> 3]) >> 5;
if(page >= MAX_PAGES)
{
@ -152,29 +152,29 @@ void GSTextureCacheSW::IncAge()
}
}
void GSTextureCacheSW::InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, const CRect& rect)
void GSTextureCacheSW::InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& rect)
{
const GSLocalMemory::psm_t& psm = GSLocalMemory::m_psm[BITBLTBUF.DPSM];
DWORD bp = BITBLTBUF.DBP;
DWORD bw = BITBLTBUF.DBW;
uint32 bp = BITBLTBUF.DBP;
uint32 bw = BITBLTBUF.DBW;
CSize s = (bp & 31) == 0 ? psm.pgs : psm.bs;
GSVector2i s = (bp & 31) == 0 ? psm.pgs : psm.bs;
CRect r;
GSVector4i r;
r.left = rect.left & ~(s.cx - 1);
r.top = rect.top & ~(s.cy - 1);
r.right = (rect.right + (s.cx - 1)) & ~(s.cx - 1);
r.bottom = (rect.bottom + (s.cy - 1)) & ~(s.cy - 1);
r.left = rect.left & ~(s.x - 1);
r.top = rect.top & ~(s.y - 1);
r.right = (rect.right + (s.x - 1)) & ~(s.x - 1);
r.bottom = (rect.bottom + (s.y - 1)) & ~(s.y - 1);
for(int y = r.top; y < r.bottom; y += s.cy)
for(int y = r.top; y < r.bottom; y += s.y)
{
DWORD base = psm.bn(0, y, bp, bw);
uint32 base = psm.bn(0, y, bp, bw);
for(int x = r.left; x < r.right; x += s.cx)
for(int x = r.left; x < r.right; x += s.x)
{
DWORD page = (base + psm.blockOffset[x >> 3]) >> 5;
uint32 page = (base + psm.blockOffset[x >> 3]) >> 5;
if(page >= MAX_PAGES)
{
@ -215,7 +215,7 @@ GSTextureCacheSW::GSTexture::~GSTexture()
}
}
bool GSTextureCacheSW::GSTexture::Update(const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const CRect* rect)
bool GSTextureCacheSW::GSTexture::Update(const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GSVector4i* rect)
{
if(m_complete)
{
@ -229,17 +229,17 @@ bool GSTextureCacheSW::GSTexture::Update(const GIFRegTEX0& TEX0, const GIFRegTEX
const GSLocalMemory::psm_t& psm = GSLocalMemory::m_psm[TEX0.PSM];
DWORD bp = TEX0.TBP0;
DWORD bw = TEX0.TBW;
uint32 bp = TEX0.TBP0;
uint32 bw = TEX0.TBW;
CSize s = psm.bs;
GSVector2i s = psm.bs;
int tw = max(1 << TEX0.TW, s.cx);
int th = max(1 << TEX0.TH, s.cy);
int tw = max(1 << TEX0.TW, s.x);
int th = max(1 << TEX0.TH, s.y);
if(m_buff == NULL)
{
m_buff = _aligned_malloc(tw * th * sizeof(DWORD), 16);
m_buff = _aligned_malloc(tw * th * sizeof(uint32), 16);
if(m_buff == NULL)
{
@ -249,14 +249,14 @@ bool GSTextureCacheSW::GSTexture::Update(const GIFRegTEX0& TEX0, const GIFRegTEX
m_tw = max(psm.pal > 0 ? 5 : 3, TEX0.TW); // makes one row 32 bytes at least, matches the smallest block size that is allocated above for m_buff
}
CRect r(0, 0, tw, th);
GSVector4i r(0, 0, tw, th);
if(rect)
{
r.left = rect->left & ~(s.cx - 1);
r.top = rect->top & ~(s.cy - 1);
r.right = (rect->right + (s.cx - 1)) & ~(s.cx - 1);
r.bottom = (rect->bottom + (s.cy - 1)) & ~(s.cy - 1);
r.left = rect->left & ~(s.x - 1);
r.top = rect->top & ~(s.y - 1);
r.right = (rect->right + (s.x - 1)) & ~(s.x - 1);
r.bottom = (rect->bottom + (s.y - 1)) & ~(s.y - 1);
}
if(r.left == 0 && r.top == 0 && r.right == tw && r.bottom == th)
@ -268,26 +268,26 @@ bool GSTextureCacheSW::GSTexture::Update(const GIFRegTEX0& TEX0, const GIFRegTEX
int bytes = psm.pal > 0 ? 1 : 4;
DWORD pitch = (1 << m_tw) * bytes;
uint32 pitch = (1 << m_tw) * bytes;
BYTE* dst = (BYTE*)m_buff + pitch * r.top;
uint8* dst = (uint8*)m_buff + pitch * r.top;
DWORD blocks = 0;
uint32 blocks = 0;
if(tw <= (bw << 6))
{
for(int y = r.top, o = pitch * s.cy; y < r.bottom; y += s.cy, dst += o)
for(int y = r.top, o = pitch * s.y; y < r.bottom; y += s.y, dst += o)
{
DWORD base = psm.bn(0, y, bp, bw);
uint32 base = psm.bn(0, y, bp, bw);
for(int x = r.left; x < r.right; x += s.cx)
for(int x = r.left; x < r.right; x += s.x)
{
DWORD block = base + psm.blockOffset[x >> 3];
uint32 block = base + psm.blockOffset[x >> 3];
if(block < MAX_BLOCKS)
{
DWORD row = block >> 5;
DWORD col = 1 << (block & 31);
uint32 row = block >> 5;
uint32 col = 1 << (block & 31);
if((m_valid[row] & col) == 0)
{
@ -308,18 +308,18 @@ bool GSTextureCacheSW::GSTexture::Update(const GIFRegTEX0& TEX0, const GIFRegTEX
// TODO: still bogus if those repeated parts aren't fetched together
for(int y = r.top, o = pitch * s.cy; y < r.bottom; y += s.cy, dst += o)
for(int y = r.top, o = pitch * s.y; y < r.bottom; y += s.y, dst += o)
{
DWORD base = psm.bn(0, y, bp, bw);
uint32 base = psm.bn(0, y, bp, bw);
for(int x = r.left; x < r.right; x += s.cx)
for(int x = r.left; x < r.right; x += s.x)
{
DWORD block = base + psm.blockOffset[x >> 3];
uint32 block = base + psm.blockOffset[x >> 3];
if(block < MAX_BLOCKS)
{
DWORD row = block >> 5;
DWORD col = 1 << (block & 31);
uint32 row = block >> 5;
uint32 col = 1 << (block & 31);
if((m_valid[row] & col) == 0)
{
@ -331,18 +331,18 @@ bool GSTextureCacheSW::GSTexture::Update(const GIFRegTEX0& TEX0, const GIFRegTEX
}
}
for(int y = r.top; y < r.bottom; y += s.cy)
for(int y = r.top; y < r.bottom; y += s.y)
{
DWORD base = psm.bn(0, y, bp, bw);
uint32 base = psm.bn(0, y, bp, bw);
for(int x = r.left; x < r.right; x += s.cx)
for(int x = r.left; x < r.right; x += s.x)
{
DWORD block = base + psm.blockOffset[x >> 3];
uint32 block = base + psm.blockOffset[x >> 3];
if(block < MAX_BLOCKS)
{
DWORD row = block >> 5;
DWORD col = 1 << (block & 31);
uint32 row = block >> 5;
uint32 col = 1 << (block & 31);
m_valid[row] |= col;
}
@ -350,7 +350,7 @@ bool GSTextureCacheSW::GSTexture::Update(const GIFRegTEX0& TEX0, const GIFRegTEX
}
}
m_state->m_perfmon.Put(GSPerfMon::Unswizzle, s.cx * s.cy * bytes * blocks);
m_state->m_perfmon.Put(GSPerfMon::Unswizzle, s.x * s.y * bytes * blocks);
return true;
}

View File

@ -36,15 +36,15 @@ public:
GIFRegTEX0 m_TEX0;
GIFRegTEXA m_TEXA;
void* m_buff;
DWORD m_tw;
DWORD m_valid[MAX_PAGES]; // each DWORD bits map to the 32 blocks of that page
DWORD m_age;
uint32 m_tw;
uint32 m_valid[MAX_PAGES]; // each uint32 bits map to the 32 blocks of that page
uint32 m_age;
bool m_complete;
explicit GSTexture(GSState* state);
virtual ~GSTexture();
bool Update(const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const CRect* r = NULL);
bool Update(const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GSVector4i* r = NULL);
};
protected:
@ -56,9 +56,9 @@ public:
GSTextureCacheSW(GSState* state);
virtual ~GSTextureCacheSW();
const GSTexture* Lookup(const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const CRect* r = NULL);
const GSTexture* Lookup(const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GSVector4i* r = NULL);
void RemoveAll();
void IncAge();
void InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, const CRect& r);
void InvalidateVideoMem(const GIFRegBITBLTBUF& BITBLTBUF, const GSVector4i& r);
};

View File

@ -163,7 +163,7 @@ bool GSTextureFX10::SetupVS(VSSelector sel, const VSConstantBuffer* cb)
{
CComPtr<ID3D10VertexShader> vs;
hash_map<DWORD, CComPtr<ID3D10VertexShader> >::iterator i = m_vs.find(sel);
hash_map<uint32, CComPtr<ID3D10VertexShader> >::iterator i = m_vs.find(sel);
if(i != m_vs.end())
{
@ -229,7 +229,7 @@ bool GSTextureFX10::SetupGS(GSSelector sel)
if(sel.prim > 0 && (sel.iip == 0 || sel.prim == 3)) // geometry shader works in every case, but not needed
{
hash_map<DWORD, CComPtr<ID3D10GeometryShader> >::iterator i = m_gs.find(sel);
hash_map<uint32, CComPtr<ID3D10GeometryShader> >::iterator i = m_gs.find(sel);
if(i != m_gs.end())
{
@ -275,7 +275,7 @@ void GSTextureFX10::UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSampl
CComPtr<ID3D10PixelShader> ps;
hash_map<DWORD, CComPtr<ID3D10PixelShader> >::iterator i = m_ps.find(sel);
hash_map<uint32, CComPtr<ID3D10PixelShader> >::iterator i = m_ps.find(sel);
if(i != m_ps.end())
{
@ -338,7 +338,7 @@ void GSTextureFX10::UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSampl
ssel.min = ssel.mag = 0;
}
hash_map<DWORD, CComPtr<ID3D10SamplerState> >::iterator i = m_ps_ss.find(ssel);
hash_map<uint32, CComPtr<ID3D10SamplerState> >::iterator i = m_ps_ss.find(ssel);
if(i != m_ps_ss.end())
{
@ -378,7 +378,7 @@ void GSTextureFX10::UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSampl
m_dev->PSSetSamplerState(ss0, ss1);
}
void GSTextureFX10::SetupRS(UINT w, UINT h, const RECT& scissor)
void GSTextureFX10::SetupRS(int w, int h, const GSVector4i& scissor)
{
m_dev->RSSet(w, h, &scissor);
}
@ -396,7 +396,7 @@ void GSTextureFX10::UpdateOM(OMDepthStencilSelector dssel, OMBlendSelector bsel,
CComPtr<ID3D10DepthStencilState> dss;
hash_map<DWORD, CComPtr<ID3D10DepthStencilState> >::iterator i = m_om_dss.find(dssel);
hash_map<uint32, CComPtr<ID3D10DepthStencilState> >::iterator i = m_om_dss.find(dssel);
if(i != m_om_dss.end())
{
@ -447,7 +447,7 @@ void GSTextureFX10::UpdateOM(OMDepthStencilSelector dssel, OMBlendSelector bsel,
CComPtr<ID3D10BlendState> bs;
hash_map<DWORD, CComPtr<ID3D10BlendState> >::iterator j = m_om_bs.find(bsel);
hash_map<uint32, CComPtr<ID3D10BlendState> >::iterator j = m_om_bs.find(bsel);
if(j != m_om_bs.end())
{

View File

@ -63,16 +63,16 @@ public:
{
struct
{
DWORD bpp:3;
DWORD bppz:2;
DWORD tme:1;
DWORD fst:1;
DWORD prim:3;
uint32 bpp:3;
uint32 bppz:2;
uint32 tme:1;
uint32 fst:1;
uint32 prim:3;
};
DWORD dw;
uint32 key;
operator DWORD() {return dw & 0x3ff;}
operator uint32() {return key & 0x3ff;}
};
__declspec(align(16)) struct PSConstantBuffer
@ -82,10 +82,10 @@ public:
float MAXU;
float MINV;
float MAXV;
DWORD UMSK;
DWORD UFIX;
DWORD VMSK;
DWORD VFIX;
uint32 UMSK;
uint32 UFIX;
uint32 VMSK;
uint32 VFIX;
float TA0;
float TA1;
float AREF;
@ -125,87 +125,87 @@ public:
{
struct
{
DWORD fst:1;
DWORD wms:2;
DWORD wmt:2;
DWORD bpp:3;
DWORD aem:1;
DWORD tfx:3;
DWORD tcc:1;
DWORD ate:1;
DWORD atst:3;
DWORD fog:1;
DWORD clr1:1;
DWORD fba:1;
DWORD aout:1;
uint32 fst:1;
uint32 wms:2;
uint32 wmt:2;
uint32 bpp:3;
uint32 aem:1;
uint32 tfx:3;
uint32 tcc:1;
uint32 ate:1;
uint32 atst:3;
uint32 fog:1;
uint32 clr1:1;
uint32 fba:1;
uint32 aout:1;
};
DWORD dw;
uint32 key;
operator DWORD() {return dw & 0x1fffff;}
operator uint32() {return key & 0x1fffff;}
};
union GSSelector
{
struct
{
DWORD iip:1;
DWORD prim:2;
uint32 iip:1;
uint32 prim:2;
};
DWORD dw;
uint32 key;
operator DWORD() {return dw & 0x7;}
operator uint32() {return key & 0x7;}
};
union PSSamplerSelector
{
struct
{
DWORD tau:1;
DWORD tav:1;
DWORD min:1;
DWORD mag:1;
uint32 tau:1;
uint32 tav:1;
uint32 min:1;
uint32 mag:1;
};
DWORD dw;
uint32 key;
operator DWORD() {return dw & 0xf;}
operator uint32() {return key & 0xf;}
};
union OMDepthStencilSelector
{
struct
{
DWORD zte:1;
DWORD ztst:2;
DWORD zwe:1;
DWORD date:1;
uint32 zte:1;
uint32 ztst:2;
uint32 zwe:1;
uint32 date:1;
};
DWORD dw;
uint32 key;
operator DWORD() {return dw & 0x1f;}
operator uint32() {return key & 0x1f;}
};
union OMBlendSelector
{
struct
{
DWORD abe:1;
DWORD a:2;
DWORD b:2;
DWORD c:2;
DWORD d:2;
DWORD wr:1;
DWORD wg:1;
DWORD wb:1;
DWORD wa:1;
uint32 abe:1;
uint32 a:2;
uint32 b:2;
uint32 c:2;
uint32 d:2;
uint32 wr:1;
uint32 wg:1;
uint32 wb:1;
uint32 wa:1;
};
DWORD dw;
uint32 key;
operator DWORD() {return dw & 0x1fff;}
operator uint32() {return key & 0x1fff;}
};
#pragma pack(pop)
@ -213,15 +213,15 @@ public:
private:
GSDevice10* m_dev;
CComPtr<ID3D10InputLayout> m_il;
hash_map<DWORD, CComPtr<ID3D10VertexShader> > m_vs;
hash_map<uint32, CComPtr<ID3D10VertexShader> > m_vs;
CComPtr<ID3D10Buffer> m_vs_cb;
hash_map<DWORD, CComPtr<ID3D10GeometryShader> > m_gs;
hash_map<DWORD, CComPtr<ID3D10PixelShader> > m_ps;
hash_map<uint32, CComPtr<ID3D10GeometryShader> > m_gs;
hash_map<uint32, CComPtr<ID3D10PixelShader> > m_ps;
CComPtr<ID3D10Buffer> m_ps_cb;
hash_map<DWORD, CComPtr<ID3D10SamplerState> > m_ps_ss;
hash_map<uint32, CComPtr<ID3D10SamplerState> > m_ps_ss;
CComPtr<ID3D10SamplerState> m_palette_ss;
hash_map<DWORD, CComPtr<ID3D10DepthStencilState> > m_om_dss;
hash_map<DWORD, CComPtr<ID3D10BlendState> > m_om_bs;
hash_map<uint32, CComPtr<ID3D10DepthStencilState> > m_om_dss;
hash_map<uint32, CComPtr<ID3D10BlendState> > m_om_bs;
CComPtr<ID3D10Buffer> m_vb, m_vb_old;
int m_vb_max;
@ -241,7 +241,7 @@ public:
bool SetupGS(GSSelector sel);
bool SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel, ID3D10ShaderResourceView* tex, ID3D10ShaderResourceView* pal);
void UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel);
void SetupRS(UINT w, UINT h, const RECT& scissor);
void SetupRS(int w, int h, const GSVector4i& scissor);
void SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, float bf, ID3D10RenderTargetView* rtv, ID3D10DepthStencilView* dsv);
void UpdateOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, float bf);
void Draw();

View File

@ -46,11 +46,11 @@ bool GSTextureFX9::Create(GSDevice9* dev)
return true;
}
bool GSTextureFX9::CreateMskFix(GSTexture9& t, DWORD size, DWORD msk, DWORD fix)
bool GSTextureFX9::CreateMskFix(GSTexture9& t, uint32 size, uint32 msk, uint32 fix)
{
DWORD hash = (size << 20) | (msk << 10) | fix;
uint32 hash = (size << 20) | (msk << 10) | fix;
hash_map<DWORD, GSTexture9>::iterator i = m_mskfix.find(hash);
hash_map<uint32, GSTexture9>::iterator i = m_mskfix.find(hash);
if(i != m_mskfix.end())
{
@ -63,12 +63,12 @@ bool GSTextureFX9::CreateMskFix(GSTexture9& t, DWORD size, DWORD msk, DWORD fix)
return false;
}
BYTE* bits;
uint8* bits;
int pitch;
if(t.Map(&bits, pitch))
{
for(DWORD i = 0; i < size; i++)
for(uint32 i = 0; i < size; i++)
{
((float*)bits)[i] = (float)((i & msk) | fix) / size;
}
@ -82,7 +82,7 @@ bool GSTextureFX9::CreateMskFix(GSTexture9& t, DWORD size, DWORD msk, DWORD fix)
return true;
}
bool GSTextureFX9::SetupIA(const GSVertexHW9* vertices, UINT count, D3DPRIMITIVETYPE prim)
bool GSTextureFX9::SetupIA(const GSVertexHW9* vertices, int count, D3DPRIMITIVETYPE prim)
{
m_dev->IASetVertexBuffer(count, vertices);
m_dev->IASetInputLayout(m_il);
@ -95,7 +95,7 @@ bool GSTextureFX9::SetupVS(VSSelector sel, const VSConstantBuffer* cb)
{
CComPtr<IDirect3DVertexShader9> vs;
hash_map<DWORD, CComPtr<IDirect3DVertexShader9> >::iterator i = m_vs.find(sel);
hash_map<uint32, CComPtr<IDirect3DVertexShader9> >::iterator i = m_vs.find(sel);
if(i != m_vs.end())
{
@ -191,7 +191,7 @@ void GSTextureFX9::UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSample
CComPtr<IDirect3DPixelShader9> ps;
hash_map<DWORD, CComPtr<IDirect3DPixelShader9> >::iterator i = m_ps.find(sel);
hash_map<uint32, CComPtr<IDirect3DPixelShader9> >::iterator i = m_ps.find(sel);
if(i != m_ps.end())
{
@ -247,7 +247,7 @@ void GSTextureFX9::UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSample
ssel.min = ssel.mag = 0;
}
hash_map<DWORD, Direct3DSamplerState9* >::iterator i = m_ps_ss.find(ssel);
hash_map<uint32, Direct3DSamplerState9* >::iterator i = m_ps_ss.find(ssel);
if(i != m_ps_ss.end())
{
@ -274,23 +274,23 @@ void GSTextureFX9::UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSample
m_dev->PSSetSamplerState(ss);
}
void GSTextureFX9::SetupRS(int w, int h, const RECT& scissor)
void GSTextureFX9::SetupRS(int w, int h, const GSVector4i& scissor)
{
m_dev->RSSet(w, h, &scissor);
}
void GSTextureFX9::SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, BYTE bf, IDirect3DSurface9* rt, IDirect3DSurface9* ds)
void GSTextureFX9::SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 bf, IDirect3DSurface9* rt, IDirect3DSurface9* ds)
{
UpdateOM(dssel, bsel, bf);
m_dev->OMSetRenderTargets(rt, ds);
}
void GSTextureFX9::UpdateOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, BYTE bf)
void GSTextureFX9::UpdateOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 bf)
{
Direct3DDepthStencilState9* dss = NULL;
hash_map<DWORD, Direct3DDepthStencilState9*>::iterator i = m_om_dss.find(dssel);
hash_map<uint32, Direct3DDepthStencilState9*>::iterator i = m_om_dss.find(dssel);
if(i != m_om_dss.end())
{
@ -335,7 +335,7 @@ void GSTextureFX9::UpdateOM(OMDepthStencilSelector dssel, OMBlendSelector bsel,
Direct3DBlendState9* bs = NULL;
hash_map<DWORD, Direct3DBlendState9*>::iterator j = m_om_bs.find(bsel);
hash_map<uint32, Direct3DBlendState9*>::iterator j = m_om_bs.find(bsel);
if(j != m_om_bs.end())
{

View File

@ -40,15 +40,15 @@ public:
{
struct
{
DWORD bppz:2;
DWORD tme:1;
DWORD fst:1;
DWORD logz:1;
uint32 bppz:2;
uint32 tme:1;
uint32 fst:1;
uint32 logz:1;
};
DWORD dw;
uint32 key;
operator DWORD() {return dw & 0x1f;}
operator uint32() {return key & 0x1f;}
};
struct PSConstantBuffer
@ -58,10 +58,10 @@ public:
float MAXU;
float MINV;
float MAXV;
DWORD UMSK;
DWORD UFIX;
DWORD VMSK;
DWORD VFIX;
uint32 UMSK;
uint32 UFIX;
uint32 VMSK;
uint32 VFIX;
float TA0;
float TA1;
float AREF;
@ -74,74 +74,74 @@ public:
{
struct
{
DWORD fst:1;
DWORD wms:2;
DWORD wmt:2;
DWORD bpp:3;
DWORD aem:1;
DWORD tfx:3;
DWORD tcc:1;
DWORD ate:1;
DWORD atst:3;
DWORD fog:1;
DWORD clr1:1;
DWORD rt:1;
uint32 fst:1;
uint32 wms:2;
uint32 wmt:2;
uint32 bpp:3;
uint32 aem:1;
uint32 tfx:3;
uint32 tcc:1;
uint32 ate:1;
uint32 atst:3;
uint32 fog:1;
uint32 clr1:1;
uint32 rt:1;
};
DWORD dw;
uint32 key;
operator DWORD() {return dw & 0xfffff;}
operator uint32() {return key & 0xfffff;}
};
union PSSamplerSelector
{
struct
{
DWORD tau:1;
DWORD tav:1;
DWORD min:1;
DWORD mag:1;
uint32 tau:1;
uint32 tav:1;
uint32 min:1;
uint32 mag:1;
};
DWORD dw;
uint32 key;
operator DWORD() {return dw & 0xf;}
operator uint32() {return key & 0xf;}
};
union OMDepthStencilSelector
{
struct
{
DWORD zte:1;
DWORD ztst:2;
DWORD zwe:1;
DWORD date:1;
DWORD fba:1;
uint32 zte:1;
uint32 ztst:2;
uint32 zwe:1;
uint32 date:1;
uint32 fba:1;
};
DWORD dw;
uint32 key;
operator DWORD() {return dw & 0x3f;}
operator uint32() {return key & 0x3f;}
};
union OMBlendSelector
{
struct
{
DWORD abe:1;
DWORD a:2;
DWORD b:2;
DWORD c:2;
DWORD d:2;
DWORD wr:1;
DWORD wg:1;
DWORD wb:1;
DWORD wa:1;
uint32 abe:1;
uint32 a:2;
uint32 b:2;
uint32 c:2;
uint32 d:2;
uint32 wr:1;
uint32 wg:1;
uint32 wb:1;
uint32 wa:1;
};
DWORD dw;
uint32 key;
operator DWORD() {return dw & 0x1fff;}
operator uint32() {return key & 0x1fff;}
};
#pragma pack(pop)
@ -149,25 +149,25 @@ public:
private:
GSDevice9* m_dev;
CComPtr<IDirect3DVertexDeclaration9> m_il;
hash_map<DWORD, CComPtr<IDirect3DVertexShader9> > m_vs;
hash_map<uint32, CComPtr<IDirect3DVertexShader9> > m_vs;
D3DXHANDLE m_vs_params;
hash_map<DWORD, CComPtr<IDirect3DPixelShader9> > m_ps;
hash_map<DWORD, Direct3DSamplerState9* > m_ps_ss;
hash_map<DWORD, Direct3DDepthStencilState9* > m_om_dss;
hash_map<DWORD, Direct3DBlendState9* > m_om_bs;
hash_map<DWORD, GSTexture9> m_mskfix;
hash_map<uint32, CComPtr<IDirect3DPixelShader9> > m_ps;
hash_map<uint32, Direct3DSamplerState9* > m_ps_ss;
hash_map<uint32, Direct3DDepthStencilState9* > m_om_dss;
hash_map<uint32, Direct3DBlendState9* > m_om_bs;
hash_map<uint32, GSTexture9> m_mskfix;
public:
GSTextureFX9();
bool Create(GSDevice9* dev);
bool CreateMskFix(GSTexture9& t, DWORD size, DWORD msk, DWORD fix);
bool CreateMskFix(GSTexture9& t, uint32 size, uint32 msk, uint32 fix);
bool SetupIA(const GSVertexHW9* vertices, UINT count, D3DPRIMITIVETYPE prim);
bool SetupIA(const GSVertexHW9* vertices, int count, D3DPRIMITIVETYPE prim);
bool SetupVS(VSSelector sel, const VSConstantBuffer* cb);
bool SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel, IDirect3DTexture9* tex, IDirect3DTexture9* pal, bool psrr);
void UpdatePS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel, bool psrr);
void SetupRS(int w, int h, const RECT& scissor);
void SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, BYTE bf, IDirect3DSurface9* rt, IDirect3DSurface9* ds);
void UpdateOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, BYTE bf);
void SetupRS(int w, int h, const GSVector4i& scissor);
void SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 bf, IDirect3DSurface9* rt, IDirect3DSurface9* ds);
void UpdateOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 bf);
};

View File

@ -37,8 +37,8 @@ public:
int GetWidth() const {return m_desc.w;}
int GetHeight() const {return m_desc.h;}
int GetFormat() const {return m_desc.format;}
bool Update(const CRect& r, const void* data, int pitch) {return true;}
bool Map(BYTE** bits, int& pitch, const RECT* r = NULL) {return true;}
bool Update(const GSVector4i& r, const void* data, int pitch) {return true;}
bool Map(uint8** bits, int& pitch) {return true;}
void Unmap() {}
bool Save(const string& fn, bool dds = false) {return false;}
};

63
plugins/GSdx/GSThread.cpp Normal file
View File

@ -0,0 +1,63 @@
/*
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#include "StdAfx.h"
#include "GSThread.h"
GSThread::GSThread()
: m_ThreadId(0)
, m_hThread(NULL)
{
}
GSThread::~GSThread()
{
CloseThread();
}
DWORD WINAPI GSThread::StaticThreadProc(LPVOID lpParam)
{
((GSThread*)lpParam)->ThreadProc();
return 0;
}
void GSThread::CreateThread()
{
m_hThread = ::CreateThread(NULL, 0, StaticThreadProc, (LPVOID)this, 0, &m_ThreadId);
}
void GSThread::CloseThread()
{
if(m_hThread != NULL)
{
if(WaitForSingleObject(m_hThread, 5000) != WAIT_OBJECT_0)
{
TerminateThread(m_hThread, 1);
}
CloseHandle(m_hThread);
m_hThread = NULL;
m_ThreadId = 0;
}
}

42
plugins/GSdx/GSThread.h Normal file
View File

@ -0,0 +1,42 @@
/*
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#pragma once
class GSThread
{
// TODO: linux
DWORD m_ThreadId;
HANDLE m_hThread;
static DWORD WINAPI StaticThreadProc(LPVOID lpParam);
protected:
virtual void ThreadProc() = 0;
void CreateThread();
void CloseThread();
public:
GSThread();
virtual ~GSThread();
};

View File

@ -23,10 +23,11 @@
#include "GS.h"
#include "GSUtil.h"
#include "svnrev.h"
#include "xbyak/xbyak_util.h"
static struct GSUtilMaps
{
BYTE PrimClassField[8];
uint8 PrimClassField[8];
bool CompatibleBitsField[64][64];
bool SharedBitsField[64][64];
@ -72,80 +73,45 @@ static struct GSUtilMaps
} s_maps;
GS_PRIM_CLASS GSUtil::GetPrimClass(DWORD prim)
GS_PRIM_CLASS GSUtil::GetPrimClass(uint32 prim)
{
return (GS_PRIM_CLASS)s_maps.PrimClassField[prim];
}
bool GSUtil::HasSharedBits(DWORD spsm, DWORD dpsm)
bool GSUtil::HasSharedBits(uint32 spsm, uint32 dpsm)
{
return s_maps.SharedBitsField[spsm][dpsm];
}
bool GSUtil::HasSharedBits(DWORD sbp, DWORD spsm, DWORD dbp, DWORD dpsm)
bool GSUtil::HasSharedBits(uint32 sbp, uint32 spsm, uint32 dbp, uint32 dpsm)
{
if(sbp != dbp) return false;
return HasSharedBits(spsm, dpsm);
}
bool GSUtil::HasCompatibleBits(DWORD spsm, DWORD dpsm)
bool GSUtil::HasCompatibleBits(uint32 spsm, uint32 dpsm)
{
if(spsm == dpsm) return true;
return s_maps.CompatibleBitsField[spsm][dpsm];
}
bool GSUtil::IsRectInRect(const CRect& inner, const CRect& outer)
bool GSUtil::IsRectInRect(const GSVector4i& inner, const GSVector4i& outer)
{
return outer.left <= inner.left && inner.right <= outer.right && outer.top <= inner.top && inner.bottom <= outer.bottom;
}
bool GSUtil::IsRectInRectH(const CRect& inner, const CRect& outer)
bool GSUtil::IsRectInRectH(const GSVector4i& inner, const GSVector4i& outer)
{
return outer.top <= inner.top && inner.bottom <= outer.bottom;
}
bool GSUtil::IsRectInRectV(const CRect& inner, const CRect& outer)
bool GSUtil::IsRectInRectV(const GSVector4i& inner, const GSVector4i& outer)
{
return outer.left <= inner.left && inner.right <= outer.right;
}
void GSUtil::FitRect(CRect& r, int aspectratio)
{
static const int ar[][2] = {{0, 0}, {4, 3}, {16, 9}};
if(aspectratio <= 0 || aspectratio >= countof(ar))
{
return;
}
int arx = ar[aspectratio][0];
int ary = ar[aspectratio][1];
CRect r2 = r;
if(arx > 0 && ary > 0)
{
if(r.Width() * ary > r.Height() * arx)
{
int w = r.Height() * arx / ary;
r.left = r.CenterPoint().x - w / 2;
if(r.left & 1) r.left++;
r.right = r.left + w;
}
else
{
int h = r.Width() * ary / arx;
r.top = r.CenterPoint().y - h / 2;
if(r.top & 1) r.top++;
r.bottom = r.top + h;
}
}
r &= r2;
}
bool GSUtil::CheckDirectX()
{
if(HINSTANCE hDll = LoadLibrary(format("d3dx9_%d.dll", D3DX_SDK_VERSION).c_str()))
@ -167,33 +133,22 @@ bool GSUtil::CheckDirectX()
return true;
}
static bool _CheckSSE()
{
__try
{
static __m128i m;
#if _M_SSE >= 0x402
m.m128i_i32[0] = _mm_popcnt_u32(1234);
#elif _M_SSE >= 0x401
m = _mm_packus_epi32(m, m);
#elif _M_SSE >= 0x301
m = _mm_alignr_epi8(m, m, 1);
#elif _M_SSE >= 0x200
m = _mm_packs_epi32(m, m);
#endif
}
__except(EXCEPTION_EXECUTE_HANDLER)
{
return false;
}
return true;
}
bool GSUtil::CheckSSE()
{
if(!_CheckSSE())
Xbyak::util::Cpu cpu;
Xbyak::util::Cpu::Type type;
#if _M_SSE >= 0x402
type = Xbyak::util::Cpu::tSSE42;
#elif _M_SSE >= 0x401
type = Xbyak::util::Cpu::tSSE41;
#elif _M_SSE >= 0x301
type = Xbyak::util::Cpu::tSSSE3;
#elif _M_SSE >= 0x200
type = Xbyak::util::Cpu::tSSE2;
#endif
if(!cpu.has(type))
{
string s = format("This CPU does not support SSE %d.%02d", _M_SSE >> 8, _M_SSE & 0xff);
@ -223,29 +178,31 @@ char* GSUtil::GetLibName()
if(SVN_MODS) str += "m";
#if _M_AMD64
#if _M_AMD64
str += " 64-bit";
#endif
#endif
list<string> sl;
#ifdef __INTEL_COMPILER
sl.push_back(format("Intel C++ %d.%02d", __INTEL_COMPILER / 100, __INTEL_COMPILER % 100));
#elif _MSC_VER
sl.push_back(format("MSVC %d.%02d", _MSC_VER / 100, _MSC_VER % 100));
#endif
// TODO: gcc
#if _M_SSE >= 0x402
#ifdef __INTEL_COMPILER
sl.push_back(format("Intel C++ %d.%02d", __INTEL_COMPILER / 100, __INTEL_COMPILER % 100));
#elif _MSC_VER
sl.push_back(format("MSVC %d.%02d", _MSC_VER / 100, _MSC_VER % 100));
#endif
#if _M_SSE >= 0x402
sl.push_back("SSE42");
#elif _M_SSE >= 0x401
#elif _M_SSE >= 0x401
sl.push_back("SSE41");
#elif _M_SSE >= 0x301
#elif _M_SSE >= 0x301
sl.push_back("SSSE3");
#elif _M_SSE >= 0x200
#elif _M_SSE >= 0x200
sl.push_back("SSE2");
#elif _M_SSE >= 0x100
#elif _M_SSE >= 0x100
sl.push_back("SSE");
#endif
#endif
for(list<string>::iterator i = sl.begin(); i != sl.end(); )
{

View File

@ -26,19 +26,17 @@
class GSUtil
{
public:
static GS_PRIM_CLASS GetPrimClass(DWORD prim);
static GS_PRIM_CLASS GetPrimClass(uint32 prim);
static bool HasSharedBits(DWORD spsm, DWORD dpsm);
static bool HasSharedBits(DWORD sbp, DWORD spsm, DWORD dbp, DWORD dpsm);
static bool HasCompatibleBits(DWORD spsm, DWORD dpsm);
static bool HasSharedBits(uint32 spsm, uint32 dpsm);
static bool HasSharedBits(uint32 sbp, uint32 spsm, uint32 dbp, uint32 dpsm);
static bool HasCompatibleBits(uint32 spsm, uint32 dpsm);
static bool IsRectInRect(const CRect& inner, const CRect& outer);
static bool IsRectInRectH(const CRect& inner, const CRect& outer);
static bool IsRectInRectV(const CRect& inner, const CRect& outer);
static void FitRect(CRect& r, int aspectratio);
static bool IsRectInRect(const GSVector4i& inner, const GSVector4i& outer);
static bool IsRectInRectH(const GSVector4i& inner, const GSVector4i& outer);
static bool IsRectInRectV(const GSVector4i& inner, const GSVector4i& outer);
static int EncodePSM(int psm)
static uint32 EncodePSM(uint32 psm)
{
switch(psm)
{

View File

@ -46,3 +46,55 @@ GSVector4 GSVector4::cast(const GSVector4i& v)
{
return GSVector4(_mm_castsi128_ps(v.m));
}
GSVector4i GSVector4i::fit(int arx, int ary) const
{
GSVector4i r = *this;
if(arx > 0 && ary > 0)
{
int w = width();
int h = height();
if(w * ary > h * arx)
{
int w2 = w * arx / ary;
r.left = (r.left + r.right - w2) >> 1;
if(r.left & 1) r.left++;
r.right = r.left + w2;
}
else
{
int h2 = w * ary / arx;
r.top = (r.top + r.bottom - h2) >> 1;
if(r.top & 1) r.top++;
r.bottom = r.top + h2;
}
r = r.rintersect(*this);
}
else
{
r = *this;
}
return r;
}
GSVector4i GSVector4i::fit(int preset) const
{
GSVector4i r;
static const int ar[][2] = {{0, 0}, {4, 3}, {16, 9}};
if(preset > 0 && preset < countof(ar))
{
r = fit(ar[preset][0], ar[preset][1]);
}
else
{
r = *this;
}
return r;
}

View File

@ -29,9 +29,11 @@ public:
*this = v;
}
void operator = (const GSVector2T& v)
const GSVector2T& operator = (const GSVector2T& v)
{
_mm_storel_epi64((__m128i*)this, _mm_loadl_epi64((__m128i*)&v));
return *this;
}
};
@ -47,16 +49,17 @@ public:
{
struct {int x, y, z, w;};
struct {int r, g, b, a;};
struct {int left, top, right, bottom;};
int v[4];
float f32[4];
unsigned __int64 u64[2];
__int8 i8[16];
__int16 i16[8];
__int32 i32[4];
__int64 i64[2];
unsigned __int8 u8[16];
unsigned __int16 u16[8];
unsigned __int32 u32[4];
int8 i8[16];
int16 i16[8];
int32 i32[4];
int64 i64[2];
uint8 u8[16];
uint16 u16[8];
uint32 u32[4];
uint64 u64[2];
__m128i m;
};
@ -113,11 +116,6 @@ public:
this->m = m;
}
explicit GSVector4i(const CRect& r)
{
*this = GSVector4i(r.left, r.top, r.right, r.bottom);
}
explicit GSVector4i(const GSVector4& v)
{
*this = v;
@ -140,29 +138,70 @@ public:
this->m = m;
}
void operator = (const CRect& r)
{
m = GSVector4i(r);
}
operator __m128i() const
{
return m;
}
operator CRect() const
// rect
int width() const
{
return *(CRect*)&m;
return right - left;
}
UINT32 rgba32() const
int height() const
{
return bottom - top;
}
bool rempty() const
{
return (*this < zwzw()).mask() != 0x00ff;
}
GSVector4i runion(const GSVector4i& a) const
{
#if _M_SSE >= 0x401
return min_i32(a).upl64(max_i32(a).srl<8>());
#else
return GSVector4i(min(x, a.x), min(y, a.y), max(z, a.z), max(x, a.w));
#endif
}
GSVector4i rintersect(const GSVector4i& a) const
{
return sat_i32(a);
}
GSVector4i fit(int arx, int ary) const;
GSVector4i fit(int preset) const;
operator LPCRECT() const
{
return (LPCRECT)this;
}
operator LPRECT()
{
return (LPRECT)this;
}
//
uint32 rgba32() const
{
GSVector4i v = *this;
v = v.ps32(v);
v = v.pu16(v);
return (UINT32)store(v);
return (uint32)store(v);
}
static GSVector4i cast(const GSVector4& v);
@ -203,6 +242,32 @@ public:
return max_i32(a.xyxy()).min_i32(a.zwzw());
}
#else
GSVector4i sat_i32(const GSVector4i& a, const GSVector4i& b) const
{
GSVector4i v;
v.x = min(max(x, a.x), b.x);
v.y = min(max(y, a.y), b.y);
v.z = min(max(z, a.z), b.z);
v.w = min(max(x, a.w), b.w);
return v;
}
GSVector4i sat_i32(const GSVector4i& a) const
{
GSVector4i v;
v.x = min(max(x, a.x), b.z);
v.y = min(max(y, a.y), b.w);
v.z = min(max(z, a.x), b.z);
v.w = min(max(x, a.y), b.w);
return v;
}
#endif
GSVector4i sat_u8(const GSVector4i& a, const GSVector4i& b) const
@ -841,6 +906,18 @@ public:
return sll16(shift + 1).mul16hs(f);
}
bool eq(const GSVector4i& v) const
{
#if _M_SSE >= 0x401
// pxor, ptest, je
GSVector4i t = *this ^ v;
return _mm_testz_si128(t, t) != 0;
#else
// pcmpeqd, pmovmskb, cmp, je
return eq32(v).alltrue();
#endif
}
GSVector4i eq8(const GSVector4i& v) const
{
return GSVector4i(_mm_cmpeq_epi8(m, v.m));
@ -1357,7 +1434,7 @@ public:
dst[1] = gather8_4<8>(ptr);
}
__forceinline void gather8_8(const BYTE* RESTRICT ptr, GSVector4i* RESTRICT dst) const
__forceinline void gather8_8(const uint8* RESTRICT ptr, GSVector4i* RESTRICT dst) const
{
dst[0] = gather8_8<>(ptr);
}
@ -2077,16 +2154,17 @@ public:
{
struct {float x, y, z, w;};
struct {float r, g, b, a;};
struct {int left, top, right, bottom;};
float v[4];
float f32[4];
unsigned __int64 u64[2];
__int8 i8[16];
__int16 i16[8];
__int32 i32[4];
__int64 i64[2];
unsigned __int8 u8[16];
unsigned __int16 u16[8];
unsigned __int32 u32[4];
int8 i8[16];
int16 i16[8];
int32 i32[4];
int64 i64[2];
uint8 u8[16];
uint16 u16[8];
uint32 u32[4];
uint64 u64[2];
__m128 m;
};
@ -2140,14 +2218,9 @@ public:
this->m = m;
}
explicit GSVector4(CRect r)
explicit GSVector4(uint32 u32)
{
m = _mm_set_ps((float)r.bottom, (float)r.right, (float)r.top, (float)r.left);
}
explicit GSVector4(DWORD dw)
{
*this = GSVector4(GSVector4i::load((int)dw).u8to32());
*this = GSVector4(GSVector4i::load((int)u32).u8to32());
}
explicit GSVector4(const GSVector4i& v)
@ -2172,14 +2245,9 @@ public:
this->m = m;
}
void operator = (DWORD dw)
void operator = (uint32 u32)
{
*this = GSVector4(GSVector4i::load((int)dw).u8to32());
}
void operator = (CRect r)
{
*this = GSVector4(GSVector4i(r.left, r.top, r.right, r.bottom));
*this = GSVector4(GSVector4i::load((int)u32).u8to32());
}
operator __m128() const
@ -2187,7 +2255,7 @@ public:
return m;
}
UINT32 rgba32() const
uint32 rgba32() const
{
return GSVector4i(*this).rgba32();
}

View File

@ -48,7 +48,7 @@ __declspec(align(16)) struct GSVertex
GSVertex() {memset(this, 0, sizeof(*this));}
GSVector4 GetUV() const {return GSVector4(GSVector4i::load(UV.ai32[0]).upl16());}
GSVector4 GetUV() const {return GSVector4(GSVector4i::load(UV.u32[0]).upl16());}
};
struct GSVertexOld

View File

@ -30,17 +30,19 @@ __declspec(align(16)) union GSVertexHW9
struct
{
GSVector2 t;
union {struct {BYTE r, g, b, a;}; DWORD c0;};
union {struct {BYTE ta0, ta1, res, f;}; DWORD c1;};
union {struct {uint8 r, g, b, a;}; uint32 c0;};
union {struct {uint8 ta0, ta1, res, f;}; uint32 c1;};
GSVector4 p;
};
#if _M_SSE >= 0x200
struct {__m128i m128i[2];};
struct {__m128 m128[2];};
#if _M_SSE >= 0x200
GSVertexHW9& operator = (GSVertexHW9& v) {m128i[0] = v.m128i[0]; m128i[1] = v.m128i[1]; return *this;}
#endif
#endif
float GetQ() {return p.w;}
};
@ -57,29 +59,31 @@ __declspec(align(16)) union GSVertexHW10
union
{
struct {union {struct {WORD x, y;}; DWORD xy;}; DWORD z;} p;
struct {union {struct {uint16 x, y;}; uint32 xy;}; uint32 z;} p;
GIFRegXYZ XYZ;
};
union
{
union {struct {BYTE r, g, b, a; float q;}; DWORD c0;};
union {struct {uint8 r, g, b, a; float q;}; uint32 c0;};
GIFRegRGBAQ RGBAQ;
};
union
{
struct {DWORD _pad[1]; union {struct {BYTE ta0, ta1, res, f;}; DWORD c1;};};
struct {uint32 _pad; union {struct {uint8 ta0, ta1, res, f;}; uint32 c1;};};
GIFRegFOG FOG;
};
};
#if _M_SSE >= 0x200
struct {__m128i m128i[2];};
struct {__m128 m128[2];};
#if _M_SSE >= 0x200
GSVertexHW10& operator = (GSVertexHW10& v) {m128i[0] = v.m128i[0]; m128i[1] = v.m128i[1]; return *this;}
#endif
#endif
float GetQ() {return q;}
};

View File

@ -25,7 +25,7 @@ template <class Vertex> class GSVertexList
{
void* m_base;
Vertex* m_v[3];
DWORD m_count;
int m_count;
public:
GSVertexList()
@ -80,7 +80,7 @@ public:
v = *m_v[i];
}
DWORD GetCount()
int GetCount()
{
return m_count;
}

View File

@ -26,7 +26,7 @@
using namespace Xbyak;
GSVertexTrace::GSVertexTraceCodeGenerator::GSVertexTraceCodeGenerator(DWORD key, void* ptr, size_t maxsize)
GSVertexTrace::GSVertexTraceCodeGenerator::GSVertexTraceCodeGenerator(uint32 key, void* ptr, size_t maxsize)
: CodeGenerator(maxsize, ptr)
{
#if _M_AMD64
@ -35,10 +35,10 @@ GSVertexTrace::GSVertexTraceCodeGenerator::GSVertexTraceCodeGenerator(DWORD key,
const int params = 0;
DWORD primclass = (key >> 0) & 3;
DWORD iip = (key >> 2) & 1;
DWORD tme = (key >> 3) & 1;
DWORD color = (key >> 4) & 1;
uint32 primclass = (key >> 0) & 3;
uint32 iip = (key >> 2) & 1;
uint32 tme = (key >> 3) & 1;
uint32 color = (key >> 4) & 1;
int n = 1;

View File

@ -222,16 +222,16 @@ __declspec(align(16)) class GSVertexTrace
class GSVertexTraceCodeGenerator : public Xbyak::CodeGenerator
{
public:
GSVertexTraceCodeGenerator(DWORD key, void* ptr, size_t maxsize);
GSVertexTraceCodeGenerator(uint32 key, void* ptr, size_t maxsize);
};
typedef void (*VertexTracePtr)(const GSVertexSW* v, int count, GSVertexSW& min, GSVertexSW& max);
class GSVertexTraceMap : public GSCodeGeneratorFunctionMap<GSVertexTraceCodeGenerator, DWORD, VertexTracePtr>
class GSVertexTraceMap : public GSCodeGeneratorFunctionMap<GSVertexTraceCodeGenerator, uint32, VertexTracePtr>
{
public:
GSVertexTraceMap() : GSCodeGeneratorFunctionMap("VertexTrace") {}
GSVertexTraceCodeGenerator* Create(DWORD key, void* ptr, size_t maxsize) {return new GSVertexTraceCodeGenerator(key, ptr, maxsize);}
GSVertexTraceCodeGenerator* Create(uint32 key, void* ptr, size_t maxsize) {return new GSVertexTraceCodeGenerator(key, ptr, maxsize);}
} m_map;
public:
@ -241,14 +241,14 @@ public:
union
{
DWORD value;
struct {DWORD x:1, y:1, z:1, f:1, s:1, t:1, q:1, _pad:1, r:1, g:1, b:1, a:1;};
struct {DWORD xyzf:4, stq:4, rgba:4;};
uint32 value;
struct {uint32 x:1, y:1, z:1, f:1, s:1, t:1, q:1, _pad:1, r:1, g:1, b:1, a:1;};
struct {uint32 xyzf:4, stq:4, rgba:4;};
} m_eq;
void Update(const GSVertexSW* v, int count, GS_PRIM_CLASS primclass, DWORD iip, DWORD tme, DWORD tfx, DWORD tcc)
void Update(const GSVertexSW* v, int count, GS_PRIM_CLASS primclass, uint32 iip, uint32 tme, uint32 tfx, uint32 tcc)
{
DWORD key = primclass | (iip << 2) | (tme << 3);
uint32 key = primclass | (iip << 2) | (tme << 3);
if(!(tme && tfx == TFX_DECAL && tcc))
{

File diff suppressed because it is too large Load Diff

View File

@ -1,80 +0,0 @@
/*
* Copyright (C) 2007-2009 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#pragma once
// sse2
#if _M_SSE >= 0x200
#include <xmmintrin.h>
#include <emmintrin.h>
#ifndef _MM_DENORMALS_ARE_ZERO
#define _MM_DENORMALS_ARE_ZERO 0x0040
#endif
#define MXCSR (_MM_DENORMALS_ARE_ZERO | _MM_MASK_MASK | _MM_ROUND_NEAREST | _MM_FLUSH_ZERO_ON)
#if _MSC_VER < 1500
__forceinline __m128i _mm_castps_si128(__m128 a) {return *(__m128i*)&a;}
__forceinline __m128 _mm_castsi128_ps(__m128i a) {return *(__m128*)&a;}
__forceinline __m128i _mm_castpd_si128(__m128d a) {return *(__m128i*)&a;}
__forceinline __m128d _mm_castsi128_pd(__m128i a) {return *(__m128d*)&a;}
__forceinline __m128d _mm_castps_pd(__m128 a) {return *(__m128d*)&a;}
__forceinline __m128 _mm_castpd_ps(__m128d a) {return *(__m128*)&a;}
#endif
#define _MM_TRANSPOSE4_SI128(row0, row1, row2, row3) \
{ \
__m128 tmp0 = _mm_shuffle_ps(_mm_castsi128_ps(row0), _mm_castsi128_ps(row1), 0x44); \
__m128 tmp2 = _mm_shuffle_ps(_mm_castsi128_ps(row0), _mm_castsi128_ps(row1), 0xEE); \
__m128 tmp1 = _mm_shuffle_ps(_mm_castsi128_ps(row2), _mm_castsi128_ps(row3), 0x44); \
__m128 tmp3 = _mm_shuffle_ps(_mm_castsi128_ps(row2), _mm_castsi128_ps(row3), 0xEE); \
(row0) = _mm_castps_si128(_mm_shuffle_ps(tmp0, tmp1, 0x88)); \
(row1) = _mm_castps_si128(_mm_shuffle_ps(tmp0, tmp1, 0xDD)); \
(row2) = _mm_castps_si128(_mm_shuffle_ps(tmp2, tmp3, 0x88)); \
(row3) = _mm_castps_si128(_mm_shuffle_ps(tmp2, tmp3, 0xDD)); \
}
#else
#error TODO: GSVector4 and GSRasterizer needs SSE2
#endif
// sse3
#if _M_SSE >= 0x301
#include <tmmintrin.h>
#endif
// sse4
#if _M_SSE >= 0x401
#include <smmintrin.h>
#endif

View File

@ -4,7 +4,7 @@
#pragma once
#pragma warning(disable: 4996)
#pragma warning(disable: 4996 4995 4324 4100)
#ifndef VC_EXTRALEAN
#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
@ -36,11 +36,9 @@
#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
//#include <afxmt.h>
#include <ddraw.h>
#include <d3d9.h>
#include <d3dx9.h>
#include <d3d10.h>
#include <d3dx10.h>
// stdc
#include <math.h>
#include <string>
@ -54,13 +52,20 @@ using namespace stdext;
extern string format(const char* fmt, ...);
#if !defined(_M_SSE) && (defined(_M_AMD64) || defined(_M_IX86_FP) && _M_IX86_FP >= 2)
#define _M_SSE 0x200
#endif
// syntactic sugar
#include "sse.h"
// put these into vc9/common7/ide/usertype.dat to have them highlighted
#define countof(a) (sizeof(a)/sizeof(a[0]))
typedef unsigned char uint8;
typedef signed char int8;
typedef unsigned short uint16;
typedef signed short int16;
typedef unsigned int uint32;
typedef signed int int32;
typedef unsigned long long uint64;
typedef signed long long int64;
#define countof(a) (sizeof(a) / sizeof(a[0]))
#define EXPORT_C extern "C" __declspec(dllexport) void __stdcall
#define EXPORT_C_(type) extern "C" __declspec(dllexport) type __stdcall
@ -68,16 +73,80 @@ extern string format(const char* fmt, ...);
#ifndef RESTRICT
#ifdef __INTEL_COMPILER
#define RESTRICT restrict
#elif _MSC_VER >= 1400
#elif _MSC_VER >= 1400 // TODO: gcc
#define RESTRICT __restrict
#else
#define RESTRICT
#endif
#endif
#pragma warning(disable : 4995 4324 4100)
// directx
#define D3DCOLORWRITEENABLE_RGB (D3DCOLORWRITEENABLE_RED|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_BLUE)
#define D3DCOLORWRITEENABLE_RGBA (D3DCOLORWRITEENABLE_RGB|D3DCOLORWRITEENABLE_ALPHA)
#include <ddraw.h>
#include <d3d9.h>
#include <d3dx9.h>
#include <d3d10.h>
#include <d3dx10.h>
#define D3DCOLORWRITEENABLE_RGBA (D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_ALPHA)
// sse
#if !defined(_M_SSE) && (defined(_M_AMD64) || defined(_M_IX86_FP) && _M_IX86_FP >= 2)
#define _M_SSE 0x200
#endif
#if _M_SSE >= 0x200
#include <xmmintrin.h>
#include <emmintrin.h>
#ifndef _MM_DENORMALS_ARE_ZERO
#define _MM_DENORMALS_ARE_ZERO 0x0040
#endif
#define MXCSR (_MM_DENORMALS_ARE_ZERO | _MM_MASK_MASK | _MM_ROUND_NEAREST | _MM_FLUSH_ZERO_ON)
#if _MSC_VER < 1500
__forceinline __m128i _mm_castps_si128(__m128 a) {return *(__m128i*)&a;}
__forceinline __m128 _mm_castsi128_ps(__m128i a) {return *(__m128*)&a;}
__forceinline __m128i _mm_castpd_si128(__m128d a) {return *(__m128i*)&a;}
__forceinline __m128d _mm_castsi128_pd(__m128i a) {return *(__m128d*)&a;}
__forceinline __m128d _mm_castps_pd(__m128 a) {return *(__m128d*)&a;}
__forceinline __m128 _mm_castpd_ps(__m128d a) {return *(__m128*)&a;}
#endif
#define _MM_TRANSPOSE4_SI128(row0, row1, row2, row3) \
{ \
__m128 tmp0 = _mm_shuffle_ps(_mm_castsi128_ps(row0), _mm_castsi128_ps(row1), 0x44); \
__m128 tmp2 = _mm_shuffle_ps(_mm_castsi128_ps(row0), _mm_castsi128_ps(row1), 0xEE); \
__m128 tmp1 = _mm_shuffle_ps(_mm_castsi128_ps(row2), _mm_castsi128_ps(row3), 0x44); \
__m128 tmp3 = _mm_shuffle_ps(_mm_castsi128_ps(row2), _mm_castsi128_ps(row3), 0xEE); \
(row0) = _mm_castps_si128(_mm_shuffle_ps(tmp0, tmp1, 0x88)); \
(row1) = _mm_castps_si128(_mm_shuffle_ps(tmp0, tmp1, 0xDD)); \
(row2) = _mm_castps_si128(_mm_shuffle_ps(tmp2, tmp3, 0x88)); \
(row3) = _mm_castps_si128(_mm_shuffle_ps(tmp2, tmp3, 0xDD)); \
}
#else
#error TODO: GSVector4 and GSRasterizer needs SSE2
#endif
#if _M_SSE >= 0x301
#include <tmmintrin.h>
#endif
#if _M_SSE >= 0x401
#include <smmintrin.h>
#endif
#define QI(i) (riid == __uuidof(i)) ? GetInterface((i*)this, ppv) :

View File

@ -62,7 +62,7 @@ enum {
DEFAULT_MAX_CODE_SIZE = 2048,
VERSION = 0x2070, /* 0xABCD = A.BC(D) */
};
/*
#ifndef MIE_DEFINED_UINT32
#define MIE_DEFINED_UINT32
#ifdef _MSC_VER
@ -81,7 +81,7 @@ enum {
#endif
#endif
#endif
*/
enum Error {
ERR_NONE = 0,
ERR_BAD_ADDRESSING,