zzogl-pg: Add Swizzle function arrays.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3525 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2010-07-18 04:14:09 +00:00
parent 30a911f9f8
commit 48bbe19bd3
4 changed files with 57 additions and 53 deletions

View File

@ -172,7 +172,7 @@ static __forceinline int FinishTransfer(TransferData data, int nLeftOver)
}
template <class T>
static __forceinline int RealTransfer(TransferData data, TransferFuncts fun, const void* pbyMem, u32 nQWordSize)
static __forceinline int RealTransfer(TransferData data, /*TransferFuncts fun,*/ const void* pbyMem, u32 nQWordSize)
{
assert(gs.imageTransfer == 0);
@ -183,6 +183,7 @@ static __forceinline int RealTransfer(TransferData data, TransferFuncts fun, con
tempY = gs.imageY;
tempX = gs.imageX;
Point alignedPt;
TransferFuncts fun(data.psm);
nSize = (nQWordSize * 4 * 2) / tp2;
nSize = min(nSize, gs.imageWnew * gs.imageHnew);
@ -212,121 +213,82 @@ static __forceinline int RealTransfer(TransferData data, TransferFuncts fun, con
return FinishTransfer(data, nLeftOver);
}
//DEFINE_TRANSFERLOCAL(32, u32, 2, 32, 8, 8, _, SwizzleBlock32);
int TransferHostLocal32(const void* pbyMem, u32 nQWordSize)
{
TransferData data(2, 32, 8, 8, 32, PSMCT32);
TransferFuncts fun(writePixel32_0, getPixelAddress32_0, SwizzleBlock32, SwizzleBlock32u);
return RealTransfer<u32>(data, fun, pbyMem, nQWordSize);
return RealTransfer<u32>(data, pbyMem, nQWordSize);
}
//DEFINE_TRANSFERLOCAL(32Z, u32, 2, 32, 8, 8, _, SwizzleBlock32);
int TransferHostLocal32Z(const void* pbyMem, u32 nQWordSize)
{
TransferData data(2, 32, 8, 8, 32, PSMT32Z);
TransferFuncts fun(writePixel32Z_0, getPixelAddress32Z_0, SwizzleBlock32, SwizzleBlock32u);
return RealTransfer<u32>(data, fun, pbyMem, nQWordSize);
return RealTransfer<u32>(data, pbyMem, nQWordSize);
}
//DEFINE_TRANSFERLOCAL(24, u8, 8, 32, 8, 8, _24, SwizzleBlock24);
int TransferHostLocal24(const void* pbyMem, u32 nQWordSize)
{
TransferData data(8, 32, 8, 8, 24, PSMCT24);
TransferFuncts fun(writePixel24_0, getPixelAddress24_0, SwizzleBlock24, SwizzleBlock24u);
return RealTransfer<u8>(data, fun, pbyMem, nQWordSize);
return RealTransfer<u8>(data, pbyMem, nQWordSize);
}
//DEFINE_TRANSFERLOCAL(24Z, u8, 8, 32, 8, 8, _24, SwizzleBlock24);
int TransferHostLocal24Z(const void* pbyMem, u32 nQWordSize)
{
TransferData data(8, 32, 8, 8, 24, PSMT24Z);
TransferFuncts fun(writePixel24Z_0, getPixelAddress24Z_0, SwizzleBlock24, SwizzleBlock24u);
return RealTransfer<u8>(data, fun, pbyMem, nQWordSize);
return RealTransfer<u8>(data, pbyMem, nQWordSize);
}
//DEFINE_TRANSFERLOCAL(16, u16, 4, 16, 16, 8, _, SwizzleBlock16);
int TransferHostLocal16(const void* pbyMem, u32 nQWordSize)
{
TransferData data(4, 16, 16, 8, 16, PSMCT16);
TransferFuncts fun(writePixel16_0, getPixelAddress16_0, SwizzleBlock16, SwizzleBlock16u);
return RealTransfer<u16>(data, fun, pbyMem, nQWordSize);
return RealTransfer<u16>(data, pbyMem, nQWordSize);
}
//DEFINE_TRANSFERLOCAL(16S, u16, 4, 16, 16, 8, _, SwizzleBlock16);
int TransferHostLocal16S(const void* pbyMem, u32 nQWordSize)
{
TransferData data(4, 16, 16, 8, 16, PSMCT16S);
TransferFuncts fun(writePixel16S_0, getPixelAddress16S_0, SwizzleBlock16, SwizzleBlock16u);
return RealTransfer<u16>(data, fun, pbyMem, nQWordSize);
return RealTransfer<u16>(data, pbyMem, nQWordSize);
}
//DEFINE_TRANSFERLOCAL(16Z, u16, 4, 16, 16, 8, _, SwizzleBlock16);
int TransferHostLocal16Z(const void* pbyMem, u32 nQWordSize)
{
TransferData data(4, 16, 16, 8, 16, PSMT16Z);
TransferFuncts fun(writePixel16Z_0, getPixelAddress16Z_0, SwizzleBlock16, SwizzleBlock16u);
return RealTransfer<u16>(data, fun, pbyMem, nQWordSize);
return RealTransfer<u16>(data, pbyMem, nQWordSize);
}
//DEFINE_TRANSFERLOCAL(16SZ, u16, 4, 16, 16, 8, _, SwizzleBlock16);
int TransferHostLocal16SZ(const void* pbyMem, u32 nQWordSize)
{
TransferData data(4, 16, 16, 8, 16, PSMT16SZ);
TransferFuncts fun(writePixel16SZ_0, getPixelAddress16SZ_0, SwizzleBlock16, SwizzleBlock16u);
return RealTransfer<u16>(data, fun, pbyMem, nQWordSize);
return RealTransfer<u16>(data, pbyMem, nQWordSize);
}
//DEFINE_TRANSFERLOCAL(8, u8, 4, 8, 16, 16, _, SwizzleBlock8);
int TransferHostLocal8(const void* pbyMem, u32 nQWordSize)
{
TransferData data(4, 8, 16, 16, 8, PSMT8);
TransferFuncts fun(writePixel8_0, getPixelAddress8_0, SwizzleBlock8, SwizzleBlock8u);
return RealTransfer<u8>(data, fun, pbyMem, nQWordSize);
return RealTransfer<u8>(data, pbyMem, nQWordSize);
}
//DEFINE_TRANSFERLOCAL(4, u8, 8, 4, 32, 16, _4, SwizzleBlock4);
int TransferHostLocal4(const void* pbyMem, u32 nQWordSize)
{
TransferData data(8, 4, 32, 16, 4, PSMT4);
TransferFuncts fun(writePixel4_0, getPixelAddress4_0, SwizzleBlock4, SwizzleBlock4u);
return RealTransfer<u8>(data, fun, pbyMem, nQWordSize);
return RealTransfer<u8>(data, pbyMem, nQWordSize);
}
//DEFINE_TRANSFERLOCAL(8H, u8, 4, 32, 8, 8, _, SwizzleBlock8H);
int TransferHostLocal8H(const void* pbyMem, u32 nQWordSize)
{
TransferData data(4, 32, 8, 8, 8, PSMT8H);
TransferFuncts fun(writePixel8H_0, getPixelAddress8H_0, SwizzleBlock8H, SwizzleBlock8Hu);
return RealTransfer<u8>(data, fun, pbyMem, nQWordSize);
return RealTransfer<u8>(data, pbyMem, nQWordSize);
}
//DEFINE_TRANSFERLOCAL(4HL, u8, 8, 32, 8, 8, _4, SwizzleBlock4HL);
int TransferHostLocal4HL(const void* pbyMem, u32 nQWordSize)
{
TransferData data(8, 32, 8, 8, 4, PSMT4HL);
TransferFuncts fun(writePixel4HL_0, getPixelAddress4HL_0, SwizzleBlock4HL, SwizzleBlock4HLu);
return RealTransfer<u8>(data, fun, pbyMem, nQWordSize);
return RealTransfer<u8>(data, pbyMem, nQWordSize);
}
//DEFINE_TRANSFERLOCAL(4HH, u8, 8, 32, 8, 8, _4, SwizzleBlock4HH);
int TransferHostLocal4HH(const void* pbyMem, u32 nQWordSize)
{
TransferData data(8, 32, 8, 8, 4, PSMT4HH);
TransferFuncts fun(writePixel4HH_0, getPixelAddress4HH_0, SwizzleBlock4HH, SwizzleBlock4HHu);
return RealTransfer<u8>(data, fun, pbyMem, nQWordSize);
return RealTransfer<u8>(data, pbyMem, nQWordSize);
}
void TransferLocalHost32(void* pbyMem, u32 nQWordSize) { FUNCLOG }

View File

@ -47,6 +47,8 @@ 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 _SwizzleBlock swizzleBlockFun[64];
extern _SwizzleBlock swizzleBlockUnFun[64];
// Both of the following structs should probably be local class variables or in a namespace,
// but this works for the moment.
@ -83,6 +85,13 @@ struct TransferFuncts
Swizzle = s;
Swizzle_u = su;
}
__forceinline TransferFuncts(u32 psm)
{
wp = writePixelFun_0[psm];
gp = getPixelFun_0[psm];
Swizzle = swizzleBlockFun[psm];
Swizzle_u = swizzleBlockUnFun[psm];
}
};
// rest not visible externally

