minor cleanups (no functional changes)

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2455 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
cottonvibes 2010-01-19 01:24:07 +00:00
parent b26d7fad2f
commit 3780b67ea8
3 changed files with 74 additions and 181 deletions

View File

@ -16,164 +16,77 @@
#include "PrecompiledHeader.h" #include "PrecompiledHeader.h"
#include "Common.h" #include "Common.h"
#include <cmath>
#include "Vif.h" #include "Vif.h"
#include "VifDma_internal.h" #include "VifDma_internal.h"
enum UnpackOffset enum UnpackOffset {
{
OFFSET_X = 0, OFFSET_X = 0,
OFFSET_Y = 1, OFFSET_Y = 1,
OFFSET_Z = 2, OFFSET_Z = 2,
OFFSET_W = 3 OFFSET_W = 3
}; };
static __forceinline u32 setVifRowRegs(u32 reg, u32 data) static __forceinline u32 setVifRowRegs(u32 reg, u32 data) {
{ switch (reg) {
switch (reg) case 0: vifRegs->r0 = data; break;
{ case 1: vifRegs->r1 = data; break;
case 0: case 2: vifRegs->r2 = data; break;
vifRegs->r0 = data; case 3: vifRegs->r3 = data; break;
break;
case 1:
vifRegs->r1 = data;
break;
case 2:
vifRegs->r2 = data;
break;
case 3:
vifRegs->r3 = data;
break;
jNO_DEFAULT; jNO_DEFAULT;
} }
return data; return data;
} }
static __forceinline u32 getVifRowRegs(u32 reg) static __forceinline u32 getVifRowRegs(u32 reg) {
{ switch (reg) {
switch (reg) case 0: return vifRegs->r0; break;
{ case 1: return vifRegs->r1; break;
case 0: case 2: return vifRegs->r2; break;
return vifRegs->r0; case 3: return vifRegs->r3; break;
break;
case 1:
return vifRegs->r1;
break;
case 2:
return vifRegs->r2;
break;
case 3:
return vifRegs->r3;
break;
jNO_DEFAULT; jNO_DEFAULT;
} }
return 0; // unreachable... return 0; // unreachable...
} }
static __forceinline u32 setVifColRegs(u32 reg, u32 data) static __forceinline u32 getVifColRegs(u32 reg) {
{ switch (reg) {
switch (reg) case 0: return vifRegs->c0; break;
{ case 1: return vifRegs->c1; break;
case 0: case 2: return vifRegs->c2; break;
vifRegs->c0 = data; default: return vifRegs->c3; break;
break;
case 1:
vifRegs->c1 = data;
break;
case 2:
vifRegs->c2 = data;
break;
case 3:
vifRegs->c3 = data;
break;
jNO_DEFAULT;
}
return data;
}
static __forceinline u32 getVifColRegs(u32 reg)
{
switch (reg)
{
case 0:
return vifRegs->c0;
break;
case 1:
return vifRegs->c1;
break;
case 2:
return vifRegs->c2;
break;
case 3:
return vifRegs->c3;
break;
jNO_DEFAULT;
} }
return 0; // unreachable... return 0; // unreachable...
} }
template< bool doMask > template< bool doMask >
static __releaseinline void writeXYZW(u32 offnum, u32 &dest, u32 data) static __releaseinline void writeXYZW(u32 offnum, u32 &dest, u32 data) {
{
int n;
u32 vifRowReg = getVifRowRegs(offnum); u32 vifRowReg = getVifRowRegs(offnum);
int n = 0;
if (doMask) if (doMask) {
{ switch (vif->cl) {
switch (vif->cl) case 0: n = (vifRegs->mask >> (offnum * 2)) & 0x3; break;
{ case 1: n = (vifRegs->mask >> ( 8 + (offnum * 2))) & 0x3; break;
case 0: case 2: n = (vifRegs->mask >> (16 + (offnum * 2))) & 0x3; break;
if (offnum == OFFSET_X) default: n = (vifRegs->mask >> (24 + (offnum * 2))) & 0x3; break;
n = (vifRegs->mask) & 0x3;
else
n = (vifRegs->mask >> (offnum * 2)) & 0x3;
break;
case 1:
n = (vifRegs->mask >> ( 8 + (offnum * 2))) & 0x3;
break;
case 2:
n = (vifRegs->mask >> (16 + (offnum * 2))) & 0x3;
break;
default:
n = (vifRegs->mask >> (24 + (offnum * 2))) & 0x3;
break;
} }
} }
else n = 0;
switch (n) switch (n) {
{
case 0: case 0:
if ((vif->cmd & 0x6F) == 0x6f) if ((vif->cmd & 0x6F) != 0x6f) {
{ switch (vifRegs->mode) {
dest = data; case 1: dest = data + vifRowReg; break;
case 2: dest = setVifRowRegs(offnum, vifRowReg + data); break;
default: dest = data; break;
} }
else switch (vifRegs->mode)
{
case 1:
dest = data + vifRowReg;
break;
case 2:
// vifRowReg isn't used after this, or I would make it equal to dest here.
dest = setVifRowRegs(offnum, vifRowReg + data);
break;
default:
dest = data;
break;
} }
else dest = data; // v4-5 Unpack Mode
break; break;
case 1: case 1: dest = vifRowReg; break;
dest = vifRowReg; case 2: dest = getVifColRegs(vif->cl); break;
break; case 3: break;
case 2:
dest = getVifColRegs((vif->cl > 2) ? 3 : vif->cl);
break;
case 3:
break;
} }
// VIF_LOG("writeX %8.8x : Mode %d, r0 = %x, data %8.8x", *dest,vifRegs->mode,vifRegs->r0,data);
} }
template < bool doMask, class T > template < bool doMask, class T >
@ -257,8 +170,8 @@ static __forceinline void __fastcall UNPACK_V3(u32 *dest, T *data, int size)
if(vifRegs->offset == OFFSET_W) if(vifRegs->offset == OFFSET_W)
{ {
//V3-# does some bizzare thing with alignment, every 6qw of data the W becomes 0 (strange console!) // V3-# does some bizarre thing with alignment, every 6qw of data the W becomes 0 (strange console!)
//Ape Escape doesnt seem to like it tho (what the hell?) gonna have to investigate // Ape Escape doesn't seem to like it tho (what the hell?) gonna have to investigate
writeXYZW<doMask>(vifRegs->offset, *dest, *data); writeXYZW<doMask>(vifRegs->offset, *dest, *data);
vifRegs->offset = OFFSET_X; vifRegs->offset = OFFSET_X;
} }
@ -354,39 +267,26 @@ static void __fastcall fUNPACK_V4_5(u32 *dest, u32 *data)
(UNPACKFUNCTYPE_ODD)_odd_s(bits) UNPACK_##vt<doMask, s##bits>, (UNPACKFUNCTYPE_ODD)_odd_s(bits) UNPACK_##vt<doMask, s##bits>,
#define UnpackFuncSet( doMask ) \ #define UnpackFuncSet( doMask ) \
{ UnpackFuncPair32( 4, S, doMask ) /* 0x0 - S-32 */ \ { UnpackFuncPair32( 4, S, doMask ) 1, 4, 4, 4 }, /* 0x0 - S-32 */ \
1, 4, 4, 4 }, \ { UnpackFuncPair ( 4, S, 16, doMask ) 2, 2, 2, 4 }, /* 0x1 - S-16 */ \
{ UnpackFuncPair ( 4, S, 16, doMask ) /* 0x1 - S-16 */ \ { UnpackFuncPair ( 4, S, 8, doMask ) 4, 1, 1, 4 }, /* 0x2 - S-8 */ \
2, 2, 2, 4 }, \
{ UnpackFuncPair ( 4, S, 8, doMask ) /* 0x2 - S-8 */ \
4, 1, 1, 4 }, \
{ NULL, NULL, NULL, NULL, 0, 0, 0, 0 }, /* 0x3 (NULL) */ \ { NULL, NULL, NULL, NULL, 0, 0, 0, 0 }, /* 0x3 (NULL) */ \
\ { UnpackFuncPair32( 2, V2, doMask ) 24, 4, 8, 2 }, /* 0x4 - V2-32 */ \
{ UnpackFuncPair32( 2, V2, doMask ) /* 0x4 - V2-32 */ \ { UnpackFuncPair ( 2, V2, 16, doMask ) 12, 2, 4, 2 }, /* 0x5 - V2-16 */ \
24, 4, 8, 2 }, \ { UnpackFuncPair ( 2, V2, 8, doMask ) 6, 1, 2, 2 }, /* 0x6 - V2-8 */ \
{ UnpackFuncPair ( 2, V2, 16, doMask ) /* 0x5 - V2-16 */ \
12, 2, 4, 2 }, \
{ UnpackFuncPair ( 2, V2, 8, doMask ) /* 0x6 - V2-8 */ \
6, 1, 2, 2 }, \
{ NULL, NULL, NULL, NULL,0, 0, 0, 0 }, /* 0x7 (NULL) */ \ { NULL, NULL, NULL, NULL,0, 0, 0, 0 }, /* 0x7 (NULL) */ \
\ { UnpackFuncPair32( 3, V3, doMask ) 36, 4, 12, 3 }, /* 0x8 - V3-32 */ \
{ UnpackFuncPair32( 3, V3, doMask ) /* 0x8 - V3-32 */ \ { UnpackFuncPair ( 3, V3, 16, doMask ) 18, 2, 6, 3 }, /* 0x9 - V3-16 */ \
36, 4, 12, 3 }, \ { UnpackFuncPair ( 3, V3, 8, doMask ) 9, 1, 3, 3 }, /* 0xA - V3-8 */ \
{ UnpackFuncPair ( 3, V3, 16, doMask ) /* 0x9 - V3-16 */ \
18, 2, 6, 3 }, \
{ UnpackFuncPair ( 3, V3, 8, doMask ) /* 0xA - V3-8 */ \
9, 1, 3, 3 }, \
{ NULL, NULL, NULL, NULL,0, 0, 0, 0 }, /* 0xB (NULL) */ \ { NULL, NULL, NULL, NULL,0, 0, 0, 0 }, /* 0xB (NULL) */ \
\ { UnpackFuncPair32( 4, V4, doMask ) 48, 4, 16, 4 }, /* 0xC - V4-32 */ \
{ UnpackFuncPair32( 4, V4, doMask ) /* 0xC - V4-32 */ \ { UnpackFuncPair ( 4, V4, 16, doMask ) 24, 2, 8, 4 }, /* 0xD - V4-16 */ \
48, 4, 16, 4 }, \ { UnpackFuncPair ( 4, V4, 8, doMask ) 12, 1, 4, 4 }, /* 0xE - V4-8 */ \
{ UnpackFuncPair ( 4, V4, 16, doMask ) /* 0xD - V4-16 */ \
24, 2, 8, 4 }, \
{ UnpackFuncPair ( 4, V4, 8, doMask ) /* 0xE - V4-8 */ \
12, 1, 4, 4 }, \
{ /* 0xF - V4-5 */ \ { /* 0xF - V4-5 */ \
(UNPACKFUNCTYPE)_unpk_u(32) fUNPACK_V4_5<doMask>, (UNPACKFUNCTYPE)_unpk_u(32) fUNPACK_V4_5<doMask>, \ (UNPACKFUNCTYPE)_unpk_u(32) fUNPACK_V4_5<doMask>, \
(UNPACKFUNCTYPE_ODD)_odd_u(32) UNPACK_V4_5<doMask>, (UNPACKFUNCTYPE_ODD)_odd_u(32) UNPACK_V4_5<doMask>, \ (UNPACKFUNCTYPE)_unpk_u(32) fUNPACK_V4_5<doMask>, \
(UNPACKFUNCTYPE_ODD)_odd_u(32) UNPACK_V4_5<doMask>, \
(UNPACKFUNCTYPE_ODD)_odd_u(32) UNPACK_V4_5<doMask>, \
6, 2, 2, 4 }, 6, 2, 2, 4 },
const __aligned16 VIFUnpackFuncTable VIFfuncTable[32] = const __aligned16 VIFUnpackFuncTable VIFfuncTable[32] =

