From 5648d07b96f396882d380e38afefae9428cb9e95 Mon Sep 17 00:00:00 2001 From: gabest11 Date: Thu, 14 May 2009 16:41:52 +0000 Subject: [PATCH] GSdx: more refactoring (aka search and replace) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1179 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GPU.cpp | 73 +- plugins/GSdx/GPU.h | 278 +- plugins/GSdx/GPUDrawScanline.cpp | 6 +- plugins/GSdx/GPUDrawScanline.h | 8 +- plugins/GSdx/GPUDrawScanlineCodeGenerator.cpp | 6 +- plugins/GSdx/GPUDrawScanlineCodeGenerator.h | 2 +- plugins/GSdx/GPUDrawingEnvironment.h | 8 +- plugins/GSdx/GPULocalMemory.cpp | 202 +- plugins/GSdx/GPULocalMemory.h | 49 +- plugins/GSdx/GPURenderer.h | 29 +- plugins/GSdx/GPURendererSW.h | 55 +- plugins/GSdx/GPUScanlineEnvironment.h | 43 +- plugins/GSdx/GPUSettingsDlg.cpp | 10 +- plugins/GSdx/GPUState.cpp | 96 +- plugins/GSdx/GPUState.h | 24 +- plugins/GSdx/GS.cpp | 56 +- plugins/GSdx/GS.h | 962 ++--- plugins/GSdx/GSBlock.h | 806 +--- plugins/GSdx/GSCapture.cpp | 74 +- plugins/GSdx/GSCapture.h | 5 +- plugins/GSdx/GSClut.cpp | 283 +- plugins/GSdx/GSClut.h | 40 +- plugins/GSdx/GSCodeBuffer.cpp | 4 +- plugins/GSdx/GSCodeBuffer.h | 2 +- plugins/GSdx/GSCrc.cpp | 6 +- plugins/GSdx/GSCrc.h | 6 +- plugins/GSdx/GSDevice.h | 22 +- plugins/GSdx/GSDevice10.cpp | 54 +- plugins/GSdx/GSDevice10.h | 30 +- plugins/GSdx/GSDevice7.cpp | 19 +- plugins/GSdx/GSDevice7.h | 6 +- plugins/GSdx/GSDevice9.cpp | 54 +- plugins/GSdx/GSDevice9.h | 32 +- plugins/GSdx/GSDeviceNull.h | 6 +- plugins/GSdx/GSDirtyRect.cpp | 65 +- plugins/GSdx/GSDirtyRect.h | 14 +- plugins/GSdx/GSDrawScanline.cpp | 40 +- plugins/GSdx/GSDrawScanline.h | 12 +- plugins/GSdx/GSDrawScanlineCodeGenerator.cpp | 10 +- plugins/GSdx/GSDump.cpp | 6 +- plugins/GSdx/GSDump.h | 6 +- plugins/GSdx/GSFunctionMap.h | 8 +- plugins/GSdx/GSLocalMemory.cpp | 591 ++- plugins/GSdx/GSLocalMemory.h | 486 +-- plugins/GSdx/GSRasterizer.cpp | 79 +- plugins/GSdx/GSRasterizer.h | 9 +- plugins/GSdx/GSRenderer.h | 67 +- plugins/GSdx/GSRendererHW.h | 71 +- plugins/GSdx/GSRendererHW10.cpp | 12 +- plugins/GSdx/GSRendererHW10.h | 6 +- plugins/GSdx/GSRendererHW9.cpp | 16 +- plugins/GSdx/GSRendererHW9.h | 4 +- plugins/GSdx/GSRendererNull.h | 4 +- plugins/GSdx/GSRendererSW.h | 65 +- plugins/GSdx/GSScanlineEnvironment.h | 100 +- plugins/GSdx/GSSettingsDlg.cpp | 18 +- plugins/GSdx/GSSetupPrimCodeGenerator.cpp | 2 +- plugins/GSdx/GSSetupPrimCodeGenerator.h | 4 +- plugins/GSdx/GSState.cpp | 271 +- plugins/GSdx/GSState.h | 47 +- plugins/GSdx/GSTables.cpp | 32 +- plugins/GSdx/GSTables.h | 32 +- plugins/GSdx/GSTexture.h | 6 +- plugins/GSdx/GSTexture10.cpp | 16 +- plugins/GSdx/GSTexture10.h | 4 +- plugins/GSdx/GSTexture7.cpp | 28 +- plugins/GSdx/GSTexture7.h | 5 +- plugins/GSdx/GSTexture9.cpp | 22 +- plugins/GSdx/GSTexture9.h | 4 +- plugins/GSdx/GSTextureCache.h | 135 +- plugins/GSdx/GSTextureCache10.cpp | 77 +- plugins/GSdx/GSTextureCache10.h | 3 +- plugins/GSdx/GSTextureCache9.cpp | 78 +- plugins/GSdx/GSTextureCache9.h | 3 +- plugins/GSdx/GSTextureCacheSW.cpp | 114 +- plugins/GSdx/GSTextureCacheSW.h | 12 +- plugins/GSdx/GSTextureFX10.cpp | 14 +- plugins/GSdx/GSTextureFX10.h | 120 +- plugins/GSdx/GSTextureFX9.cpp | 28 +- plugins/GSdx/GSTextureFX9.h | 118 +- plugins/GSdx/GSTextureNull.h | 4 +- plugins/GSdx/GSThread.cpp | 63 + plugins/GSdx/GSThread.h | 42 + plugins/GSdx/GSUtil.cpp | 119 +- plugins/GSdx/GSUtil.h | 18 +- plugins/GSdx/GSVector.cpp | 52 + plugins/GSdx/GSVector.h | 162 +- plugins/GSdx/GSVertex.h | 2 +- plugins/GSdx/GSVertexHW.h | 22 +- plugins/GSdx/GSVertexList.h | 4 +- plugins/GSdx/GSVertexSW.cpp | 10 +- plugins/GSdx/GSVertexSW.h | 16 +- plugins/GSdx/GSdx_vs2008.vcproj | 3620 +++++++++-------- plugins/GSdx/sse.h | 80 - plugins/GSdx/stdafx.h | 101 +- plugins/GSdx/xbyak/xbyak.h | 4 +- 96 files changed, 4863 insertions(+), 5676 deletions(-) create mode 100644 plugins/GSdx/GSThread.cpp create mode 100644 plugins/GSdx/GSThread.h delete mode 100644 plugins/GSdx/sse.h diff --git a/plugins/GSdx/GPU.cpp b/plugins/GSdx/GPU.cpp index 63ab5b5309..4583b48b90 100644 --- a/plugins/GSdx/GPU.cpp +++ b/plugins/GSdx/GPU.cpp @@ -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 } diff --git a/plugins/GSdx/GPU.h b/plugins/GSdx/GPU.h index d341870565..d1ec2d6a3e 100644 --- a/plugins/GSdx/GPU.h +++ b/plugins/GSdx/GPU.h @@ -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) diff --git a/plugins/GSdx/GPUDrawScanline.cpp b/plugins/GSdx/GPUDrawScanline.cpp index 9fc3c64e01..e067278dd0 100644 --- a/plugins/GSdx/GPUDrawScanline.cpp +++ b/plugins/GSdx/GPUDrawScanline.cpp @@ -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); } diff --git a/plugins/GSdx/GPUDrawScanline.h b/plugins/GSdx/GPUDrawScanline.h index 9a39d87875..9d6f01fda3 100644 --- a/plugins/GSdx/GPUDrawScanline.h +++ b/plugins/GSdx/GPUDrawScanline.h @@ -34,24 +34,24 @@ class GPUDrawScanline : public GSAlignedClass<16>, public IDrawScanline // - class GPUSetupPrimMap : public GSCodeGeneratorFunctionMap + class GPUSetupPrimMap : public GSCodeGeneratorFunctionMap { 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 + class GPUDrawScanlineMap : public GSCodeGeneratorFunctionMap { 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: diff --git a/plugins/GSdx/GPUDrawScanlineCodeGenerator.cpp b/plugins/GSdx/GPUDrawScanlineCodeGenerator.cpp index 523b434f11..1a7699658d 100644 --- a/plugins/GSdx/GPUDrawScanlineCodeGenerator.cpp +++ b/plugins/GSdx/GPUDrawScanlineCodeGenerator.cpp @@ -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}, diff --git a/plugins/GSdx/GPUDrawScanlineCodeGenerator.h b/plugins/GSdx/GPUDrawScanlineCodeGenerator.h index 6e1d7f4256..423074b8bf 100644 --- a/plugins/GSdx/GPUDrawScanlineCodeGenerator.h +++ b/plugins/GSdx/GPUDrawScanlineCodeGenerator.h @@ -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; diff --git a/plugins/GSdx/GPUDrawingEnvironment.h b/plugins/GSdx/GPUDrawingEnvironment.h index e42064a450..c89ea4920a 100644 --- a/plugins/GSdx/GPUDrawingEnvironment.h +++ b/plugins/GSdx/GPUDrawingEnvironment.h @@ -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() diff --git a/plugins/GSdx/GPULocalMemory.cpp b/plugins/GSdx/GPULocalMemory.cpp index 4dcdc97975..c0bfefb076 100644 --- a/plugins/GSdx/GPULocalMemory.cpp +++ b/plugins/GSdx/GPULocalMemory.cpp @@ -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); diff --git a/plugins/GSdx/GPULocalMemory.h b/plugins/GSdx/GPULocalMemory.h index a4adfb4855..5759779a7e 100644 --- a/plugins/GSdx/GPULocalMemory.h +++ b/plugins/GSdx/GPULocalMemory.h @@ -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) \ No newline at end of file diff --git a/plugins/GSdx/GPURenderer.h b/plugins/GSdx/GPURenderer.h index 9adaa4968a..bd683a67c5 100644 --- a/plugins/GSdx/GPURenderer.h +++ b/plugins/GSdx/GPURenderer.h @@ -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) diff --git a/plugins/GSdx/GPURendererSW.h b/plugins/GSdx/GPURendererSW.h index 2ee2599b29..4ea9d29082 100644 --- a/plugins/GSdx/GPURendererSW.h +++ b/plugins/GSdx/GPURendererSW.h @@ -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); } diff --git a/plugins/GSdx/GPUScanlineEnvironment.h b/plugins/GSdx/GPUScanlineEnvironment.h index 4c7d9e66da..189341e7f8 100644 --- a/plugins/GSdx/GPUScanlineEnvironment.h +++ b/plugins/GSdx/GPUScanlineEnvironment.h @@ -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 diff --git a/plugins/GSdx/GPUSettingsDlg.cpp b/plugins/GSdx/GPUSettingsDlg.cpp index 0bccfa1d53..b1bbc9aa17 100644 --- a/plugins/GSdx/GPUSettingsDlg.cpp +++ b/plugins/GSdx/GPUSettingsDlg.cpp @@ -154,13 +154,13 @@ BOOL GPUSettingsDlg::OnInitDialog() if(CComPtr 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; diff --git a/plugins/GSdx/GPUState.cpp b/plugins/GSdx/GPUState.cpp index a8e7630f22..dae0e4cc1a 100644 --- a/plugins/GSdx/GPUState.cpp +++ b/plugins/GSdx/GPUState.cpp @@ -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); diff --git a/plugins/GSdx/GPUState.h b/plugins/GSdx/GPUState.h index 82d93692fd..db55189d3f 100644 --- a/plugins/GSdx/GPUState.h +++ b/plugins/GSdx/GPUState.h @@ -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); diff --git a/plugins/GSdx/GS.cpp b/plugins/GSdx/GS.cpp index c4fce6e68a..a06decfe00 100644 --- a/plugins/GSdx/GS.cpp +++ b/plugins/GSdx/GS.cpp @@ -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 buff; + vector 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]; diff --git a/plugins/GSdx/GS.h b/plugins/GSdx/GS.h index 43585a0aab..90ddc3f126 100644 --- a/plugins/GSdx/GS.h +++ b/plugins/GSdx/GS.h @@ -212,14 +212,14 @@ enum GS_AFAIL #define REG32(name) \ union name \ { \ - UINT32 ai32; \ + uint32 u32; \ struct { \ #define REG64(name) \ union name \ { \ - UINT64 i64; \ - UINT32 ai32[2]; \ + uint64 u64; \ + uint32 u32[2]; \ void operator = (const GSVector4i& v) {GSVector4i::storel(this, v);} \ operator GSVector4i() const {return GSVector4i::loadl(this);} \ struct { \ @@ -227,8 +227,8 @@ union name \ #define REG128(name)\ union name \ { \ - UINT64 ai64[2]; \ - UINT32 ai32[4]; \ + uint64 u64[2]; \ + uint32 u32[4]; \ struct { \ #define REG32_(prefix, name) REG32(prefix##name) @@ -241,176 +241,176 @@ union name \ #define REG32_SET(name) \ union name \ { \ - UINT32 ai32; \ + uint32 u32; \ #define REG64_SET(name) \ union name \ { \ - UINT64 i64; \ - UINT32 ai32[2]; \ + uint64 u64; \ + uint32 u32[2]; \ #define REG128_SET(name)\ union name \ { \ - __m128i ai128; \ - UINT64 ai64[2]; \ - UINT32 ai32[4]; \ + __m128i m128; \ + uint64 u64[2]; \ + uint32 u32[4]; \ #define REG_SET_END }; REG64_(GSReg, BGCOLOR) - UINT32 R:8; - UINT32 G:8; - UINT32 B:8; - UINT32 _PAD1:8; - UINT32 _PAD2:32; + uint32 R:8; + uint32 G:8; + uint32 B:8; + uint32 _PAD1:8; + uint32 _PAD2:32; REG_END REG64_(GSReg, BUSDIR) - UINT32 DIR:1; - UINT32 _PAD1:31; - UINT32 _PAD2:32; + uint32 DIR:1; + uint32 _PAD1:31; + uint32 _PAD2:32; REG_END REG64_(GSReg, CSR) - UINT32 rSIGNAL:1; - UINT32 rFINISH:1; - UINT32 rHSINT:1; - UINT32 rVSINT:1; - UINT32 rEDWINT:1; - UINT32 rZERO1:1; - UINT32 rZERO2:1; - UINT32 r_PAD1:1; - UINT32 rFLUSH:1; - UINT32 rRESET:1; - UINT32 r_PAD2:2; - UINT32 rNFIELD:1; - UINT32 rFIELD:1; - UINT32 rFIFO:2; - UINT32 rREV:8; - UINT32 rID:8; - UINT32 wSIGNAL:1; - UINT32 wFINISH:1; - UINT32 wHSINT:1; - UINT32 wVSINT:1; - UINT32 wEDWINT:1; - UINT32 wZERO1:1; - UINT32 wZERO2:1; - UINT32 w_PAD1:1; - UINT32 wFLUSH:1; - UINT32 wRESET:1; - UINT32 w_PAD2:2; - UINT32 wNFIELD:1; - UINT32 wFIELD:1; - UINT32 wFIFO:2; - UINT32 wREV:8; - UINT32 wID:8; + uint32 rSIGNAL:1; + uint32 rFINISH:1; + uint32 rHSINT:1; + uint32 rVSINT:1; + uint32 rEDWINT:1; + uint32 rZERO1:1; + uint32 rZERO2:1; + uint32 r_PAD1:1; + uint32 rFLUSH:1; + uint32 rRESET:1; + uint32 r_PAD2:2; + uint32 rNFIELD:1; + uint32 rFIELD:1; + uint32 rFIFO:2; + uint32 rREV:8; + uint32 rID:8; + uint32 wSIGNAL:1; + uint32 wFINISH:1; + uint32 wHSINT:1; + uint32 wVSINT:1; + uint32 wEDWINT:1; + uint32 wZERO1:1; + uint32 wZERO2:1; + uint32 w_PAD1:1; + uint32 wFLUSH:1; + uint32 wRESET:1; + uint32 w_PAD2:2; + uint32 wNFIELD:1; + uint32 wFIELD:1; + uint32 wFIFO:2; + uint32 wREV:8; + uint32 wID:8; REG_END REG64_(GSReg, DISPFB) // (-1/2) - UINT32 FBP:9; - UINT32 FBW:6; - UINT32 PSM:5; - UINT32 _PAD:12; - UINT32 DBX:11; - UINT32 DBY:11; - UINT32 _PAD2:10; + uint32 FBP:9; + uint32 FBW:6; + uint32 PSM:5; + uint32 _PAD:12; + uint32 DBX:11; + uint32 DBY:11; + uint32 _PAD2:10; REG_END2 - UINT32 Block() const {return FBP << 5;} + uint32 Block() const {return FBP << 5;} REG_END2 REG64_(GSReg, DISPLAY) // (-1/2) - UINT32 DX:12; - UINT32 DY:11; - UINT32 MAGH:4; - UINT32 MAGV:2; - UINT32 _PAD:3; - UINT32 DW:12; - UINT32 DH:11; - UINT32 _PAD2:9; + uint32 DX:12; + uint32 DY:11; + uint32 MAGH:4; + uint32 MAGV:2; + uint32 _PAD:3; + uint32 DW:12; + uint32 DH:11; + uint32 _PAD2:9; REG_END REG64_(GSReg, EXTBUF) - UINT32 EXBP:14; - UINT32 EXBW:6; - UINT32 FBIN:2; - UINT32 WFFMD:1; - UINT32 EMODA:2; - UINT32 EMODC:2; - UINT32 _PAD1:5; - UINT32 WDX:11; - UINT32 WDY:11; - UINT32 _PAD2:10; + uint32 EXBP:14; + uint32 EXBW:6; + uint32 FBIN:2; + uint32 WFFMD:1; + uint32 EMODA:2; + uint32 EMODC:2; + uint32 _PAD1:5; + uint32 WDX:11; + uint32 WDY:11; + uint32 _PAD2:10; REG_END REG64_(GSReg, EXTDATA) - UINT32 SX:12; - UINT32 SY:11; - UINT32 SMPH:4; - UINT32 SMPV:2; - UINT32 _PAD1:3; - UINT32 WW:12; - UINT32 WH:11; - UINT32 _PAD2:9; + uint32 SX:12; + uint32 SY:11; + uint32 SMPH:4; + uint32 SMPV:2; + uint32 _PAD1:3; + uint32 WW:12; + uint32 WH:11; + uint32 _PAD2:9; REG_END REG64_(GSReg, EXTWRITE) - UINT32 WRITE:1; - UINT32 _PAD1:31; - UINT32 _PAD2:32; + uint32 WRITE:1; + uint32 _PAD1:31; + uint32 _PAD2:32; REG_END REG64_(GSReg, IMR) - UINT32 _PAD1:8; - UINT32 SIGMSK:1; - UINT32 FINISHMSK:1; - UINT32 HSMSK:1; - UINT32 VSMSK:1; - UINT32 EDWMSK:1; - UINT32 _PAD2:19; - UINT32 _PAD3:32; + uint32 _PAD1:8; + uint32 SIGMSK:1; + uint32 FINISHMSK:1; + uint32 HSMSK:1; + uint32 VSMSK:1; + uint32 EDWMSK:1; + uint32 _PAD2:19; + uint32 _PAD3:32; REG_END REG64_(GSReg, PMODE) - UINT32 EN1:1; - UINT32 EN2:1; - UINT32 CRTMD:3; - UINT32 MMOD:1; - UINT32 AMOD:1; - UINT32 SLBG:1; - UINT32 ALP:8; - UINT32 _PAD:16; - UINT32 _PAD1:32; + uint32 EN1:1; + uint32 EN2:1; + uint32 CRTMD:3; + uint32 MMOD:1; + uint32 AMOD:1; + uint32 SLBG:1; + uint32 ALP:8; + uint32 _PAD:16; + uint32 _PAD1:32; REG_END REG64_(GSReg, SIGLBLID) - UINT32 SIGID:32; - UINT32 LBLID:32; + uint32 SIGID:32; + uint32 LBLID:32; REG_END REG64_(GSReg, SMODE1) - UINT32 RC:3; - UINT32 LC:7; - UINT32 T1248:2; - UINT32 SLCK:1; - UINT32 CMOD:2; - UINT32 EX:1; - UINT32 PRST:1; - UINT32 SINT:1; - UINT32 XPCK:1; - UINT32 PCK2:2; - UINT32 SPML:4; - UINT32 GCONT:1; // YCrCb - UINT32 PHS:1; - UINT32 PVS:1; - UINT32 PEHS:1; - UINT32 PEVS:1; - UINT32 CLKSEL:2; - UINT32 NVCK:1; - UINT32 SLCK2:1; - UINT32 VCKSEL:2; - UINT32 VHP:1; - UINT32 _PAD1:27; + uint32 RC:3; + uint32 LC:7; + uint32 T1248:2; + uint32 SLCK:1; + uint32 CMOD:2; + uint32 EX:1; + uint32 PRST:1; + uint32 SINT:1; + uint32 XPCK:1; + uint32 PCK2:2; + uint32 SPML:4; + uint32 GCONT:1; // YCrCb + uint32 PHS:1; + uint32 PVS:1; + uint32 PEHS:1; + uint32 PEVS:1; + uint32 CLKSEL:2; + uint32 NVCK:1; + uint32 SLCK2:1; + uint32 VCKSEL:2; + uint32 VHP:1; + uint32 _PAD1:27; REG_END /* @@ -430,11 +430,11 @@ CLKSEL=1 CMOD=0 EX=0 GCONT=0 LC=32 NVCK=1 PCK2=0 PEHS=0 PEVS=0 PHS=0 PRST=1 PVS= */ REG64_(GSReg, SMODE2) - UINT32 INT:1; - UINT32 FFMD:1; - UINT32 DPMS:2; - UINT32 _PAD2:28; - UINT32 _PAD3:32; + uint32 INT:1; + uint32 FFMD:1; + uint32 DPMS:2; + uint32 _PAD2:28; + uint32 _PAD3:32; REG_END REG64_(GSReg, SRFSH) @@ -474,41 +474,41 @@ REG_SET_END // #define SET_GIF_REG(gifTag, iRegNo, uiValue) \ - {((GIFTag*)&gifTag)->ai64[1] |= (((uiValue) & 0xf) << ((iRegNo) << 2));} + {((GIFTag*)&gifTag)->u64[1] |= (((uiValue) & 0xf) << ((iRegNo) << 2));} #ifdef _M_AMD64 #define GET_GIF_REG(tag, reg) \ - (((tag).ai64[1] >> ((reg) << 2)) & 0xf) + (((tag).u64[1] >> ((reg) << 2)) & 0xf) #else #define GET_GIF_REG(tag, reg) \ - (((tag).ai32[2 + ((reg) >> 3)] >> (((reg) & 7) << 2)) & 0xf) + (((tag).u32[2 + ((reg) >> 3)] >> (((reg) & 7) << 2)) & 0xf) #endif // // GIFTag REG128(GIFTag) - UINT32 NLOOP:15; - UINT32 EOP:1; - UINT32 _PAD1:16; - UINT32 _PAD2:14; - UINT32 PRE:1; - UINT32 PRIM:11; - UINT32 FLG:2; // enum GIF_FLG - UINT32 NREG:4; - UINT64 REGS:64; + uint32 NLOOP:15; + uint32 EOP:1; + uint32 _PAD1:16; + uint32 _PAD2:14; + uint32 PRE:1; + uint32 PRIM:11; + uint32 FLG:2; // enum GIF_FLG + uint32 NREG:4; + uint64 REGS:64; REG_END // GIFReg REG64_(GIFReg, ALPHA) - UINT32 A:2; - UINT32 B:2; - UINT32 C:2; - UINT32 D:2; - UINT32 _PAD1:24; - UINT32 FIX:8; - UINT32 _PAD2:24; + uint32 A:2; + uint32 B:2; + uint32 C:2; + uint32 D:2; + uint32 _PAD1:24; + uint32 FIX:8; + uint32 _PAD2:24; REG_END2 // opaque => output will be Cs/As __forceinline bool IsOpaque() const {return (A == B || C == 2 && FIX == 0) && D == 0 || (A == 0 && B == D && C == 2 && FIX == 0x80);} @@ -516,18 +516,18 @@ REG_END2 REG_END2 REG64_(GIFReg, BITBLTBUF) - UINT32 SBP:14; - UINT32 _PAD1:2; - UINT32 SBW:6; - UINT32 _PAD2:2; - UINT32 SPSM:6; - UINT32 _PAD3:2; - UINT32 DBP:14; - UINT32 _PAD4:2; - UINT32 DBW:6; - UINT32 _PAD5:2; - UINT32 DPSM:6; - UINT32 _PAD6:2; + uint32 SBP:14; + uint32 _PAD1:2; + uint32 SBW:6; + uint32 _PAD2:2; + uint32 SPSM:6; + uint32 _PAD3:2; + uint32 DBP:14; + uint32 _PAD4:2; + uint32 DBW:6; + uint32 _PAD5:2; + uint32 DPSM:6; + uint32 _PAD6:2; REG_END REG64_(GIFReg, CLAMP) @@ -535,212 +535,212 @@ union { struct { - UINT32 WMS:2; - UINT32 WMT:2; - UINT32 MINU:10; - UINT32 MAXU:10; - UINT32 _PAD1:8; - UINT32 _PAD2:2; - UINT32 MAXV:10; - UINT32 _PAD3:20; + uint32 WMS:2; + uint32 WMT:2; + uint32 MINU:10; + uint32 MAXU:10; + uint32 _PAD1:8; + uint32 _PAD2:2; + uint32 MAXV:10; + uint32 _PAD3:20; }; struct { - UINT64 _PAD4:24; - UINT64 MINV:10; - UINT64 _PAD5:30; + uint64 _PAD4:24; + uint64 MINV:10; + uint64 _PAD5:30; }; }; REG_END REG64_(GIFReg, COLCLAMP) - UINT32 CLAMP:1; - UINT32 _PAD1:31; - UINT32 _PAD2:32; + uint32 CLAMP:1; + uint32 _PAD1:31; + uint32 _PAD2:32; REG_END REG64_(GIFReg, DIMX) - INT32 DM00:3; - INT32 _PAD00:1; - INT32 DM01:3; - INT32 _PAD01:1; - INT32 DM02:3; - INT32 _PAD02:1; - INT32 DM03:3; - INT32 _PAD03:1; - INT32 DM10:3; - INT32 _PAD10:1; - INT32 DM11:3; - INT32 _PAD11:1; - INT32 DM12:3; - INT32 _PAD12:1; - INT32 DM13:3; - INT32 _PAD13:1; - INT32 DM20:3; - INT32 _PAD20:1; - INT32 DM21:3; - INT32 _PAD21:1; - INT32 DM22:3; - INT32 _PAD22:1; - INT32 DM23:3; - INT32 _PAD23:1; - INT32 DM30:3; - INT32 _PAD30:1; - INT32 DM31:3; - INT32 _PAD31:1; - INT32 DM32:3; - INT32 _PAD32:1; - INT32 DM33:3; - INT32 _PAD33:1; + int32 DM00:3; + int32 _PAD00:1; + int32 DM01:3; + int32 _PAD01:1; + int32 DM02:3; + int32 _PAD02:1; + int32 DM03:3; + int32 _PAD03:1; + int32 DM10:3; + int32 _PAD10:1; + int32 DM11:3; + int32 _PAD11:1; + int32 DM12:3; + int32 _PAD12:1; + int32 DM13:3; + int32 _PAD13:1; + int32 DM20:3; + int32 _PAD20:1; + int32 DM21:3; + int32 _PAD21:1; + int32 DM22:3; + int32 _PAD22:1; + int32 DM23:3; + int32 _PAD23:1; + int32 DM30:3; + int32 _PAD30:1; + int32 DM31:3; + int32 _PAD31:1; + int32 DM32:3; + int32 _PAD32:1; + int32 DM33:3; + int32 _PAD33:1; REG_END REG64_(GIFReg, DTHE) - UINT32 DTHE:1; - UINT32 _PAD1:31; - UINT32 _PAD2:32; + uint32 DTHE:1; + uint32 _PAD1:31; + uint32 _PAD2:32; REG_END REG64_(GIFReg, FBA) - UINT32 FBA:1; - UINT32 _PAD1:31; - UINT32 _PAD2:32; + uint32 FBA:1; + uint32 _PAD1:31; + uint32 _PAD2:32; REG_END REG64_(GIFReg, FINISH) - UINT32 _PAD1:32; - UINT32 _PAD2:32; + uint32 _PAD1:32; + uint32 _PAD2:32; REG_END REG64_(GIFReg, FOG) - UINT32 _PAD1:32; - UINT32 _PAD2:24; - UINT32 F:8; + uint32 _PAD1:32; + uint32 _PAD2:24; + uint32 F:8; REG_END REG64_(GIFReg, FOGCOL) - UINT32 FCR:8; - UINT32 FCG:8; - UINT32 FCB:8; - UINT32 _PAD1:8; - UINT32 _PAD2:32; + uint32 FCR:8; + uint32 FCG:8; + uint32 FCB:8; + uint32 _PAD1:8; + uint32 _PAD2:32; REG_END REG64_(GIFReg, FRAME) - UINT32 FBP:9; - UINT32 _PAD1:7; - UINT32 FBW:6; - UINT32 _PAD2:2; - UINT32 PSM:6; - UINT32 _PAD3:2; - UINT32 FBMSK:32; + uint32 FBP:9; + uint32 _PAD1:7; + uint32 FBW:6; + uint32 _PAD2:2; + uint32 PSM:6; + uint32 _PAD3:2; + uint32 FBMSK:32; REG_END2 - UINT32 Block() const {return FBP << 5;} + uint32 Block() const {return FBP << 5;} REG_END2 REG64_(GIFReg, HWREG) - UINT32 DATA_LOWER:32; - UINT32 DATA_UPPER:32; + uint32 DATA_LOWER:32; + uint32 DATA_UPPER:32; REG_END REG64_(GIFReg, LABEL) - UINT32 ID:32; - UINT32 IDMSK:32; + uint32 ID:32; + uint32 IDMSK:32; REG_END REG64_(GIFReg, MIPTBP1) - UINT64 TBP1:14; - UINT64 TBW1:6; - UINT64 TBP2:14; - UINT64 TBW2:6; - UINT64 TBP3:14; - UINT64 TBW3:6; - UINT64 _PAD:4; + uint64 TBP1:14; + uint64 TBW1:6; + uint64 TBP2:14; + uint64 TBW2:6; + uint64 TBP3:14; + uint64 TBW3:6; + uint64 _PAD:4; REG_END REG64_(GIFReg, MIPTBP2) - UINT64 TBP4:14; - UINT64 TBW4:6; - UINT64 TBP5:14; - UINT64 TBW5:6; - UINT64 TBP6:14; - UINT64 TBW6:6; - UINT64 _PAD:4; + uint64 TBP4:14; + uint64 TBW4:6; + uint64 TBP5:14; + uint64 TBW5:6; + uint64 TBP6:14; + uint64 TBW6:6; + uint64 _PAD:4; REG_END REG64_(GIFReg, NOP) - UINT32 _PAD1:32; - UINT32 _PAD2:32; + uint32 _PAD1:32; + uint32 _PAD2:32; REG_END REG64_(GIFReg, PABE) - UINT32 PABE:1; - UINT32 _PAD1:31; - UINT32 _PAD2:32; + uint32 PABE:1; + uint32 _PAD1:31; + uint32 _PAD2:32; REG_END REG64_(GIFReg, PRIM) - UINT32 PRIM:3; - UINT32 IIP:1; - UINT32 TME:1; - UINT32 FGE:1; - UINT32 ABE:1; - UINT32 AA1:1; - UINT32 FST:1; - UINT32 CTXT:1; - UINT32 FIX:1; - UINT32 _PAD1:21; - UINT32 _PAD2:32; + uint32 PRIM:3; + uint32 IIP:1; + uint32 TME:1; + uint32 FGE:1; + uint32 ABE:1; + uint32 AA1:1; + uint32 FST:1; + uint32 CTXT:1; + uint32 FIX:1; + uint32 _PAD1:21; + uint32 _PAD2:32; REG_END REG64_(GIFReg, PRMODE) - UINT32 _PRIM:3; - UINT32 IIP:1; - UINT32 TME:1; - UINT32 FGE:1; - UINT32 ABE:1; - UINT32 AA1:1; - UINT32 FST:1; - UINT32 CTXT:1; - UINT32 FIX:1; - UINT32 _PAD2:21; - UINT32 _PAD3:32; + uint32 _PRIM:3; + uint32 IIP:1; + uint32 TME:1; + uint32 FGE:1; + uint32 ABE:1; + uint32 AA1:1; + uint32 FST:1; + uint32 CTXT:1; + uint32 FIX:1; + uint32 _PAD2:21; + uint32 _PAD3:32; REG_END REG64_(GIFReg, PRMODECONT) - UINT32 AC:1; - UINT32 _PAD1:31; - UINT32 _PAD2:32; + uint32 AC:1; + uint32 _PAD1:31; + uint32 _PAD2:32; REG_END REG64_(GIFReg, RGBAQ) - UINT32 R:8; - UINT32 G:8; - UINT32 B:8; - UINT32 A:8; + uint32 R:8; + uint32 G:8; + uint32 B:8; + uint32 A:8; float Q; REG_END REG64_(GIFReg, SCANMSK) - UINT32 MSK:2; - UINT32 _PAD1:30; - UINT32 _PAD2:32; + uint32 MSK:2; + uint32 _PAD1:30; + uint32 _PAD2:32; REG_END REG64_(GIFReg, SCISSOR) - UINT32 SCAX0:11; - UINT32 _PAD1:5; - UINT32 SCAX1:11; - UINT32 _PAD2:5; - UINT32 SCAY0:11; - UINT32 _PAD3:5; - UINT32 SCAY1:11; - UINT32 _PAD4:5; + uint32 SCAX0:11; + uint32 _PAD1:5; + uint32 SCAX1:11; + uint32 _PAD2:5; + uint32 SCAY0:11; + uint32 _PAD3:5; + uint32 SCAY1:11; + uint32 _PAD4:5; REG_END REG64_(GIFReg, SIGNAL) - UINT32 ID:32; - UINT32 IDMSK:32; + uint32 ID:32; + uint32 IDMSK:32; REG_END REG64_(GIFReg, ST) @@ -749,16 +749,16 @@ REG64_(GIFReg, ST) REG_END REG64_(GIFReg, TEST) - UINT32 ATE:1; - UINT32 ATST:3; - UINT32 AREF:8; - UINT32 AFAIL:2; - UINT32 DATE:1; - UINT32 DATM:1; - UINT32 ZTE:1; - UINT32 ZTST:2; - UINT32 _PAD1:13; - UINT32 _PAD2:32; + uint32 ATE:1; + uint32 ATST:3; + uint32 AREF:8; + uint32 AFAIL:2; + uint32 DATE:1; + uint32 DATM:1; + uint32 ZTE:1; + uint32 ZTST:2; + uint32 _PAD1:13; + uint32 _PAD2:32; REG_END2 __forceinline bool DoFirstPass() {return !ATE || ATST != 0;} // not all pixels fail automatically __forceinline bool DoSecondPass() {return ATE && ATST != 1 && AFAIL != 0;} // pixels may fail, write fb/z @@ -770,42 +770,42 @@ union { struct { - UINT32 TBP0:14; - UINT32 TBW:6; - UINT32 PSM:6; - UINT32 TW:4; - UINT32 _PAD1:2; - UINT32 _PAD2:2; - UINT32 TCC:1; - UINT32 TFX:2; - UINT32 CBP:14; - UINT32 CPSM:4; - UINT32 CSM:1; - UINT32 CSA:5; - UINT32 CLD:3; + uint32 TBP0:14; + uint32 TBW:6; + uint32 PSM:6; + uint32 TW:4; + uint32 _PAD1:2; + uint32 _PAD2:2; + uint32 TCC:1; + uint32 TFX:2; + uint32 CBP:14; + uint32 CPSM:4; + uint32 CSM:1; + uint32 CSA:5; + uint32 CLD:3; }; struct { - UINT64 _PAD3:30; - UINT64 TH:4; - UINT64 _PAD4:30; + uint64 _PAD3:30; + uint64 TH:4; + uint64 _PAD4:30; }; }; REG_END REG64_(GIFReg, TEX1) - UINT32 LCM:1; - UINT32 _PAD1:1; - UINT32 MXL:3; - UINT32 MMAG:1; - UINT32 MMIN:3; - UINT32 MTBA:1; - UINT32 _PAD2:9; - UINT32 L:2; - UINT32 _PAD3:11; - UINT32 K:12; - UINT32 _PAD4:20; + uint32 LCM:1; + uint32 _PAD1:1; + uint32 MXL:3; + uint32 MMAG:1; + uint32 MMIN:3; + uint32 MTBA:1; + uint32 _PAD2:9; + uint32 L:2; + uint32 _PAD3:11; + uint32 K:12; + uint32 _PAD4:20; REG_END2 bool IsLinear() const { @@ -817,105 +817,105 @@ REG_END2 REG_END2 REG64_(GIFReg, TEX2) - UINT32 _PAD1:20; - UINT32 PSM:6; - UINT32 _PAD2:6; - UINT32 _PAD3:5; - UINT32 CBP:14; - UINT32 CPSM:4; - UINT32 CSM:1; - UINT32 CSA:5; - UINT32 CLD:3; + uint32 _PAD1:20; + uint32 PSM:6; + uint32 _PAD2:6; + uint32 _PAD3:5; + uint32 CBP:14; + uint32 CPSM:4; + uint32 CSM:1; + uint32 CSA:5; + uint32 CLD:3; REG_END REG64_(GIFReg, TEXA) - UINT32 TA0:8; - UINT32 _PAD1:7; - UINT32 AEM:1; - UINT32 _PAD2:16; - UINT32 TA1:8; - UINT32 _PAD3:24; + uint32 TA0:8; + uint32 _PAD1:7; + uint32 AEM:1; + uint32 _PAD2:16; + uint32 TA1:8; + uint32 _PAD3:24; REG_END REG64_(GIFReg, TEXCLUT) - UINT32 CBW:6; - UINT32 COU:6; - UINT32 COV:10; - UINT32 _PAD1:10; - UINT32 _PAD2:32; + uint32 CBW:6; + uint32 COU:6; + uint32 COV:10; + uint32 _PAD1:10; + uint32 _PAD2:32; REG_END REG64_(GIFReg, TEXFLUSH) - UINT32 _PAD1:32; - UINT32 _PAD2:32; + uint32 _PAD1:32; + uint32 _PAD2:32; REG_END REG64_(GIFReg, TRXDIR) - UINT32 XDIR:2; - UINT32 _PAD1:30; - UINT32 _PAD2:32; + uint32 XDIR:2; + uint32 _PAD1:30; + uint32 _PAD2:32; REG_END REG64_(GIFReg, TRXPOS) - UINT32 SSAX:11; - UINT32 _PAD1:5; - UINT32 SSAY:11; - UINT32 _PAD2:5; - UINT32 DSAX:11; - UINT32 _PAD3:5; - UINT32 DSAY:11; - UINT32 DIR:2; - UINT32 _PAD4:3; + uint32 SSAX:11; + uint32 _PAD1:5; + uint32 SSAY:11; + uint32 _PAD2:5; + uint32 DSAX:11; + uint32 _PAD3:5; + uint32 DSAY:11; + uint32 DIR:2; + uint32 _PAD4:3; REG_END REG64_(GIFReg, TRXREG) - UINT32 RRW:12; - UINT32 _PAD1:20; - UINT32 RRH:12; - UINT32 _PAD2:20; + uint32 RRW:12; + uint32 _PAD1:20; + uint32 RRH:12; + uint32 _PAD2:20; REG_END // GSState::GIFPackedRegHandlerUV and GSState::GIFRegHandlerUV will make sure that the _PAD1/2 bits are set to zero REG64_(GIFReg, UV) - UINT32 U:16; -// UINT32 _PAD1:2; - UINT32 V:16; -// UINT32 _PAD2:2; - UINT32 _PAD3:32; + uint32 U:16; +// uint32 _PAD1:2; + uint32 V:16; +// uint32 _PAD2:2; + uint32 _PAD3:32; REG_END // GSState::GIFRegHandlerXYOFFSET will make sure that the _PAD1/2 bits are set to zero REG64_(GIFReg, XYOFFSET) - UINT32 OFX; // :16; UINT32 _PAD1:16; - UINT32 OFY; // :16; UINT32 _PAD2:16; + uint32 OFX; // :16; uint32 _PAD1:16; + uint32 OFY; // :16; uint32 _PAD2:16; REG_END REG64_(GIFReg, XYZ) - UINT32 X:16; - UINT32 Y:16; - UINT32 Z:32; + uint32 X:16; + uint32 Y:16; + uint32 Z:32; REG_END REG64_(GIFReg, XYZF) - UINT32 X:16; - UINT32 Y:16; - UINT32 Z:24; - UINT32 F:8; + uint32 X:16; + uint32 Y:16; + uint32 Z:24; + uint32 F:8; REG_END REG64_(GIFReg, ZBUF) - UINT32 ZBP:9; - UINT32 _PAD1:15; - // UINT32 PSM:4; - // UINT32 _PAD2:4; - UINT32 PSM:6; - UINT32 _PAD2:2; - UINT32 ZMSK:1; - UINT32 _PAD3:31; + uint32 ZBP:9; + uint32 _PAD1:15; + // uint32 PSM:4; + // uint32 _PAD2:4; + uint32 PSM:6; + uint32 _PAD2:2; + uint32 ZMSK:1; + uint32 _PAD3:31; REG_END2 - UINT32 Block() const {return ZBP << 5;} + uint32 Block() const {return ZBP << 5;} REG_END2 REG64_SET(GIFReg) @@ -964,87 +964,87 @@ REG_SET_END // GIFPacked REG128_(GIFPacked, PRIM) - UINT32 PRIM:11; - UINT32 _PAD1:21; - UINT32 _PAD2:32; - UINT32 _PAD3:32; - UINT32 _PAD4:32; + uint32 PRIM:11; + uint32 _PAD1:21; + uint32 _PAD2:32; + uint32 _PAD3:32; + uint32 _PAD4:32; REG_END REG128_(GIFPacked, RGBA) - UINT32 R:8; - UINT32 _PAD1:24; - UINT32 G:8; - UINT32 _PAD2:24; - UINT32 B:8; - UINT32 _PAD3:24; - UINT32 A:8; - UINT32 _PAD4:24; + uint32 R:8; + uint32 _PAD1:24; + uint32 G:8; + uint32 _PAD2:24; + uint32 B:8; + uint32 _PAD3:24; + uint32 A:8; + uint32 _PAD4:24; REG_END REG128_(GIFPacked, STQ) float S; float T; float Q; - UINT32 _PAD1:32; + uint32 _PAD1:32; REG_END REG128_(GIFPacked, UV) - UINT32 U:14; - UINT32 _PAD1:18; - UINT32 V:14; - UINT32 _PAD2:18; - UINT32 _PAD3:32; - UINT32 _PAD4:32; + uint32 U:14; + uint32 _PAD1:18; + uint32 V:14; + uint32 _PAD2:18; + uint32 _PAD3:32; + uint32 _PAD4:32; REG_END REG128_(GIFPacked, XYZF2) - UINT32 X:16; - UINT32 _PAD1:16; - UINT32 Y:16; - UINT32 _PAD2:16; - UINT32 _PAD3:4; - UINT32 Z:24; - UINT32 _PAD4:4; - UINT32 _PAD5:4; - UINT32 F:8; - UINT32 _PAD6:3; - UINT32 ADC:1; - UINT32 _PAD7:16; + uint32 X:16; + uint32 _PAD1:16; + uint32 Y:16; + uint32 _PAD2:16; + uint32 _PAD3:4; + uint32 Z:24; + uint32 _PAD4:4; + uint32 _PAD5:4; + uint32 F:8; + uint32 _PAD6:3; + uint32 ADC:1; + uint32 _PAD7:16; REG_END REG128_(GIFPacked, XYZ2) - UINT32 X:16; - UINT32 _PAD1:16; - UINT32 Y:16; - UINT32 _PAD2:16; - UINT32 Z:32; - UINT32 _PAD3:15; - UINT32 ADC:1; - UINT32 _PAD4:16; + uint32 X:16; + uint32 _PAD1:16; + uint32 Y:16; + uint32 _PAD2:16; + uint32 Z:32; + uint32 _PAD3:15; + uint32 ADC:1; + uint32 _PAD4:16; REG_END REG128_(GIFPacked, FOG) - UINT32 _PAD1:32; - UINT32 _PAD2:32; - UINT32 _PAD3:32; - UINT32 _PAD4:4; - UINT32 F:8; - UINT32 _PAD5:20; + uint32 _PAD1:32; + uint32 _PAD2:32; + uint32 _PAD3:32; + uint32 _PAD4:4; + uint32 F:8; + uint32 _PAD5:20; REG_END REG128_(GIFPacked, A_D) - UINT64 DATA:64; - UINT32 ADDR:8; // enum GIF_A_D_REG - UINT32 _PAD1:24; - UINT32 _PAD2:32; + uint64 DATA:64; + uint32 ADDR:8; // enum GIF_A_D_REG + uint32 _PAD1:24; + uint32 _PAD2:32; REG_END REG128_(GIFPacked, NOP) - UINT32 _PAD1:32; - UINT32 _PAD2:32; - UINT32 _PAD3:32; - UINT32 _PAD4:32; + uint32 _PAD1:32; + uint32 _PAD2:32; + uint32 _PAD3:32; + uint32 _PAD4:32; REG_END REG128_SET(GIFPackedReg) @@ -1063,10 +1063,10 @@ REG_SET_END __declspec(align(16)) struct GIFPath { GIFTag tag; - UINT32 reg; - UINT32 nreg; - UINT32 nloop; - UINT32 adonly; + uint32 reg; + uint32 nreg; + uint32 nloop; + uint32 adonly; GSVector4i regs; void SetTag(const void* mem) @@ -1080,9 +1080,9 @@ __declspec(align(16)) struct GIFPath adonly = nreg == 1 && regs.u8[0] == GIF_REG_A_D; } - __forceinline DWORD GetReg() + __forceinline uint8 GetReg() { - return regs.u8[reg]; // (DWORD)GET_GIF_REG(tag, nreg); + return regs.u8[reg]; // GET_GIF_REG(tag, reg); } __forceinline bool StepReg() @@ -1108,36 +1108,36 @@ struct GSPrivRegSet struct { GSRegPMODE PMODE; - UINT64 _pad1; + uint64 _pad1; GSRegSMODE1 SMODE1; - UINT64 _pad2; + uint64 _pad2; GSRegSMODE2 SMODE2; - UINT64 _pad3; + uint64 _pad3; GSRegSRFSH SRFSH; - UINT64 _pad4; + uint64 _pad4; GSRegSYNCH1 SYNCH1; - UINT64 _pad5; + uint64 _pad5; GSRegSYNCH2 SYNCH2; - UINT64 _pad6; + uint64 _pad6; GSRegSYNCV SYNCV; - UINT64 _pad7; + uint64 _pad7; struct { GSRegDISPFB DISPFB; - UINT64 _pad1; + uint64 _pad1; GSRegDISPLAY DISPLAY; - UINT64 _pad2; + uint64 _pad2; } DISP[2]; GSRegEXTBUF EXTBUF; - UINT64 _pad8; + uint64 _pad8; GSRegEXTDATA EXTDATA; - UINT64 _pad9; + uint64 _pad9; GSRegEXTWRITE EXTWRITE; - UINT64 _pad10; + uint64 _pad10; GSRegBGCOLOR BGCOLOR; - UINT64 _pad11; + uint64 _pad11; }; - BYTE _pad12[0x1000]; + uint8 _pad12[0x1000]; }; union @@ -1145,27 +1145,27 @@ struct GSPrivRegSet struct { GSRegCSR CSR; - UINT64 _pad13; + uint64 _pad13; GSRegIMR IMR; - UINT64 _pad14; - UINT64 _unk1[4]; + uint64 _pad14; + uint64 _unk1[4]; GSRegBUSDIR BUSDIR; - UINT64 _pad15; - UINT64 _unk2[6]; + uint64 _pad15; + uint64 _unk2[6]; GSRegSIGLBLID SIGLBLID; - UINT64 _pad16; + uint64 _pad16; }; - BYTE _pad17[0x1000]; + uint8 _pad17[0x1000]; }; }; #pragma pack(pop) enum {KEYPRESS=1, KEYRELEASE=2}; -struct keyEvent {UINT32 key, event;}; +struct keyEvent {uint32 key, event;}; enum {FREEZE_LOAD=0, FREEZE_SAVE=1, FREEZE_SIZE=2}; -struct GSFreezeData {int size; BYTE* data;}; +struct GSFreezeData {int size; uint8* data;}; enum stateType {ST_WRITE, ST_TRANSFER, ST_VSYNC}; diff --git a/plugins/GSdx/GSBlock.h b/plugins/GSdx/GSBlock.h index e244a2b240..2ac27a0f12 100644 --- a/plugins/GSdx/GSBlock.h +++ b/plugins/GSdx/GSBlock.h @@ -42,10 +42,8 @@ class GSBlock static const GSVector4i m_uw8hmask3; public: - template __forceinline static void WriteColumn32(BYTE* RESTRICT dst, const BYTE* RESTRICT src, int srcpitch) + template __forceinline static void WriteColumn32(uint8* RESTRICT dst, const uint8* RESTRICT src, int srcpitch) { - #if _M_SSE >= 0x200 - const GSVector4i* s0 = (const GSVector4i*)&src[srcpitch * 0]; const GSVector4i* s1 = (const GSVector4i*)&src[srcpitch * 1]; @@ -92,33 +90,10 @@ public: #endif } - - #else - - const BYTE* d = &columnTable32[(i & 3) << 1][0]; - - for(int j = 0; j < 2; j++, d += 8, src += srcpitch) - { - for(int i = 0; i < 8; i++) - { - if(mask == 0xffffffff) - { - ((DWORD*)dst)[d[i]] = ((DWORD*)src)[i]; - } - else - { - ((DWORD*)dst)[d[i]] = (((DWORD*)dst)[d[i]] & ~mask) | (((DWORD*)src)[i] & mask); - } - } - } - - #endif } - template __forceinline static void WriteColumn16(BYTE* RESTRICT dst, const BYTE* RESTRICT src, int srcpitch) + template __forceinline static void WriteColumn16(uint8* RESTRICT dst, const uint8* RESTRICT src, int srcpitch) { - #if _M_SSE >= 0x200 - const GSVector4i* s0 = (const GSVector4i*)&src[srcpitch * 0]; const GSVector4i* s1 = (const GSVector4i*)&src[srcpitch * 1]; @@ -134,26 +109,10 @@ public: ((GSVector4i*)dst)[i * 4 + 1] = v2; ((GSVector4i*)dst)[i * 4 + 2] = v1; ((GSVector4i*)dst)[i * 4 + 3] = v3; - - #else - - const BYTE* d = &columnTable16[(i & 3) << 1][0]; - - for(int j = 0; j < 2; j++, d += 16, src += srcpitch) - { - for(int i = 0; i < 16; i++) - { - ((WORD*)dst)[d[i]] = ((WORD*)src)[i]; - } - } - - #endif } - template __forceinline static void WriteColumn8(BYTE* RESTRICT dst, const BYTE* RESTRICT src, int srcpitch) + template __forceinline static void WriteColumn8(uint8* RESTRICT dst, const uint8* RESTRICT src, int srcpitch) { - #if _M_SSE >= 0x200 - GSVector4i v0 = GSVector4i::load(&src[srcpitch * 0]); GSVector4i v1 = GSVector4i::load(&src[srcpitch * 1]); GSVector4i v2 = GSVector4i::load(&src[srcpitch * 2]); @@ -178,28 +137,12 @@ public: ((GSVector4i*)dst)[i * 4 + 1] = v2; ((GSVector4i*)dst)[i * 4 + 2] = v1; ((GSVector4i*)dst)[i * 4 + 3] = v3; - - #else - - const BYTE* d = &columnTable8[(i & 3) << 2][0]; - - for(int j = 0; j < 4; j++, d += 16, src += srcpitch) - { - for(int i = 0; i < 16; i++) - { - dst[d[i]] = src[i]; - } - } - - #endif } - template __forceinline static void WriteColumn4(BYTE* RESTRICT dst, const BYTE* RESTRICT src, int srcpitch) + template __forceinline static void WriteColumn4(uint8* RESTRICT dst, const uint8* RESTRICT src, int srcpitch) { // TODO: pshufb - #if _M_SSE >= 0x200 - GSVector4i v0 = GSVector4i::load(&src[srcpitch * 0]); GSVector4i v1 = GSVector4i::load(&src[srcpitch * 1]); GSVector4i v2 = GSVector4i::load(&src[srcpitch * 2]); @@ -225,26 +168,9 @@ public: ((GSVector4i*)dst)[i * 4 + 1] = v1; ((GSVector4i*)dst)[i * 4 + 2] = v2; ((GSVector4i*)dst)[i * 4 + 3] = v3; - - #else - - const WORD* d = &columnTable4[(i & 3) << 2][0]; - - for(int j = 0; j < 4; j++, d += 32, src += srcpitch) - { - for(int i = 0; i < 32; i++) - { - DWORD addr = d[i]; - BYTE c = (src[i >> 1] >> ((i & 1) << 2)) & 0x0f; - DWORD shift = (addr & 1) << 2; - dst[addr >> 1] = (dst[addr >> 1] & (0xf0 >> shift)) | (c << shift); - } - } - - #endif } - template static void WriteColumn32(int y, BYTE* RESTRICT dst, const BYTE* RESTRICT src, int srcpitch) + template static void WriteColumn32(int y, uint8* RESTRICT dst, const uint8* RESTRICT src, int srcpitch) { switch((y >> 1) & 3) { @@ -256,7 +182,7 @@ public: } } - template static void WriteColumn16(int y, BYTE* RESTRICT dst, const BYTE* RESTRICT src, int srcpitch) + template static void WriteColumn16(int y, uint8* RESTRICT dst, const uint8* RESTRICT src, int srcpitch) { switch((y >> 1) & 3) { @@ -268,7 +194,7 @@ public: } } - template static void WriteColumn8(int y, BYTE* RESTRICT dst, const BYTE* RESTRICT src, int srcpitch) + template static void WriteColumn8(int y, uint8* RESTRICT dst, const uint8* RESTRICT src, int srcpitch) { switch((y >> 2) & 3) { @@ -280,7 +206,7 @@ public: } } - template static void WriteColumn4(int y, BYTE* RESTRICT dst, const BYTE* RESTRICT src, int srcpitch) + template static void WriteColumn4(int y, uint8* RESTRICT dst, const uint8* RESTRICT src, int srcpitch) { switch((y >> 2) & 3) { @@ -292,10 +218,8 @@ public: } } - template static void WriteBlock32(BYTE* RESTRICT dst, const BYTE* RESTRICT src, int srcpitch) + template static void WriteBlock32(uint8* RESTRICT dst, const uint8* RESTRICT src, int srcpitch) { - #if _M_SSE >= 0x200 - WriteColumn32<0, aligned, mask>(dst, src, srcpitch); src += srcpitch * 2; WriteColumn32<1, aligned, mask>(dst, src, srcpitch); @@ -303,33 +227,10 @@ public: WriteColumn32<2, aligned, mask>(dst, src, srcpitch); src += srcpitch * 2; WriteColumn32<3, aligned, mask>(dst, src, srcpitch); - - #else - - const BYTE* d = &columnTable32[0][0]; - - for(int j = 0; j < 8; j++, d += 8, src += srcpitch) - { - for(int i = 0; i < 8; i++) - { - if(mask == 0xffffffff) - { - ((DWORD*)dst)[d[i]] = ((DWORD*)src)[i]; - } - else - { - ((DWORD*)dst)[d[i]] = (((DWORD*)dst)[d[i]] & ~mask) | (((DWORD*)src)[i] & mask); - } - } - } - - #endif } - template static void WriteBlock16(BYTE* RESTRICT dst, const BYTE* RESTRICT src, int srcpitch) + template static void WriteBlock16(uint8* RESTRICT dst, const uint8* RESTRICT src, int srcpitch) { - #if _M_SSE >= 0x200 - WriteColumn16<0, aligned>(dst, src, srcpitch); src += srcpitch * 2; WriteColumn16<1, aligned>(dst, src, srcpitch); @@ -337,26 +238,10 @@ public: WriteColumn16<2, aligned>(dst, src, srcpitch); src += srcpitch * 2; WriteColumn16<3, aligned>(dst, src, srcpitch); - - #else - - const BYTE* d = &columnTable16[0][0]; - - for(int j = 0; j < 8; j++, d += 16, src += srcpitch) - { - for(int i = 0; i < 16; i++) - { - ((WORD*)dst)[d[i]] = ((WORD*)src)[i]; - } - } - - #endif } - template static void WriteBlock8(BYTE* RESTRICT dst, const BYTE* RESTRICT src, int srcpitch) + template static void WriteBlock8(uint8* RESTRICT dst, const uint8* RESTRICT src, int srcpitch) { - #if _M_SSE >= 0x200 - WriteColumn8<0, aligned>(dst, src, srcpitch); src += srcpitch * 4; WriteColumn8<1, aligned>(dst, src, srcpitch); @@ -364,26 +249,10 @@ public: WriteColumn8<2, aligned>(dst, src, srcpitch); src += srcpitch * 4; WriteColumn8<3, aligned>(dst, src, srcpitch); - - #else - - const BYTE* d = &columnTable8[0][0]; - - for(int j = 0; j < 16; j++, d += 16, src += srcpitch) - { - for(int i = 0; i < 16; i++) - { - dst[d[i]] = src[i]; - } - } - - #endif } - template static void WriteBlock4(BYTE* RESTRICT dst, const BYTE* RESTRICT src, int srcpitch) + template static void WriteBlock4(uint8* RESTRICT dst, const uint8* RESTRICT src, int srcpitch) { - #if _M_SSE >= 0x200 - WriteColumn4<0, aligned>(dst, src, srcpitch); src += srcpitch * 4; WriteColumn4<1, aligned>(dst, src, srcpitch); @@ -391,29 +260,10 @@ public: WriteColumn4<2, aligned>(dst, src, srcpitch); src += srcpitch * 4; WriteColumn4<3, aligned>(dst, src, srcpitch); - - #else - - const WORD* d = &columnTable4[0][0]; - - for(int j = 0; j < 16; j++, d += 32, src += srcpitch) - { - for(int i = 0; i < 32; i++) - { - DWORD addr = d[i]; - BYTE c = (src[i >> 1] >> ((i & 1) << 2)) & 0x0f; - DWORD shift = (addr & 1) << 2; - dst[addr >> 1] = (dst[addr >> 1] & (0xf0 >> shift)) | (c << shift); - } - } - - #endif } - template __forceinline static void ReadColumn32(const BYTE* RESTRICT src, BYTE* RESTRICT dst, int dstpitch) + template __forceinline static void ReadColumn32(const uint8* RESTRICT src, uint8* RESTRICT dst, int dstpitch) { - #if _M_SSE >= 0x200 - const GSVector4i* s = (const GSVector4i*)src; GSVector4i v0 = s[i * 4 + 0]; @@ -430,23 +280,9 @@ public: GSVector4i::store(&d0[1], v1); GSVector4i::store(&d1[0], v2); GSVector4i::store(&d1[1], v3); - - #else - - const BYTE* s = &columnTable32[(i & 3) << 1][0]; - - for(int j = 0; j < 2; j++, s += 8, dst += dstpitch) - { - for(int i = 0; i < 8; i++) - { - ((DWORD*)dst)[i] = ((DWORD*)src)[s[i]]; - } - } - - #endif } - template __forceinline static void ReadColumn16(const BYTE* RESTRICT src, BYTE* RESTRICT dst, int dstpitch) + template __forceinline static void ReadColumn16(const uint8* RESTRICT src, uint8* RESTRICT dst, int dstpitch) { #if _M_SSE >= 0x301 @@ -468,7 +304,7 @@ public: GSVector4i::store(&d1[0], v1); GSVector4i::store(&d1[1], v3); - #elif _M_SSE >= 0x200 + #else const GSVector4i* s = (const GSVector4i*)src; @@ -489,22 +325,10 @@ public: GSVector4i::store(&d1[0], v2); GSVector4i::store(&d1[1], v3); - #else - - const BYTE* s = &columnTable16[(i & 3) << 1][0]; - - for(int j = 0; j < 2; j++, s += 16, dst += dstpitch) - { - for(int i = 0; i < 16; i++) - { - ((WORD*)dst)[i] = ((WORD*)src)[s[i]]; - } - } - #endif } - template __forceinline static void ReadColumn8(const BYTE* RESTRICT src, BYTE* RESTRICT dst, int dstpitch) + template __forceinline static void ReadColumn8(const uint8* RESTRICT src, uint8* RESTRICT dst, int dstpitch) { #if _M_SSE >= 0x301 @@ -540,7 +364,7 @@ public: GSVector4i::store(&dst[dstpitch * 2], v1); GSVector4i::store(&dst[dstpitch * 3], v2); - #elif _M_SSE >= 0x200 + #else const GSVector4i* s = (const GSVector4i*)src; @@ -570,22 +394,10 @@ public: GSVector4i::store(&dst[dstpitch * 2], v2); GSVector4i::store(&dst[dstpitch * 3], v3); - #else - - const BYTE* s = &columnTable8[(i & 3) << 2][0]; - - for(int j = 0; j < 4; j++, s += 16, dst += dstpitch) - { - for(int i = 0; i < 16; i++) - { - dst[i] = src[s[i]]; - } - } - #endif } - template __forceinline static void ReadColumn4(const BYTE* RESTRICT src, BYTE* RESTRICT dst, int dstpitch) + template __forceinline static void ReadColumn4(const uint8* RESTRICT src, uint8* RESTRICT dst, int dstpitch) { #if _M_SSE >= 0x301 @@ -619,7 +431,7 @@ public: GSVector4i::store(&dst[dstpitch * 2], v2); GSVector4i::store(&dst[dstpitch * 3], v3); - #elif _M_SSE >= 0x200 + #else const GSVector4i* s = (const GSVector4i*)src; @@ -657,25 +469,10 @@ public: GSVector4i::store(&dst[dstpitch * 2], v2); GSVector4i::store(&dst[dstpitch * 3], v3); - #else - - const WORD* s = &columnTable4[(i & 3) << 2][0]; - - for(int j = 0; j < 4; j++, s += 32, dst += dstpitch) - { - for(int i = 0; i < 32; i++) - { - DWORD addr = s[i]; - BYTE c = (src[addr >> 1] >> ((addr & 1) << 2)) & 0x0f; - int shift = (i & 1) << 2; - dst[i >> 1] = (dst[i >> 1] & (0xf0 >> shift)) | (c << shift); - } - } - #endif } - template static void ReadColumn32(int y, const BYTE* RESTRICT src, BYTE* RESTRICT dst, int dstpitch) + template static void ReadColumn32(int y, const uint8* RESTRICT src, uint8* RESTRICT dst, int dstpitch) { switch((y >> 1) & 3) { @@ -687,7 +484,7 @@ public: } } - template static void ReadColumn16(int y, const BYTE* RESTRICT src, BYTE* RESTRICT dst, int dstpitch) + template static void ReadColumn16(int y, const uint8* RESTRICT src, uint8* RESTRICT dst, int dstpitch) { switch((y >> 1) & 3) { @@ -699,7 +496,7 @@ public: } } - template static void ReadColumn8(int y, const BYTE* RESTRICT src, BYTE* RESTRICT dst, int dstpitch) + template static void ReadColumn8(int y, const uint8* RESTRICT src, uint8* RESTRICT dst, int dstpitch) { switch((y >> 2) & 3) { @@ -711,7 +508,7 @@ public: } } - template static void ReadColumn4(int y, const BYTE* RESTRICT src, BYTE* RESTRICT dst, int dstpitch) + template static void ReadColumn4(int y, const uint8* RESTRICT src, uint8* RESTRICT dst, int dstpitch) { switch((y >> 2) & 3) { @@ -723,10 +520,8 @@ public: } } - template static void ReadBlock32(const BYTE* RESTRICT src, BYTE* RESTRICT dst, int dstpitch) + template static void ReadBlock32(const uint8* RESTRICT src, uint8* RESTRICT dst, int dstpitch) { - #if _M_SSE >= 0x200 - ReadColumn32<0, aligned>(src, dst, dstpitch); dst += dstpitch * 2; ReadColumn32<1, aligned>(src, dst, dstpitch); @@ -734,26 +529,10 @@ public: ReadColumn32<2, aligned>(src, dst, dstpitch); dst += dstpitch * 2; ReadColumn32<3, aligned>(src, dst, dstpitch); - - #else - - const BYTE* s = &columnTable32[0][0]; - - for(int j = 0; j < 8; j++, s += 8, dst += dstpitch) - { - for(int i = 0; i < 8; i++) - { - ((DWORD*)dst)[i] = ((DWORD*)src)[s[i]]; - } - } - - #endif } - template static void ReadBlock16(const BYTE* RESTRICT src, BYTE* RESTRICT dst, int dstpitch) + template static void ReadBlock16(const uint8* RESTRICT src, uint8* RESTRICT dst, int dstpitch) { - #if _M_SSE >= 0x200 - ReadColumn16<0, aligned>(src, dst, dstpitch); dst += dstpitch * 2; ReadColumn16<1, aligned>(src, dst, dstpitch); @@ -761,26 +540,10 @@ public: ReadColumn16<2, aligned>(src, dst, dstpitch); dst += dstpitch * 2; ReadColumn16<3, aligned>(src, dst, dstpitch); - - #else - - const BYTE* s = &columnTable16[0][0]; - - for(int j = 0; j < 8; j++, s += 16, dst += dstpitch) - { - for(int i = 0; i < 16; i++) - { - ((WORD*)dst)[i] = ((WORD*)src)[s[i]]; - } - } - - #endif } - template static void ReadBlock8(const BYTE* RESTRICT src, BYTE* RESTRICT dst, int dstpitch) + template static void ReadBlock8(const uint8* RESTRICT src, uint8* RESTRICT dst, int dstpitch) { - #if _M_SSE >= 0x200 - ReadColumn8<0, aligned>(src, dst, dstpitch); dst += dstpitch * 4; ReadColumn8<1, aligned>(src, dst, dstpitch); @@ -788,26 +551,10 @@ public: ReadColumn8<2, aligned>(src, dst, dstpitch); dst += dstpitch * 4; ReadColumn8<3, aligned>(src, dst, dstpitch); - - #else - - const BYTE* s = &columnTable8[0][0]; - - for(int j = 0; j < 16; j++, s += 16, dst += dstpitch) - { - for(int i = 0; i < 16; i++) - { - dst[i] = src[s[i]]; - } - } - - #endif } - template static void ReadBlock4(const BYTE* RESTRICT src, BYTE* RESTRICT dst, int dstpitch) + template static void ReadBlock4(const uint8* RESTRICT src, uint8* RESTRICT dst, int dstpitch) { - #if _M_SSE >= 0x200 - ReadColumn4<0, aligned>(src, dst, dstpitch); dst += dstpitch * 4; ReadColumn4<1, aligned>(src, dst, dstpitch); @@ -815,29 +562,10 @@ public: ReadColumn4<2, aligned>(src, dst, dstpitch); dst += dstpitch * 4; ReadColumn4<3, aligned>(src, dst, dstpitch); - - #else - - const WORD* s = &columnTable4[0][0]; - - for(int j = 0; j < 16; j++, s += 32, dst += dstpitch) - { - for(int i = 0; i < 32; i++) - { - DWORD addr = s[i]; - BYTE c = (src[addr >> 1] >> ((addr & 1) << 2)) & 0x0f; - int shift = (i & 1) << 2; - dst[i >> 1] = (dst[i >> 1] & (0xf0 >> shift)) | (c << shift); - } - } - - #endif } - __forceinline static void ReadBlock4P(const BYTE* RESTRICT src, BYTE* RESTRICT dst, int dstpitch) + __forceinline static void ReadBlock4P(const uint8* RESTRICT src, uint8* RESTRICT dst, int dstpitch) { - #if _M_SSE >= 0x200 - const GSVector4i* s = (const GSVector4i*)src; GSVector4i v0, v1, v2, v3; @@ -896,18 +624,10 @@ public: dst += dstpitch * 2; } - - #else - - // TODO - - #endif } - __forceinline static void ReadBlock8HP(const BYTE* RESTRICT src, BYTE* RESTRICT dst, int dstpitch) + __forceinline static void ReadBlock8HP(const uint8* RESTRICT src, uint8* RESTRICT dst, int dstpitch) { - #if _M_SSE >= 0x200 - const GSVector4i* s = (const GSVector4i*)src; GSVector4i v0, v1, v2, v3; @@ -931,26 +651,10 @@ public: dst += dstpitch; } - - #else - - const BYTE* s = &columnTable32[0][0]; - - for(int j = 0; j < 8; j++, s += 8, dst += dstpitch) - { - for(int i = 0; i < 8; i++) - { - ((BYTE*)dst)[i] = ((DWORD*)src)[s[i]] >> 24; - } - } - - #endif } - __forceinline static void ReadBlock4HLP(const BYTE* RESTRICT src, BYTE* RESTRICT dst, int dstpitch) + __forceinline static void ReadBlock4HLP(const uint8* RESTRICT src, uint8* RESTRICT dst, int dstpitch) { - #if _M_SSE >= 0x200 - const GSVector4i* s = (const GSVector4i*)src; GSVector4i v0, v1, v2, v3; @@ -976,26 +680,10 @@ public: dst += dstpitch; } - - #else - - const BYTE* s = &columnTable32[0][0]; - - for(int j = 0; j < 8; j++, s += 8, dst += dstpitch) - { - for(int i = 0; i < 8; i++) - { - ((BYTE*)dst)[i] = (((DWORD*)src)[s[i]] >> 24) & 0xf; - } - } - - #endif } - __forceinline static void ReadBlock4HHP(const BYTE* RESTRICT src, BYTE* RESTRICT dst, int dstpitch) + __forceinline static void ReadBlock4HHP(const uint8* RESTRICT src, uint8* RESTRICT dst, int dstpitch) { - #if _M_SSE >= 0x200 - const GSVector4i* s = (const GSVector4i*)src; GSVector4i v0, v1, v2, v3; @@ -1019,26 +707,10 @@ public: dst += dstpitch; } - - #else - - const BYTE* s = &columnTable32[0][0]; - - for(int j = 0; j < 8; j++, s += 8, dst += dstpitch) - { - for(int i = 0; i < 8; i++) - { - ((BYTE*)dst)[i] = ((DWORD*)src)[s[i]] >> 28; - } - } - - #endif } - static void UnpackBlock24(const BYTE* RESTRICT src, int srcpitch, DWORD* RESTRICT dst) + static void UnpackBlock24(const uint8* RESTRICT src, int srcpitch, uint32* RESTRICT dst) { - #if _M_SSE >= 0x200 - GSVector4i mask = GSVector4i::x00ffffff(); for(int i = 0; i < 4; i++, src += srcpitch * 2) @@ -1061,24 +733,10 @@ public: ((GSVector4i*)dst)[i * 4 + 3] = v0.upl32(v0.srl<3>()).upl64(v0.srl<6>().upl32(v0.srl<9>())) & mask; } - - #else - - for(int j = 0, diff = srcpitch - 8 * 3; j < 8; j++, src += diff, dst += 8) - { - for(int i = 0; i < 8; i++, src += 3) - { - dst[i] = (src[2] << 16) | (src[1] << 8) | src[0]; - } - } - - #endif } - static void UnpackBlock8H(const BYTE* RESTRICT src, int srcpitch, DWORD* RESTRICT dst) + static void UnpackBlock8H(const uint8* RESTRICT src, int srcpitch, uint32* RESTRICT dst) { - #if _M_SSE >= 0x200 - GSVector4i zero = GSVector4i::zero(); for(int i = 0; i < 4; i++, src += srcpitch * 2) @@ -1093,34 +751,20 @@ public: ((GSVector4i*)dst)[i * 4 + 2] = zero.upl16(v1); ((GSVector4i*)dst)[i * 4 + 3] = zero.uph16(v1); } - - #else - - for(int j = 0; j < 8; j++, src += srcpitch, dst += 8) - { - for(int i = 0; i < 8; i++) - { - dst[i] = src[i] << 24; - } - } - - #endif } - static void UnpackBlock4HL(const BYTE* RESTRICT src, int srcpitch, DWORD* RESTRICT dst) + static void UnpackBlock4HL(const uint8* RESTRICT src, int srcpitch, uint32* RESTRICT dst) { - #if _M_SSE >= 0x200 - GSVector4i zero = GSVector4i::zero(); GSVector4i mask(0x0f0f0f0f); for(int i = 0; i < 2; i++, src += srcpitch * 4) { GSVector4i v( - *(DWORD*)&src[srcpitch * 0], - *(DWORD*)&src[srcpitch * 1], - *(DWORD*)&src[srcpitch * 2], - *(DWORD*)&src[srcpitch * 3]); + *(uint32*)&src[srcpitch * 0], + *(uint32*)&src[srcpitch * 1], + *(uint32*)&src[srcpitch * 2], + *(uint32*)&src[srcpitch * 3]); GSVector4i lo = v & mask; GSVector4i hi = (v >> 4) & mask; @@ -1142,35 +786,20 @@ public: ((GSVector4i*)dst)[i * 8 + 6] = zero.upl16(v5); ((GSVector4i*)dst)[i * 8 + 7] = zero.uph16(v5); } - - #else - - for(int j = 0; j < 8; j++, src += srcpitch, dst += 8) - { - for(int i = 0; i < 4; i++) - { - dst[i * 2 + 0] = (src[i] & 0x0f) << 24; - dst[i * 2 + 1] = (src[i] & 0xf0) << 20; - } - } - - #endif } - static void UnpackBlock4HH(const BYTE* RESTRICT src, int srcpitch, DWORD* RESTRICT dst) + static void UnpackBlock4HH(const uint8* RESTRICT src, int srcpitch, uint32* RESTRICT dst) { - #if _M_SSE >= 0x200 - GSVector4i zero = GSVector4i::zero(); GSVector4i mask(0xf0f0f0f0); for(int i = 0; i < 2; i++, src += srcpitch * 4) { GSVector4i v( - *(DWORD*)&src[srcpitch * 0], - *(DWORD*)&src[srcpitch * 1], - *(DWORD*)&src[srcpitch * 2], - *(DWORD*)&src[srcpitch * 3]); + *(uint32*)&src[srcpitch * 0], + *(uint32*)&src[srcpitch * 1], + *(uint32*)&src[srcpitch * 2], + *(uint32*)&src[srcpitch * 3]); GSVector4i lo = (v << 4) & mask; GSVector4i hi = v & mask; @@ -1192,25 +821,10 @@ public: ((GSVector4i*)dst)[i * 8 + 6] = zero.upl16(v5); ((GSVector4i*)dst)[i * 8 + 7] = zero.uph16(v5); } - - #else - - for(int j = 0; j < 8; j++, src += srcpitch, dst += 8) - { - for(int i = 0; i < 4; i++) - { - dst[i * 2 + 0] = (src[i] & 0x0f) << 28; - dst[i * 2 + 1] = (src[i] & 0xf0) << 24; - } - } - - #endif } - template static void ExpandBlock24(const DWORD* RESTRICT src, BYTE* RESTRICT dst, int dstpitch, const GIFRegTEXA& TEXA) + template static void ExpandBlock24(const uint32* RESTRICT src, uint8* RESTRICT dst, int dstpitch, const GIFRegTEXA& TEXA) { - #if _M_SSE >= 0x200 - const GSVector4i* s = (const GSVector4i*)src; GSVector4i TA0(TEXA.TA0 << 24); @@ -1241,35 +855,10 @@ public: d1[1] = v3 | TA0; } } - - #else - - DWORD TA0 = TEXA.TA0 << 24; - - for(int j = 0; j < 8; j++, src += 8, dst += dstpitch) - { - for(int i = 0; i < 8; i++) - { - DWORD c = src[i] & 0xffffff; - - if(AEM) - { - ((DWORD*)dst)[i] = c | (c ? TA0 : 0); - } - else - { - ((DWORD*)dst)[i] = c | TA0; - } - } - } - - #endif } - static void ExpandBlock16(const WORD* RESTRICT src, BYTE* RESTRICT dst, int dstpitch, const GIFRegTEXA& TEXA) // do not inline, uses too many xmm regs + static void ExpandBlock16(const uint16* RESTRICT src, uint8* RESTRICT dst, int dstpitch, const GIFRegTEXA& TEXA) // do not inline, uses too many xmm regs { - #if _M_SSE >= 0x200 - const GSVector4i* s = (const GSVector4i*)src; GSVector4i TA0(TEXA.TA0 << 24); @@ -1321,37 +910,9 @@ public: ((GSVector4i*)dst)[3] = ((h & rm) << 3) | ((h & gm) << 6) | ((h & bm) << 9) | TA0.blend(TA1, h.sra16(15)); } } - - #else - - DWORD TA0 = TEXA.TA0 << 24; - DWORD TA1 = TEXA.TA1 << 24; - - if(TEXA.AEM) - { - for(int j = 0; j < 8; j++, src += 16, dst += dstpitch) - { - for(int i = 0; i < 16; i++) - { - ((DWORD*)dst)[i] = ((src[i] & 0x8000) ? TA1 : src[i] ? TA0 : 0) | ((src[i] & 0x7c00) << 9) | ((src[i] & 0x03e0) << 6) | ((src[i] & 0x001f) << 3); - } - } - } - else - { - for(int j = 0; j < 8; j++, src += 16, dst += dstpitch) - { - for(int i = 0; i < 16; i++) - { - ((DWORD*)dst)[i] = ((src[i] & 0x8000) ? TA1 : TA0) | ((src[i] & 0x7c00) << 9) | ((src[i] & 0x03e0) << 6) | ((src[i] & 0x001f) << 3); - } - } - } - - #endif } - __forceinline static void ExpandBlock8_32(const BYTE* RESTRICT src, BYTE* RESTRICT dst, int dstpitch, const DWORD* RESTRICT pal) + __forceinline static void ExpandBlock8_32(const uint8* RESTRICT src, uint8* RESTRICT dst, int dstpitch, const uint32* RESTRICT pal) { for(int j = 0; j < 16; j++, dst += dstpitch) { @@ -1359,7 +920,7 @@ public: } } - __forceinline static void ExpandBlock8_16(const BYTE* RESTRICT src, BYTE* RESTRICT dst, int dstpitch, const DWORD* RESTRICT pal) + __forceinline static void ExpandBlock8_16(const uint8* RESTRICT src, uint8* RESTRICT dst, int dstpitch, const uint32* RESTRICT pal) { for(int j = 0; j < 16; j++, dst += dstpitch) { @@ -1367,7 +928,7 @@ public: } } - __forceinline static void ExpandBlock4_32(const BYTE* RESTRICT src, BYTE* RESTRICT dst, int dstpitch, const UINT64* RESTRICT pal) + __forceinline static void ExpandBlock4_32(const uint8* RESTRICT src, uint8* RESTRICT dst, int dstpitch, const UINT64* RESTRICT pal) { for(int j = 0; j < 16; j++, dst += dstpitch) { @@ -1375,7 +936,7 @@ public: } } - __forceinline static void ExpandBlock4_16(const BYTE* RESTRICT src, BYTE* RESTRICT dst, int dstpitch, const UINT64* RESTRICT pal) + __forceinline static void ExpandBlock4_16(const uint8* RESTRICT src, uint8* RESTRICT dst, int dstpitch, const UINT64* RESTRICT pal) { for(int j = 0; j < 16; j++, dst += dstpitch) { @@ -1383,7 +944,7 @@ public: } } - __forceinline static void ExpandBlock8H_32(DWORD* RESTRICT src, BYTE* RESTRICT dst, int dstpitch, const DWORD* RESTRICT pal) + __forceinline static void ExpandBlock8H_32(uint32* RESTRICT src, uint8* RESTRICT dst, int dstpitch, const uint32* RESTRICT pal) { for(int j = 0; j < 8; j++, dst += dstpitch) { @@ -1394,7 +955,7 @@ public: } } - __forceinline static void ExpandBlock8H_16(DWORD* RESTRICT src, BYTE* RESTRICT dst, int dstpitch, const DWORD* RESTRICT pal) + __forceinline static void ExpandBlock8H_16(uint32* RESTRICT src, uint8* RESTRICT dst, int dstpitch, const uint32* RESTRICT pal) { for(int j = 0; j < 8; j++, dst += dstpitch) { @@ -1411,14 +972,14 @@ public: for(int i = 0; i < 8; i++) { - ((WORD*)dst)[i] = (WORD)pal[src[j * 8 + i] >> 24]; + ((uint16*)dst)[i] = (uint16)pal[src[j * 8 + i] >> 24]; } #endif } } - __forceinline static void ExpandBlock4HL_32(DWORD* RESTRICT src, BYTE* RESTRICT dst, int dstpitch, const DWORD* RESTRICT pal) + __forceinline static void ExpandBlock4HL_32(uint32* RESTRICT src, uint8* RESTRICT dst, int dstpitch, const uint32* RESTRICT pal) { for(int j = 0; j < 8; j++, dst += dstpitch) { @@ -1429,7 +990,7 @@ public: } } - __forceinline static void ExpandBlock4HL_16(DWORD* RESTRICT src, BYTE* RESTRICT dst, int dstpitch, const DWORD* RESTRICT pal) + __forceinline static void ExpandBlock4HL_16(uint32* RESTRICT src, uint8* RESTRICT dst, int dstpitch, const uint32* RESTRICT pal) { for(int j = 0; j < 8; j++, dst += dstpitch) { @@ -1446,14 +1007,14 @@ public: for(int i = 0; i < 8; i++) { - ((WORD*)dst)[i] = (WORD)pal[(src[j * 8 + i] >> 24) & 0xf]; + ((uint16*)dst)[i] = (uint16)pal[(src[j * 8 + i] >> 24) & 0xf]; } #endif } } - __forceinline static void ExpandBlock4HH_32(DWORD* RESTRICT src, BYTE* RESTRICT dst, int dstpitch, const DWORD* RESTRICT pal) + __forceinline static void ExpandBlock4HH_32(uint32* RESTRICT src, uint8* RESTRICT dst, int dstpitch, const uint32* RESTRICT pal) { for(int j = 0; j < 8; j++, dst += dstpitch) { @@ -1464,7 +1025,7 @@ public: } } - __forceinline static void ExpandBlock4HH_16(DWORD* RESTRICT src, BYTE* RESTRICT dst, int dstpitch, const DWORD* RESTRICT pal) + __forceinline static void ExpandBlock4HH_16(uint32* RESTRICT src, uint8* RESTRICT dst, int dstpitch, const uint32* RESTRICT pal) { for(int j = 0; j < 8; j++, dst += dstpitch) { @@ -1481,17 +1042,15 @@ public: for(int i = 0; i < 8; i++) { - ((WORD*)dst)[i] = (WORD)pal[src[j * 8 + i] >> 28]; + ((uint16*)dst)[i] = (uint16)pal[src[j * 8 + i] >> 28]; } #endif } } - __forceinline static void UnpackAndWriteBlock24(const BYTE* RESTRICT src, int srcpitch, BYTE* RESTRICT dst) + __forceinline static void UnpackAndWriteBlock24(const uint8* RESTRICT src, int srcpitch, uint8* RESTRICT dst) { - #if _M_SSE >= 0x200 - GSVector4i mask(0x00ffffff); for(int i = 0; i < 4; i++, src += srcpitch * 2) @@ -1534,23 +1093,9 @@ public: #endif } - - #else - - const BYTE* d = &columnTable32[0][0]; - - for(int j = 0, diff = srcpitch - 8 * 3; j < 8; j++, src += diff, d += 8) - { - for(int i = 0; i < 8; i++, src += 3) - { - ((DWORD*)dst)[d[i]] = (((DWORD*)dst)[d[i]] & ~0x00ffffff) | (src[2] << 16) | (src[1] << 8) | src[0]; - } - } - - #endif } - __forceinline static void UnpackAndWriteBlock8H(const BYTE* RESTRICT src, int srcpitch, BYTE* RESTRICT dst) + __forceinline static void UnpackAndWriteBlock8H(const uint8* RESTRICT src, int srcpitch, uint8* RESTRICT dst) { #if _M_SSE >= 0x301 @@ -1576,7 +1121,7 @@ public: ((GSVector4i*)dst)[i * 4 + 3] = ((GSVector4i*)dst)[i * 4 + 3].blend8(v3, mask); } - #elif _M_SSE >= 0x200 + #else GSVector4i mask(0xff000000); @@ -1600,22 +1145,10 @@ public: ((GSVector4i*)dst)[i * 4 + 3] = ((GSVector4i*)dst)[i * 4 + 3].blend8(v3, mask); } - #else - - const BYTE* d = &columnTable32[0][0]; - - for(int j = 0; j < 8; j++, src += srcpitch, dst += 8) - { - for(int i = 0; i < 8; i++) - { - ((DWORD*)dst)[d[i]] = (((DWORD*)dst)[d[i]] & ~0xff000000) | (src[i] << 24); - } - } - #endif } - __forceinline static void UnpackAndWriteBlock4HL(const BYTE* RESTRICT src, int srcpitch, BYTE* RESTRICT dst) + __forceinline static void UnpackAndWriteBlock4HL(const uint8* RESTRICT src, int srcpitch, uint8* RESTRICT dst) { #if _M_SSE >= 0x301 @@ -1629,10 +1162,10 @@ public: for(int i = 0; i < 2; i++, src += srcpitch * 4) { GSVector4i v( - *(DWORD*)&src[srcpitch * 0], - *(DWORD*)&src[srcpitch * 1], - *(DWORD*)&src[srcpitch * 2], - *(DWORD*)&src[srcpitch * 3]); + *(uint32*)&src[srcpitch * 0], + *(uint32*)&src[srcpitch * 1], + *(uint32*)&src[srcpitch * 2], + *(uint32*)&src[srcpitch * 3]); GSVector4i lo = v & mask; GSVector4i hi = (v >> 4) & mask; @@ -1666,13 +1199,13 @@ public: } } - #elif _M_SSE >= 0x200 + #else /* - __declspec(align(16)) DWORD block[8 * 8]; + __declspec(align(16)) uint32 block[8 * 8]; UnpackBlock4HL(src, srcpitch, block); - WriteBlock32(dst, (BYTE*)block, sizeof(block) / 8); + WriteBlock32(dst, (uint8*)block, sizeof(block) / 8); */ GSVector4i mask(0x0f0f0f0f); GSVector4i mask2(0x0f000000); @@ -1680,10 +1213,10 @@ public: for(int i = 0; i < 2; i++, src += srcpitch * 4) { GSVector4i v( - *(DWORD*)&src[srcpitch * 0], - *(DWORD*)&src[srcpitch * 1], - *(DWORD*)&src[srcpitch * 2], - *(DWORD*)&src[srcpitch * 3]); + *(uint32*)&src[srcpitch * 0], + *(uint32*)&src[srcpitch * 1], + *(uint32*)&src[srcpitch * 2], + *(uint32*)&src[srcpitch * 3]); GSVector4i lo = v & mask; GSVector4i hi = (v >> 4) & mask; @@ -1727,23 +1260,10 @@ public: } } - #else - - const BYTE* d = &columnTable32[0][0]; - - for(int j = 0; j < 8; j++, d += 8, src += srcpitch) - { - for(int i = 0; i < 4; i++) - { - ((DWORD*)dst)[d[i * 2 + 0]] = (((DWORD*)dst)[d[i * 2 + 0]] & ~0x0f000000) | ((src[i] & 0x0f) << 24); - ((DWORD*)dst)[d[i * 2 + 1]] = (((DWORD*)dst)[d[i * 2 + 1]] & ~0x0f000000) | ((src[i] & 0xf0) << 20); - } - } - #endif } - __forceinline static void UnpackAndWriteBlock4HH(const BYTE* RESTRICT src, int srcpitch, BYTE* RESTRICT dst) + __forceinline static void UnpackAndWriteBlock4HH(const uint8* RESTRICT src, int srcpitch, uint8* RESTRICT dst) { #if _M_SSE >= 0x301 @@ -1757,10 +1277,10 @@ public: for(int i = 0; i < 2; i++, src += srcpitch * 4) { GSVector4i v( - *(DWORD*)&src[srcpitch * 0], - *(DWORD*)&src[srcpitch * 1], - *(DWORD*)&src[srcpitch * 2], - *(DWORD*)&src[srcpitch * 3]); + *(uint32*)&src[srcpitch * 0], + *(uint32*)&src[srcpitch * 1], + *(uint32*)&src[srcpitch * 2], + *(uint32*)&src[srcpitch * 3]); GSVector4i lo = (v << 4) & mask; GSVector4i hi = v & mask; @@ -1794,13 +1314,13 @@ public: } } - #elif _M_SSE >= 0x200 + #else /* - __declspec(align(16)) DWORD block[8 * 8]; + __declspec(align(16)) uint32 block[8 * 8]; UnpackBlock4HH(src, srcpitch, block); - WriteBlock32(dst, (BYTE*)block, sizeof(block) / 8); + WriteBlock32(dst, (uint8*)block, sizeof(block) / 8); */ GSVector4i mask(0xf0f0f0f0); GSVector4i mask2(0xf0000000); @@ -1808,10 +1328,10 @@ public: for(int i = 0; i < 2; i++, src += srcpitch * 4) { GSVector4i v( - *(DWORD*)&src[srcpitch * 0], - *(DWORD*)&src[srcpitch * 1], - *(DWORD*)&src[srcpitch * 2], - *(DWORD*)&src[srcpitch * 3]); + *(uint32*)&src[srcpitch * 0], + *(uint32*)&src[srcpitch * 1], + *(uint32*)&src[srcpitch * 2], + *(uint32*)&src[srcpitch * 3]); GSVector4i lo = (v << 4) & mask; GSVector4i hi = v & mask; @@ -1855,26 +1375,11 @@ public: } } - #else - - const BYTE* d = &columnTable32[0][0]; - - for(int j = 0; j < 8; j++, d += 8, src += srcpitch) - { - for(int i = 0; i < 4; i++) - { - ((DWORD*)dst)[d[i * 2 + 0]] = (((DWORD*)dst)[d[i * 2 + 0]] & ~0xf0000000) | ((src[i] & 0x0f) << 28); - ((DWORD*)dst)[d[i * 2 + 1]] = (((DWORD*)dst)[d[i * 2 + 1]] & ~0xf0000000) | ((src[i] & 0xf0) << 24); - } - } - #endif } - template __forceinline static void ReadAndExpandBlock24(const BYTE* RESTRICT src, BYTE* RESTRICT dst, int dstpitch, const GIFRegTEXA& TEXA) + template __forceinline static void ReadAndExpandBlock24(const uint8* RESTRICT src, uint8* RESTRICT dst, int dstpitch, const GIFRegTEXA& TEXA) { - #if _M_SSE >= 0x200 - const GSVector4i* s = (const GSVector4i*)src; GSVector4i TA0(TEXA.TA0 << 24); @@ -1912,34 +1417,9 @@ public: d1[1] = v3 | TA0; } } - - #else - - DWORD TA0 = TEXA.TA0 << 24; - - const BYTE* s = &columnTable32[0][0]; - - for(int j = 0; j < 8; j++, s += 8, dst += dstpitch) - { - for(int i = 0; i < 8; i++) - { - DWORD c = ((DWORD*)src)[s[i]] & 0xffffff; - - if(AEM) - { - ((DWORD*)dst)[i] = c | (c ? TA0 : 0); - } - else - { - ((DWORD*)dst)[i] = c | TA0; - } - } - } - - #endif } - __forceinline static void ReadAndExpandBlock8_32(const BYTE* RESTRICT src, BYTE* RESTRICT dst, int dstpitch, const DWORD* RESTRICT pal) + __forceinline static void ReadAndExpandBlock8_32(const uint8* RESTRICT src, uint8* RESTRICT dst, int dstpitch, const uint32* RESTRICT pal) { #if _M_SSE >= 0x401 @@ -1985,32 +1465,20 @@ public: dst += dstpitch; } - #elif _M_SSE >= 0x200 - - __declspec(align(16)) BYTE block[16 * 16]; - - ReadBlock8(src, (BYTE*)block, sizeof(block) / 16); - - ExpandBlock8_32(block, dst, dstpitch, pal); - #else - const BYTE* s = &columnTable8[0][0]; + __declspec(align(16)) uint8 block[16 * 16]; - for(int j = 0; j < 16; j++, s += 16, dst += dstpitch) - { - for(int i = 0; i < 16; i++) - { - ((DWORD*)dst)[i] = pal[src[s[i]]]; - } - } + ReadBlock8(src, (uint8*)block, sizeof(block) / 16); + + ExpandBlock8_32(block, dst, dstpitch, pal); #endif } // TODO: ReadAndExpandBlock8_16 - __forceinline static void ReadAndExpandBlock4_32(const BYTE* RESTRICT src, BYTE* RESTRICT dst, int dstpitch, const UINT64* RESTRICT pal) + __forceinline static void ReadAndExpandBlock4_32(const uint8* RESTRICT src, uint8* RESTRICT dst, int dstpitch, const UINT64* RESTRICT pal) { #if _M_SSE >= 0x401 @@ -2072,38 +1540,20 @@ public: dst += dstpitch; } - #elif _M_SSE >= 0x200 - - __declspec(align(16)) BYTE block[(32 / 2) * 16]; - - ReadBlock4(src, (BYTE*)block, sizeof(block) / 16); - - ExpandBlock4_32(block, dst, dstpitch, pal); - #else - const WORD* s = &columnTable4[0][0]; + __declspec(align(16)) uint8 block[(32 / 2) * 16]; - for(int j = 0; j < 16; j++, s += 32, dst += dstpitch) - { - for(int i = 0; i < 16; i++) - { - BYTE a0 = s[i * 2 + 0]; - BYTE a1 = s[i * 2 + 1]; + ReadBlock4(src, (uint8*)block, sizeof(block) / 16); - BYTE c0 = (src[a0 >> 1] >> ((a0 & 1) << 2)) & 0x0f; - BYTE c1 = (src[a1 >> 1] >> ((a1 & 1) << 2)) & 0x0f; - - ((UINT64*)dst)[i] = pal[(c1 << 4) | c0]; - } - } + ExpandBlock4_32(block, dst, dstpitch, pal); #endif } // TODO: ReadAndExpandBlock4_16 - __forceinline static void ReadAndExpandBlock8H_32(const BYTE* RESTRICT src, BYTE* RESTRICT dst, int dstpitch, const DWORD* RESTRICT pal) + __forceinline static void ReadAndExpandBlock8H_32(const uint8* RESTRICT src, uint8* RESTRICT dst, int dstpitch, const uint32* RESTRICT pal) { #if _M_SSE >= 0x401 @@ -2131,32 +1581,20 @@ public: dst += dstpitch; } - #elif _M_SSE >= 0x200 - - __declspec(align(16)) DWORD block[8 * 8]; - - ReadBlock32(src, (BYTE*)block, sizeof(block) / 8); - - ExpandBlock8H_32(block, dst, dstpitch, pal); - #else - const BYTE* s = &columnTable32[0][0]; + __declspec(align(16)) uint32 block[8 * 8]; - for(int j = 0; j < 8; j++, s += 8, dst += dstpitch) - { - for(int i = 0; i < 8; i++) - { - ((DWORD*)dst)[i] = pal[((DWORD*)src)[s[i]] >> 24]; - } - } + ReadBlock32(src, (uint8*)block, sizeof(block) / 8); + + ExpandBlock8H_32(block, dst, dstpitch, pal); #endif } // TODO: ReadAndExpandBlock8H_16 - __forceinline static void ReadAndExpandBlock4HL_32(const BYTE* RESTRICT src, BYTE* RESTRICT dst, int dstpitch, const DWORD* RESTRICT pal) + __forceinline static void ReadAndExpandBlock4HL_32(const uint8* RESTRICT src, uint8* RESTRICT dst, int dstpitch, const uint32* RESTRICT pal) { #if _M_SSE >= 0x401 @@ -2184,32 +1622,20 @@ public: dst += dstpitch; } - #elif _M_SSE >= 0x200 - - __declspec(align(16)) DWORD block[8 * 8]; - - ReadBlock32(src, (BYTE*)block, sizeof(block) / 8); - - ExpandBlock4HL_32(block, dst, dstpitch, pal); - #else - const BYTE* s = &columnTable32[0][0]; + __declspec(align(16)) uint32 block[8 * 8]; - for(int j = 0; j < 8; j++, s += 8, dst += dstpitch) - { - for(int i = 0; i < 8; i++) - { - ((DWORD*)dst)[i] = pal[(((DWORD*)src)[s[i]] >> 24) & 0xf]; - } - } + ReadBlock32(src, (uint8*)block, sizeof(block) / 8); + + ExpandBlock4HL_32(block, dst, dstpitch, pal); #endif } // TODO: ReadAndExpandBlock4HL_16 - __forceinline static void ReadAndExpandBlock4HH_32(const BYTE* RESTRICT src, BYTE* RESTRICT dst, int dstpitch, const DWORD* RESTRICT pal) + __forceinline static void ReadAndExpandBlock4HH_32(const uint8* RESTRICT src, uint8* RESTRICT dst, int dstpitch, const uint32* RESTRICT pal) { #if _M_SSE >= 0x401 @@ -2237,25 +1663,13 @@ public: dst += dstpitch; } - #elif _M_SSE >= 0x200 - - __declspec(align(16)) DWORD block[8 * 8]; - - ReadBlock32(src, (BYTE*)block, sizeof(block) / 8); - - ExpandBlock4HH_32(block, dst, dstpitch, pal); - #else - const BYTE* s = &columnTable32[0][0]; + __declspec(align(16)) uint32 block[8 * 8]; - for(int j = 0; j < 8; j++, s += 8, dst += dstpitch) - { - for(int i = 0; i < 8; i++) - { - ((DWORD*)dst)[i] = pal[((DWORD*)src)[s[i]] >> 28]; - } - } + ReadBlock32(src, (uint8*)block, sizeof(block) / 8); + + ExpandBlock4HH_32(block, dst, dstpitch, pal); #endif } diff --git a/plugins/GSdx/GSCapture.cpp b/plugins/GSdx/GSCapture.cpp index 069e71841b..7fca7cc0b8 100644 --- a/plugins/GSdx/GSCapture.cpp +++ b/plugins/GSdx/GSCapture.cpp @@ -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 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"))) diff --git a/plugins/GSdx/GSCapture.h b/plugins/GSdx/GSCapture.h index 74a1808160..c6b71a2f12 100644 --- a/plugins/GSdx/GSCapture.h +++ b/plugins/GSdx/GSCapture.h @@ -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 m_graph; CComPtr m_src; @@ -39,5 +40,5 @@ public: bool EndCapture(); bool IsCapturing() {return m_capturing;} - CSize GetSize() {return m_size;} + GSVector2i GetSize() {return m_size;} }; diff --git a/plugins/GSdx/GSClut.cpp b/plugins/GSdx/GSClut.cpp index ed8fad82b2..879764e108 100644 --- a/plugins/GSdx/GSClut.cpp +++ b/plugins/GSdx/GSClut.cpp @@ -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 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 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 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(this) == GSVector4i::load(&TEX0, &TEXCLUT)).alltrue(); + return dirty || !GSVector4i::load(this).eq(GSVector4i::load(&TEX0, &TEXCLUT)); } bool GSClut::ReadState::IsDirty(const GIFRegTEX0& TEX0) { - return dirty || !(GSVector4i::load(this) == GSVector4i::load(&TEX0, &this->TEXA)).alltrue(); + return dirty || !GSVector4i::load(this).eq(GSVector4i::load(&TEX0, &this->TEXA)); } bool GSClut::ReadState::IsDirty(const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) { - return dirty || !(GSVector4i::load(this) == GSVector4i::load(&TEX0, &TEXA)).alltrue(); + return dirty || !GSVector4i::load(this).eq(GSVector4i::load(&TEX0, &TEXA)); } diff --git a/plugins/GSdx/GSClut.h b/plugins/GSdx/GSClut.h index 9c7fa4241a..2d8333cfb4 100644 --- a/plugins/GSdx/GSClut.h +++ b/plugins/GSdx/GSClut.h @@ -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;} }; diff --git a/plugins/GSdx/GSCodeBuffer.cpp b/plugins/GSdx/GSCodeBuffer.cpp index 7f90f53569..83b0f45f61 100644 --- a/plugins/GSdx/GSCodeBuffer.cpp +++ b/plugins/GSdx/GSCodeBuffer.cpp @@ -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; diff --git a/plugins/GSdx/GSCodeBuffer.h b/plugins/GSdx/GSCodeBuffer.h index 7011d00950..badaed81a8 100644 --- a/plugins/GSdx/GSCodeBuffer.h +++ b/plugins/GSdx/GSCodeBuffer.h @@ -26,7 +26,7 @@ class GSCodeBuffer list 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 diff --git a/plugins/GSdx/GSCrc.cpp b/plugins/GSdx/GSCrc.cpp index 85abd05cb5..a4a3fde2e1 100644 --- a/plugins/GSdx/GSCrc.cpp +++ b/plugins/GSdx/GSCrc.cpp @@ -131,9 +131,9 @@ CRC::Game CRC::m_games[] = {0xFB236A46, SonicUnleashed, US}, }; -hash_map CRC::m_map; +hash_map 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::iterator i = m_map.find(crc); + hash_map::iterator i = m_map.find(crc); if(i != m_map.end()) { diff --git a/plugins/GSdx/GSCrc.h b/plugins/GSdx/GSCrc.h index c5187f3b87..731e495a09 100644 --- a/plugins/GSdx/GSCrc.h +++ b/plugins/GSdx/GSCrc.h @@ -84,15 +84,15 @@ public: struct Game { - DWORD crc; + uint32 crc; Title title; Region region; }; private: static Game m_games[]; - static hash_map m_map; + static hash_map m_map; public: - static Game Lookup(DWORD crc); + static Game Lookup(uint32 crc); }; diff --git a/plugins/GSdx/GSDevice.h b/plugins/GSdx/GSDevice.h index 01d06f42cc..bf0595a1b6 100644 --- a/plugins/GSdx/GSDevice.h +++ b/plugins/GSdx/GSDevice.h @@ -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); diff --git a/plugins/GSdx/GSDevice10.cpp b/plugins/GSdx/GSDevice10.cpp index 97465aa013..72d6f65a11 100644 --- a/plugins/GSdx/GSDevice10.cpp +++ b/plugins/GSdx/GSDevice10.cpp @@ -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)) { diff --git a/plugins/GSdx/GSDevice10.h b/plugins/GSdx/GSDevice10.h index a3ad0c1a75..81c5b7cecf 100644 --- a/plugins/GSdx/GSDevice10.h +++ b/plugins/GSdx/GSDevice10.h @@ -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); }; diff --git a/plugins/GSdx/GSDevice7.cpp b/plugins/GSdx/GSDevice7.cpp index 8ca5a59f36..477efe6638 100644 --- a/plugins/GSdx/GSDevice7.cpp +++ b/plugins/GSdx/GSDevice7.cpp @@ -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) { diff --git a/plugins/GSdx/GSDevice7.h b/plugins/GSdx/GSDevice7.h index 42d2853cf7..3029259a92 100644 --- a/plugins/GSdx/GSDevice7.h +++ b/plugins/GSdx/GSDevice7.h @@ -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) {} }; diff --git a/plugins/GSdx/GSDevice9.cpp b/plugins/GSdx/GSDevice9.cpp index 73f46d7482..4e38b0af0d 100644 --- a/plugins/GSdx/GSDevice9.cpp +++ b/plugins/GSdx/GSDevice9.cpp @@ -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 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 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 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); diff --git a/plugins/GSdx/GSDevice9.h b/plugins/GSdx/GSDevice9.h index 105b3f72f9..c299688715 100644 --- a/plugins/GSdx/GSDevice9.h +++ b/plugins/GSdx/GSDevice9.h @@ -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 void IASetVertexBuffer(UINT count, T* vertices) + template 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() { diff --git a/plugins/GSdx/GSDeviceNull.h b/plugins/GSdx/GSDeviceNull.h index acd471f71d..bc452f7a7e 100644 --- a/plugins/GSdx/GSDeviceNull.h +++ b/plugins/GSdx/GSDeviceNull.h @@ -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) {} }; diff --git a/plugins/GSdx/GSDirtyRect.cpp b/plugins/GSdx/GSDirtyRect.cpp index f1d12497bb..9815a4a28c 100644 --- a/plugins/GSdx/GSDirtyRect.cpp +++ b/plugins/GSdx/GSDirtyRect.cpp @@ -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::iterator i = begin(); i != end(); i++) - { - r |= i->GetDirtyRect(TEX0); + for(list::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(); } diff --git a/plugins/GSdx/GSDirtyRect.h b/plugins/GSdx/GSDirtyRect.h index a573d79ab2..e9b7699055 100644 --- a/plugins/GSdx/GSDirtyRect.h +++ b/plugins/GSdx/GSDirtyRect.h @@ -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 { public: GSDirtyRectList() {} - CRect GetDirtyRect(const GIFRegTEX0& TEX0, CSize size); + GSVector4i GetDirtyRectAndClear(const GIFRegTEX0& TEX0, const GSVector2i& size); }; \ No newline at end of file diff --git a/plugins/GSdx/GSDrawScanline.cpp b/plugins/GSdx/GSDrawScanline.cpp index 4813bc0440..c3452fe05c 100644 --- a/plugins/GSdx/GSDrawScanline.cpp +++ b/plugins/GSdx/GSDrawScanline.cpp @@ -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(m_env.zbr, m_env.zbc[0], r, z, m); + DrawSolidRectT(m_env.zbr, m_env.zbc[0], r, z, m); } else { - DrawSolidRectT(m_env.zbr, m_env.zbc[0], r, z, m); + DrawSolidRectT(m_env.zbr, m_env.zbc[0], r, z, m); } } else { if(m == 0) { - DrawSolidRectT(m_env.zbr, m_env.zbc[0], r, z, m); + DrawSolidRectT(m_env.zbr, m_env.zbc[0], r, z, m); } else { - DrawSolidRectT(m_env.zbr, m_env.zbc[0], r, z, m); + DrawSolidRectT(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(m_env.fbr, m_env.fbc[0], r, c, m); + DrawSolidRectT(m_env.fbr, m_env.fbc[0], r, c, m); } else { - DrawSolidRectT(m_env.fbr, m_env.fbc[0], r, c, m); + DrawSolidRectT(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(m_env.fbr, m_env.fbc[0], r, c, m); + DrawSolidRectT(m_env.fbr, m_env.fbc[0], r, c, m); } else { - DrawSolidRectT(m_env.fbr, m_env.fbc[0], r, c, m); + DrawSolidRectT(m_env.fbr, m_env.fbc[0], r, c, m); } } } } template -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 -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); } diff --git a/plugins/GSdx/GSDrawScanline.h b/plugins/GSdx/GSDrawScanline.h index 2221707dc8..9f9a1ea3d1 100644 --- a/plugins/GSdx/GSDrawScanline.h +++ b/plugins/GSdx/GSDrawScanline.h @@ -35,24 +35,24 @@ class GSDrawScanline : public GSAlignedClass<16>, public IDrawScanline // - class GSSetupPrimMap : public GSCodeGeneratorFunctionMap + class GSSetupPrimMap : public GSCodeGeneratorFunctionMap { 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 + class GSDrawScanlineMap : public GSCodeGeneratorFunctionMap { 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 - 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 - __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 __forceinline void FillBlock(const GSVector4i* row, int* col, const GSVector4i& r, const GSVector4i& c, const GSVector4i& m); diff --git a/plugins/GSdx/GSDrawScanlineCodeGenerator.cpp b/plugins/GSdx/GSDrawScanlineCodeGenerator.cpp index a6eb172b3e..e87c75c4f8 100644 --- a/plugins/GSdx/GSDrawScanlineCodeGenerator.cpp +++ b/plugins/GSdx/GSDrawScanlineCodeGenerator.cpp @@ -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); diff --git a/plugins/GSdx/GSDump.cpp b/plugins/GSdx/GSDump.cpp index 7f1095a5b3..4082e7823f 100644 --- a/plugins/GSdx/GSDump.cpp +++ b/plugins/GSdx/GSDump.cpp @@ -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) { diff --git a/plugins/GSdx/GSDump.h b/plugins/GSdx/GSDump.h index 1ffc8167ec..5cc2c88104 100644 --- a/plugins/GSdx/GSDump.h +++ b/plugins/GSdx/GSDump.h @@ -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;} diff --git a/plugins/GSdx/GSFunctionMap.h b/plugins/GSdx/GSFunctionMap.h index 34074703d0..2d7d052d8d 100644 --- a/plugins/GSdx/GSFunctionMap.h +++ b/plugins/GSdx/GSFunctionMap.h @@ -158,9 +158,9 @@ public: template class GSCodeGeneratorFunctionMap : public GSFunctionMap { - DWORD m_id; + uint32 m_id; string m_name; - hash_map m_cgmap; + hash_map m_cgmap; GSCodeBuffer m_cb; enum {MAX_SIZE = 4096}; @@ -177,7 +177,7 @@ public: virtual ~GSCodeGeneratorFunctionMap() { - for(hash_map::iterator i = m_cgmap.begin(); i != m_cgmap.end(); i++) + for(hash_map::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; diff --git a/plugins/GSdx/GSLocalMemory.cpp b/plugins/GSdx/GSLocalMemory.cpp index 4a8a8ebff7..5e1ab20d09 100644 --- a/plugins/GSdx/GSLocalMemory.cpp +++ b/plugins/GSdx/GSLocalMemory.cpp @@ -31,26 +31,26 @@ ASSERT((r).Width() >= w && (r).Height() >= h && !((r).left&(w-1)) && !((r).top&(h-1)) && !((r).right&(w-1)) && !((r).bottom&(h-1))); \ #define FOREACH_BLOCK_START(w, h, bpp) \ - DWORD bp = TEX0.TBP0; \ - DWORD bw = TEX0.TBW; \ - int offset = dstpitch * h - (r.right - r.left) * bpp / 8; \ - for(int y = r.top; y < r.bottom; y += h, dst += offset) \ + uint32 bp = TEX0.TBP0; \ + uint32 bw = TEX0.TBW; \ + int offset = dstpitch * h - r.width() * bpp / 8; \ + for(int y = r.top, ye = r.bottom; y < ye; y += h, dst += offset) \ { ASSERT_BLOCK(r, w, h); \ - for(int x = r.left; x < r.right; x += w, dst += w * bpp / 8) \ + for(int x = r.left, xe = r.right; x < xe; x += w, dst += w * bpp / 8) \ { \ #define FOREACH_BLOCK_END }} // -DWORD GSLocalMemory::pageOffset32[32][32][64]; -DWORD GSLocalMemory::pageOffset32Z[32][32][64]; -DWORD GSLocalMemory::pageOffset16[32][64][64]; -DWORD GSLocalMemory::pageOffset16S[32][64][64]; -DWORD GSLocalMemory::pageOffset16Z[32][64][64]; -DWORD GSLocalMemory::pageOffset16SZ[32][64][64]; -DWORD GSLocalMemory::pageOffset8[32][64][128]; -DWORD GSLocalMemory::pageOffset4[32][128][128]; +uint32 GSLocalMemory::pageOffset32[32][32][64]; +uint32 GSLocalMemory::pageOffset32Z[32][32][64]; +uint32 GSLocalMemory::pageOffset16[32][64][64]; +uint32 GSLocalMemory::pageOffset16S[32][64][64]; +uint32 GSLocalMemory::pageOffset16Z[32][64][64]; +uint32 GSLocalMemory::pageOffset16SZ[32][64][64]; +uint32 GSLocalMemory::pageOffset8[32][64][128]; +uint32 GSLocalMemory::pageOffset4[32][128][128]; int GSLocalMemory::rowOffset32[2048]; int GSLocalMemory::rowOffset32Z[2048]; @@ -72,8 +72,8 @@ int GSLocalMemory::blockOffset4[256]; // -DWORD GSLocalMemory::m_xtbl[1024]; -DWORD GSLocalMemory::m_ytbl[1024]; +uint32 GSLocalMemory::m_xtbl[1024]; +uint32 GSLocalMemory::m_ytbl[1024]; // @@ -84,7 +84,7 @@ GSLocalMemory::psm_t GSLocalMemory::m_psm[64]; GSLocalMemory::GSLocalMemory() : m_clut(this) { - m_vm8 = (BYTE*)VirtualAlloc(NULL, m_vmsize * 2, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); + m_vm8 = (uint8*)VirtualAlloc(NULL, m_vmsize * 2, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); memset(m_vm8, 0, m_vmsize); @@ -218,8 +218,8 @@ GSLocalMemory::GSLocalMemory() m_psm[i].rtxbP = &GSLocalMemory::ReadTextureBlock32; m_psm[i].bpp = m_psm[i].trbpp = 32; m_psm[i].pal = 0; - m_psm[i].bs = CSize(8, 8); - m_psm[i].pgs = CSize(64, 32); + m_psm[i].bs = GSVector2i(8, 8); + m_psm[i].pgs = GSVector2i(64, 32); for(int j = 0; j < 8; j++) m_psm[i].rowOffset[j] = rowOffset32; m_psm[i].blockOffset = blockOffset32; } @@ -432,15 +432,15 @@ GSLocalMemory::GSLocalMemory() m_psm[PSM_PSMZ24].trbpp = 24; m_psm[PSM_PSMZ16].trbpp = m_psm[PSM_PSMZ16S].trbpp = 16; - m_psm[PSM_PSMCT16].bs = m_psm[PSM_PSMCT16S].bs = CSize(16, 8); - m_psm[PSM_PSMT8].bs = CSize(16, 16); - m_psm[PSM_PSMT4].bs = CSize(32, 16); - m_psm[PSM_PSMZ16].bs = m_psm[PSM_PSMZ16S].bs = CSize(16, 8); + m_psm[PSM_PSMCT16].bs = m_psm[PSM_PSMCT16S].bs = GSVector2i(16, 8); + m_psm[PSM_PSMT8].bs = GSVector2i(16, 16); + m_psm[PSM_PSMT4].bs = GSVector2i(32, 16); + m_psm[PSM_PSMZ16].bs = m_psm[PSM_PSMZ16S].bs = GSVector2i(16, 8); - m_psm[PSM_PSMCT16].pgs = m_psm[PSM_PSMCT16S].pgs = CSize(64, 64); - m_psm[PSM_PSMT8].pgs = CSize(128, 64); - m_psm[PSM_PSMT4].pgs = CSize(128, 128); - m_psm[PSM_PSMZ16].pgs = m_psm[PSM_PSMZ16S].pgs = CSize(64, 64); + m_psm[PSM_PSMCT16].pgs = m_psm[PSM_PSMCT16S].pgs = GSVector2i(64, 64); + m_psm[PSM_PSMT8].pgs = GSVector2i(128, 64); + m_psm[PSM_PSMT4].pgs = GSVector2i(128, 128); + m_psm[PSM_PSMZ16].pgs = m_psm[PSM_PSMZ16S].pgs = GSVector2i(64, 64); for(int i = 0; i < 8; i++) m_psm[PSM_PSMCT16].rowOffset[i] = rowOffset16; for(int i = 0; i < 8; i++) m_psm[PSM_PSMCT16S].rowOffset[i] = rowOffset16S; @@ -465,7 +465,7 @@ GSLocalMemory::~GSLocalMemory() { VirtualFree(m_vm8, 0, MEM_RELEASE); - for(hash_map::iterator i = m_omap.begin(); i != m_omap.end(); i++) + for(hash_map::iterator i = m_omap.begin(); i != m_omap.end(); i++) { Offset* o = (*i).second; @@ -477,21 +477,21 @@ GSLocalMemory::~GSLocalMemory() _aligned_free(o); } - for(hash_map::iterator i = m_o4map.begin(); i != m_o4map.end(); i++) + for(hash_map::iterator i = m_o4map.begin(); i != m_o4map.end(); i++) { _aligned_free((*i).second); } } -GSLocalMemory::Offset* GSLocalMemory::GetOffset(DWORD bp, DWORD bw, DWORD psm) +GSLocalMemory::Offset* GSLocalMemory::GetOffset(uint32 bp, uint32 bw, uint32 psm) { if(bw == 0) {ASSERT(0); return NULL;} ASSERT(m_psm[psm].bpp > 8); // only for 16/24/32/8h/4hh/4hl formats where all columns are the same - DWORD hash = bp | (bw << 14) | (psm << 20); + uint32 hash = bp | (bw << 14) | (psm << 20); - hash_map::iterator i = m_omap.find(hash); + hash_map::iterator i = m_omap.find(hash); if(i != m_omap.end()) { @@ -525,22 +525,22 @@ GSLocalMemory::Offset* GSLocalMemory::GetOffset(DWORD bp, DWORD bw, DWORD psm) GSLocalMemory::Offset4* GSLocalMemory::GetOffset4(const GIFRegFRAME& FRAME, const GIFRegZBUF& ZBUF) { - DWORD fbp = FRAME.Block(); - DWORD zbp = ZBUF.Block(); - DWORD fpsm = FRAME.PSM; - DWORD zpsm = ZBUF.PSM; - DWORD bw = FRAME.FBW; + uint32 fbp = FRAME.Block(); + uint32 zbp = ZBUF.Block(); + uint32 fpsm = FRAME.PSM; + uint32 zpsm = ZBUF.PSM; + uint32 bw = FRAME.FBW; ASSERT(m_psm[fpsm].trbpp > 8 || m_psm[zpsm].trbpp > 8); // "(psm & 0x0f) ^ ((psm & 0xf0) >> 2)" creates 4 bit unique identifiers for render target formats (only) - DWORD fpsm_hash = (fpsm & 0x0f) ^ ((fpsm & 0x30) >> 2); - DWORD zpsm_hash = (zpsm & 0x0f) ^ ((zpsm & 0x30) >> 2); + uint32 fpsm_hash = (fpsm & 0x0f) ^ ((fpsm & 0x30) >> 2); + uint32 zpsm_hash = (zpsm & 0x0f) ^ ((zpsm & 0x30) >> 2); - DWORD hash = (FRAME.FBP << 0) | (ZBUF.ZBP << 9) | (bw << 18) | (fpsm_hash << 24) | (zpsm_hash << 28); + uint32 hash = (FRAME.FBP << 0) | (ZBUF.ZBP << 9) | (bw << 18) | (fpsm_hash << 24) | (zpsm_hash << 28); - hash_map::iterator i = m_o4map.find(hash); + hash_map::iterator i = m_o4map.find(hash); if(i != m_o4map.end()) { @@ -574,15 +574,15 @@ GSLocalMemory::Offset4* GSLocalMemory::GetOffset4(const GIFRegFRAME& FRAME, cons return o; } -bool GSLocalMemory::FillRect(const GSVector4i& r, DWORD c, DWORD psm, DWORD bp, DWORD bw) +bool GSLocalMemory::FillRect(const GSVector4i& r, uint32 c, uint32 psm, uint32 bp, uint32 bw) { const psm_t& tbl = m_psm[psm]; writePixel wp = tbl.wp; pixelAddress bn = tbl.bn; - int w = tbl.bs.cx; - int h = tbl.bs.cy; + int w = tbl.bs.x; + int h = tbl.bs.y; int bpp = tbl.bpp; switch(bpp) @@ -593,24 +593,24 @@ bool GSLocalMemory::FillRect(const GSVector4i& r, DWORD c, DWORD psm, DWORD bp, case 4: c = (c & 0xf) * 0x11111111; break; } - CRect clip; + GSVector4i clip; - clip.left = (r.x + (w - 1)) & ~(w - 1); - clip.top = (r.y + (h - 1)) & ~(h - 1); - clip.right = r.z & ~(w - 1); - clip.bottom = r.w & ~(h - 1); + clip.left = (r.left + (w - 1)) & ~(w - 1); + clip.top = (r.top + (h - 1)) & ~(h - 1); + clip.right = r.right & ~(w - 1); + clip.bottom = r.bottom & ~(h - 1); - for(int y = r.y; y < clip.top; y++) + for(int y = r.top; y < clip.top; y++) { - for(int x = r.x; x < r.z; x++) + for(int x = r.left; x < r.right; x++) { (this->*wp)(x, y, c, bp, bw); } } - for(int y = clip.bottom; y < r.w; y++) + for(int y = clip.bottom; y < r.bottom; y++) { - for(int x = r.x; x < r.z; x++) + for(int x = r.left; x < r.right; x++) { (this->*wp)(x, y, c, bp, bw); } @@ -622,12 +622,12 @@ bool GSLocalMemory::FillRect(const GSVector4i& r, DWORD c, DWORD psm, DWORD bp, { for(int ys = y, ye = y + h; ys < ye; ys++) { - for(int x = r.x; x < clip.left; x++) + for(int x = r.left; x < clip.left; x++) { (this->*wp)(x, ys, c, bp, bw); } - for(int x = clip.right; x < r.z; x++) + for(int x = clip.right; x < r.right; x++) { (this->*wp)(x, ys, c, bp, bw); } @@ -635,11 +635,10 @@ bool GSLocalMemory::FillRect(const GSVector4i& r, DWORD c, DWORD psm, DWORD bp, } } + GSVector4i c128(c); + if(psm == PSM_PSMCT24 || psm == PSM_PSMZ24) { - #if _M_SSE >= 0x200 - - GSVector4i c128(c); GSVector4i mask(0x00ffffff); for(int y = clip.top; y < clip.bottom; y += h) @@ -657,35 +656,9 @@ bool GSLocalMemory::FillRect(const GSVector4i& r, DWORD c, DWORD psm, DWORD bp, } } } - - #else - - c &= 0x00ffffff; - - for(int y = clip.top; y < clip.bottom; y += h) - { - for(int x = clip.left; x < clip.right; x += w) - { - DWORD* p = (DWORD*)&m_vm8[bn(x, y, bp, bw) << 8]; - - for(int i = 0; i < 64; i += 4) - { - p[i + 0] = (p[i + 0] & 0xff000000) | c; - p[i + 1] = (p[i + 1] & 0xff000000) | c; - p[i + 2] = (p[i + 2] & 0xff000000) | c; - p[i + 3] = (p[i + 3] & 0xff000000) | c; - } - } - } - - #endif } else { - #if _M_SSE >= 0x200 - - GSVector4i c128(c); - for(int y = clip.top; y < clip.bottom; y += h) { for(int x = clip.left; x < clip.right; x += w) @@ -701,26 +674,6 @@ bool GSLocalMemory::FillRect(const GSVector4i& r, DWORD c, DWORD psm, DWORD bp, } } } - - #else - - for(int y = clip.top; y < clip.bottom; y += h) - { - for(int x = clip.left; x < clip.right; x += w) - { - DWORD* p = (DWORD*)&m_vm8[bn(x, y, bp, bw) << 8]; - - for(int i = 0; i < 64; i += 4) - { - p[i + 0] = c; - p[i + 1] = c; - p[i + 2] = c; - p[i + 3] = c; - } - } - } - - #endif } return true; @@ -729,10 +682,10 @@ bool GSLocalMemory::FillRect(const GSVector4i& r, DWORD c, DWORD psm, DWORD bp, //////////////////// template -void GSLocalMemory::WriteImageColumn(int l, int r, int y, int h, BYTE* src, int srcpitch, const GIFRegBITBLTBUF& BITBLTBUF) +void GSLocalMemory::WriteImageColumn(int l, int r, int y, int h, uint8* src, int srcpitch, const GIFRegBITBLTBUF& BITBLTBUF) { - DWORD bp = BITBLTBUF.DBP; - DWORD bw = BITBLTBUF.DBW; + uint32 bp = BITBLTBUF.DBP; + uint32 bw = BITBLTBUF.DBW; const int csy = bsy / 4; @@ -758,10 +711,10 @@ void GSLocalMemory::WriteImageColumn(int l, int r, int y, int h, BYTE* src, int } template -void GSLocalMemory::WriteImageBlock(int l, int r, int y, int h, BYTE* src, int srcpitch, const GIFRegBITBLTBUF& BITBLTBUF) +void GSLocalMemory::WriteImageBlock(int l, int r, int y, int h, uint8* src, int srcpitch, const GIFRegBITBLTBUF& BITBLTBUF) { - DWORD bp = BITBLTBUF.DBP; - DWORD bw = BITBLTBUF.DBW; + uint32 bp = BITBLTBUF.DBP; + uint32 bw = BITBLTBUF.DBW; for(int offset = srcpitch * bsy; h >= bsy; h -= bsy, y += bsy, src += offset) { @@ -785,10 +738,10 @@ void GSLocalMemory::WriteImageBlock(int l, int r, int y, int h, BYTE* src, int s } template -void GSLocalMemory::WriteImageLeftRight(int l, int r, int y, int h, BYTE* src, int srcpitch, const GIFRegBITBLTBUF& BITBLTBUF) +void GSLocalMemory::WriteImageLeftRight(int l, int r, int y, int h, uint8* src, int srcpitch, const GIFRegBITBLTBUF& BITBLTBUF) { - DWORD bp = BITBLTBUF.DBP; - DWORD bw = BITBLTBUF.DBW; + uint32 bp = BITBLTBUF.DBP; + uint32 bw = BITBLTBUF.DBW; for(; h > 0; y++, h--, src += srcpitch) { @@ -796,14 +749,14 @@ void GSLocalMemory::WriteImageLeftRight(int l, int r, int y, int h, BYTE* src, i { switch(psm) { - case PSM_PSMCT32: WritePixel32(x, y, *(DWORD*)&src[x * 4], bp, bw); break; - case PSM_PSMCT16: WritePixel16(x, y, *(WORD*)&src[x * 2], bp, bw); break; - case PSM_PSMCT16S: WritePixel16S(x, y, *(WORD*)&src[x * 2], bp, bw); break; + case PSM_PSMCT32: WritePixel32(x, y, *(uint32*)&src[x * 4], bp, bw); break; + case PSM_PSMCT16: WritePixel16(x, y, *(uint16*)&src[x * 2], bp, bw); break; + case PSM_PSMCT16S: WritePixel16S(x, y, *(uint16*)&src[x * 2], bp, bw); break; case PSM_PSMT8: WritePixel8(x, y, src[x], bp, bw); break; case PSM_PSMT4: WritePixel4(x, y, src[x >> 1] >> ((x & 1) << 2), bp, bw); break; - case PSM_PSMZ32: WritePixel32Z(x, y, *(DWORD*)&src[x * 4], bp, bw); break; - case PSM_PSMZ16: WritePixel16Z(x, y, *(WORD*)&src[x * 2], bp, bw); break; - case PSM_PSMZ16S: WritePixel16SZ(x, y, *(WORD*)&src[x * 2], bp, bw); break; + case PSM_PSMZ32: WritePixel32Z(x, y, *(uint32*)&src[x * 4], bp, bw); break; + case PSM_PSMZ16: WritePixel16Z(x, y, *(uint16*)&src[x * 2], bp, bw); break; + case PSM_PSMZ16S: WritePixel16SZ(x, y, *(uint16*)&src[x * 2], bp, bw); break; // TODO default: __assume(0); } @@ -812,12 +765,12 @@ void GSLocalMemory::WriteImageLeftRight(int l, int r, int y, int h, BYTE* src, i } template -void GSLocalMemory::WriteImageTopBottom(int l, int r, int y, int h, BYTE* src, int srcpitch, const GIFRegBITBLTBUF& BITBLTBUF) +void GSLocalMemory::WriteImageTopBottom(int l, int r, int y, int h, uint8* src, int srcpitch, const GIFRegBITBLTBUF& BITBLTBUF) { - __declspec(align(16)) BYTE buff[64]; // merge buffer for one column + __declspec(align(16)) uint8 buff[64]; // merge buffer for one column - DWORD bp = BITBLTBUF.DBP; - DWORD bw = BITBLTBUF.DBW; + uint32 bp = BITBLTBUF.DBP; + uint32 bw = BITBLTBUF.DBW; const int csy = bsy / 4; @@ -831,7 +784,7 @@ void GSLocalMemory::WriteImageTopBottom(int l, int r, int y, int h, BYTE* src, i for(int x = l; x < r; x += bsx) { - BYTE* dst = NULL; + uint8* dst = NULL; switch(psm) { @@ -912,7 +865,7 @@ void GSLocalMemory::WriteImageTopBottom(int l, int r, int y, int h, BYTE* src, i { for(int x = l; x < r; x += bsx) { - BYTE* dst = NULL; + uint8* dst = NULL; switch(psm) { @@ -963,7 +916,7 @@ void GSLocalMemory::WriteImageTopBottom(int l, int r, int y, int h, BYTE* src, i } template -void GSLocalMemory::WriteImage(int& tx, int& ty, BYTE* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG) +void GSLocalMemory::WriteImage(int& tx, int& ty, uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG) { if(TRXREG.RRW == 0) return; @@ -987,7 +940,7 @@ void GSLocalMemory::WriteImage(int& tx, int& ty, BYTE* src, int len, GIFRegBITBL if(ra - la >= bsx && h > 0) // "transfer width" >= "block width" && there is at least one full row { - BYTE* s = &src[-l * trbpp >> 3]; + uint8* s = &src[-l * trbpp >> 3]; src += srcpitch * h; len -= srcpitch * h; @@ -1072,12 +1025,12 @@ void GSLocalMemory::WriteImage(int& tx, int& ty, BYTE* src, int len, GIFRegBITBL #define IsTopLeftAligned(dsax, tx, ty, bw, bh) \ ((((int)dsax) & ((bw)-1)) == 0 && ((tx) & ((bw)-1)) == 0 && ((int)dsax) == (tx) && ((ty) & ((bh)-1)) == 0) -void GSLocalMemory::WriteImage24(int& tx, int& ty, BYTE* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG) +void GSLocalMemory::WriteImage24(int& tx, int& ty, uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG) { if(TRXREG.RRW == 0) return; - DWORD bp = BITBLTBUF.DBP; - DWORD bw = BITBLTBUF.DBW; + uint32 bp = BITBLTBUF.DBP; + uint32 bw = BITBLTBUF.DBW; int tw = TRXPOS.DSAX + TRXREG.RRW, srcpitch = TRXREG.RRW * 3; int th = len / srcpitch; @@ -1106,12 +1059,12 @@ void GSLocalMemory::WriteImage24(int& tx, int& ty, BYTE* src, int len, GIFRegBIT } } -void GSLocalMemory::WriteImage8H(int& tx, int& ty, BYTE* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG) +void GSLocalMemory::WriteImage8H(int& tx, int& ty, uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG) { if(TRXREG.RRW == 0) return; - DWORD bp = BITBLTBUF.DBP; - DWORD bw = BITBLTBUF.DBW; + uint32 bp = BITBLTBUF.DBP; + uint32 bw = BITBLTBUF.DBW; int tw = TRXPOS.DSAX + TRXREG.RRW, srcpitch = TRXREG.RRW; int th = len / srcpitch; @@ -1140,12 +1093,12 @@ void GSLocalMemory::WriteImage8H(int& tx, int& ty, BYTE* src, int len, GIFRegBIT } } -void GSLocalMemory::WriteImage4HL(int& tx, int& ty, BYTE* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG) +void GSLocalMemory::WriteImage4HL(int& tx, int& ty, uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG) { if(TRXREG.RRW == 0) return; - DWORD bp = BITBLTBUF.DBP; - DWORD bw = BITBLTBUF.DBW; + uint32 bp = BITBLTBUF.DBP; + uint32 bw = BITBLTBUF.DBW; int tw = TRXPOS.DSAX + TRXREG.RRW, srcpitch = TRXREG.RRW / 2; int th = len / srcpitch; @@ -1174,12 +1127,12 @@ void GSLocalMemory::WriteImage4HL(int& tx, int& ty, BYTE* src, int len, GIFRegBI } } -void GSLocalMemory::WriteImage4HH(int& tx, int& ty, BYTE* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG) +void GSLocalMemory::WriteImage4HH(int& tx, int& ty, uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG) { if(TRXREG.RRW == 0) return; - DWORD bp = BITBLTBUF.DBP; - DWORD bw = BITBLTBUF.DBW; + uint32 bp = BITBLTBUF.DBP; + uint32 bw = BITBLTBUF.DBW; int tw = TRXPOS.DSAX + TRXREG.RRW, srcpitch = TRXREG.RRW / 2; int th = len / srcpitch; @@ -1207,12 +1160,12 @@ void GSLocalMemory::WriteImage4HH(int& tx, int& ty, BYTE* src, int len, GIFRegBI ty = th; } } -void GSLocalMemory::WriteImage24Z(int& tx, int& ty, BYTE* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG) +void GSLocalMemory::WriteImage24Z(int& tx, int& ty, uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG) { if(TRXREG.RRW == 0) return; - DWORD bp = BITBLTBUF.DBP; - DWORD bw = BITBLTBUF.DBW; + uint32 bp = BITBLTBUF.DBP; + uint32 bw = BITBLTBUF.DBW; int tw = TRXPOS.DSAX + TRXREG.RRW, srcpitch = TRXREG.RRW * 3; int th = len / srcpitch; @@ -1240,16 +1193,16 @@ void GSLocalMemory::WriteImage24Z(int& tx, int& ty, BYTE* src, int len, GIFRegBI ty = th; } } -void GSLocalMemory::WriteImageX(int& tx, int& ty, BYTE* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG) +void GSLocalMemory::WriteImageX(int& tx, int& ty, uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG) { if(len <= 0) return; - BYTE* pb = (BYTE*)src; - WORD* pw = (WORD*)src; - DWORD* pd = (DWORD*)src; + uint8* pb = (uint8*)src; + uint16* pw = (uint16*)src; + uint32* pd = (uint32*)src; - DWORD bp = BITBLTBUF.DBP; - DWORD bw = BITBLTBUF.DBW; + uint32 bp = BITBLTBUF.DBP; + uint32 bw = BITBLTBUF.DBW; psm_t* psm = &m_psm[BITBLTBUF.DPSM]; int x = tx; @@ -1266,7 +1219,7 @@ void GSLocalMemory::WriteImageX(int& tx, int& ty, BYTE* src, int len, GIFRegBITB while(len > 0) { - DWORD addr = psm->pa(0, y, bp, bw); + uint32 addr = psm->pa(0, y, bp, bw); int* offset = psm->rowOffset[y & 7]; for(; len > 0 && x < ex; len--, x++, pd++) @@ -1286,12 +1239,12 @@ void GSLocalMemory::WriteImageX(int& tx, int& ty, BYTE* src, int len, GIFRegBITB while(len > 0) { - DWORD addr = psm->pa(0, y, bp, bw); + uint32 addr = psm->pa(0, y, bp, bw); int* offset = psm->rowOffset[y & 7]; for(; len > 0 && x < ex; len--, x++, pb += 3) { - WritePixel24(addr + offset[x], *(DWORD*)pb); + WritePixel24(addr + offset[x], *(uint32*)pb); } if(x == ex) {x = sx; y++;} @@ -1308,7 +1261,7 @@ void GSLocalMemory::WriteImageX(int& tx, int& ty, BYTE* src, int len, GIFRegBITB while(len > 0) { - DWORD addr = psm->pa(0, y, bp, bw); + uint32 addr = psm->pa(0, y, bp, bw); int* offset = psm->rowOffset[y & 7]; for(; len > 0 && x < ex; len--, x++, pw++) @@ -1325,7 +1278,7 @@ void GSLocalMemory::WriteImageX(int& tx, int& ty, BYTE* src, int len, GIFRegBITB while(len > 0) { - DWORD addr = psm->pa(0, y, bp, bw); + uint32 addr = psm->pa(0, y, bp, bw); int* offset = psm->rowOffset[y & 7]; for(; len > 0 && x < ex; len--, x++, pb++) @@ -1342,7 +1295,7 @@ void GSLocalMemory::WriteImageX(int& tx, int& ty, BYTE* src, int len, GIFRegBITB while(len > 0) { - DWORD addr = psm->pa(0, y, bp, bw); + uint32 addr = psm->pa(0, y, bp, bw); int* offset = psm->rowOffset[y & 7]; for(; len > 0 && x < ex; len--, x += 2, pb++) @@ -1360,7 +1313,7 @@ void GSLocalMemory::WriteImageX(int& tx, int& ty, BYTE* src, int len, GIFRegBITB while(len > 0) { - DWORD addr = psm->pa(0, y, bp, bw); + uint32 addr = psm->pa(0, y, bp, bw); int* offset = psm->rowOffset[y & 7]; for(; len > 0 && x < ex; len--, x++, pb++) @@ -1377,7 +1330,7 @@ void GSLocalMemory::WriteImageX(int& tx, int& ty, BYTE* src, int len, GIFRegBITB while(len > 0) { - DWORD addr = psm->pa(0, y, bp, bw); + uint32 addr = psm->pa(0, y, bp, bw); int* offset = psm->rowOffset[y & 7]; for(; len > 0 && x < ex; len--, x += 2, pb++) @@ -1395,7 +1348,7 @@ void GSLocalMemory::WriteImageX(int& tx, int& ty, BYTE* src, int len, GIFRegBITB while(len > 0) { - DWORD addr = psm->pa(0, y, bp, bw); + uint32 addr = psm->pa(0, y, bp, bw); int* offset = psm->rowOffset[y & 7]; for(; len > 0 && x < ex; len--, x += 2, pb++) @@ -1416,16 +1369,16 @@ void GSLocalMemory::WriteImageX(int& tx, int& ty, BYTE* src, int len, GIFRegBITB // -void GSLocalMemory::ReadImageX(int& tx, int& ty, BYTE* dst, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG) const +void GSLocalMemory::ReadImageX(int& tx, int& ty, uint8* dst, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG) const { if(len <= 0) return; - BYTE* pb = (BYTE*)dst; - WORD* pw = (WORD*)dst; - DWORD* pd = (DWORD*)dst; + uint8* pb = (uint8*)dst; + uint16* pw = (uint16*)dst; + uint32* pd = (uint32*)dst; - DWORD bp = BITBLTBUF.SBP; - DWORD bw = BITBLTBUF.SBW; + uint32 bp = BITBLTBUF.SBP; + uint32 bw = BITBLTBUF.SBW; psm_t* psm = &m_psm[BITBLTBUF.SPSM]; int x = tx; @@ -1442,7 +1395,7 @@ void GSLocalMemory::ReadImageX(int& tx, int& ty, BYTE* dst, int len, GIFRegBITBL while(len > 0) { - DWORD addr = psm->pa(0, y, bp, bw); + uint32 addr = psm->pa(0, y, bp, bw); int* offset = psm->rowOffset[y & 7]; for(; len > 0 && x < ex; len--, x++, pd++) @@ -1462,16 +1415,16 @@ void GSLocalMemory::ReadImageX(int& tx, int& ty, BYTE* dst, int len, GIFRegBITBL while(len > 0) { - DWORD addr = psm->pa(0, y, bp, bw); + uint32 addr = psm->pa(0, y, bp, bw); int* offset = psm->rowOffset[y & 7]; for(; len > 0 && x < ex; len--, x++, pb += 3) { - DWORD dw = ReadPixel32(addr + offset[x]); + uint32 c = ReadPixel32(addr + offset[x]); - pb[0] = ((BYTE*)&dw)[0]; - pb[1] = ((BYTE*)&dw)[1]; - pb[2] = ((BYTE*)&dw)[2]; + pb[0] = ((uint8*)&c)[0]; + pb[1] = ((uint8*)&c)[1]; + pb[2] = ((uint8*)&c)[2]; } if(x == ex) {x = sx; y++;} @@ -1488,7 +1441,7 @@ void GSLocalMemory::ReadImageX(int& tx, int& ty, BYTE* dst, int len, GIFRegBITBL while(len > 0) { - DWORD addr = psm->pa(0, y, bp, bw); + uint32 addr = psm->pa(0, y, bp, bw); int* offset = psm->rowOffset[y & 7]; for(; len > 0 && x < ex; len--, x++, pw++) @@ -1505,7 +1458,7 @@ void GSLocalMemory::ReadImageX(int& tx, int& ty, BYTE* dst, int len, GIFRegBITBL while(len > 0) { - DWORD addr = psm->pa(0, y, bp, bw); + uint32 addr = psm->pa(0, y, bp, bw); int* offset = psm->rowOffset[y & 7]; for(; len > 0 && x < ex; len--, x++, pb++) @@ -1522,7 +1475,7 @@ void GSLocalMemory::ReadImageX(int& tx, int& ty, BYTE* dst, int len, GIFRegBITBL while(len > 0) { - DWORD addr = psm->pa(0, y, bp, bw); + uint32 addr = psm->pa(0, y, bp, bw); int* offset = psm->rowOffset[y & 7]; for(; len > 0 && x < ex; len--, x += 2, pb++) @@ -1539,7 +1492,7 @@ void GSLocalMemory::ReadImageX(int& tx, int& ty, BYTE* dst, int len, GIFRegBITBL while(len > 0) { - DWORD addr = psm->pa(0, y, bp, bw); + uint32 addr = psm->pa(0, y, bp, bw); int* offset = psm->rowOffset[y & 7]; for(; len > 0 && x < ex; len--, x++, pb++) @@ -1556,7 +1509,7 @@ void GSLocalMemory::ReadImageX(int& tx, int& ty, BYTE* dst, int len, GIFRegBITBL while(len > 0) { - DWORD addr = psm->pa(0, y, bp, bw); + uint32 addr = psm->pa(0, y, bp, bw); int* offset = psm->rowOffset[y & 7]; for(; len > 0 && x < ex; len--, x += 2, pb++) @@ -1573,7 +1526,7 @@ void GSLocalMemory::ReadImageX(int& tx, int& ty, BYTE* dst, int len, GIFRegBITBL while(len > 0) { - DWORD addr = psm->pa(0, y, bp, bw); + uint32 addr = psm->pa(0, y, bp, bw); int* offset = psm->rowOffset[y & 7]; for(; len > 0 && x < ex; len--, x += 2, pb++) @@ -1593,7 +1546,7 @@ void GSLocalMemory::ReadImageX(int& tx, int& ty, BYTE* dst, int len, GIFRegBITBL /////////////////// -void GSLocalMemory::ReadTexture32(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTexture32(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { FOREACH_BLOCK_START(8, 8, 32) { @@ -1602,7 +1555,7 @@ void GSLocalMemory::ReadTexture32(const CRect& r, BYTE* dst, int dstpitch, const FOREACH_BLOCK_END } -void GSLocalMemory::ReadTexture24(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTexture24(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { if(TEXA.AEM) { @@ -1622,35 +1575,35 @@ void GSLocalMemory::ReadTexture24(const CRect& r, BYTE* dst, int dstpitch, const } } -void GSLocalMemory::ReadTexture16(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTexture16(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { - __declspec(align(16)) WORD block[16 * 8]; + __declspec(align(16)) uint16 block[16 * 8]; FOREACH_BLOCK_START(16, 8, 32) { - ReadBlock16(BlockPtr16(x, y, bp, bw), (BYTE*)block, sizeof(block) / 8); + ReadBlock16(BlockPtr16(x, y, bp, bw), (uint8*)block, sizeof(block) / 8); ExpandBlock16(block, dst, dstpitch, TEXA); } FOREACH_BLOCK_END } -void GSLocalMemory::ReadTexture16S(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTexture16S(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { - __declspec(align(16)) WORD block[16 * 8]; + __declspec(align(16)) uint16 block[16 * 8]; FOREACH_BLOCK_START(16, 8, 32) { - ReadBlock16(BlockPtr16S(x, y, bp, bw), (BYTE*)block, sizeof(block) / 8); + ReadBlock16(BlockPtr16S(x, y, bp, bw), (uint8*)block, sizeof(block) / 8); ExpandBlock16(block, dst, dstpitch, TEXA); } FOREACH_BLOCK_END } -void GSLocalMemory::ReadTexture8(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTexture8(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { - const DWORD* pal = m_clut; + const uint32* pal = m_clut; FOREACH_BLOCK_START(16, 16, 32) { @@ -1659,9 +1612,9 @@ void GSLocalMemory::ReadTexture8(const CRect& r, BYTE* dst, int dstpitch, const FOREACH_BLOCK_END } -void GSLocalMemory::ReadTexture4(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTexture4(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { - const UINT64* pal = m_clut; + const uint64* pal = m_clut; FOREACH_BLOCK_START(32, 16, 32) { @@ -1670,9 +1623,9 @@ void GSLocalMemory::ReadTexture4(const CRect& r, BYTE* dst, int dstpitch, const FOREACH_BLOCK_END } -void GSLocalMemory::ReadTexture8H(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTexture8H(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { - const DWORD* pal = m_clut; + const uint32* pal = m_clut; FOREACH_BLOCK_START(8, 8, 32) { @@ -1681,9 +1634,9 @@ void GSLocalMemory::ReadTexture8H(const CRect& r, BYTE* dst, int dstpitch, const FOREACH_BLOCK_END } -void GSLocalMemory::ReadTexture4HL(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTexture4HL(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { - const DWORD* pal = m_clut; + const uint32* pal = m_clut; FOREACH_BLOCK_START(8, 8, 32) { @@ -1692,9 +1645,9 @@ void GSLocalMemory::ReadTexture4HL(const CRect& r, BYTE* dst, int dstpitch, cons FOREACH_BLOCK_END } -void GSLocalMemory::ReadTexture4HH(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTexture4HH(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { - const DWORD* pal = m_clut; + const uint32* pal = m_clut; FOREACH_BLOCK_START(8, 8, 32) { @@ -1703,7 +1656,7 @@ void GSLocalMemory::ReadTexture4HH(const CRect& r, BYTE* dst, int dstpitch, cons FOREACH_BLOCK_END } -void GSLocalMemory::ReadTexture32Z(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTexture32Z(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { FOREACH_BLOCK_START(8, 8, 32) { @@ -1712,7 +1665,7 @@ void GSLocalMemory::ReadTexture32Z(const CRect& r, BYTE* dst, int dstpitch, cons FOREACH_BLOCK_END } -void GSLocalMemory::ReadTexture24Z(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTexture24Z(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { if(TEXA.AEM) { @@ -1732,26 +1685,26 @@ void GSLocalMemory::ReadTexture24Z(const CRect& r, BYTE* dst, int dstpitch, cons } } -void GSLocalMemory::ReadTexture16Z(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTexture16Z(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { - __declspec(align(16)) WORD block[16 * 8]; + __declspec(align(16)) uint16 block[16 * 8]; FOREACH_BLOCK_START(16, 8, 32) { - ReadBlock16(BlockPtr16Z(x, y, bp, bw), (BYTE*)block, sizeof(block) / 8); + ReadBlock16(BlockPtr16Z(x, y, bp, bw), (uint8*)block, sizeof(block) / 8); ExpandBlock16(block, dst, dstpitch, TEXA); } FOREACH_BLOCK_END } -void GSLocalMemory::ReadTexture16SZ(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTexture16SZ(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { - __declspec(align(16)) WORD block[16 * 8]; + __declspec(align(16)) uint16 block[16 * 8]; FOREACH_BLOCK_START(16, 8, 32) { - ReadBlock16(BlockPtr16SZ(x, y, bp, bw), (BYTE*)block, sizeof(block) / 8); + ReadBlock16(BlockPtr16SZ(x, y, bp, bw), (uint8*)block, sizeof(block) / 8); ExpandBlock16(block, dst, dstpitch, TEXA); } @@ -1760,12 +1713,12 @@ void GSLocalMemory::ReadTexture16SZ(const CRect& r, BYTE* dst, int dstpitch, con /////////////////// -void GSLocalMemory::ReadTextureBlock32(DWORD bp, BYTE* dst, int dstpitch, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTextureBlock32(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const { ReadBlock32(BlockPtr(bp), dst, dstpitch); } -void GSLocalMemory::ReadTextureBlock24(DWORD bp, BYTE* dst, int dstpitch, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTextureBlock24(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const { if(TEXA.AEM) { @@ -1777,65 +1730,65 @@ void GSLocalMemory::ReadTextureBlock24(DWORD bp, BYTE* dst, int dstpitch, const } } -void GSLocalMemory::ReadTextureBlock16(DWORD bp, BYTE* dst, int dstpitch, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTextureBlock16(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const { - __declspec(align(16)) WORD block[16 * 8]; + __declspec(align(16)) uint16 block[16 * 8]; - ReadBlock16(BlockPtr(bp), (BYTE*)block, sizeof(block) / 8); + ReadBlock16(BlockPtr(bp), (uint8*)block, sizeof(block) / 8); ExpandBlock16(block, dst, dstpitch, TEXA); } -void GSLocalMemory::ReadTextureBlock16S(DWORD bp, BYTE* dst, int dstpitch, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTextureBlock16S(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const { - __declspec(align(16)) WORD block[16 * 8]; + __declspec(align(16)) uint16 block[16 * 8]; - ReadBlock16(BlockPtr(bp), (BYTE*)block, sizeof(block) / 8); + ReadBlock16(BlockPtr(bp), (uint8*)block, sizeof(block) / 8); ExpandBlock16(block, dst, dstpitch, TEXA); } -void GSLocalMemory::ReadTextureBlock8(DWORD bp, BYTE* dst, int dstpitch, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTextureBlock8(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const { - const DWORD* pal = m_clut; + const uint32* pal = m_clut; ReadAndExpandBlock8_32(BlockPtr(bp), dst, dstpitch, pal); } -void GSLocalMemory::ReadTextureBlock4(DWORD bp, BYTE* dst, int dstpitch, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTextureBlock4(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const { const UINT64* pal = m_clut; ReadAndExpandBlock4_32(BlockPtr(bp), dst, dstpitch, pal); } -void GSLocalMemory::ReadTextureBlock8H(DWORD bp, BYTE* dst, int dstpitch, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTextureBlock8H(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const { - const DWORD* pal = m_clut; + const uint32* pal = m_clut; ReadAndExpandBlock8H_32(BlockPtr(bp), dst, dstpitch, pal); } -void GSLocalMemory::ReadTextureBlock4HL(DWORD bp, BYTE* dst, int dstpitch, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTextureBlock4HL(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const { - const DWORD* pal = m_clut; + const uint32* pal = m_clut; ReadAndExpandBlock4HL_32(BlockPtr(bp), dst, dstpitch, pal); } -void GSLocalMemory::ReadTextureBlock4HH(DWORD bp, BYTE* dst, int dstpitch, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTextureBlock4HH(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const { - const DWORD* pal = m_clut; + const uint32* pal = m_clut; ReadAndExpandBlock4HH_32(BlockPtr(bp), dst, dstpitch, pal); } -void GSLocalMemory::ReadTextureBlock32Z(DWORD bp, BYTE* dst, int dstpitch, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTextureBlock32Z(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const { ReadBlock32(BlockPtr(bp), dst, dstpitch); } -void GSLocalMemory::ReadTextureBlock24Z(DWORD bp, BYTE* dst, int dstpitch, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTextureBlock24Z(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const { if(TEXA.AEM) { @@ -1847,38 +1800,38 @@ void GSLocalMemory::ReadTextureBlock24Z(DWORD bp, BYTE* dst, int dstpitch, const } } -void GSLocalMemory::ReadTextureBlock16Z(DWORD bp, BYTE* dst, int dstpitch, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTextureBlock16Z(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const { - __declspec(align(16)) WORD block[16 * 8]; + __declspec(align(16)) uint16 block[16 * 8]; - ReadBlock16(BlockPtr(bp), (BYTE*)block, sizeof(block) / 8); + ReadBlock16(BlockPtr(bp), (uint8*)block, sizeof(block) / 8); ExpandBlock16(block, dst, dstpitch, TEXA); } -void GSLocalMemory::ReadTextureBlock16SZ(DWORD bp, BYTE* dst, int dstpitch, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTextureBlock16SZ(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const { - __declspec(align(16)) WORD block[16 * 8]; + __declspec(align(16)) uint16 block[16 * 8]; - ReadBlock16(BlockPtr(bp), (BYTE*)block, sizeof(block) / 8); + ReadBlock16(BlockPtr(bp), (uint8*)block, sizeof(block) / 8); ExpandBlock16(block, dst, dstpitch, TEXA); } /////////////////// -void GSLocalMemory::ReadTexture(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GIFRegCLAMP& CLAMP) +void GSLocalMemory::ReadTexture(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GIFRegCLAMP& CLAMP) { readTexture rtx = m_psm[TEX0.PSM].rtx; readTexel rt = m_psm[TEX0.PSM].rt; - CSize bs = m_psm[TEX0.PSM].bs; + GSVector2i bs = m_psm[TEX0.PSM].bs; - if(r.Width() < bs.cx || r.Height() < bs.cy - || (r.left & (bs.cx-1)) || (r.top & (bs.cy-1)) - || (r.right & (bs.cx-1)) || (r.bottom & (bs.cy-1)) - || (CLAMP.WMS == 3) || (CLAMP.WMT == 3)) + if(r.width() < bs.x || r.height() < bs.y + || (r.left & (bs.x - 1)) || (r.top & (bs.y - 1)) + || (r.right & (bs.x - 1)) || (r.bottom & (bs.y - 1)) + || CLAMP.WMS == 3 || CLAMP.WMT == 3) { - ReadTexture(r, dst, dstpitch, TEX0, TEXA, CLAMP, rt, rtx); + ReadTexture(r, dst, dstpitch, TEX0, TEXA, CLAMP, rt, rtx); } else { @@ -1886,17 +1839,17 @@ void GSLocalMemory::ReadTexture(const CRect& r, BYTE* dst, int dstpitch, const G } } -void GSLocalMemory::ReadTextureNC(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GIFRegCLAMP& CLAMP) +void GSLocalMemory::ReadTextureNC(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GIFRegCLAMP& CLAMP) { readTexture rtx = m_psm[TEX0.PSM].rtx; readTexel rt = m_psm[TEX0.PSM].rt; - CSize bs = m_psm[TEX0.PSM].bs; + GSVector2i bs = m_psm[TEX0.PSM].bs; - if(r.Width() < bs.cx || r.Height() < bs.cy - || (r.left & (bs.cx-1)) || (r.top & (bs.cy-1)) - || (r.right & (bs.cx-1)) || (r.bottom & (bs.cy-1))) + if(r.width() < bs.x || r.height() < bs.y + || (r.left & (bs.x - 1)) || (r.top & (bs.y - 1)) + || (r.right & (bs.x - 1)) || (r.bottom & (bs.y - 1))) { - ReadTextureNC(r, dst, dstpitch, TEX0, TEXA, rt, rtx); + ReadTextureNC(r, dst, dstpitch, TEX0, TEXA, rt, rtx); } else { @@ -1905,7 +1858,7 @@ void GSLocalMemory::ReadTextureNC(const CRect& r, BYTE* dst, int dstpitch, const } /////////////////// -void GSLocalMemory::ReadTexture16NP(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTexture16NP(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { FOREACH_BLOCK_START(16, 8, 16) { @@ -1914,7 +1867,7 @@ void GSLocalMemory::ReadTexture16NP(const CRect& r, BYTE* dst, int dstpitch, con FOREACH_BLOCK_END } -void GSLocalMemory::ReadTexture16SNP(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTexture16SNP(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { FOREACH_BLOCK_START(16, 8, 16) { @@ -1923,9 +1876,9 @@ void GSLocalMemory::ReadTexture16SNP(const CRect& r, BYTE* dst, int dstpitch, co FOREACH_BLOCK_END } -void GSLocalMemory::ReadTexture8NP(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTexture8NP(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { - const DWORD* pal = m_clut; + const uint32* pal = m_clut; if(TEX0.CPSM == PSM_PSMCT32 || TEX0.CPSM == PSM_PSMCT24) { @@ -1939,11 +1892,11 @@ void GSLocalMemory::ReadTexture8NP(const CRect& r, BYTE* dst, int dstpitch, cons { ASSERT(TEX0.CPSM == PSM_PSMCT16 || TEX0.CPSM == PSM_PSMCT16S); - __declspec(align(16)) BYTE block[16 * 16]; + __declspec(align(16)) uint8 block[16 * 16]; FOREACH_BLOCK_START(16, 16, 16) { - ReadBlock8(BlockPtr8(x, y, bp, bw), (BYTE*)block, sizeof(block) / 16); + ReadBlock8(BlockPtr8(x, y, bp, bw), (uint8*)block, sizeof(block) / 16); ExpandBlock8_16(block, dst, dstpitch, pal); } @@ -1951,7 +1904,7 @@ void GSLocalMemory::ReadTexture8NP(const CRect& r, BYTE* dst, int dstpitch, cons } } -void GSLocalMemory::ReadTexture4NP(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTexture4NP(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { const UINT64* pal = m_clut; @@ -1967,11 +1920,11 @@ void GSLocalMemory::ReadTexture4NP(const CRect& r, BYTE* dst, int dstpitch, cons { ASSERT(TEX0.CPSM == PSM_PSMCT16 || TEX0.CPSM == PSM_PSMCT16S); - __declspec(align(16)) BYTE block[(32 / 2) * 16]; + __declspec(align(16)) uint8 block[(32 / 2) * 16]; FOREACH_BLOCK_START(32, 16, 16) { - ReadBlock4(BlockPtr4(x, y, bp, bw), (BYTE*)block, sizeof(block) / 16); + ReadBlock4(BlockPtr4(x, y, bp, bw), (uint8*)block, sizeof(block) / 16); ExpandBlock4_16(block, dst, dstpitch, pal); } @@ -1979,9 +1932,9 @@ void GSLocalMemory::ReadTexture4NP(const CRect& r, BYTE* dst, int dstpitch, cons } } -void GSLocalMemory::ReadTexture8HNP(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTexture8HNP(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { - const DWORD* pal = m_clut; + const uint32* pal = m_clut; if(TEX0.CPSM == PSM_PSMCT32 || TEX0.CPSM == PSM_PSMCT24) { @@ -1995,11 +1948,11 @@ void GSLocalMemory::ReadTexture8HNP(const CRect& r, BYTE* dst, int dstpitch, con { ASSERT(TEX0.CPSM == PSM_PSMCT16 || TEX0.CPSM == PSM_PSMCT16S); - __declspec(align(16)) DWORD block[8 * 8]; + __declspec(align(16)) uint32 block[8 * 8]; FOREACH_BLOCK_START(8, 8, 16) { - ReadBlock32(BlockPtr32(x, y, bp, bw), (BYTE*)block, sizeof(block) / 8); + ReadBlock32(BlockPtr32(x, y, bp, bw), (uint8*)block, sizeof(block) / 8); ExpandBlock8H_16(block, dst, dstpitch, pal); } @@ -2007,9 +1960,9 @@ void GSLocalMemory::ReadTexture8HNP(const CRect& r, BYTE* dst, int dstpitch, con } } -void GSLocalMemory::ReadTexture4HLNP(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTexture4HLNP(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { - const DWORD* pal = m_clut; + const uint32* pal = m_clut; if(TEX0.CPSM == PSM_PSMCT32 || TEX0.CPSM == PSM_PSMCT24) { @@ -2023,11 +1976,11 @@ void GSLocalMemory::ReadTexture4HLNP(const CRect& r, BYTE* dst, int dstpitch, co { ASSERT(TEX0.CPSM == PSM_PSMCT16 || TEX0.CPSM == PSM_PSMCT16S); - __declspec(align(16)) DWORD block[8 * 8]; + __declspec(align(16)) uint32 block[8 * 8]; FOREACH_BLOCK_START(8, 8, 16) { - ReadBlock32(BlockPtr32(x, y, bp, bw), (BYTE*)block, sizeof(block) / 8); + ReadBlock32(BlockPtr32(x, y, bp, bw), (uint8*)block, sizeof(block) / 8); ExpandBlock4HL_16(block, dst, dstpitch, pal); } @@ -2035,9 +1988,9 @@ void GSLocalMemory::ReadTexture4HLNP(const CRect& r, BYTE* dst, int dstpitch, co } } -void GSLocalMemory::ReadTexture4HHNP(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTexture4HHNP(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { - const DWORD* pal = m_clut; + const uint32* pal = m_clut; if(TEX0.CPSM == PSM_PSMCT32 || TEX0.CPSM == PSM_PSMCT24) { @@ -2051,11 +2004,11 @@ void GSLocalMemory::ReadTexture4HHNP(const CRect& r, BYTE* dst, int dstpitch, co { ASSERT(TEX0.CPSM == PSM_PSMCT16 || TEX0.CPSM == PSM_PSMCT16S); - __declspec(align(16)) DWORD block[8 * 8]; + __declspec(align(16)) uint32 block[8 * 8]; FOREACH_BLOCK_START(8, 8, 16) { - ReadBlock32(BlockPtr32(x, y, bp, bw), (BYTE*)block, sizeof(block) / 8); + ReadBlock32(BlockPtr32(x, y, bp, bw), (uint8*)block, sizeof(block) / 8); ExpandBlock4HH_16(block, dst, dstpitch, pal); } @@ -2063,7 +2016,7 @@ void GSLocalMemory::ReadTexture4HHNP(const CRect& r, BYTE* dst, int dstpitch, co } } -void GSLocalMemory::ReadTexture16ZNP(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTexture16ZNP(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { FOREACH_BLOCK_START(16, 8, 16) { @@ -2072,7 +2025,7 @@ void GSLocalMemory::ReadTexture16ZNP(const CRect& r, BYTE* dst, int dstpitch, co FOREACH_BLOCK_END } -void GSLocalMemory::ReadTexture16SZNP(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTexture16SZNP(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { FOREACH_BLOCK_START(16, 8, 16) { @@ -2083,18 +2036,18 @@ void GSLocalMemory::ReadTexture16SZNP(const CRect& r, BYTE* dst, int dstpitch, c /////////////////// -void GSLocalMemory::ReadTextureNP(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GIFRegCLAMP& CLAMP) +void GSLocalMemory::ReadTextureNP(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GIFRegCLAMP& CLAMP) { readTexture rtx = m_psm[TEX0.PSM].rtxNP; readTexel rt = m_psm[TEX0.PSM].rtNP; - CSize bs = m_psm[TEX0.PSM].bs; + GSVector2i bs = m_psm[TEX0.PSM].bs; - if(r.Width() < bs.cx || r.Height() < bs.cy - || (r.left & (bs.cx-1)) || (r.top & (bs.cy-1)) - || (r.right & (bs.cx-1)) || (r.bottom & (bs.cy-1)) - || (CLAMP.WMS == 3) || (CLAMP.WMT == 3)) + if(r.width() < bs.x || r.height() < bs.y + || (r.left & (bs.x - 1)) || (r.top & (bs.y - 1)) + || (r.right & (bs.x - 1)) || (r.bottom & (bs.y - 1)) + || CLAMP.WMS == 3 || CLAMP.WMT == 3) { - DWORD psm = TEX0.PSM; + uint32 psm = TEX0.PSM; switch(psm) { @@ -2112,11 +2065,11 @@ void GSLocalMemory::ReadTextureNP(const CRect& r, BYTE* dst, int dstpitch, const default: case PSM_PSMCT32: case PSM_PSMCT24: - ReadTexture(r, dst, dstpitch, TEX0, TEXA, CLAMP, rt, rtx); + ReadTexture(r, dst, dstpitch, TEX0, TEXA, CLAMP, rt, rtx); break; case PSM_PSMCT16: case PSM_PSMCT16S: - ReadTexture(r, dst, dstpitch, TEX0, TEXA, CLAMP, rt, rtx); + ReadTexture(r, dst, dstpitch, TEX0, TEXA, CLAMP, rt, rtx); break; } } @@ -2126,17 +2079,17 @@ void GSLocalMemory::ReadTextureNP(const CRect& r, BYTE* dst, int dstpitch, const } } -void GSLocalMemory::ReadTextureNPNC(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GIFRegCLAMP& CLAMP) +void GSLocalMemory::ReadTextureNPNC(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GIFRegCLAMP& CLAMP) { readTexture rtx = m_psm[TEX0.PSM].rtxNP; readTexel rt = m_psm[TEX0.PSM].rtNP; - CSize bs = m_psm[TEX0.PSM].bs; + GSVector2i bs = m_psm[TEX0.PSM].bs; - if(r.Width() < bs.cx || r.Height() < bs.cy - || (r.left & (bs.cx-1)) || (r.top & (bs.cy-1)) - || (r.right & (bs.cx-1)) || (r.bottom & (bs.cy-1))) + if(r.width() < bs.x || r.height() < bs.y + || (r.left & (bs.x - 1)) || (r.top & (bs.y - 1)) + || (r.right & (bs.x - 1)) || (r.bottom & (bs.y - 1))) { - DWORD psm = TEX0.PSM; + uint32 psm = TEX0.PSM; switch(psm) { @@ -2154,11 +2107,11 @@ void GSLocalMemory::ReadTextureNPNC(const CRect& r, BYTE* dst, int dstpitch, con default: case PSM_PSMCT32: case PSM_PSMCT24: - ReadTextureNC(r, dst, dstpitch, TEX0, TEXA, rt, rtx); + ReadTextureNC(r, dst, dstpitch, TEX0, TEXA, rt, rtx); break; case PSM_PSMCT16: case PSM_PSMCT16S: - ReadTextureNC(r, dst, dstpitch, TEX0, TEXA, rt, rtx); + ReadTextureNC(r, dst, dstpitch, TEX0, TEXA, rt, rtx); break; } } @@ -2170,7 +2123,7 @@ void GSLocalMemory::ReadTextureNPNC(const CRect& r, BYTE* dst, int dstpitch, con // 32/8 -void GSLocalMemory::ReadTexture8P(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTexture8P(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { FOREACH_BLOCK_START(16, 16, 8) { @@ -2179,7 +2132,7 @@ void GSLocalMemory::ReadTexture8P(const CRect& r, BYTE* dst, int dstpitch, const FOREACH_BLOCK_END } -void GSLocalMemory::ReadTexture4P(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTexture4P(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { FOREACH_BLOCK_START(32, 16, 8) { @@ -2188,7 +2141,7 @@ void GSLocalMemory::ReadTexture4P(const CRect& r, BYTE* dst, int dstpitch, const FOREACH_BLOCK_END } -void GSLocalMemory::ReadTexture8HP(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTexture8HP(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { FOREACH_BLOCK_START(8, 8, 8) { @@ -2197,7 +2150,7 @@ void GSLocalMemory::ReadTexture8HP(const CRect& r, BYTE* dst, int dstpitch, cons FOREACH_BLOCK_END } -void GSLocalMemory::ReadTexture4HLP(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTexture4HLP(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { FOREACH_BLOCK_START(8, 8, 8) { @@ -2206,7 +2159,7 @@ void GSLocalMemory::ReadTexture4HLP(const CRect& r, BYTE* dst, int dstpitch, con FOREACH_BLOCK_END } -void GSLocalMemory::ReadTexture4HHP(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTexture4HHP(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { FOREACH_BLOCK_START(8, 8, 8) { @@ -2217,27 +2170,27 @@ void GSLocalMemory::ReadTexture4HHP(const CRect& r, BYTE* dst, int dstpitch, con // -void GSLocalMemory::ReadTextureBlock8P(DWORD bp, BYTE* dst, int dstpitch, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTextureBlock8P(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const { ReadBlock8(BlockPtr(bp), dst, dstpitch); } -void GSLocalMemory::ReadTextureBlock4P(DWORD bp, BYTE* dst, int dstpitch, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTextureBlock4P(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const { ReadBlock4P(BlockPtr(bp), dst, dstpitch); } -void GSLocalMemory::ReadTextureBlock8HP(DWORD bp, BYTE* dst, int dstpitch, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTextureBlock8HP(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const { ReadBlock8HP(BlockPtr(bp), dst, dstpitch); } -void GSLocalMemory::ReadTextureBlock4HLP(DWORD bp, BYTE* dst, int dstpitch, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTextureBlock4HLP(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const { ReadBlock4HLP(BlockPtr(bp), dst, dstpitch); } -void GSLocalMemory::ReadTextureBlock4HHP(DWORD bp, BYTE* dst, int dstpitch, const GIFRegTEXA& TEXA) const +void GSLocalMemory::ReadTextureBlock4HHP(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const { ReadBlock4HHP(BlockPtr(bp), dst, dstpitch); } @@ -2245,18 +2198,20 @@ void GSLocalMemory::ReadTextureBlock4HHP(DWORD bp, BYTE* dst, int dstpitch, cons // template -void GSLocalMemory::ReadTexture(CRect r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GIFRegCLAMP& CLAMP, readTexel rt, readTexture rtx) +void GSLocalMemory::ReadTexture(const GSVector4i& r2, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GIFRegCLAMP& CLAMP, readTexel rt, readTexture rtx) { // TODO: this is a mess, make it more simple - DWORD wms = CLAMP.WMS, wmt = CLAMP.WMT; - DWORD minu = CLAMP.MINU, maxu = CLAMP.MAXU; - DWORD minv = CLAMP.MINV, maxv = CLAMP.MAXV; + GSVector4i r = r2; - CSize bs = m_psm[TEX0.PSM].bs; + uint32 wms = CLAMP.WMS, wmt = CLAMP.WMT; + uint32 minu = CLAMP.MINU, maxu = CLAMP.MAXU; + uint32 minv = CLAMP.MINV, maxv = CLAMP.MAXV; - int bsxm = bs.cx - 1; - int bsym = bs.cy - 1; + GSVector2i bs = m_psm[TEX0.PSM].bs; + + int bsxm = bs.x - 1; + int bsym = bs.y - 1; if(wms == 3 || wmt == 3) { @@ -2268,13 +2223,13 @@ void GSLocalMemory::ReadTexture(CRect r, BYTE* dst, int dstpitch, const GIFRegTE w = (w + bsxm) & ~bsxm; h = (h + bsym) & ~bsym; - if(w % bs.cx == 0 && maxu % bs.cx == 0 && h % bs.cy == 0 && maxv % bs.cy == 0) + if(w % bs.x == 0 && maxu % bs.x == 0 && h % bs.y == 0 && maxv % bs.y == 0) { // printf("!!! 1 wms = %d, wmt = %d, %3x %3x %3x %3x, %d %d - %d %d\n", wms, wmt, minu, maxu, minv, maxv, r.left, r.top, r.right, r.bottom); T* buff = (T*)_aligned_malloc(w * h * sizeof(T), 16); - (this->*rtx)(CRect(CPoint(maxu, maxv), CSize(w, h)), (BYTE*)buff, w * sizeof(T), TEX0, TEXA); + (this->*rtx)(GSVector4i(maxu, maxv, maxu + w, maxv + h), (uint8*)buff, w * sizeof(T), TEX0, TEXA); dst -= r.left * sizeof(T); @@ -2329,7 +2284,7 @@ void GSLocalMemory::ReadTexture(CRect r, BYTE* dst, int dstpitch, const GIFRegTE { int w = ((minu + 1) + bsxm) & ~bsxm; - if(w % bs.cx == 0 && maxu % bs.cx == 0) + if(w % bs.x == 0 && maxu % bs.x == 0) { // printf("!!! 2 wms = %d, wmt = %d, %3x %3x %3x %3x, %d %d - %d %d\n", wms, wmt, minu, maxu, minv, maxv, r.left, r.top, r.right, r.bottom); int top = r.top & ~bsym; @@ -2339,7 +2294,7 @@ void GSLocalMemory::ReadTexture(CRect r, BYTE* dst, int dstpitch, const GIFRegTE T* buff = (T*)_aligned_malloc(w * h * sizeof(T), 16); - (this->*rtx)(CRect(CPoint(maxu, top), CSize(w, h)), (BYTE*)buff, w * sizeof(T), TEX0, TEXA); + (this->*rtx)(GSVector4i(maxu, top, maxu + w, top + h), (uint8*)buff, w * sizeof(T), TEX0, TEXA); dst -= r.left * sizeof(T); @@ -2378,7 +2333,7 @@ void GSLocalMemory::ReadTexture(CRect r, BYTE* dst, int dstpitch, const GIFRegTE { int h = (minv + 1 + bsym) & ~bsym; - if(h % bs.cy == 0 && maxv % bs.cy == 0) + if(h % bs.y == 0 && maxv % bs.y == 0) { // printf("!!! 3 wms = %d, wmt = %d, %3x %3x %3x %3x, %d %d - %d %d\n", wms, wmt, minu, maxu, minv, maxv, r.left, r.top, r.right, r.bottom); int left = r.left & ~bsxm; @@ -2388,13 +2343,13 @@ void GSLocalMemory::ReadTexture(CRect r, BYTE* dst, int dstpitch, const GIFRegTE T* buff = (T*)_aligned_malloc(w * h * sizeof(T), 16); - (this->*rtx)(CRect(CPoint(left, maxv), CSize(w, h)), (BYTE*)buff, w * sizeof(T), TEX0, TEXA); + (this->*rtx)(GSVector4i(left, maxv, left + w, maxv + h), (uint8*)buff, w * sizeof(T), TEX0, TEXA); for(int y = r.top; y < r.bottom; y++, dst += dstpitch) { T* src = &buff[(y & minv) * w + (r.left - left)]; - memcpy(dst, src, sizeof(T) * r.Width()); + memcpy(dst, src, sizeof(T) * r.width()); } _aligned_free(buff); @@ -2425,8 +2380,8 @@ void GSLocalMemory::ReadTexture(CRect r, BYTE* dst, int dstpitch, const GIFRegTE { // find a block-aligned rect that fits between r and the region clamped area (if any) - CRect r1 = r; - CRect r2 = r; + GSVector4i r1 = r; + GSVector4i r2 = r; r1.left = (r1.left + bsxm) & ~bsxm; r1.top = (r1.top + bsym) & ~bsym; @@ -2445,11 +2400,11 @@ void GSLocalMemory::ReadTexture(CRect r, BYTE* dst, int dstpitch, const GIFRegTE r2.bottom = (maxv + bsym) & ~bsym; } - CRect cr = r1 & r2; + GSVector4i cr = r1.rintersect(r2); bool aligned = ((DWORD_PTR)(dst + (cr.left - r.left) * sizeof(T)) & 0xf) == 0; - if(cr.left >= cr.right && cr.top >= cr.bottom || !aligned) + if(cr.rempty() || !aligned) { // TODO: expand r to block size, read into temp buffer, copy to r (like above) @@ -2469,7 +2424,7 @@ if(!aligned) printf("unaligned memory pointer passed to ReadTexture\n"); for(int x = r.left, i = 0; x < r.right; x++, i++) ((T*)dst)[i] = (T)(this->*rt)(x, y, TEX0, TEXA); - if(!cr.IsRectEmpty()) + if(!cr.rempty()) { (this->*rtx)(cr, dst + (cr.left - r.left) * sizeof(T), dstpitch, TEX0, TEXA); } @@ -2490,14 +2445,14 @@ if(!aligned) printf("unaligned memory pointer passed to ReadTexture\n"); } template -void GSLocalMemory::ReadTextureNC(CRect r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, readTexel rt, readTexture rtx) +void GSLocalMemory::ReadTextureNC(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, readTexel rt, readTexture rtx) { - CSize bs = m_psm[TEX0.PSM].bs; + GSVector2i bs = m_psm[TEX0.PSM].bs; - int bsxm = bs.cx - 1; - int bsym = bs.cy - 1; + int bsxm = bs.x - 1; + int bsym = bs.y - 1; - CRect cr; + GSVector4i cr; cr.left = (r.left + bsxm) & ~bsxm; cr.top = (r.top + bsym) & ~bsym; @@ -2506,7 +2461,7 @@ void GSLocalMemory::ReadTextureNC(CRect r, BYTE* dst, int dstpitch, const GIFReg bool aligned = ((DWORD_PTR)(dst + (cr.left - r.left) * sizeof(T)) & 0xf) == 0; - if(cr.left >= cr.right && cr.top >= cr.bottom || !aligned) + if(cr.rempty() || !aligned) { // TODO: expand r to block size, read into temp buffer, copy to r (like above) @@ -2522,7 +2477,7 @@ if(!aligned) printf("unaligned memory pointer passed to ReadTexture\n"); for(int x = r.left, i = 0; x < r.right; x++, i++) ((T*)dst)[i] = (T)(this->*rt)(x, y, TEX0, TEXA); - if(!cr.IsRectEmpty()) + if(!cr.rempty()) (this->*rtx)(cr, dst + (cr.left - r.left) * sizeof(T), dstpitch, TEX0, TEXA); for(int y = cr.top; y < cr.bottom; y++, dst += dstpitch) @@ -2539,7 +2494,7 @@ if(!aligned) printf("unaligned memory pointer passed to ReadTexture\n"); } } -HRESULT GSLocalMemory::SaveBMP(const string& fn, DWORD bp, DWORD bw, DWORD psm, int w, int h) +HRESULT GSLocalMemory::SaveBMP(const string& fn, uint32 bp, uint32 bw, uint32 psm, int w, int h) { int pitch = w * 4; int size = pitch * h; @@ -2557,15 +2512,15 @@ HRESULT GSLocalMemory::SaveBMP(const string& fn, DWORD bp, DWORD bw, DWORD psm, TEXA.TA0 = 0; TEXA.TA1 = 0x80; - // (this->*m_psm[TEX0.PSM].rtx)(CRect(0, 0, w, h), bits, pitch, TEX0, TEXA); + // (this->*m_psm[TEX0.PSM].rtx)(GSVector4i(0, 0, w, h), bits, pitch, TEX0, TEXA); readPixel rp = m_psm[psm].rp; - BYTE* p = (BYTE*)bits; + uint8* p = (uint8*)bits; for(int j = h-1; j >= 0; j--, p += pitch) for(int i = 0; i < w; i++) - ((DWORD*)p)[i] = (this->*rp)(i, j, TEX0.TBP0, TEX0.TBW); + ((uint32*)p)[i] = (this->*rp)(i, j, TEX0.TBP0, TEX0.TBW); if(FILE* fp = fopen(fn.c_str(), "wb")) { diff --git a/plugins/GSdx/GSLocalMemory.h b/plugins/GSdx/GSLocalMemory.h index fadd7ecee0..4f111289a3 100644 --- a/plugins/GSdx/GSLocalMemory.h +++ b/plugins/GSdx/GSLocalMemory.h @@ -32,19 +32,19 @@ class GSLocalMemory : public GSBlock { public: - typedef DWORD (*pixelAddress)(int x, int y, DWORD bp, DWORD bw); - typedef void (GSLocalMemory::*writePixel)(int x, int y, DWORD c, DWORD bp, DWORD bw); - typedef void (GSLocalMemory::*writeFrame)(int x, int y, DWORD c, DWORD bp, DWORD bw); - typedef DWORD (GSLocalMemory::*readPixel)(int x, int y, DWORD bp, DWORD bw) const; - typedef DWORD (GSLocalMemory::*readTexel)(int x, int y, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; - typedef void (GSLocalMemory::*writePixelAddr)(DWORD addr, DWORD c); - typedef void (GSLocalMemory::*writeFrameAddr)(DWORD addr, DWORD c); - typedef DWORD (GSLocalMemory::*readPixelAddr)(DWORD addr) const; - typedef DWORD (GSLocalMemory::*readTexelAddr)(DWORD addr, const GIFRegTEXA& TEXA) const; - typedef void (GSLocalMemory::*writeImage)(int& tx, int& ty, BYTE* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG); - typedef void (GSLocalMemory::*readImage)(int& tx, int& ty, BYTE* dst, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG) const; - typedef void (GSLocalMemory::*readTexture)(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; - typedef void (GSLocalMemory::*readTextureBlock)(DWORD bp, BYTE* dst, int dstpitch, const GIFRegTEXA& TEXA) const; + typedef uint32 (*pixelAddress)(int x, int y, uint32 bp, uint32 bw); + typedef void (GSLocalMemory::*writePixel)(int x, int y, uint32 c, uint32 bp, uint32 bw); + typedef void (GSLocalMemory::*writeFrame)(int x, int y, uint32 c, uint32 bp, uint32 bw); + typedef uint32 (GSLocalMemory::*readPixel)(int x, int y, uint32 bp, uint32 bw) const; + typedef uint32 (GSLocalMemory::*readTexel)(int x, int y, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; + typedef void (GSLocalMemory::*writePixelAddr)(uint32 addr, uint32 c); + typedef void (GSLocalMemory::*writeFrameAddr)(uint32 addr, uint32 c); + typedef uint32 (GSLocalMemory::*readPixelAddr)(uint32 addr) const; + typedef uint32 (GSLocalMemory::*readTexelAddr)(uint32 addr, const GIFRegTEXA& TEXA) const; + typedef void (GSLocalMemory::*writeImage)(int& tx, int& ty, uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG); + typedef void (GSLocalMemory::*readImage)(int& tx, int& ty, uint8* dst, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG) const; + typedef void (GSLocalMemory::*readTexture)(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; + typedef void (GSLocalMemory::*readTextureBlock)(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const; typedef union { @@ -62,14 +62,14 @@ public: readImage ri; readTexture rtx, rtxNP, rtxP; readTextureBlock rtxb, rtxbP; - WORD bpp, trbpp; - DWORD pal; - CSize bs, pgs; + short bpp, trbpp; + int pal; + GSVector2i bs, pgs; int* rowOffset[8]; int* blockOffset; }; - BYTE dummy[128]; + uint8 dummy[128]; } psm_t; @@ -77,7 +77,7 @@ public: static const int m_vmsize = 1024 * 1024 * 4; - union {BYTE* m_vm8; WORD* m_vm16; DWORD* m_vm32;}; + union {uint8* m_vm8; uint16* m_vm16; uint32* m_vm32;}; GSClut m_clut; @@ -85,7 +85,7 @@ public: { GSVector4i row[2048]; // 0 | 0 | 0 | 0 int* col[4]; // x | x+1 | x+2 | x+3 - DWORD hash; + uint32 hash; }; struct Offset4 @@ -94,18 +94,18 @@ public: GSVector2i row[2048]; // f yn | z yn (n = 0 1 2 ...) GSVector2i col[512]; // f xn | z xn (n = 0 4 8 ...) - DWORD hash; + uint32 hash; }; protected: - static DWORD pageOffset32[32][32][64]; - static DWORD pageOffset32Z[32][32][64]; - static DWORD pageOffset16[32][64][64]; - static DWORD pageOffset16S[32][64][64]; - static DWORD pageOffset16Z[32][64][64]; - static DWORD pageOffset16SZ[32][64][64]; - static DWORD pageOffset8[32][64][128]; - static DWORD pageOffset4[32][128][128]; + static uint32 pageOffset32[32][32][64]; + static uint32 pageOffset32Z[32][32][64]; + static uint32 pageOffset16[32][64][64]; + static uint32 pageOffset16S[32][64][64]; + static uint32 pageOffset16Z[32][64][64]; + static uint32 pageOffset16SZ[32][64][64]; + static uint32 pageOffset8[32][64][128]; + static uint32 pageOffset4[32][128][128]; static int rowOffset32[2048]; static int rowOffset32Z[2048]; @@ -125,12 +125,12 @@ protected: static int blockOffset8[256]; static int blockOffset4[256]; - __forceinline static DWORD Expand24To32(DWORD c, const GIFRegTEXA& TEXA) + __forceinline static uint32 Expand24To32(uint32 c, const GIFRegTEXA& TEXA) { return (((!TEXA.AEM | (c & 0xffffff)) ? TEXA.TA0 : 0) << 24) | (c & 0xffffff); } - __forceinline static DWORD Expand16To32(WORD c, const GIFRegTEXA& TEXA) + __forceinline static uint32 Expand16To32(uint16 c, const GIFRegTEXA& TEXA) { return (((c & 0x8000) ? TEXA.TA1 : (!TEXA.AEM | c) ? TEXA.TA0 : 0) << 24) | ((c & 0x7c00) << 9) | ((c & 0x03e0) << 6) | ((c & 0x001f) << 3); } @@ -141,619 +141,619 @@ protected: // - hash_map m_omap; - hash_map m_o4map; + hash_map m_omap; + hash_map m_o4map; public: GSLocalMemory(); virtual ~GSLocalMemory(); - Offset* GetOffset(DWORD bp, DWORD bw, DWORD psm); + Offset* GetOffset(uint32 bp, uint32 bw, uint32 psm); Offset4* GetOffset4(const GIFRegFRAME& FRAME, const GIFRegZBUF& ZBUF); // address - static DWORD BlockNumber32(int x, int y, DWORD bp, DWORD bw) + static uint32 BlockNumber32(int x, int y, uint32 bp, uint32 bw) { return bp + (y & ~0x1f) * bw + ((x >> 1) & ~0x1f) + blockTable32[(y >> 3) & 3][(x >> 3) & 7]; } - static DWORD BlockNumber16(int x, int y, DWORD bp, DWORD bw) + static uint32 BlockNumber16(int x, int y, uint32 bp, uint32 bw) { return bp + ((y >> 1) & ~0x1f) * bw + ((x >> 1) & ~0x1f) + blockTable16[(y >> 3) & 7][(x >> 4) & 3]; } - static DWORD BlockNumber16S(int x, int y, DWORD bp, DWORD bw) + static uint32 BlockNumber16S(int x, int y, uint32 bp, uint32 bw) { return bp + ((y >> 1) & ~0x1f) * bw + ((x >> 1) & ~0x1f) + blockTable16S[(y >> 3) & 7][(x >> 4) & 3]; } - static DWORD BlockNumber8(int x, int y, DWORD bp, DWORD bw) + static uint32 BlockNumber8(int x, int y, uint32 bp, uint32 bw) { ASSERT((bw & 1) == 0); return bp + ((y >> 1) & ~0x1f) * (bw >> 1) + ((x >> 2) & ~0x1f) + blockTable8[(y >> 4) & 3][(x >> 4) & 7]; } - static DWORD BlockNumber4(int x, int y, DWORD bp, DWORD bw) + static uint32 BlockNumber4(int x, int y, uint32 bp, uint32 bw) { ASSERT((bw & 1) == 0); return bp + ((y >> 2) & ~0x1f) * (bw >> 1) + ((x >> 2) & ~0x1f) + blockTable4[(y >> 4) & 7][(x >> 5) & 3]; } - static DWORD BlockNumber32Z(int x, int y, DWORD bp, DWORD bw) + static uint32 BlockNumber32Z(int x, int y, uint32 bp, uint32 bw) { return bp + (y & ~0x1f) * bw + ((x >> 1) & ~0x1f) + blockTable32Z[(y >> 3) & 3][(x >> 3) & 7]; } - static DWORD BlockNumber16Z(int x, int y, DWORD bp, DWORD bw) + static uint32 BlockNumber16Z(int x, int y, uint32 bp, uint32 bw) { return bp + ((y >> 1) & ~0x1f) * bw + ((x >> 1) & ~0x1f) + blockTable16Z[(y >> 3) & 7][(x >> 4) & 3]; } - static DWORD BlockNumber16SZ(int x, int y, DWORD bp, DWORD bw) + static uint32 BlockNumber16SZ(int x, int y, uint32 bp, uint32 bw) { return bp + ((y >> 1) & ~0x1f) * bw + ((x >> 1) & ~0x1f) + blockTable16SZ[(y >> 3) & 7][(x >> 4) & 3]; } - BYTE* BlockPtr(DWORD bp) const + uint8* BlockPtr(uint32 bp) const { ASSERT(bp < 16384); return &m_vm8[bp << 8]; } - BYTE* BlockPtr32(int x, int y, DWORD bp, DWORD bw) const + uint8* BlockPtr32(int x, int y, uint32 bp, uint32 bw) const { return &m_vm8[BlockNumber32(x, y, bp, bw) << 8]; } - BYTE* BlockPtr16(int x, int y, DWORD bp, DWORD bw) const + uint8* BlockPtr16(int x, int y, uint32 bp, uint32 bw) const { return &m_vm8[BlockNumber16(x, y, bp, bw) << 8]; } - BYTE* BlockPtr16S(int x, int y, DWORD bp, DWORD bw) const + uint8* BlockPtr16S(int x, int y, uint32 bp, uint32 bw) const { return &m_vm8[BlockNumber16S(x, y, bp, bw) << 8]; } - BYTE* BlockPtr8(int x, int y, DWORD bp, DWORD bw) const + uint8* BlockPtr8(int x, int y, uint32 bp, uint32 bw) const { return &m_vm8[BlockNumber8(x, y, bp, bw) << 8]; } - BYTE* BlockPtr4(int x, int y, DWORD bp, DWORD bw) const + uint8* BlockPtr4(int x, int y, uint32 bp, uint32 bw) const { return &m_vm8[BlockNumber4(x, y, bp, bw) << 8]; } - BYTE* BlockPtr32Z(int x, int y, DWORD bp, DWORD bw) const + uint8* BlockPtr32Z(int x, int y, uint32 bp, uint32 bw) const { return &m_vm8[BlockNumber32Z(x, y, bp, bw) << 8]; } - BYTE* BlockPtr16Z(int x, int y, DWORD bp, DWORD bw) const + uint8* BlockPtr16Z(int x, int y, uint32 bp, uint32 bw) const { return &m_vm8[BlockNumber16Z(x, y, bp, bw) << 8]; } - BYTE* BlockPtr16SZ(int x, int y, DWORD bp, DWORD bw) const + uint8* BlockPtr16SZ(int x, int y, uint32 bp, uint32 bw) const { return &m_vm8[BlockNumber16SZ(x, y, bp, bw) << 8]; } - static DWORD PixelAddressOrg32(int x, int y, DWORD bp, DWORD bw) + static uint32 PixelAddressOrg32(int x, int y, uint32 bp, uint32 bw) { return (BlockNumber32(x, y, bp, bw) << 6) + columnTable32[y & 7][x & 7]; } - static DWORD PixelAddressOrg16(int x, int y, DWORD bp, DWORD bw) + static uint32 PixelAddressOrg16(int x, int y, uint32 bp, uint32 bw) { return (BlockNumber16(x, y, bp, bw) << 7) + columnTable16[y & 7][x & 15]; } - static DWORD PixelAddressOrg16S(int x, int y, DWORD bp, DWORD bw) + static uint32 PixelAddressOrg16S(int x, int y, uint32 bp, uint32 bw) { return (BlockNumber16S(x, y, bp, bw) << 7) + columnTable16[y & 7][x & 15]; } - static DWORD PixelAddressOrg8(int x, int y, DWORD bp, DWORD bw) + static uint32 PixelAddressOrg8(int x, int y, uint32 bp, uint32 bw) { return (BlockNumber8(x, y, bp, bw) << 8) + columnTable8[y & 15][x & 15]; } - static DWORD PixelAddressOrg4(int x, int y, DWORD bp, DWORD bw) + static uint32 PixelAddressOrg4(int x, int y, uint32 bp, uint32 bw) { return (BlockNumber4(x, y, bp, bw) << 9) + columnTable4[y & 15][x & 31]; } - static DWORD PixelAddressOrg32Z(int x, int y, DWORD bp, DWORD bw) + static uint32 PixelAddressOrg32Z(int x, int y, uint32 bp, uint32 bw) { return (BlockNumber32Z(x, y, bp, bw) << 6) + columnTable32[y & 7][x & 7]; } - static DWORD PixelAddressOrg16Z(int x, int y, DWORD bp, DWORD bw) + static uint32 PixelAddressOrg16Z(int x, int y, uint32 bp, uint32 bw) { return (BlockNumber16Z(x, y, bp, bw) << 7) + columnTable16[y & 7][x & 15]; } - static DWORD PixelAddressOrg16SZ(int x, int y, DWORD bp, DWORD bw) + static uint32 PixelAddressOrg16SZ(int x, int y, uint32 bp, uint32 bw) { return (BlockNumber16SZ(x, y, bp, bw) << 7) + columnTable16[y & 7][x & 15]; } - static __forceinline DWORD PixelAddress32(int x, int y, DWORD bp, DWORD bw) + static __forceinline uint32 PixelAddress32(int x, int y, uint32 bp, uint32 bw) { - DWORD page = (bp >> 5) + (y >> 5) * bw + (x >> 6); - DWORD word = (page << 11) + pageOffset32[bp & 0x1f][y & 0x1f][x & 0x3f]; + uint32 page = (bp >> 5) + (y >> 5) * bw + (x >> 6); + uint32 word = (page << 11) + pageOffset32[bp & 0x1f][y & 0x1f][x & 0x3f]; return word; } - static __forceinline DWORD PixelAddress16(int x, int y, DWORD bp, DWORD bw) + static __forceinline uint32 PixelAddress16(int x, int y, uint32 bp, uint32 bw) { - DWORD page = (bp >> 5) + (y >> 6) * bw + (x >> 6); - DWORD word = (page << 12) + pageOffset16[bp & 0x1f][y & 0x3f][x & 0x3f]; + uint32 page = (bp >> 5) + (y >> 6) * bw + (x >> 6); + uint32 word = (page << 12) + pageOffset16[bp & 0x1f][y & 0x3f][x & 0x3f]; return word; } - static __forceinline DWORD PixelAddress16S(int x, int y, DWORD bp, DWORD bw) + static __forceinline uint32 PixelAddress16S(int x, int y, uint32 bp, uint32 bw) { - DWORD page = (bp >> 5) + (y >> 6) * bw + (x >> 6); - DWORD word = (page << 12) + pageOffset16S[bp & 0x1f][y & 0x3f][x & 0x3f]; + uint32 page = (bp >> 5) + (y >> 6) * bw + (x >> 6); + uint32 word = (page << 12) + pageOffset16S[bp & 0x1f][y & 0x3f][x & 0x3f]; return word; } - static __forceinline DWORD PixelAddress8(int x, int y, DWORD bp, DWORD bw) + static __forceinline uint32 PixelAddress8(int x, int y, uint32 bp, uint32 bw) { ASSERT((bw & 1) == 0); - DWORD page = (bp >> 5) + (y >> 6) * (bw >> 1) + (x >> 7); - DWORD word = (page << 13) + pageOffset8[bp & 0x1f][y & 0x3f][x & 0x7f]; + uint32 page = (bp >> 5) + (y >> 6) * (bw >> 1) + (x >> 7); + uint32 word = (page << 13) + pageOffset8[bp & 0x1f][y & 0x3f][x & 0x7f]; return word; } - static __forceinline DWORD PixelAddress4(int x, int y, DWORD bp, DWORD bw) + static __forceinline uint32 PixelAddress4(int x, int y, uint32 bp, uint32 bw) { ASSERT((bw & 1) == 0); - DWORD page = (bp >> 5) + (y >> 7) * (bw >> 1) + (x >> 7); - DWORD word = (page << 14) + pageOffset4[bp & 0x1f][y & 0x7f][x & 0x7f]; + uint32 page = (bp >> 5) + (y >> 7) * (bw >> 1) + (x >> 7); + uint32 word = (page << 14) + pageOffset4[bp & 0x1f][y & 0x7f][x & 0x7f]; return word; } - static __forceinline DWORD PixelAddress32Z(int x, int y, DWORD bp, DWORD bw) + static __forceinline uint32 PixelAddress32Z(int x, int y, uint32 bp, uint32 bw) { - DWORD page = (bp >> 5) + (y >> 5) * bw + (x >> 6); - DWORD word = (page << 11) + pageOffset32Z[bp & 0x1f][y & 0x1f][x & 0x3f]; + uint32 page = (bp >> 5) + (y >> 5) * bw + (x >> 6); + uint32 word = (page << 11) + pageOffset32Z[bp & 0x1f][y & 0x1f][x & 0x3f]; return word; } - static __forceinline DWORD PixelAddress16Z(int x, int y, DWORD bp, DWORD bw) + static __forceinline uint32 PixelAddress16Z(int x, int y, uint32 bp, uint32 bw) { - DWORD page = (bp >> 5) + (y >> 6) * bw + (x >> 6); - DWORD word = (page << 12) + pageOffset16Z[bp & 0x1f][y & 0x3f][x & 0x3f]; + uint32 page = (bp >> 5) + (y >> 6) * bw + (x >> 6); + uint32 word = (page << 12) + pageOffset16Z[bp & 0x1f][y & 0x3f][x & 0x3f]; return word; } - static __forceinline DWORD PixelAddress16SZ(int x, int y, DWORD bp, DWORD bw) + static __forceinline uint32 PixelAddress16SZ(int x, int y, uint32 bp, uint32 bw) { - DWORD page = (bp >> 5) + (y >> 6) * bw + (x >> 6); - DWORD word = (page << 12) + pageOffset16SZ[bp & 0x1f][y & 0x3f][x & 0x3f]; + uint32 page = (bp >> 5) + (y >> 6) * bw + (x >> 6); + uint32 word = (page << 12) + pageOffset16SZ[bp & 0x1f][y & 0x3f][x & 0x3f]; return word; } // pixel R/W - __forceinline DWORD ReadPixel32(DWORD addr) const + __forceinline uint32 ReadPixel32(uint32 addr) const { return m_vm32[addr]; } - __forceinline DWORD ReadPixel24(DWORD addr) const + __forceinline uint32 ReadPixel24(uint32 addr) const { return m_vm32[addr] & 0x00ffffff; } - __forceinline DWORD ReadPixel16(DWORD addr) const + __forceinline uint32 ReadPixel16(uint32 addr) const { - return (DWORD)m_vm16[addr]; + return (uint32)m_vm16[addr]; } - __forceinline DWORD ReadPixel8(DWORD addr) const + __forceinline uint32 ReadPixel8(uint32 addr) const { - return (DWORD)m_vm8[addr]; + return (uint32)m_vm8[addr]; } - __forceinline DWORD ReadPixel4(DWORD addr) const + __forceinline uint32 ReadPixel4(uint32 addr) const { return (m_vm8[addr >> 1] >> ((addr & 1) << 2)) & 0x0f; } - __forceinline DWORD ReadPixel8H(DWORD addr) const + __forceinline uint32 ReadPixel8H(uint32 addr) const { return m_vm32[addr] >> 24; } - __forceinline DWORD ReadPixel4HL(DWORD addr) const + __forceinline uint32 ReadPixel4HL(uint32 addr) const { return (m_vm32[addr] >> 24) & 0x0f; } - __forceinline DWORD ReadPixel4HH(DWORD addr) const + __forceinline uint32 ReadPixel4HH(uint32 addr) const { return (m_vm32[addr] >> 28) & 0x0f; } - __forceinline DWORD ReadFrame24(DWORD addr) const + __forceinline uint32 ReadFrame24(uint32 addr) const { return 0x80000000 | (m_vm32[addr] & 0xffffff); } - __forceinline DWORD ReadFrame16(DWORD addr) const + __forceinline uint32 ReadFrame16(uint32 addr) const { - DWORD c = (DWORD)m_vm16[addr]; + uint32 c = (uint32)m_vm16[addr]; return ((c & 0x8000) << 16) | ((c & 0x7c00) << 9) | ((c & 0x03e0) << 6) | ((c & 0x001f) << 3); } - __forceinline DWORD ReadPixel32(int x, int y, DWORD bp, DWORD bw) const + __forceinline uint32 ReadPixel32(int x, int y, uint32 bp, uint32 bw) const { return ReadPixel32(PixelAddress32(x, y, bp, bw)); } - __forceinline DWORD ReadPixel24(int x, int y, DWORD bp, DWORD bw) const + __forceinline uint32 ReadPixel24(int x, int y, uint32 bp, uint32 bw) const { return ReadPixel24(PixelAddress32(x, y, bp, bw)); } - __forceinline DWORD ReadPixel16(int x, int y, DWORD bp, DWORD bw) const + __forceinline uint32 ReadPixel16(int x, int y, uint32 bp, uint32 bw) const { return ReadPixel16(PixelAddress16(x, y, bp, bw)); } - __forceinline DWORD ReadPixel16S(int x, int y, DWORD bp, DWORD bw) const + __forceinline uint32 ReadPixel16S(int x, int y, uint32 bp, uint32 bw) const { return ReadPixel16(PixelAddress16S(x, y, bp, bw)); } - __forceinline DWORD ReadPixel8(int x, int y, DWORD bp, DWORD bw) const + __forceinline uint32 ReadPixel8(int x, int y, uint32 bp, uint32 bw) const { return ReadPixel8(PixelAddress8(x, y, bp, bw)); } - __forceinline DWORD ReadPixel4(int x, int y, DWORD bp, DWORD bw) const + __forceinline uint32 ReadPixel4(int x, int y, uint32 bp, uint32 bw) const { return ReadPixel4(PixelAddress4(x, y, bp, bw)); } - __forceinline DWORD ReadPixel8H(int x, int y, DWORD bp, DWORD bw) const + __forceinline uint32 ReadPixel8H(int x, int y, uint32 bp, uint32 bw) const { return ReadPixel8H(PixelAddress32(x, y, bp, bw)); } - __forceinline DWORD ReadPixel4HL(int x, int y, DWORD bp, DWORD bw) const + __forceinline uint32 ReadPixel4HL(int x, int y, uint32 bp, uint32 bw) const { return ReadPixel4HL(PixelAddress32(x, y, bp, bw)); } - __forceinline DWORD ReadPixel4HH(int x, int y, DWORD bp, DWORD bw) const + __forceinline uint32 ReadPixel4HH(int x, int y, uint32 bp, uint32 bw) const { return ReadPixel4HH(PixelAddress32(x, y, bp, bw)); } - __forceinline DWORD ReadPixel32Z(int x, int y, DWORD bp, DWORD bw) const + __forceinline uint32 ReadPixel32Z(int x, int y, uint32 bp, uint32 bw) const { return ReadPixel32(PixelAddress32Z(x, y, bp, bw)); } - __forceinline DWORD ReadPixel24Z(int x, int y, DWORD bp, DWORD bw) const + __forceinline uint32 ReadPixel24Z(int x, int y, uint32 bp, uint32 bw) const { return ReadPixel24(PixelAddress32Z(x, y, bp, bw)); } - __forceinline DWORD ReadPixel16Z(int x, int y, DWORD bp, DWORD bw) const + __forceinline uint32 ReadPixel16Z(int x, int y, uint32 bp, uint32 bw) const { return ReadPixel16(PixelAddress16Z(x, y, bp, bw)); } - __forceinline DWORD ReadPixel16SZ(int x, int y, DWORD bp, DWORD bw) const + __forceinline uint32 ReadPixel16SZ(int x, int y, uint32 bp, uint32 bw) const { return ReadPixel16(PixelAddress16SZ(x, y, bp, bw)); } - __forceinline DWORD ReadFrame24(int x, int y, DWORD bp, DWORD bw) const + __forceinline uint32 ReadFrame24(int x, int y, uint32 bp, uint32 bw) const { return ReadFrame24(PixelAddress32(x, y, bp, bw)); } - __forceinline DWORD ReadFrame16(int x, int y, DWORD bp, DWORD bw) const + __forceinline uint32 ReadFrame16(int x, int y, uint32 bp, uint32 bw) const { return ReadFrame16(PixelAddress16(x, y, bp, bw)); } - __forceinline DWORD ReadFrame16S(int x, int y, DWORD bp, DWORD bw) const + __forceinline uint32 ReadFrame16S(int x, int y, uint32 bp, uint32 bw) const { return ReadFrame16(PixelAddress16S(x, y, bp, bw)); } - __forceinline DWORD ReadFrame24Z(int x, int y, DWORD bp, DWORD bw) const + __forceinline uint32 ReadFrame24Z(int x, int y, uint32 bp, uint32 bw) const { return ReadFrame24(PixelAddress32Z(x, y, bp, bw)); } - __forceinline DWORD ReadFrame16Z(int x, int y, DWORD bp, DWORD bw) const + __forceinline uint32 ReadFrame16Z(int x, int y, uint32 bp, uint32 bw) const { return ReadFrame16(PixelAddress16Z(x, y, bp, bw)); } - __forceinline DWORD ReadFrame16SZ(int x, int y, DWORD bp, DWORD bw) const + __forceinline uint32 ReadFrame16SZ(int x, int y, uint32 bp, uint32 bw) const { return ReadFrame16(PixelAddress16SZ(x, y, bp, bw)); } - __forceinline void WritePixel32(DWORD addr, DWORD c) + __forceinline void WritePixel32(uint32 addr, uint32 c) { m_vm32[addr] = c; } - __forceinline void WritePixel24(DWORD addr, DWORD c) + __forceinline void WritePixel24(uint32 addr, uint32 c) { m_vm32[addr] = (m_vm32[addr] & 0xff000000) | (c & 0x00ffffff); } - __forceinline void WritePixel16(DWORD addr, DWORD c) + __forceinline void WritePixel16(uint32 addr, uint32 c) { - m_vm16[addr] = (WORD)c; + m_vm16[addr] = (uint16)c; } - __forceinline void WritePixel8(DWORD addr, DWORD c) + __forceinline void WritePixel8(uint32 addr, uint32 c) { - m_vm8[addr] = (BYTE)c; + m_vm8[addr] = (uint8)c; } - __forceinline void WritePixel4(DWORD addr, DWORD c) + __forceinline void WritePixel4(uint32 addr, uint32 c) { int shift = (addr & 1) << 2; addr >>= 1; - m_vm8[addr] = (BYTE)((m_vm8[addr] & (0xf0 >> shift)) | ((c & 0x0f) << shift)); + m_vm8[addr] = (uint8)((m_vm8[addr] & (0xf0 >> shift)) | ((c & 0x0f) << shift)); } - __forceinline void WritePixel8H(DWORD addr, DWORD c) + __forceinline void WritePixel8H(uint32 addr, uint32 c) { m_vm32[addr] = (m_vm32[addr] & 0x00ffffff) | (c << 24); } - __forceinline void WritePixel4HL(DWORD addr, DWORD c) + __forceinline void WritePixel4HL(uint32 addr, uint32 c) { m_vm32[addr] = (m_vm32[addr] & 0xf0ffffff) | ((c & 0x0f) << 24); } - __forceinline void WritePixel4HH(DWORD addr, DWORD c) + __forceinline void WritePixel4HH(uint32 addr, uint32 c) { m_vm32[addr] = (m_vm32[addr] & 0x0fffffff) | ((c & 0x0f) << 28); } - __forceinline void WriteFrame16(DWORD addr, DWORD c) + __forceinline void WriteFrame16(uint32 addr, uint32 c) { - DWORD rb = c & 0x00f800f8; - DWORD ga = c & 0x8000f800; + uint32 rb = c & 0x00f800f8; + uint32 ga = c & 0x8000f800; WritePixel16(addr, (ga >> 16) | (rb >> 9) | (ga >> 6) | (rb >> 3)); } - __forceinline void WritePixel32(int x, int y, DWORD c, DWORD bp, DWORD bw) + __forceinline void WritePixel32(int x, int y, uint32 c, uint32 bp, uint32 bw) { WritePixel32(PixelAddress32(x, y, bp, bw), c); } - __forceinline void WritePixel24(int x, int y, DWORD c, DWORD bp, DWORD bw) + __forceinline void WritePixel24(int x, int y, uint32 c, uint32 bp, uint32 bw) { WritePixel24(PixelAddress32(x, y, bp, bw), c); } - __forceinline void WritePixel16(int x, int y, DWORD c, DWORD bp, DWORD bw) + __forceinline void WritePixel16(int x, int y, uint32 c, uint32 bp, uint32 bw) { WritePixel16(PixelAddress16(x, y, bp, bw), c); } - __forceinline void WritePixel16S(int x, int y, DWORD c, DWORD bp, DWORD bw) + __forceinline void WritePixel16S(int x, int y, uint32 c, uint32 bp, uint32 bw) { WritePixel16(PixelAddress16S(x, y, bp, bw), c); } - __forceinline void WritePixel8(int x, int y, DWORD c, DWORD bp, DWORD bw) + __forceinline void WritePixel8(int x, int y, uint32 c, uint32 bp, uint32 bw) { WritePixel8(PixelAddress8(x, y, bp, bw), c); } - __forceinline void WritePixel4(int x, int y, DWORD c, DWORD bp, DWORD bw) + __forceinline void WritePixel4(int x, int y, uint32 c, uint32 bp, uint32 bw) { WritePixel4(PixelAddress4(x, y, bp, bw), c); } - __forceinline void WritePixel8H(int x, int y, DWORD c, DWORD bp, DWORD bw) + __forceinline void WritePixel8H(int x, int y, uint32 c, uint32 bp, uint32 bw) { WritePixel8H(PixelAddress32(x, y, bp, bw), c); } - __forceinline void WritePixel4HL(int x, int y, DWORD c, DWORD bp, DWORD bw) + __forceinline void WritePixel4HL(int x, int y, uint32 c, uint32 bp, uint32 bw) { WritePixel4HL(PixelAddress32(x, y, bp, bw), c); } - __forceinline void WritePixel4HH(int x, int y, DWORD c, DWORD bp, DWORD bw) + __forceinline void WritePixel4HH(int x, int y, uint32 c, uint32 bp, uint32 bw) { WritePixel4HH(PixelAddress32(x, y, bp, bw), c); } - __forceinline void WritePixel32Z(int x, int y, DWORD c, DWORD bp, DWORD bw) + __forceinline void WritePixel32Z(int x, int y, uint32 c, uint32 bp, uint32 bw) { WritePixel32(PixelAddress32Z(x, y, bp, bw), c); } - __forceinline void WritePixel24Z(int x, int y, DWORD c, DWORD bp, DWORD bw) + __forceinline void WritePixel24Z(int x, int y, uint32 c, uint32 bp, uint32 bw) { WritePixel24(PixelAddress32Z(x, y, bp, bw), c); } - __forceinline void WritePixel16Z(int x, int y, DWORD c, DWORD bp, DWORD bw) + __forceinline void WritePixel16Z(int x, int y, uint32 c, uint32 bp, uint32 bw) { WritePixel16(PixelAddress16Z(x, y, bp, bw), c); } - __forceinline void WritePixel16SZ(int x, int y, DWORD c, DWORD bp, DWORD bw) + __forceinline void WritePixel16SZ(int x, int y, uint32 c, uint32 bp, uint32 bw) { WritePixel16(PixelAddress16SZ(x, y, bp, bw), c); } - __forceinline void WriteFrame16(int x, int y, DWORD c, DWORD bp, DWORD bw) + __forceinline void WriteFrame16(int x, int y, uint32 c, uint32 bp, uint32 bw) { WriteFrame16(PixelAddress16(x, y, bp, bw), c); } - __forceinline void WriteFrame16S(int x, int y, DWORD c, DWORD bp, DWORD bw) + __forceinline void WriteFrame16S(int x, int y, uint32 c, uint32 bp, uint32 bw) { WriteFrame16(PixelAddress16S(x, y, bp, bw), c); } - __forceinline void WriteFrame16Z(int x, int y, DWORD c, DWORD bp, DWORD bw) + __forceinline void WriteFrame16Z(int x, int y, uint32 c, uint32 bp, uint32 bw) { WriteFrame16(PixelAddress16Z(x, y, bp, bw), c); } - __forceinline void WriteFrame16SZ(int x, int y, DWORD c, DWORD bp, DWORD bw) + __forceinline void WriteFrame16SZ(int x, int y, uint32 c, uint32 bp, uint32 bw) { WriteFrame16(PixelAddress16SZ(x, y, bp, bw), c); } - __forceinline DWORD ReadTexel32(DWORD addr, const GIFRegTEXA& TEXA) const + __forceinline uint32 ReadTexel32(uint32 addr, const GIFRegTEXA& TEXA) const { return m_vm32[addr]; } - __forceinline DWORD ReadTexel24(DWORD addr, const GIFRegTEXA& TEXA) const + __forceinline uint32 ReadTexel24(uint32 addr, const GIFRegTEXA& TEXA) const { return Expand24To32(m_vm32[addr], TEXA); } - __forceinline DWORD ReadTexel16(DWORD addr, const GIFRegTEXA& TEXA) const + __forceinline uint32 ReadTexel16(uint32 addr, const GIFRegTEXA& TEXA) const { return Expand16To32(m_vm16[addr], TEXA); } - __forceinline DWORD ReadTexel8(DWORD addr, const GIFRegTEXA& TEXA) const + __forceinline uint32 ReadTexel8(uint32 addr, const GIFRegTEXA& TEXA) const { return m_clut[ReadPixel8(addr)]; } - __forceinline DWORD ReadTexel4(DWORD addr, const GIFRegTEXA& TEXA) const + __forceinline uint32 ReadTexel4(uint32 addr, const GIFRegTEXA& TEXA) const { return m_clut[ReadPixel4(addr)]; } - __forceinline DWORD ReadTexel8H(DWORD addr, const GIFRegTEXA& TEXA) const + __forceinline uint32 ReadTexel8H(uint32 addr, const GIFRegTEXA& TEXA) const { return m_clut[ReadPixel8H(addr)]; } - __forceinline DWORD ReadTexel4HL(DWORD addr, const GIFRegTEXA& TEXA) const + __forceinline uint32 ReadTexel4HL(uint32 addr, const GIFRegTEXA& TEXA) const { return m_clut[ReadPixel4HL(addr)]; } - __forceinline DWORD ReadTexel4HH(DWORD addr, const GIFRegTEXA& TEXA) const + __forceinline uint32 ReadTexel4HH(uint32 addr, const GIFRegTEXA& TEXA) const { return m_clut[ReadPixel4HH(addr)]; } - __forceinline DWORD ReadTexel32(int x, int y, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const + __forceinline uint32 ReadTexel32(int x, int y, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { return ReadTexel32(PixelAddress32(x, y, TEX0.TBP0, TEX0.TBW), TEXA); } - __forceinline DWORD ReadTexel24(int x, int y, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const + __forceinline uint32 ReadTexel24(int x, int y, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { return ReadTexel24(PixelAddress32(x, y, TEX0.TBP0, TEX0.TBW), TEXA); } - __forceinline DWORD ReadTexel16(int x, int y, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const + __forceinline uint32 ReadTexel16(int x, int y, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { return ReadTexel16(PixelAddress16(x, y, TEX0.TBP0, TEX0.TBW), TEXA); } - __forceinline DWORD ReadTexel16S(int x, int y, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const + __forceinline uint32 ReadTexel16S(int x, int y, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { return ReadTexel16(PixelAddress16S(x, y, TEX0.TBP0, TEX0.TBW), TEXA); } - __forceinline DWORD ReadTexel8(int x, int y, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const + __forceinline uint32 ReadTexel8(int x, int y, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { return ReadTexel8(PixelAddress8(x, y, TEX0.TBP0, TEX0.TBW), TEXA); } - __forceinline DWORD ReadTexel4(int x, int y, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const + __forceinline uint32 ReadTexel4(int x, int y, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { return ReadTexel4(PixelAddress4(x, y, TEX0.TBP0, TEX0.TBW), TEXA); } - __forceinline DWORD ReadTexel8H(int x, int y, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const + __forceinline uint32 ReadTexel8H(int x, int y, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { return ReadTexel8H(PixelAddress32(x, y, TEX0.TBP0, TEX0.TBW), TEXA); } - __forceinline DWORD ReadTexel4HL(int x, int y, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const + __forceinline uint32 ReadTexel4HL(int x, int y, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { return ReadTexel4HL(PixelAddress32(x, y, TEX0.TBP0, TEX0.TBW), TEXA); } - __forceinline DWORD ReadTexel4HH(int x, int y, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const + __forceinline uint32 ReadTexel4HH(int x, int y, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { return ReadTexel4HH(PixelAddress32(x, y, TEX0.TBP0, TEX0.TBW), TEXA); } - __forceinline DWORD ReadTexel32Z(int x, int y, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const + __forceinline uint32 ReadTexel32Z(int x, int y, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { return ReadTexel32(PixelAddress32Z(x, y, TEX0.TBP0, TEX0.TBW), TEXA); } - __forceinline DWORD ReadTexel24Z(int x, int y, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const + __forceinline uint32 ReadTexel24Z(int x, int y, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { return ReadTexel24(PixelAddress32Z(x, y, TEX0.TBP0, TEX0.TBW), TEXA); } - __forceinline DWORD ReadTexel16Z(int x, int y, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const + __forceinline uint32 ReadTexel16Z(int x, int y, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { return ReadTexel16(PixelAddress16Z(x, y, TEX0.TBP0, TEX0.TBW), TEXA); } - __forceinline DWORD ReadTexel16SZ(int x, int y, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const + __forceinline uint32 ReadTexel16SZ(int x, int y, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { return ReadTexel16(PixelAddress16SZ(x, y, TEX0.TBP0, TEX0.TBW), TEXA); } - __forceinline DWORD ReadTexel16NP(int x, int y, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const + __forceinline uint32 ReadTexel16NP(int x, int y, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { return ReadPixel16(x, y, TEX0.TBP0, TEX0.TBW); } - __forceinline DWORD ReadTexel16SNP(int x, int y, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const + __forceinline uint32 ReadTexel16SNP(int x, int y, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { return ReadPixel16S(x, y, TEX0.TBP0, TEX0.TBW); } - __forceinline DWORD ReadTexel16ZNP(int x, int y, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const + __forceinline uint32 ReadTexel16ZNP(int x, int y, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { return ReadPixel16Z(x, y, TEX0.TBP0, TEX0.TBW); } - __forceinline DWORD ReadTexel16SZNP(int x, int y, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const + __forceinline uint32 ReadTexel16SZNP(int x, int y, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { return ReadPixel16SZ(x, y, TEX0.TBP0, TEX0.TBW); } // - __forceinline DWORD PixelAddressX(int PSM, int x, int y, DWORD bp, DWORD bw) + __forceinline uint32 PixelAddressX(int PSM, int x, int y, uint32 bp, uint32 bw) { switch(PSM) { @@ -774,7 +774,7 @@ public: } } - __forceinline DWORD ReadPixelX(int PSM, DWORD addr) const + __forceinline uint32 ReadPixelX(int PSM, uint32 addr) const { switch(PSM) { @@ -795,7 +795,7 @@ public: } } - __forceinline DWORD ReadFrameX(int PSM, DWORD addr) const + __forceinline uint32 ReadFrameX(int PSM, uint32 addr) const { switch(PSM) { @@ -811,7 +811,7 @@ public: } } - __forceinline DWORD ReadTexelX(int PSM, DWORD addr, const GIFRegTEXA& TEXA) const + __forceinline uint32 ReadTexelX(int PSM, uint32 addr, const GIFRegTEXA& TEXA) const { switch(PSM) { @@ -832,7 +832,7 @@ public: } } - __forceinline DWORD ReadTexelX(int PSM, int x, int y, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const + __forceinline uint32 ReadTexelX(int PSM, int x, int y, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const { switch(PSM) { @@ -853,7 +853,7 @@ public: } } - __forceinline void WritePixelX(int PSM, DWORD addr, DWORD c) + __forceinline void WritePixelX(int PSM, uint32 addr, uint32 c) { switch(PSM) { @@ -874,7 +874,7 @@ public: } } - __forceinline void WriteFrameX(int PSM, DWORD addr, DWORD c) + __forceinline void WriteFrameX(int PSM, uint32 addr, uint32 c) { switch(PSM) { @@ -892,108 +892,108 @@ public: // FillRect - bool FillRect(const GSVector4i& r, DWORD c, DWORD psm, DWORD bp, DWORD bw); + bool FillRect(const GSVector4i& r, uint32 c, uint32 psm, uint32 bp, uint32 bw); // template - void WriteImageColumn(int l, int r, int y, int h, BYTE* src, int srcpitch, const GIFRegBITBLTBUF& BITBLTBUF); + void WriteImageColumn(int l, int r, int y, int h, uint8* src, int srcpitch, const GIFRegBITBLTBUF& BITBLTBUF); template - void WriteImageBlock(int l, int r, int y, int h, BYTE* src, int srcpitch, const GIFRegBITBLTBUF& BITBLTBUF); + void WriteImageBlock(int l, int r, int y, int h, uint8* src, int srcpitch, const GIFRegBITBLTBUF& BITBLTBUF); template - void WriteImageLeftRight(int l, int r, int y, int h, BYTE* src, int srcpitch, const GIFRegBITBLTBUF& BITBLTBUF); + void WriteImageLeftRight(int l, int r, int y, int h, uint8* src, int srcpitch, const GIFRegBITBLTBUF& BITBLTBUF); template - void WriteImageTopBottom(int l, int r, int y, int h, BYTE* src, int srcpitch, const GIFRegBITBLTBUF& BITBLTBUF); + void WriteImageTopBottom(int l, int r, int y, int h, uint8* src, int srcpitch, const GIFRegBITBLTBUF& BITBLTBUF); template - void WriteImage(int& tx, int& ty, BYTE* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG); + void WriteImage(int& tx, int& ty, uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG); - void WriteImage24(int& tx, int& ty, BYTE* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG); - void WriteImage8H(int& tx, int& ty, BYTE* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG); - void WriteImage4HL(int& tx, int& ty, BYTE* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG); - void WriteImage4HH(int& tx, int& ty, BYTE* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG); - void WriteImage24Z(int& tx, int& ty, BYTE* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG); - void WriteImageX(int& tx, int& ty, BYTE* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG); + void WriteImage24(int& tx, int& ty, uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG); + void WriteImage8H(int& tx, int& ty, uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG); + void WriteImage4HL(int& tx, int& ty, uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG); + void WriteImage4HH(int& tx, int& ty, uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG); + void WriteImage24Z(int& tx, int& ty, uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG); + void WriteImageX(int& tx, int& ty, uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG); // TODO: ReadImage32/24/... - void ReadImageX(int& tx, int& ty, BYTE* dst, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG) const; + void ReadImageX(int& tx, int& ty, uint8* dst, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG) const; // * => 32 - void ReadTexture32(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; - void ReadTexture24(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; - void ReadTexture16(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; - void ReadTexture16S(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; - void ReadTexture8(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; - void ReadTexture4(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; - void ReadTexture8H(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; - void ReadTexture4HL(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; - void ReadTexture4HH(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; - void ReadTexture32Z(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; - void ReadTexture24Z(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; - void ReadTexture16Z(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; - void ReadTexture16SZ(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; + void ReadTexture32(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; + void ReadTexture24(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; + void ReadTexture16(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; + void ReadTexture16S(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; + void ReadTexture8(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; + void ReadTexture4(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; + void ReadTexture8H(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; + void ReadTexture4HL(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; + void ReadTexture4HH(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; + void ReadTexture32Z(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; + void ReadTexture24Z(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; + void ReadTexture16Z(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; + void ReadTexture16SZ(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; - void ReadTexture(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GIFRegCLAMP& CLAMP); - void ReadTextureNC(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GIFRegCLAMP& CLAMP); + void ReadTexture(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GIFRegCLAMP& CLAMP); + void ReadTextureNC(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GIFRegCLAMP& CLAMP); - void ReadTextureBlock32(DWORD bp, BYTE* dst, int dstpitch, const GIFRegTEXA& TEXA) const; - void ReadTextureBlock24(DWORD bp, BYTE* dst, int dstpitch, const GIFRegTEXA& TEXA) const; - void ReadTextureBlock16(DWORD bp, BYTE* dst, int dstpitch, const GIFRegTEXA& TEXA) const; - void ReadTextureBlock16S(DWORD bp, BYTE* dst, int dstpitch, const GIFRegTEXA& TEXA) const; - void ReadTextureBlock8(DWORD bp, BYTE* dst, int dstpitch, const GIFRegTEXA& TEXA) const; - void ReadTextureBlock4(DWORD bp, BYTE* dst, int dstpitch, const GIFRegTEXA& TEXA) const; - void ReadTextureBlock8H(DWORD bp, BYTE* dst, int dstpitch, const GIFRegTEXA& TEXA) const; - void ReadTextureBlock4HL(DWORD bp, BYTE* dst, int dstpitch, const GIFRegTEXA& TEXA) const; - void ReadTextureBlock4HH(DWORD bp, BYTE* dst, int dstpitch, const GIFRegTEXA& TEXA) const; - void ReadTextureBlock32Z(DWORD bp, BYTE* dst, int dstpitch, const GIFRegTEXA& TEXA) const; - void ReadTextureBlock24Z(DWORD bp, BYTE* dst, int dstpitch, const GIFRegTEXA& TEXA) const; - void ReadTextureBlock16Z(DWORD bp, BYTE* dst, int dstpitch, const GIFRegTEXA& TEXA) const; - void ReadTextureBlock16SZ(DWORD bp, BYTE* dst, int dstpitch, const GIFRegTEXA& TEXA) const; + void ReadTextureBlock32(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const; + void ReadTextureBlock24(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const; + void ReadTextureBlock16(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const; + void ReadTextureBlock16S(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const; + void ReadTextureBlock8(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const; + void ReadTextureBlock4(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const; + void ReadTextureBlock8H(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const; + void ReadTextureBlock4HL(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const; + void ReadTextureBlock4HH(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const; + void ReadTextureBlock32Z(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const; + void ReadTextureBlock24Z(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const; + void ReadTextureBlock16Z(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const; + void ReadTextureBlock16SZ(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const; // * => 32/16 - void ReadTexture16NP(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; - void ReadTexture16SNP(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; - void ReadTexture8NP(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; - void ReadTexture4NP(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; - void ReadTexture8HNP(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; - void ReadTexture4HLNP(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; - void ReadTexture4HHNP(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; - void ReadTexture16ZNP(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; - void ReadTexture16SZNP(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; + void ReadTexture16NP(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; + void ReadTexture16SNP(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; + void ReadTexture8NP(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; + void ReadTexture4NP(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; + void ReadTexture8HNP(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; + void ReadTexture4HLNP(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; + void ReadTexture4HHNP(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; + void ReadTexture16ZNP(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; + void ReadTexture16SZNP(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; - void ReadTextureNP(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GIFRegCLAMP& CLAMP); - void ReadTextureNPNC(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GIFRegCLAMP& CLAMP); + void ReadTextureNP(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GIFRegCLAMP& CLAMP); + void ReadTextureNPNC(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GIFRegCLAMP& CLAMP); // pal ? 8 : 32 - void ReadTexture8P(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; - void ReadTexture4P(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; - void ReadTexture8HP(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; - void ReadTexture4HLP(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; - void ReadTexture4HHP(const CRect& r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; + void ReadTexture8P(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; + void ReadTexture4P(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; + void ReadTexture8HP(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; + void ReadTexture4HLP(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; + void ReadTexture4HHP(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA) const; - void ReadTextureBlock8P(DWORD bp, BYTE* dst, int dstpitch, const GIFRegTEXA& TEXA) const; - void ReadTextureBlock4P(DWORD bp, BYTE* dst, int dstpitch, const GIFRegTEXA& TEXA) const; - void ReadTextureBlock8HP(DWORD bp, BYTE* dst, int dstpitch, const GIFRegTEXA& TEXA) const; - void ReadTextureBlock4HLP(DWORD bp, BYTE* dst, int dstpitch, const GIFRegTEXA& TEXA) const; - void ReadTextureBlock4HHP(DWORD bp, BYTE* dst, int dstpitch, const GIFRegTEXA& TEXA) const; + void ReadTextureBlock8P(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const; + void ReadTextureBlock4P(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const; + void ReadTextureBlock8HP(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const; + void ReadTextureBlock4HLP(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const; + void ReadTextureBlock4HHP(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const; // - static DWORD m_xtbl[1024], m_ytbl[1024]; + static uint32 m_xtbl[1024], m_ytbl[1024]; - template void ReadTexture(CRect r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GIFRegCLAMP& CLAMP, readTexel rt, readTexture rtx); - template void ReadTextureNC(CRect r, BYTE* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, readTexel rt, readTexture rtx); + template void ReadTexture(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, const GIFRegCLAMP& CLAMP, readTexel rt, readTexture rtx); + template void ReadTextureNC(const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEX0& TEX0, const GIFRegTEXA& TEXA, readTexel rt, readTexture rtx); // - HRESULT SaveBMP(const string& fn, DWORD bp, DWORD bw, DWORD psm, int w, int h); + HRESULT SaveBMP(const string& fn, uint32 bp, uint32 bw, uint32 psm, int w, int h); }; #pragma warning(default: 4244) \ No newline at end of file diff --git a/plugins/GSdx/GSRasterizer.cpp b/plugins/GSdx/GSRasterizer.cpp index 17795fd9c5..b3d0a640a4 100644 --- a/plugins/GSdx/GSRasterizer.cpp +++ b/plugins/GSdx/GSRasterizer.cpp @@ -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; } // diff --git a/plugins/GSdx/GSRasterizer.h b/plugins/GSdx/GSRasterizer.h index 651899b91a..00a2009baf 100644 --- a/plugins/GSdx/GSRasterizer.h +++ b/plugins/GSdx/GSRasterizer.h @@ -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); diff --git a/plugins/GSdx/GSRenderer.h b/plugins/GSdx/GSRenderer.h index e25a0fe6f4..923b1e2003 100644 --- a/plugins/GSdx/GSRenderer.h +++ b/plugins/GSdx/GSRenderer.h @@ -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 __forceinline Vertex* DrawingKick(bool skip, DWORD& count) + template __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(base, mt, irq, rs, psrr) , m_count(0) , m_maxcount(0) diff --git a/plugins/GSdx/GSRendererHW.h b/plugins/GSdx/GSRendererHW.h index 1fb8a3b597..c19c5de96e 100644 --- a/plugins/GSdx/GSRendererHW.h +++ b/plugins/GSdx/GSRendererHW.h @@ -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(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); diff --git a/plugins/GSdx/GSRendererHW10.cpp b/plugins/GSdx/GSRendererHW10.cpp index 4069eb711c..f334118a9c 100644 --- a/plugins/GSdx/GSRendererHW10.cpp +++ b/plugins/GSdx/GSRendererHW10.cpp @@ -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(base, mt, irq, rs, true) { InitVertexKick(); @@ -70,7 +70,7 @@ bool GSRendererHW10::Create(const string& title) return true; } -template +template 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(skip, count)) { @@ -412,7 +412,7 @@ void GSRendererHW10::Draw(int prim, Texture& rt, Texture& ds, GSTextureCachescissor.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 void VertexKick(bool skip); + template void VertexKick(bool skip); }; \ No newline at end of file diff --git a/plugins/GSdx/GSRendererHW9.cpp b/plugins/GSdx/GSRendererHW9.cpp index 48bff43558..036290eea3 100644 --- a/plugins/GSdx/GSRendererHW9.cpp +++ b/plugins/GSdx/GSRendererHW9.cpp @@ -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(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 +template 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(skip, count)) { @@ -234,7 +234,7 @@ void GSRendererHW9::Draw(int prim, Texture& rt, Texture& ds, GSTextureCacheFRAME.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, GSTextureCachescissor.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 void VertexKick(bool skip); + template void VertexKick(bool skip); }; diff --git a/plugins/GSdx/GSRendererNull.h b/plugins/GSdx/GSRendererNull.h index bb9152443e..a12986c203 100644 --- a/plugins/GSdx/GSRendererNull.h +++ b/plugins/GSdx/GSRendererNull.h @@ -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(base, mt, irq, rs) { InitVertexKick >(); } - template void VertexKick(bool skip) + template void VertexKick(bool skip) { } }; \ No newline at end of file diff --git a/plugins/GSdx/GSRendererSW.h b/plugins/GSdx/GSRendererSW.h index 127e94ecd0..2b70069b02 100644 --- a/plugins/GSdx/GSRendererSW.h +++ b/plugins/GSdx/GSRendererSW.h @@ -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(this, threads); @@ -799,12 +790,12 @@ public: delete m_tc; } - template + template 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(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(); diff --git a/plugins/GSdx/GSScanlineEnvironment.h b/plugins/GSdx/GSScanlineEnvironment.h index d959930197..b7ee1cdb9a 100644 --- a/plugins/GSdx/GSScanlineEnvironment.h +++ b/plugins/GSdx/GSScanlineEnvironment.h @@ -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; diff --git a/plugins/GSdx/GSSettingsDlg.cpp b/plugins/GSdx/GSSettingsDlg.cpp index 133cc864d6..0f3d5577fb 100644 --- a/plugins/GSdx/GSSettingsDlg.cpp +++ b/plugins/GSdx/GSSettingsDlg.cpp @@ -165,13 +165,13 @@ BOOL GSSettingsDlg::OnInitDialog() if(CComPtr 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); diff --git a/plugins/GSdx/GSSetupPrimCodeGenerator.cpp b/plugins/GSdx/GSSetupPrimCodeGenerator.cpp index 4fa97f8ab6..57f204f855 100644 --- a/plugins/GSdx/GSSetupPrimCodeGenerator.cpp +++ b/plugins/GSdx/GSSetupPrimCodeGenerator.cpp @@ -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) { diff --git a/plugins/GSdx/GSSetupPrimCodeGenerator.h b/plugins/GSdx/GSSetupPrimCodeGenerator.h index f12913da7b..af7dd116b8 100644 --- a/plugins/GSdx/GSSetupPrimCodeGenerator.h +++ b/plugins/GSdx/GSSetupPrimCodeGenerator.h @@ -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); }; \ No newline at end of file diff --git a/plugins/GSdx/GSState.cpp b/plugins/GSdx/GSState.cpp index 620f41959b..93721c5236 100644 --- a/plugins/GSdx/GSState.cpp +++ b/plugins/GSdx/GSState.cpp @@ -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(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(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 void GSState::GIFPackedRegHandlerTEX0(GIFPackedReg* r) { - GIFRegHandlerTEX0((GIFReg*)&r->ai64[0]); + GIFRegHandlerTEX0((GIFReg*)&r->u64[0]); } template void GSState::GIFPackedRegHandlerCLAMP(GIFPackedReg* r) { - GIFRegHandlerCLAMP((GIFReg*)&r->ai64[0]); + GIFRegHandlerCLAMP((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 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 void GSState::GIFRegHandlerTEX0(GIFReg* r) template 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 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 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(r); } @@ -622,7 +575,7 @@ template 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 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 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 void GSState::GIFRegHandlerMIPTBP1(GIFReg* r) template 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 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 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 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 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 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 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 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 void GSState::GIFRegHandlerFBA(GIFReg* r) template 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 void GSState::GIFRegHandlerFRAME(GIFReg* r) template 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 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 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 void GSState::Transfer(BYTE* mem, UINT32 size) +template 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 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 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 void GSState::Transfer(BYTE* mem, UINT32 size) { do { - DWORD reg = path.GetReg(); + uint32 reg = path.GetReg(); switch(reg) { @@ -1343,13 +1296,13 @@ template void GSState::Transfer(BYTE* mem, UINT32 size) } } -template static void WriteState(BYTE*& dst, T* src, size_t len = sizeof(T)) +template static void WriteState(uint8*& dst, T* src, size_t len = sizeof(T)) { memcpy(dst, src, len); dst += len; } -template static void ReadState(T* dst, BYTE*& src, size_t len = sizeof(T)) +template 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); diff --git a/plugins/GSdx/GSState.h b/plugins/GSdx/GSState.h index d22a814890..595a8b538f 100644 --- a/plugins/GSdx/GSState.h +++ b/plugins/GSdx/GSState.h @@ -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 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 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); }; diff --git a/plugins/GSdx/GSTables.cpp b/plugins/GSdx/GSTables.cpp index ec0aa149e7..f24b9ec179 100644 --- a/plugins/GSdx/GSTables.cpp +++ b/plugins/GSdx/GSTables.cpp @@ -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 diff --git a/plugins/GSdx/GSTables.h b/plugins/GSdx/GSTables.h index 1ed40beea8..258a22d0e8 100644 --- a/plugins/GSdx/GSTables.h +++ b/plugins/GSdx/GSTables.h @@ -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]; diff --git a/plugins/GSdx/GSTexture.h b/plugins/GSdx/GSTexture.h index 39d8af3a27..6f485905bd 100644 --- a/plugins/GSdx/GSTexture.h +++ b/plugins/GSdx/GSTexture.h @@ -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());} }; diff --git a/plugins/GSdx/GSTexture10.cpp b/plugins/GSdx/GSTexture10.cpp index 4b14de0539..051cbb07fd 100644 --- a/plugins/GSdx/GSTexture10.cpp +++ b/plugins/GSdx/GSTexture10.cpp @@ -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); } } diff --git a/plugins/GSdx/GSTexture10.h b/plugins/GSdx/GSTexture10.h index 3609224696..e01ae272f2 100644 --- a/plugins/GSdx/GSTexture10.h +++ b/plugins/GSdx/GSTexture10.h @@ -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); diff --git a/plugins/GSdx/GSTexture7.cpp b/plugins/GSdx/GSTexture7.cpp index c817e2130d..fd2d2dcbef 100644 --- a/plugins/GSdx/GSTexture7.cpp +++ b/plugins/GSdx/GSTexture7.cpp @@ -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); } } diff --git a/plugins/GSdx/GSTexture7.h b/plugins/GSdx/GSTexture7.h index b2bdc0656a..fafccbd863 100644 --- a/plugins/GSdx/GSTexture7.h +++ b/plugins/GSdx/GSTexture7.h @@ -30,7 +30,6 @@ class GSTexture7 : public GSTexture CComPtr m_system; CComPtr 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); diff --git a/plugins/GSdx/GSTexture9.cpp b/plugins/GSdx/GSTexture9.cpp index b12fc2f684..bbb42e0420 100644 --- a/plugins/GSdx/GSTexture9.cpp +++ b/plugins/GSdx/GSTexture9.cpp @@ -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 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]; } diff --git a/plugins/GSdx/GSTexture9.h b/plugins/GSdx/GSTexture9.h index fe46918e34..dff127d4ac 100644 --- a/plugins/GSdx/GSTexture9.h +++ b/plugins/GSdx/GSTexture9.h @@ -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); diff --git a/plugins/GSdx/GSTextureCache.h b/plugins/GSdx/GSTextureCache.h index 6168bc88a4..d409d54f30 100644 --- a/plugins/GSdx/GSTextureCache.h +++ b/plugins/GSdx/GSTextureCache.h @@ -28,7 +28,7 @@ template class GSTextureCache typedef typename Device::Texture Texture; public: - class GSSurface + class GSSurface : public GSAlignedClass<16> { protected: GSRenderer* 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::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::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 diff --git a/plugins/GSdx/GSTextureCache10.cpp b/plugins/GSdx/GSTextureCache10.cpp index 0ab8210bdc..6a59e815dd 100644 --- a/plugins/GSdx/GSTextureCache10.cpp +++ b/plugins/GSdx/GSTextureCache10.cpp @@ -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); -} diff --git a/plugins/GSdx/GSTextureCache10.h b/plugins/GSdx/GSTextureCache10.h index 48b304325a..7076c62594 100644 --- a/plugins/GSdx/GSTextureCache10.h +++ b/plugins/GSdx/GSTextureCache10.h @@ -34,7 +34,7 @@ class GSTextureCache10 : public GSTextureCache explicit GSRenderTargetHW10(GSRenderer* 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 bool Create(); bool Create(GSRenderTarget* rt); bool Create(GSDepthStencil* ds); - void Update(); }; protected: diff --git a/plugins/GSdx/GSTextureCache9.cpp b/plugins/GSdx/GSTextureCache9.cpp index 52f733b4de..8ae4d90c42 100644 --- a/plugins/GSdx/GSTextureCache9.cpp +++ b/plugins/GSdx/GSTextureCache9.cpp @@ -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); -} diff --git a/plugins/GSdx/GSTextureCache9.h b/plugins/GSdx/GSTextureCache9.h index e0f73ec01a..e7ebef5ea1 100644 --- a/plugins/GSdx/GSTextureCache9.h +++ b/plugins/GSdx/GSTextureCache9.h @@ -34,7 +34,7 @@ class GSTextureCache9 : public GSTextureCache explicit GSRenderTarget9(GSRenderer* 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 bool Create(); bool Create(GSRenderTarget* rt); bool Create(GSDepthStencil* ds); - void Update(); }; protected: diff --git a/plugins/GSdx/GSTextureCacheSW.cpp b/plugins/GSdx/GSTextureCacheSW.cpp index 2aed3b6b64..a9433b9ccb 100644 --- a/plugins/GSdx/GSTextureCacheSW.cpp +++ b/plugins/GSdx/GSTextureCacheSW.cpp @@ -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; } diff --git a/plugins/GSdx/GSTextureCacheSW.h b/plugins/GSdx/GSTextureCacheSW.h index 540cdd6e1b..ea5128c566 100644 --- a/plugins/GSdx/GSTextureCacheSW.h +++ b/plugins/GSdx/GSTextureCacheSW.h @@ -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); }; diff --git a/plugins/GSdx/GSTextureFX10.cpp b/plugins/GSdx/GSTextureFX10.cpp index 80167bcc3a..e81b5f5d77 100644 --- a/plugins/GSdx/GSTextureFX10.cpp +++ b/plugins/GSdx/GSTextureFX10.cpp @@ -163,7 +163,7 @@ bool GSTextureFX10::SetupVS(VSSelector sel, const VSConstantBuffer* cb) { CComPtr vs; - hash_map >::iterator i = m_vs.find(sel); + hash_map >::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 >::iterator i = m_gs.find(sel); + hash_map >::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 ps; - hash_map >::iterator i = m_ps.find(sel); + hash_map >::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 >::iterator i = m_ps_ss.find(ssel); + hash_map >::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 dss; - hash_map >::iterator i = m_om_dss.find(dssel); + hash_map >::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 bs; - hash_map >::iterator j = m_om_bs.find(bsel); + hash_map >::iterator j = m_om_bs.find(bsel); if(j != m_om_bs.end()) { diff --git a/plugins/GSdx/GSTextureFX10.h b/plugins/GSdx/GSTextureFX10.h index 7c554e66c1..2774b721ba 100644 --- a/plugins/GSdx/GSTextureFX10.h +++ b/plugins/GSdx/GSTextureFX10.h @@ -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 m_il; - hash_map > m_vs; + hash_map > m_vs; CComPtr m_vs_cb; - hash_map > m_gs; - hash_map > m_ps; + hash_map > m_gs; + hash_map > m_ps; CComPtr m_ps_cb; - hash_map > m_ps_ss; + hash_map > m_ps_ss; CComPtr m_palette_ss; - hash_map > m_om_dss; - hash_map > m_om_bs; + hash_map > m_om_dss; + hash_map > m_om_bs; CComPtr 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(); diff --git a/plugins/GSdx/GSTextureFX9.cpp b/plugins/GSdx/GSTextureFX9.cpp index c6709d9e1f..e108c6bd6c 100644 --- a/plugins/GSdx/GSTextureFX9.cpp +++ b/plugins/GSdx/GSTextureFX9.cpp @@ -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::iterator i = m_mskfix.find(hash); + hash_map::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 vs; - hash_map >::iterator i = m_vs.find(sel); + hash_map >::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 ps; - hash_map >::iterator i = m_ps.find(sel); + hash_map >::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::iterator i = m_ps_ss.find(ssel); + hash_map::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::iterator i = m_om_dss.find(dssel); + hash_map::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::iterator j = m_om_bs.find(bsel); + hash_map::iterator j = m_om_bs.find(bsel); if(j != m_om_bs.end()) { diff --git a/plugins/GSdx/GSTextureFX9.h b/plugins/GSdx/GSTextureFX9.h index a8c1ab9a3f..6cca7aad7b 100644 --- a/plugins/GSdx/GSTextureFX9.h +++ b/plugins/GSdx/GSTextureFX9.h @@ -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 m_il; - hash_map > m_vs; + hash_map > m_vs; D3DXHANDLE m_vs_params; - hash_map > m_ps; - hash_map m_ps_ss; - hash_map m_om_dss; - hash_map m_om_bs; - hash_map m_mskfix; + hash_map > m_ps; + hash_map m_ps_ss; + hash_map m_om_dss; + hash_map m_om_bs; + hash_map 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); }; diff --git a/plugins/GSdx/GSTextureNull.h b/plugins/GSdx/GSTextureNull.h index 1d6e07868b..cc094240a8 100644 --- a/plugins/GSdx/GSTextureNull.h +++ b/plugins/GSdx/GSTextureNull.h @@ -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;} }; diff --git a/plugins/GSdx/GSThread.cpp b/plugins/GSdx/GSThread.cpp new file mode 100644 index 0000000000..8b64fdce55 --- /dev/null +++ b/plugins/GSdx/GSThread.cpp @@ -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; + } +} + diff --git a/plugins/GSdx/GSThread.h b/plugins/GSdx/GSThread.h new file mode 100644 index 0000000000..79dca94f9e --- /dev/null +++ b/plugins/GSdx/GSThread.h @@ -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(); +}; diff --git a/plugins/GSdx/GSUtil.cpp b/plugins/GSdx/GSUtil.cpp index b6f391ddf3..57b75cf6f2 100644 --- a/plugins/GSdx/GSUtil.cpp +++ b/plugins/GSdx/GSUtil.cpp @@ -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 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::iterator i = sl.begin(); i != sl.end(); ) { diff --git a/plugins/GSdx/GSUtil.h b/plugins/GSdx/GSUtil.h index 2d0eacb569..bd3f580c6b 100644 --- a/plugins/GSdx/GSUtil.h +++ b/plugins/GSdx/GSUtil.h @@ -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) { diff --git a/plugins/GSdx/GSVector.cpp b/plugins/GSdx/GSVector.cpp index 18a2e9fcc1..206fa163b9 100644 --- a/plugins/GSdx/GSVector.cpp +++ b/plugins/GSdx/GSVector.cpp @@ -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; +} diff --git a/plugins/GSdx/GSVector.h b/plugins/GSdx/GSVector.h index 2f413e3a0a..90dce5b963 100644 --- a/plugins/GSdx/GSVector.h +++ b/plugins/GSdx/GSVector.h @@ -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(); } diff --git a/plugins/GSdx/GSVertex.h b/plugins/GSdx/GSVertex.h index bfe77ee796..9caff2d673 100644 --- a/plugins/GSdx/GSVertex.h +++ b/plugins/GSdx/GSVertex.h @@ -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 diff --git a/plugins/GSdx/GSVertexHW.h b/plugins/GSdx/GSVertexHW.h index add5e9eeeb..7afaf65ac4 100644 --- a/plugins/GSdx/GSVertexHW.h +++ b/plugins/GSdx/GSVertexHW.h @@ -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;} }; diff --git a/plugins/GSdx/GSVertexList.h b/plugins/GSdx/GSVertexList.h index c7152a8ff0..c6edc3dc61 100644 --- a/plugins/GSdx/GSVertexList.h +++ b/plugins/GSdx/GSVertexList.h @@ -25,7 +25,7 @@ template 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; } diff --git a/plugins/GSdx/GSVertexSW.cpp b/plugins/GSdx/GSVertexSW.cpp index d037c1611f..43702ed972 100644 --- a/plugins/GSdx/GSVertexSW.cpp +++ b/plugins/GSdx/GSVertexSW.cpp @@ -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; diff --git a/plugins/GSdx/GSVertexSW.h b/plugins/GSdx/GSVertexSW.h index 146aa1531b..8766fc9249 100644 --- a/plugins/GSdx/GSVertexSW.h +++ b/plugins/GSdx/GSVertexSW.h @@ -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 + class GSVertexTraceMap : public GSCodeGeneratorFunctionMap { 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)) { diff --git a/plugins/GSdx/GSdx_vs2008.vcproj b/plugins/GSdx/GSdx_vs2008.vcproj index 8fa577240e..b012278704 100644 --- a/plugins/GSdx/GSdx_vs2008.vcproj +++ b/plugins/GSdx/GSdx_vs2008.vcproj @@ -82,452 +82,6 @@ Name="VCPostBuildEventTool" /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1191,14 +1199,6 @@ AssemblerOutput="4" /> - - - + + @@ -1420,6 +1424,10 @@ RelativePath=".\GSTextureNull.cpp" > + + @@ -1459,62 +1467,6 @@ UsePrecompiledHeader="1" /> - - - - - - - - - - - - - - - - - - - - - @@ -1523,6 +1475,14 @@ UsePrecompiledHeader="1" /> + + + @@ -1531,6 +1491,14 @@ UsePrecompiledHeader="1" /> + + + @@ -1539,6 +1507,14 @@ UsePrecompiledHeader="1" /> + + + @@ -1547,6 +1523,14 @@ UsePrecompiledHeader="1" /> + + + @@ -1555,6 +1539,14 @@ UsePrecompiledHeader="1" /> + + + @@ -1563,6 +1555,14 @@ UsePrecompiledHeader="1" /> + + + @@ -1571,6 +1571,14 @@ UsePrecompiledHeader="1" /> + + + @@ -1730,6 +1738,10 @@ RelativePath=".\GSRasterizer.h" > + + @@ -1822,6 +1834,10 @@ RelativePath=".\GSTextureNull.h" > + + @@ -1850,10 +1866,6 @@ RelativePath=".\GSWnd.h" > - - @@ -1947,62 +1959,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -2011,6 +1967,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2019,6 +1983,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2027,6 +1999,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2035,6 +2015,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2043,6 +2031,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2051,6 +2047,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2059,6 +2063,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2083,62 +2095,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -2147,6 +2103,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2155,6 +2119,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2163,6 +2135,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2171,6 +2151,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2179,6 +2167,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2187,6 +2183,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2195,6 +2199,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2219,62 +2231,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -2283,6 +2239,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2291,6 +2255,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2299,6 +2271,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2307,6 +2287,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2315,6 +2303,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2323,6 +2319,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2331,6 +2335,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2355,62 +2367,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -2419,6 +2375,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2427,6 +2391,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2435,6 +2407,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2443,6 +2423,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2451,6 +2439,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2459,6 +2455,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2467,6 +2471,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2491,62 +2503,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -2555,6 +2511,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2563,6 +2527,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2571,6 +2543,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2579,6 +2559,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2587,6 +2575,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2595,6 +2591,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2603,6 +2607,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2627,62 +2639,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -2691,6 +2647,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2699,6 +2663,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2707,6 +2679,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2715,6 +2695,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2723,6 +2711,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2731,6 +2727,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2739,6 +2743,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2779,62 +2791,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -2843,6 +2799,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2851,6 +2815,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2859,6 +2831,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2867,6 +2847,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2875,6 +2863,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2883,6 +2879,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2891,6 +2895,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2915,62 +2927,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -2979,6 +2935,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2987,6 +2951,14 @@ UsePrecompiledHeader="0" /> + + + @@ -2995,6 +2967,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3003,6 +2983,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3011,6 +2999,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3019,6 +3015,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3027,6 +3031,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3051,62 +3063,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -3115,6 +3071,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3123,6 +3087,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3131,6 +3103,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3139,6 +3119,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3147,6 +3135,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3155,6 +3151,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3163,6 +3167,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3187,62 +3199,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -3251,6 +3207,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3259,6 +3223,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3267,6 +3239,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3275,6 +3255,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3283,6 +3271,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3291,6 +3287,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3299,6 +3303,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3323,62 +3335,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -3387,6 +3343,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3395,6 +3359,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3403,6 +3375,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3411,6 +3391,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3419,6 +3407,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3427,6 +3423,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3435,6 +3439,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3463,62 +3475,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -3527,6 +3483,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3535,6 +3499,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3543,6 +3515,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3551,6 +3531,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3559,6 +3547,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3567,6 +3563,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3575,6 +3579,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3599,62 +3611,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -3663,6 +3619,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3671,6 +3635,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3679,6 +3651,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3687,6 +3667,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3695,6 +3683,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3703,6 +3699,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3711,6 +3715,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3735,62 +3747,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -3799,6 +3755,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3807,6 +3771,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3815,6 +3787,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3823,6 +3803,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3831,6 +3819,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3839,6 +3835,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3847,6 +3851,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3871,62 +3883,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -3935,6 +3891,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3943,6 +3907,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3951,6 +3923,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3959,6 +3939,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3967,6 +3955,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3975,6 +3971,14 @@ UsePrecompiledHeader="0" /> + + + @@ -3983,6 +3987,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4011,62 +4023,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -4075,6 +4031,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4083,6 +4047,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4091,6 +4063,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4099,6 +4079,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4107,6 +4095,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4115,6 +4111,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4123,6 +4127,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4147,62 +4159,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -4211,6 +4167,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4219,6 +4183,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4227,6 +4199,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4235,6 +4215,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4243,6 +4231,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4251,6 +4247,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4259,6 +4263,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4283,62 +4295,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -4347,6 +4303,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4355,6 +4319,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4363,6 +4335,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4371,6 +4351,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4379,6 +4367,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4387,6 +4383,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4395,6 +4399,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4419,62 +4431,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -4483,6 +4439,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4491,6 +4455,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4499,6 +4471,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4507,6 +4487,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4515,6 +4503,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4523,6 +4519,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4531,6 +4535,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4555,62 +4567,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -4619,6 +4575,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4627,6 +4591,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4635,6 +4607,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4643,6 +4623,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4651,6 +4639,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4659,6 +4655,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4667,6 +4671,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4691,62 +4703,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -4755,6 +4711,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4763,6 +4727,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4771,6 +4743,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4779,6 +4759,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4787,6 +4775,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4795,6 +4791,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4803,6 +4807,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4827,62 +4839,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -4891,6 +4847,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4899,6 +4863,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4907,6 +4879,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4915,6 +4895,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4923,6 +4911,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4931,6 +4927,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4939,6 +4943,14 @@ UsePrecompiledHeader="0" /> + + + @@ -4963,62 +4975,6 @@ UsePrecompiledHeader="0" /> - - - - - - - - - - - - - - - - - - - - - @@ -5027,6 +4983,14 @@ UsePrecompiledHeader="0" /> + + + @@ -5035,6 +4999,14 @@ UsePrecompiledHeader="0" /> + + + @@ -5043,6 +5015,14 @@ UsePrecompiledHeader="0" /> + + + @@ -5051,6 +5031,14 @@ UsePrecompiledHeader="0" /> + + + @@ -5059,6 +5047,14 @@ UsePrecompiledHeader="0" /> + + + @@ -5067,6 +5063,14 @@ UsePrecompiledHeader="0" /> + + + @@ -5075,6 +5079,14 @@ UsePrecompiledHeader="0" /> + + + diff --git a/plugins/GSdx/sse.h b/plugins/GSdx/sse.h deleted file mode 100644 index d1b35dd2d7..0000000000 --- a/plugins/GSdx/sse.h +++ /dev/null @@ -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 - #include - - #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 - -#endif - -// sse4 - -#if _M_SSE >= 0x401 - - #include - -#endif diff --git a/plugins/GSdx/stdafx.h b/plugins/GSdx/stdafx.h index 8b3acecd95..5d2b8eae29 100644 --- a/plugins/GSdx/stdafx.h +++ b/plugins/GSdx/stdafx.h @@ -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 // MFC support for Windows Common Controls #endif // _AFX_NO_AFXCMN_SUPPORT //#include -#include -#include -#include -#include -#include + +// stdc + #include #include @@ -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 +#include +#include +#include +#include + +#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 + #include + + #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 + +#endif + +#if _M_SSE >= 0x401 + + #include + +#endif -#define QI(i) (riid == __uuidof(i)) ? GetInterface((i*)this, ppv) : diff --git a/plugins/GSdx/xbyak/xbyak.h b/plugins/GSdx/xbyak/xbyak.h index 6282d9b4bd..564cca6262 100644 --- a/plugins/GSdx/xbyak/xbyak.h +++ b/plugins/GSdx/xbyak/xbyak.h @@ -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,