zzogl-pg: Messing around with the BLOCK struct.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3528 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2010-07-18 06:59:23 +00:00
parent b58a43cdf6
commit 6972792a4e
3 changed files with 131 additions and 59 deletions

View File

@ -253,26 +253,27 @@ void TransferLocalHost16SZ(void* pbyMem, u32 nQWordSize) {FUNCLOG}
b.pageTable = &g_pageTable##psm[0][0]; \
b.blockTable = &g_blockTable##psm[0][0]; \
b.columnTable = &g_columnTable##psmcol[0][0]; \
\
assert( sizeof(g_pageTable##psm) == bw*bh*sizeof(g_pageTable##psm[0][0]) ); \
\
psrcf = (float*)&vBlockData[0] + ox + oy * BLOCK_TEXWIDTH; \
psrcw = (u16*)&vBlockData[0] + ox + oy * BLOCK_TEXWIDTH; \
for(i = 0; i < bh; ++i) { \
for(j = 0; j < bw; ++j) { \
/* fill the table */ \
u32 u = g_blockTable##psm[(i / b.colheight)][(j / b.colwidth)] * 64 * mult + g_columnTable##psmcol[i%b.colheight][j%b.colwidth]; \
b.pageTable[i*bw+j] = u; \
if( floatfmt ) { \
\
if (floatfmt) \
{ \
for(i = 0; i < bh; ++i) \
{ \
for(j = 0; j < bw; ++j) \
{ \
/* fill the table */ \
u32 u = g_blockTable##psm[(i / b.colheight)][(j / b.colwidth)] * 64 * mult + g_columnTable##psmcol[i%b.colheight][j%b.colwidth]; \
b.pageTable[i*bw+j] = u; \
psrcf[i*BLOCK_TEXWIDTH+j] = (float)(u) / (float)(GPU_TEXWIDTH*mult); \
} \
else { \
psrcw[i*BLOCK_TEXWIDTH+j] = u; \
} \
} \
} \
\
if( floatfmt ) { \
assert( floatfmt ); \
psrcv = (Vector*)&vBilinearData[0] + ox + oy * BLOCK_TEXWIDTH; \
\
for(i = 0; i < bh; ++i) { \
for(j = 0; j < bw; ++j) { \
Vector* pv = &psrcv[i*BLOCK_TEXWIDTH+j]; \
@ -283,14 +284,19 @@ void TransferLocalHost16SZ(void* pbyMem, u32 nQWordSize) {FUNCLOG}
} \
} \
} \
b.getPixelAddress = getPixelAddress##psm; \
b.getPixelAddress_0 = getPixelAddress##psm##_0; \
b.writePixel = writePixel##psm; \
b.writePixel_0 = writePixel##psm##_0; \
b.readPixel = readPixel##psm; \
b.readPixel_0 = readPixel##psm##_0; \
b.TransferHostLocal = TransferHostLocal##psm; \
b.TransferLocalHost = TransferLocalHost##psm; \
else \
{ \
for(i = 0; i < bh; ++i) \
{ \
for(j = 0; j < bw; ++j) \
{ \
/* fill the table */ \
u32 u = g_blockTable##psm[(i / b.colheight)][(j / b.colwidth)] * 64 * mult + g_columnTable##psmcol[i%b.colheight][j%b.colwidth]; \
b.pageTable[i*bw+j] = u; \
psrcw[i*BLOCK_TEXWIDTH+j] = u; \
} \
} \
} \
} \
void BLOCK::FillBlocks(vector<char>& vBlockData, vector<char>& vBilinearData, int floatfmt)
@ -298,94 +304,71 @@ void BLOCK::FillBlocks(vector<char>& vBlockData, vector<char>& vBilinearData, in
FUNCLOG
vBlockData.resize(BLOCK_TEXWIDTH * BLOCK_TEXHEIGHT * (floatfmt ? 4 : 2));
if (floatfmt)
vBilinearData.resize(BLOCK_TEXWIDTH * BLOCK_TEXHEIGHT * sizeof(Vector));
if (floatfmt) vBilinearData.resize(BLOCK_TEXWIDTH * BLOCK_TEXHEIGHT * sizeof(Vector));
int i, j;
BLOCK b;
float* psrcf = NULL;
u16* psrcw = NULL;
Vector* psrcv = NULL;
memset(m_Blocks, 0, sizeof(m_Blocks));
// 32
FILL_BLOCK(64, 32, 0, 0, 1, 32, 32);
m_Blocks[PSMCT32] = b;
m_Blocks[PSMCT32].SetFun(PSMCT32);
// 24 (same as 32 except write/readPixel are different)
m_Blocks[PSMCT24] = b;
m_Blocks[PSMCT24].writePixel = writePixel24;
m_Blocks[PSMCT24].writePixel_0 = writePixel24_0;
m_Blocks[PSMCT24].readPixel = readPixel24;
m_Blocks[PSMCT24].readPixel_0 = readPixel24_0;
m_Blocks[PSMCT24].TransferHostLocal = TransferHostLocal24;
m_Blocks[PSMCT24].TransferLocalHost = TransferLocalHost24;
m_Blocks[PSMCT24].SetFun(PSMCT24);
// 8H (same as 32 except write/readPixel are different)
m_Blocks[PSMT8H] = b;
m_Blocks[PSMT8H].writePixel = writePixel8H;
m_Blocks[PSMT8H].writePixel_0 = writePixel8H_0;
m_Blocks[PSMT8H].readPixel = readPixel8H;
m_Blocks[PSMT8H].readPixel_0 = readPixel8H_0;
m_Blocks[PSMT8H].TransferHostLocal = TransferHostLocal8H;
m_Blocks[PSMT8H].TransferLocalHost = TransferLocalHost8H;
m_Blocks[PSMT8H].SetFun(PSMT8H);
m_Blocks[PSMT4HL] = b;
m_Blocks[PSMT4HL].writePixel = writePixel4HL;
m_Blocks[PSMT4HL].writePixel_0 = writePixel4HL_0;
m_Blocks[PSMT4HL].readPixel = readPixel4HL;
m_Blocks[PSMT4HL].readPixel_0 = readPixel4HL_0;
m_Blocks[PSMT4HL].TransferHostLocal = TransferHostLocal4HL;
m_Blocks[PSMT4HL].TransferLocalHost = TransferLocalHost4HL;
m_Blocks[PSMT4HH] = b;
m_Blocks[PSMT4HL].SetFun(PSMT4HL);
m_Blocks[PSMT4HH].writePixel = writePixel4HH;
m_Blocks[PSMT4HH].writePixel_0 = writePixel4HH_0;
m_Blocks[PSMT4HH].readPixel = readPixel4HH;
m_Blocks[PSMT4HH].readPixel_0 = readPixel4HH_0;
m_Blocks[PSMT4HH].TransferHostLocal = TransferHostLocal4HH;
m_Blocks[PSMT4HH].TransferLocalHost = TransferLocalHost4HH;
m_Blocks[PSMT4HH] = b;
m_Blocks[PSMT4HH].SetFun(PSMT4HH);
// 32z
FILL_BLOCK(64, 32, 64, 0, 1, 32Z, 32);
m_Blocks[PSMT32Z] = b;
m_Blocks[PSMT32Z].SetFun(PSMT32Z);
// 24Z (same as 32Z except write/readPixel are different)
m_Blocks[PSMT24Z] = b;
m_Blocks[PSMT24Z].writePixel = writePixel24Z;
m_Blocks[PSMT24Z].writePixel_0 = writePixel24Z_0;
m_Blocks[PSMT24Z].readPixel = readPixel24Z;
m_Blocks[PSMT24Z].readPixel_0 = readPixel24Z_0;
m_Blocks[PSMT24Z].TransferHostLocal = TransferHostLocal24Z;
m_Blocks[PSMT24Z].TransferLocalHost = TransferLocalHost24Z;
m_Blocks[PSMT24Z].SetFun(PSMT24Z);
// 16
FILL_BLOCK(64, 64, 0, 32, 2, 16, 16);
m_Blocks[PSMCT16] = b;
m_Blocks[PSMCT16].SetFun(PSMCT16);
// 16s
FILL_BLOCK(64, 64, 64, 32, 2, 16S, 16);
m_Blocks[PSMCT16S] = b;
m_Blocks[PSMCT16S].SetFun(PSMCT16S);
// 16z
FILL_BLOCK(64, 64, 0, 96, 2, 16Z, 16);
m_Blocks[PSMT16Z] = b;
m_Blocks[PSMT16Z].SetFun(PSMT16Z);
// 16sz
FILL_BLOCK(64, 64, 64, 96, 2, 16SZ, 16);
m_Blocks[PSMT16SZ] = b;
m_Blocks[PSMT16SZ].SetFun(PSMT16SZ);
// 8
FILL_BLOCK(128, 64, 0, 160, 4, 8, 8);
m_Blocks[PSMT8] = b;
m_Blocks[PSMT8].SetFun(PSMT8);
// 4
FILL_BLOCK(128, 128, 0, 224, 8, 4, 4);
m_Blocks[PSMT4] = b;
m_Blocks[PSMT4].SetFun(PSMT4);
}

View File

@ -47,8 +47,12 @@ 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];
extern _writePixel writePixelFun[64];
extern _readPixel readPixelFun[64];
extern _SwizzleBlock swizzleBlockFun[64];
extern _SwizzleBlock swizzleBlockUnFun[64];
extern _TransferHostLocal TransferHostLocalFun[64];
extern _TransferLocalHost TransferLocalHostFun[64];
// Both of the following structs should probably be local class variables or in a namespace,
// but this works for the moment.
@ -122,6 +126,15 @@ struct BLOCK
// texture must be of dims BLOCK_TEXWIDTH and BLOCK_TEXHEIGHT
static void FillBlocks(std::vector<char>& vBlockData, std::vector<char>& vBilinearData, int floatfmt);
void SetFun(u32 psm)
{
writePixel = writePixelFun[psm];
writePixel_0 = writePixelFun_0[psm];
readPixel = readPixelFun[psm];
readPixel_0 = readPixelFun_0[psm];
TransferHostLocal = TransferHostLocalFun[psm];
TransferLocalHost = TransferLocalHostFun[psm];
}
};
extern BLOCK m_Blocks[];
@ -593,4 +606,32 @@ static __forceinline u32 readPixel16SZ_0(const void* pmem, int x, int y, u32 bw)
return ((const u16*)pmem)[getPixelAddress16SZ_0(x, y, bw)];
}
extern int TransferHostLocal32(const void* pbyMem, u32 nQWordSize);
extern int TransferHostLocal32Z(const void* pbyMem, u32 nQWordSize);
extern int TransferHostLocal24(const void* pbyMem, u32 nQWordSize);
extern int TransferHostLocal24Z(const void* pbyMem, u32 nQWordSize);
extern int TransferHostLocal16(const void* pbyMem, u32 nQWordSize);
extern int TransferHostLocal16S(const void* pbyMem, u32 nQWordSize);
extern int TransferHostLocal16Z(const void* pbyMem, u32 nQWordSize);
extern int TransferHostLocal16SZ(const void* pbyMem, u32 nQWordSize);
extern int TransferHostLocal8(const void* pbyMem, u32 nQWordSize);
extern int TransferHostLocal4(const void* pbyMem, u32 nQWordSize);
extern int TransferHostLocal8H(const void* pbyMem, u32 nQWordSize);
extern int TransferHostLocal4HL(const void* pbyMem, u32 nQWordSize);
extern int TransferHostLocal4HH(const void* pbyMem, u32 nQWordSize);
extern void TransferLocalHost32(void* pbyMem, u32 nQWordSize);
extern void TransferLocalHost24(void* pbyMem, u32 nQWordSize);
extern void TransferLocalHost16(void* pbyMem, u32 nQWordSize);
extern void TransferLocalHost16S(void* pbyMem, u32 nQWordSize);
extern void TransferLocalHost8(void* pbyMem, u32 nQWordSize);
extern void TransferLocalHost4(void* pbyMem, u32 nQWordSize);
extern void TransferLocalHost8H(void* pbyMem, u32 nQWordSize);
extern void TransferLocalHost4HL(void* pbyMem, u32 nQWordSize);
extern void TransferLocalHost4HH(void* pbyMem, u32 nQWordSize);
extern void TransferLocalHost32Z(void* pbyMem, u32 nQWordSize);
extern void TransferLocalHost24Z(void* pbyMem, u32 nQWordSize);
extern void TransferLocalHost16Z(void* pbyMem, u32 nQWordSize);
extern void TransferLocalHost16SZ(void* pbyMem, u32 nQWordSize);
#endif /* __MEM_H__ */

View File

@ -326,6 +326,54 @@ _readPixel_0 readPixelFun_0[64] =
NULL, NULL, readPixel16SZ_0, NULL, NULL, NULL, NULL, NULL
};
_writePixel writePixelFun[64] =
{
writePixel32, writePixel24, writePixel16, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, writePixel16S, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, writePixel8, writePixel4, NULL, NULL, NULL,
NULL, NULL, NULL, writePixel8H, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, writePixel4HL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, writePixel4HH, NULL, NULL, NULL,
writePixel32Z, writePixel24Z, writePixel16Z, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, writePixel16SZ, NULL, NULL, NULL, NULL, NULL
};
_readPixel readPixelFun[64] =
{
readPixel32, readPixel24, readPixel16, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, readPixel16S, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, readPixel8, readPixel4, NULL, NULL, NULL,
NULL, NULL, NULL, readPixel8H, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, readPixel4HL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, readPixel4HH, NULL, NULL, NULL,
readPixel32Z, readPixel24Z, readPixel16Z, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, readPixel16SZ, NULL, NULL, NULL, NULL, NULL
};
_TransferHostLocal TransferHostLocalFun[64] =
{
TransferHostLocal32, TransferHostLocal24, TransferHostLocal16, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, TransferHostLocal16S, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, TransferHostLocal8, TransferHostLocal4, NULL, NULL, NULL,
NULL, NULL, NULL, TransferHostLocal8H, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, TransferHostLocal4HL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, TransferHostLocal4HH, NULL, NULL, NULL,
TransferHostLocal32Z, TransferHostLocal24Z, TransferHostLocal16Z, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, TransferHostLocal16SZ, NULL, NULL, NULL, NULL, NULL
};
_TransferLocalHost TransferLocalHostFun[64] =
{
TransferLocalHost32, TransferLocalHost24, TransferLocalHost16, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, TransferLocalHost16S, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, TransferLocalHost8, TransferLocalHost4, NULL, NULL, NULL,
NULL, NULL, NULL, TransferLocalHost8H, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, TransferLocalHost4HL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, TransferLocalHost4HH, NULL, NULL, NULL,
TransferLocalHost32Z, TransferLocalHost24Z, TransferLocalHost16Z, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, TransferLocalHost16SZ, NULL, NULL, NULL, NULL, NULL
};
#define TD_NULL {0,0,0,0,0,0}
TransferData tData[64] =
{