View File

@ -97,7 +97,7 @@ struct nVifStruct {
}; };
extern __aligned16 nVifStruct nVif[2]; extern __aligned16 nVifStruct nVif[2];
extern __aligned16 const u8 nVifT[32]; extern __aligned16 const u8 nVifT[16];
extern __aligned16 nVifCall nVifUpk[(2*2*16)*4]; // ([USN][Masking][Unpack Type]) [curCycle] extern __aligned16 nVifCall nVifUpk[(2*2*16)*4]; // ([USN][Masking][Unpack Type]) [curCycle]
extern __aligned16 u32 nVifMask[3][4][4]; // [MaskNumber][CycleNumber][Vector] extern __aligned16 u32 nVifMask[3][4][4]; // [MaskNumber][CycleNumber][Vector]

View File

@ -29,11 +29,7 @@ __aligned16 nVifStruct nVif[2];
__aligned16 nVifCall nVifUpk[(2*2*16) *4]; // ([USN][Masking][Unpack Type]) [curCycle] __aligned16 nVifCall nVifUpk[(2*2*16) *4]; // ([USN][Masking][Unpack Type]) [curCycle]
__aligned16 u32 nVifMask[3][4][4] = {0}; // [MaskNumber][CycleNumber][Vector] __aligned16 u32 nVifMask[3][4][4] = {0}; // [MaskNumber][CycleNumber][Vector]
// Contents of this table are doubled up for doMask(false) and doMask(true) lookups. __aligned16 const u8 nVifT[16] = {
// (note: currently unused, I'm using gsize in the interp tables instead since it
// seems to be faster for now, which may change when nVif isn't reliant on interpreted
// unpackers anymore --air)
__aligned16 const u8 nVifT[32] = {
4, // S-32 4, // S-32
2, // S-16 2, // S-16
1, // S-8 1, // S-8
@ -50,9 +46,6 @@ __aligned16 const u8 nVifT[32] = {
8, // V4-16 8, // V4-16
4, // V4-8 4, // V4-8
2, // V4-5 2, // V4-5
// Second verse, same as the first!
4,2,1,0,8,4,2,0,12,6,3,0,16,8,4,2
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------