GregMiscellaneous: zzogl-pg:

* Remplace RESOLVE_32_BIT with a nice template (only a 8bytes format for the moment, the others part is not used anyway)
* copy the function RGBA32to16 due to 'missing external linkage' ???
* Remove trailling space


git-svn-id: http://pcsx2.googlecode.com/svn/branches/GregMiscellaneous@3772 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
gregory.hainaut@gmail.com 2010-09-15 21:04:45 +00:00
parent 30c9763c34
commit bed38e12a0
1 changed files with 113 additions and 34 deletions

View File

@ -2925,6 +2925,83 @@ void FlushTransferRanges(const tex0Info* ptex)
} \
} \
template <typename T, typename Tret>
inline Tret dummy_return(T value) { return value; }
inline u16 RGBA32to16(u32 c)
{
return (u16)((((c) & 0x000000f8) >> 3) |
(((c) & 0x0000f800) >> 6) |
(((c) & 0x00f80000) >> 9) |
(((c) & 0x80000000) >> 16));
}
template <typename T, typename Tsrc, T (*convfn)(Tsrc)>
inline void Resolve_32_Bit(const void* psrc, int fbp, int fbw, int fbh, const int psm, u32 fbm)
{
u32 mask, imask;
if (PSMT_ISHALF(psm)) /* 16 bit */
{
/* mask is shifted*/
imask = RGBA32to16(fbm);
mask = (~imask)&0xffff;
}
else
{
mask = ~fbm;
imask = fbm;
}
Tsrc* src = (Tsrc*)(psrc);
T* pPageOffset = (T*)g_pbyGSMemory + fbp*(256/sizeof(T)), *dst;
int maxfbh = (MEMORY_END-fbp*256) / (sizeof(T) * fbw);
if( maxfbh > fbh ) maxfbh = fbh;
for(int i = 0; i < maxfbh; ++i) {
for(int j = 0; j < fbw; ++j) {
T dsrc = (T)convfn(src[RW(j)]);
// They are 3 methods to call the functions
// macro (compact, inline) but need a nice psm ; swich (inline) ; function pointer (compact)
// Use a switch to allow inlining of the getPixel function.
// Note: psm is const so the switch is completely optimized
// Function method example:
// dst = pPageOffset + getPixelFun_0[psm](j, i, fbw);
switch (psm)
{
case PSMCT32:
case PSMCT24:
dst = pPageOffset + getPixelAddress32_0(j, i, fbw);
break;
case PSMCT16:
dst = pPageOffset + getPixelAddress16_0(j, i, fbw);
break;
case PSMCT16S:
dst = pPageOffset + getPixelAddress16S_0(j, i, fbw);
break;
case PSMT32Z:
case PSMT24Z:
dst = pPageOffset + getPixelAddress32Z_0(j, i, fbw);
break;
case PSMT16Z:
dst = pPageOffset + getPixelAddress16Z_0(j, i, fbw);
break;
case PSMT16SZ:
dst = pPageOffset + getPixelAddress16SZ_0(j, i, fbw);
break;
}
*dst = (dsrc & mask) | (*dst & imask);
}
src += RH(Pitch(fbw))/sizeof(Tsrc);
}
}
void _Resolve(const void* psrc, int fbp, int fbw, int fbh, int psm, u32 fbm, bool mode = true)
{
FUNCLOG
@ -2943,30 +3020,32 @@ void _Resolve(const void* psrc, int fbp, int fbw, int fbh, int psm, u32 fbm, boo
switch (psm)
{
// NOTE pass psm as a constant value otherwise gcc does not do its job. It keep
// the psm switch in Resolve_32_Bit
case PSMCT32:
case PSMCT24:
RESOLVE_32_BIT(32, u32, u32, (u32));
Resolve_32_Bit<u32, u32, dummy_return >(psrc, fbp, fbw, fbh, PSMCT32, fbm);
break;
case PSMCT16:
RESOLVE_32_BIT(16, u16, u32, RGBA32to16);
Resolve_32_Bit<u16, u32, RGBA32to16 >(psrc, fbp, fbw, fbh, PSMCT16, fbm);
break;
case PSMCT16S:
RESOLVE_32_BIT(16S, u16, u32, RGBA32to16);
Resolve_32_Bit<u16, u32, RGBA32to16 >(psrc, fbp, fbw, fbh, PSMCT16S, fbm);
break;
case PSMT32Z:
case PSMT24Z:
RESOLVE_32_BIT(32Z, u32, u32, (u32));
Resolve_32_Bit<u32, u32, dummy_return >(psrc, fbp, fbw, fbh, PSMT32Z, fbm);
break;
case PSMT16Z:
RESOLVE_32_BIT(16Z, u16, u32, (u16));
Resolve_32_Bit<u16, u32, dummy_return >(psrc, fbp, fbw, fbh, PSMT16Z, fbm);
break;
case PSMT16SZ:
RESOLVE_32_BIT(16SZ, u16, u32, (u16));
Resolve_32_Bit<u16, u32, dummy_return >(psrc, fbp, fbw, fbh, PSMT16SZ, fbm);
break;
}
}