View File

@ -49,4 +49,16 @@ extern __forceinline void SwizzleBlock4HL(u8 *dst, u8 *src, int pitch, u32 Write
#define SwizzleBlock4HHu SwizzleBlock4HH
#define SwizzleBlock4HLu SwizzleBlock4HL
#define SwizzleBlock16S SwizzleBlock16
#define SwizzleBlock32Z SwizzleBlock32
#define SwizzleBlock24Z SwizzleBlock24
#define SwizzleBlock16Z SwizzleBlock16
#define SwizzleBlock16SZ SwizzleBlock16
#define SwizzleBlock16Su SwizzleBlock16u
#define SwizzleBlock32Zu SwizzleBlock32u
#define SwizzleBlock24Zu SwizzleBlock24u
#define SwizzleBlock16Zu SwizzleBlock16u
#define SwizzleBlock16SZu SwizzleBlock16u
#endif // MEM_SWIZZLE_H_INCLUDED

View File

@ -19,6 +19,7 @@
#include "GS.h"
#include "Mem.h"
#include "Mem_Swizzle.h"
u32 g_blockTable32[4][8] =
{
@ -269,6 +270,26 @@ char* psm_name[64] =
"PSMT32Z", "PSMT24Z", "PSMT16Z", NULL, NULL, NULL, NULL, NULL,
NULL, NULL, "PSMT16SZ", NULL, NULL, NULL, NULL, NULL };
_SwizzleBlock swizzleBlockFun[64] =
{ SwizzleBlock32, SwizzleBlock24, SwizzleBlock16, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, SwizzleBlock16S, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, SwizzleBlock8, SwizzleBlock4, NULL, NULL, NULL,
NULL, NULL, NULL, SwizzleBlock8H, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, SwizzleBlock4HL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, SwizzleBlock4HH, NULL, NULL, NULL,
SwizzleBlock32Z, SwizzleBlock24Z, SwizzleBlock16Z, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, SwizzleBlock16SZ, NULL, NULL, NULL, NULL, NULL };
_SwizzleBlock swizzleBlockUnFun[64] =
{ SwizzleBlock32u, SwizzleBlock24u, SwizzleBlock16u, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, SwizzleBlock16Su, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, SwizzleBlock8u, SwizzleBlock4u, NULL, NULL, NULL,
NULL, NULL, NULL, SwizzleBlock8Hu, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, SwizzleBlock4HLu, NULL, NULL, NULL,
NULL, NULL, NULL, NULL, SwizzleBlock4HHu, NULL, NULL, NULL,
SwizzleBlock32Zu, SwizzleBlock24Zu, SwizzleBlock16Zu, NULL, NULL, NULL, NULL, NULL,
NULL, NULL, SwizzleBlock16SZu, NULL, NULL, NULL, NULL, NULL };
_getPixelAddress_0 getPixelFun_0[64] =
{
getPixelAddress32_0, getPixelAddress24_0, getPixelAddress16_0, NULL, NULL, NULL, NULL, NULL,