zzogl-pg: Convert the helper function into arrays. Use them in other places as well.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3510 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2010-07-17 06:10:39 +00:00
parent 1a3373a9a4
commit ecad8b7a4f
3 changed files with 81 additions and 349 deletions

View File

@ -27,7 +27,6 @@
#include "zerogs.h"
#include "targets.h"
namespace ZeroGS
{
extern CRangeManager s_RangeMngr; // manages overwritten memory
@ -249,8 +248,10 @@
}
template <class T>
void TransferLocalHost(void* pbyMem, u32 nQWordSize, int& x, int& y, u8 *pstart, _readPixel_0 rp)
void TransferLocalHost(void* pbyMem, u32 nQWordSize, int& x, int& y, u8 *pstart)
{
_readPixel_0 rp = readPixelFun_0[gs.srcbuf.psm];
int i = x, j = y;
T* pbuf = (T*)pbyMem;
u32 nSize = nQWordSize * 16 / sizeof(T);
@ -275,8 +276,10 @@
}
}
void TransferLocalHost_24(void* pbyMem, u32 nQWordSize, int& x, int& y, u8 *pstart, _readPixel_0 rp)
void TransferLocalHost_24(void* pbyMem, u32 nQWordSize, int& x, int& y, u8 *pstart)
{
_readPixel_0 rp = readPixelFun_0[gs.srcbuf.psm];
int i = x, j = y;
u8* pbuf = (u8*)pbyMem;
u32 nSize = nQWordSize * 16 / 3;
@ -312,153 +315,28 @@
assert(gs.imageTransfer == 1);
u8* pstart = g_pbyGSMemory + 256 * gs.srcbuf.bp;
int i = gs.imageY, j = gs.imageX;
switch (gs.srcbuf.psm)
switch(PSMT_BITMODE(gs.srcbuf.psm))
{
case PSMCT32:
TransferLocalHost<u32>(pbyMem, nQWordSize, i, j, pstart, readPixel32_0);
break;
case PSMCT24:
TransferLocalHost_24(pbyMem, nQWordSize, i, j, pstart, readPixel24_0);
break;
case PSMCT16:
TransferLocalHost<u16>(pbyMem, nQWordSize, i, j, pstart, readPixel16_0);
break;
case PSMCT16S:
TransferLocalHost<u16>(pbyMem, nQWordSize, i, j, pstart, readPixel16S_0);
break;
case PSMT8:
TransferLocalHost<u8>(pbyMem, nQWordSize, i, j, pstart, readPixel8_0);
break;
case PSMT8H:
TransferLocalHost<u8>(pbyMem, nQWordSize, i, j, pstart, readPixel8H_0);
break;
case PSMT32Z:
TransferLocalHost<u32>(pbyMem, nQWordSize, i, j, pstart, readPixel32Z_0);
break;
case PSMT24Z:
TransferLocalHost_24(pbyMem, nQWordSize, i, j, pstart, readPixel24Z_0);
break;
case PSMT16Z:
TransferLocalHost<u16>(pbyMem, nQWordSize, i, j, pstart, readPixel16Z_0);
break;
case PSMT16SZ:
TransferLocalHost<u16>(pbyMem, nQWordSize, i, j, pstart, readPixel16SZ_0);
break;
default:
assert(0);
case 0: TransferLocalHost<u32>(pbyMem, nQWordSize, gs.imageY, gs.imageX, pstart); break;
case 1: TransferLocalHost_24(pbyMem, nQWordSize, gs.imageY, gs.imageX, pstart); break;
case 2: TransferLocalHost<u16>(pbyMem, nQWordSize, gs.imageY, gs.imageX, pstart); break;
case 3: TransferLocalHost<u8>(pbyMem, nQWordSize, gs.imageY, gs.imageX, pstart); break;
default: assert(0); break;
}
gs.imageY = i;
gs.imageX = j;
if (gs.imageY >= gs.imageEndY)
{
assert(gs.imageY == gs.imageEndY);
gs.imageTransfer = -1;
}
}
/*__forceinline void _TransferLocalLocal(_writePixel_0 wp, _readPixel_0 rp, u32 widthlimit)
{
u8* pSrcBuf = g_pbyGSMemory + gs.srcbuf.bp * 256;
u8* pDstBuf = g_pbyGSMemory + gs.dstbuf.bp * 256;
if ((gs.imageWnew & widthlimit) != 0) return;
assert(widthlimit <= 4);
for(int i = gs.trxpos.sy, i2 = gs.trxpos.dy; i < gs.trxpos.sy+gs.imageHnew; i++, i2++)
{
for(int j = gs.trxpos.sx, j2 = gs.trxpos.dx; j < gs.trxpos.sx+gs.imageWnew; j+=widthlimit, j2+=widthlimit)
{
wp(pDstBuf, j2%2048, i2%2048,
rp(pSrcBuf, j%2048, i%2048, gs.srcbuf.bw), gs.dstbuf.bw);
if (widthlimit > 1)
{
wp(pDstBuf, (j2+1)%2048, i2%2048,
rp(pSrcBuf, (j+1)%2048, i%2048, gs.srcbuf.bw), gs.dstbuf.bw);
if (widthlimit > 2)
{
wp(pDstBuf, (j2+2)%2048, i2%2048,
rp(pSrcBuf, (j+2)%2048, i%2048, gs.srcbuf.bw), gs.dstbuf.bw);
if (widthlimit > 3)
{
wp(pDstBuf, (j2+3)%2048, i2%2048,
rp(pSrcBuf, (j+3)%2048, i%2048, gs.srcbuf.bw), gs.dstbuf.bw);
}
}
}
}
}
}
__forceinline void _TransferLocalLocal_4(_getPixelAddress_0 gsp, _getPixelAddress_0 gdp)
{
u8* pSrcBuf = g_pbyGSMemory + gs.srcbuf.bp * 256;
u8* pDstBuf = g_pbyGSMemory + gs.dstbuf.bp * 256;
assert((gs.imageWnew % 8) == 0);
for(int i = gs.trxpos.sy, i2 = gs.trxpos.dy; i < gs.trxpos.sy + gs.imageHnew; ++i, ++i2)
{
for(int j = gs.trxpos.sx, j2 = gs.trxpos.dx; j < gs.trxpos.sx + gs.imageWnew; j += 8, j2 += 8)
{
// NOTE: the 2 conseq 4bit values are in NOT in the same byte
u32 read = gsp(j%2048, i%2048, gs.srcbuf.bw);
u32 write = gdp(j2%2048, i2%2048, gs.dstbuf.bw);
pDstBuf[write] = (pDstBuf[write]&0xf0)|(pSrcBuf[read]&0x0f);
read = gsp((j+1)%2048, i%2048, gs.srcbuf.bw);
write = gdp((j2+1)%2048, i2%2048, gs.dstbuf.bw);
pDstBuf[write] = (pDstBuf[write]&0x0f)|(pSrcBuf[read]&0xf0);
read = gsp((j+2)%2048, i%2048, gs.srcbuf.bw);
write = gdp((j2+2)%2048, i2%2048, gs.dstbuf.bw);
pDstBuf[write] = (pDstBuf[write]&0xf0)|(pSrcBuf[read]&0x0f);
read = gsp((j+3)%2048, i%2048, gs.srcbuf.bw);
write = gdp((j2+3)%2048, i2%2048, gs.dstbuf.bw);
pDstBuf[write] = (pDstBuf[write]&0x0f)|(pSrcBuf[read]&0xf0);
read = gsp((j+2)%2048, i%2048, gs.srcbuf.bw);
write = gdp((j2+2)%2048, i2%2048, gs.dstbuf.bw);
pDstBuf[write] = (pDstBuf[write]&0xf0)|(pSrcBuf[read]&0x0f);
read = gsp((j+3)%2048, i%2048, gs.srcbuf.bw);
write = gdp((j2+3)%2048, i2%2048, gs.dstbuf.bw);
pDstBuf[write] = (pDstBuf[write]&0x0f)|(pSrcBuf[read]&0xf0);
read = gsp((j+2)%2048, i%2048, gs.srcbuf.bw);
write = gdp((j2+2)%2048, i2%2048, gs.dstbuf.bw);
pDstBuf[write] = (pDstBuf[write]&0xf0)|(pSrcBuf[read]&0x0f);
read = gsp((j+3)%2048, i%2048, gs.srcbuf.bw);
write = gdp((j2+3)%2048, i2%2048, gs.dstbuf.bw);
pDstBuf[write] = (pDstBuf[write]&0x0f)|(pSrcBuf[read]&0xf0);
}
}
}*/
__forceinline void _TransferLocalLocal()
{
//ZZLog::Error_Log("TransferLocalLocal(0x%x, 0x%x)", gs.srcbuf.psm, gs.dstbuf.psm);
_writePixel_0 wp = writePixelFunction_0(gs.srcbuf.psm);
_readPixel_0 rp = readPixelFunction_0(gs.dstbuf.psm);
_writePixel_0 wp = writePixelFun_0[gs.srcbuf.psm]; //writePixelFunction_0(gs.srcbuf.psm);
_readPixel_0 rp = readPixelFun_0[gs.dstbuf.psm]; //readPixelFunction_0(gs.dstbuf.psm);
u8* pSrcBuf = g_pbyGSMemory + gs.srcbuf.bp * 256;
u8* pDstBuf = g_pbyGSMemory + gs.dstbuf.bp * 256;
u32 widthlimit = 4;
@ -497,8 +375,8 @@ __forceinline void _TransferLocalLocal()
__forceinline void _TransferLocalLocal_4()
{
//ZZLog::Error_Log("TransferLocalLocal_4(0x%x, 0x%x)", gs.srcbuf.psm, gs.dstbuf.psm);
_getPixelAddress_0 gsp = getPixelFunction_0(gs.srcbuf.psm);
_getPixelAddress_0 gdp = getPixelFunction_0(gs.dstbuf.psm);
_getPixelAddress_0 gsp = getPixelFun_0[gs.srcbuf.psm]; //getPixelFunction_0(gs.srcbuf.psm);
_getPixelAddress_0 gdp = getPixelFun_0[gs.dstbuf.psm]; //getPixelFunction_0(gs.dstbuf.psm);
u8* pSrcBuf = g_pbyGSMemory + gs.srcbuf.bp * 256;
u8* pDstBuf = g_pbyGSMemory + gs.dstbuf.bp * 256;
@ -590,210 +468,6 @@ __forceinline void _TransferLocalLocal_4()
{
_TransferLocalLocal_4();
}
/*switch (gs.srcbuf.psm)
{
case PSMCT32:
if (gs.dstbuf.psm == PSMCT32)
{
_TransferLocalLocal(writePixel32_0, readPixel32_0, 2);
}
else
{
_TransferLocalLocal(writePixel32_0, readPixel32Z_0, 2);
}
break;
case PSMCT24:
if (gs.dstbuf.psm == PSMCT24)
{
_TransferLocalLocal(writePixel24_0, readPixel24_0, 4);
}
else
{
_TransferLocalLocal(writePixel24_0, readPixel24Z_0, 4);
}
break;
case PSMCT16:
switch (gs.dstbuf.psm)
{
case PSMCT16:
_TransferLocalLocal(writePixel16_0, readPixel16_0, 4);
break;
case PSMCT16S:
_TransferLocalLocal(writePixel16_0, readPixel16S_0, 4);
break;
case PSMT16Z:
_TransferLocalLocal(writePixel16_0, readPixel16Z_0, 4);
break;
case PSMT16SZ:
_TransferLocalLocal(writePixel16_0, readPixel16SZ_0, 4);
break;
}
break;
case PSMCT16S:
switch (gs.dstbuf.psm)
{
case PSMCT16:
_TransferLocalLocal(writePixel16S_0, readPixel16_0, 4);
break;
case PSMCT16S:
_TransferLocalLocal(writePixel16S_0, readPixel16S_0, 4);
break;
case PSMT16Z:
_TransferLocalLocal(writePixel16S_0, readPixel16Z_0, 4);
break;
case PSMT16SZ:
_TransferLocalLocal(writePixel16S_0, readPixel16SZ_0, 4);
break;
}
break;
case PSMT8:
if (gs.dstbuf.psm == PSMT8)
{
_TransferLocalLocal(writePixel8_0, readPixel8_0, 4);
}
else
{
_TransferLocalLocal(writePixel8_0, readPixel8H_0, 4);
}
break;
case PSMT4:
switch (gs.dstbuf.psm)
{
case PSMT4:
_TransferLocalLocal_4(getPixelAddress4_0, getPixelAddress4_0);
break;
case PSMT4HL:
_TransferLocalLocal_4(getPixelAddress4_0, getPixelAddress4HL_0);
break;
case PSMT4HH:
_TransferLocalLocal_4(getPixelAddress4_0, getPixelAddress4HH_0);
break;
}
break;
case PSMT8H:
if (gs.dstbuf.psm == PSMT8)
{
_TransferLocalLocal(writePixel8H_0, readPixel8_0, 4);
}
else
{
_TransferLocalLocal(writePixel8H_0, readPixel8H_0, 4);
}
break;
case PSMT4HL:
switch (gs.dstbuf.psm)
{
case PSMT4:
_TransferLocalLocal_4(getPixelAddress4HL_0, getPixelAddress4_0);
break;
case PSMT4HL:
_TransferLocalLocal_4(getPixelAddress4HL_0, getPixelAddress4HL_0);
break;
case PSMT4HH:
_TransferLocalLocal_4(getPixelAddress4HL_0, getPixelAddress4HH_0);
break;
}
break;
case PSMT4HH:
switch (gs.dstbuf.psm)
{
case PSMT4:
_TransferLocalLocal_4(getPixelAddress4HH_0, getPixelAddress4_0);
break;
case PSMT4HL:
_TransferLocalLocal_4(getPixelAddress4HH_0, getPixelAddress4HL_0);
break;
case PSMT4HH:
_TransferLocalLocal_4(getPixelAddress4HH_0, getPixelAddress4HH_0);
break;
}
break;
case PSMT32Z:
if (gs.dstbuf.psm == PSMCT32)
{
_TransferLocalLocal(writePixel32Z_0, readPixel32_0, 2);
}
else
{
_TransferLocalLocal(writePixel32Z_0, readPixel32Z_0, 2);
}
break;
case PSMT24Z:
if (gs.dstbuf.psm == PSMCT24)
{
_TransferLocalLocal(writePixel24Z_0, readPixel24_0, 4);
}
else
{
_TransferLocalLocal(writePixel24Z_0, readPixel24Z_0, 4);
}
break;
case PSMT16Z:
switch (gs.dstbuf.psm)
{
case PSMCT16:
_TransferLocalLocal(writePixel16Z_0, readPixel16_0, 4);
break;
case PSMCT16S:
_TransferLocalLocal(writePixel16Z_0, readPixel16S_0, 4);
break;
case PSMT16Z:
_TransferLocalLocal(writePixel16Z_0, readPixel16Z_0, 4);
break;
case PSMT16SZ:
_TransferLocalLocal(writePixel16Z_0, readPixel16SZ_0, 4);
break;
}
break;
case PSMT16SZ:
switch (gs.dstbuf.psm)
{
case PSMCT16:
_TransferLocalLocal(writePixel16SZ_0, readPixel16_0, 4);
break;
case PSMCT16S:
_TransferLocalLocal(writePixel16SZ_0, readPixel16S_0, 4);
break;
case PSMT16Z:
_TransferLocalLocal(writePixel16SZ_0, readPixel16Z_0, 4);
break;
case PSMT16SZ:
_TransferLocalLocal(writePixel16SZ_0, readPixel16SZ_0, 4);
break;
}
break;
}*/
g_MemTargs.ClearRange(dststart, dstend);

View File

@ -44,6 +44,10 @@ typedef int (*_TransferHostLocal)(const void* pbyMem, u32 nQWordSize);
typedef void (*_TransferLocalHost)(void* pbyMem, u32 nQWordSize);
typedef void (*_SwizzleBlock)(u8 *dst, u8 *src, int pitch, u32 WriteMask);
extern _getPixelAddress_0 getPixelFun_0[64];
extern _writePixel_0 writePixelFun_0[64];
extern _readPixel_0 readPixelFun_0[64];
enum Psm_Size
{
PSM_ = 0,
@ -268,7 +272,8 @@ static __forceinline u32 getPixelAddress16SZ_0(int x, int y, u32 bw)
static __forceinline _getPixelAddress_0 getPixelFunction_0(u32 psm)
{
switch(psm)
return getPixelFun_0[psm];
/*switch(psm)
{
case PSMCT32: return getPixelAddress32_0;
case PSMCT24: return getPixelAddress24_0;
@ -284,7 +289,7 @@ static __forceinline _getPixelAddress_0 getPixelFunction_0(u32 psm)
case PSMT16Z: return getPixelAddress16Z_0;
case PSMT16SZ: return getPixelAddress16SZ_0;
default: return getPixelAddress32_0;
}
}*/
}
#define getPixelAddress_0(psm,x,y,bw) getPixelAddress##psm##_0(x,y,bw)
@ -532,9 +537,11 @@ static __forceinline void writePixel16SZ_0(void* pmem, int x, int y, u32 pixel,
((u16*)pmem)[getPixelAddress16SZ_0(x, y, bw)] = pixel;
}
static __forceinline _writePixel_0 writePixelFunction_0(u32 psm)
{
switch(psm)
return writePixelFun_0[psm];
/*switch(psm)
{
case PSMCT32: return writePixel32_0;
case PSMCT24: return writePixel24_0;
@ -550,7 +557,7 @@ static __forceinline _writePixel_0 writePixelFunction_0(u32 psm)
case PSMT16Z: return writePixel16Z_0;
case PSMT16SZ: return writePixel16SZ_0;
default: return writePixel32_0;
}
}*/
}
///////////////
@ -632,7 +639,8 @@ static __forceinline u32 readPixel16SZ_0(const void* pmem, int x, int y, u32 bw)
static __forceinline _readPixel_0 readPixelFunction_0(u32 psm)
{
switch(psm)
return readPixelFun_0[psm];
/*switch(psm)
{
case PSMCT32: return readPixel32_0;
case PSMCT24: return readPixel24_0;
@ -648,6 +656,6 @@ static __forceinline _readPixel_0 readPixelFunction_0(u32 psm)
case PSMT16Z: return readPixel16Z_0;
case PSMT16SZ: return readPixel16SZ_0;
default: return readPixel32_0;
}
}*/
}
#endif /* __MEM_H__ */

View File

@ -18,6 +18,7 @@
*/
#include "GS.h"
#include "Mem.h"
u32 g_blockTable32[4][8] =
{
@ -247,3 +248,52 @@ u32 g_pageTable16Z[64][64];
u32 g_pageTable16SZ[64][64];
u32 g_pageTable8[64][128];
u32 g_pageTable4[128][128];
/* PSM reference array
{ 32, 24, 16, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, 16S, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, 8, 4, NULL, NULL, NULL,
NULL, NULL, NULL, 8H, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, 4HL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, 4HH, NULL, NULL, NULL,
32Z, 24Z, 16Z, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, 16SZ, NULL, NULL, NULL, NULL, NULL };
*/
_getPixelAddress_0 getPixelFun_0[64] =
{
getPixelAddress32_0, getPixelAddress24_0, getPixelAddress16_0, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, getPixelAddress16S_0, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, getPixelAddress8_0, getPixelAddress4_0, NULL, NULL, NULL,
NULL, NULL, NULL, getPixelAddress8H_0, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, getPixelAddress4HL_0, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, getPixelAddress4HH_0, NULL, NULL, NULL,
getPixelAddress32Z_0, getPixelAddress24Z_0, getPixelAddress16Z_0, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, getPixelAddress16SZ_0, NULL, NULL, NULL, NULL, NULL
};
_writePixel_0 writePixelFun_0[64] =
{
writePixel32_0, writePixel24_0, writePixel16_0, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, writePixel16S_0, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, writePixel8_0, writePixel4_0, NULL, NULL, NULL,
NULL, NULL, NULL, writePixel8H_0, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, writePixel4HL_0, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, writePixel4HH_0, NULL, NULL, NULL,
writePixel32Z_0, writePixel24Z_0, writePixel16Z_0, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, writePixel16SZ_0, NULL, NULL, NULL, NULL, NULL
};
_readPixel_0 readPixelFun_0[64] =
{
readPixel32_0, readPixel24_0, readPixel16_0, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, readPixel16S_0, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, readPixel8_0, readPixel4_0, NULL, NULL, NULL,
NULL, NULL, NULL, readPixel8H_0, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, readPixel4HL_0, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, readPixel4HH_0, NULL, NULL, NULL,
readPixel32Z_0, readPixel24Z_0, readPixel16Z_0, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, readPixel16SZ_0, NULL, NULL, NULL, NULL, NULL
};