From 3780b67ea8d1e598bbe56902d39739a8fe156ea9 Mon Sep 17 00:00:00 2001 From: cottonvibes Date: Tue, 19 Jan 2010 01:24:07 +0000 Subject: [PATCH] minor cleanups (no functional changes) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2455 96395faa-99c1-11dd-bbfe-3dabce05a288 --- pcsx2/VIFunpack.cpp | 242 +++++++++++------------------------- pcsx2/x86/newVif.h | 2 +- pcsx2/x86/newVif_Unpack.cpp | 11 +- 3 files changed, 74 insertions(+), 181 deletions(-) diff --git a/pcsx2/VIFunpack.cpp b/pcsx2/VIFunpack.cpp index 89c4dea8fd..3ffbc838de 100644 --- a/pcsx2/VIFunpack.cpp +++ b/pcsx2/VIFunpack.cpp @@ -16,164 +16,77 @@ #include "PrecompiledHeader.h" #include "Common.h" - -#include - #include "Vif.h" #include "VifDma_internal.h" -enum UnpackOffset -{ +enum UnpackOffset { OFFSET_X = 0, OFFSET_Y = 1, OFFSET_Z = 2, OFFSET_W = 3 }; -static __forceinline u32 setVifRowRegs(u32 reg, u32 data) -{ - switch (reg) - { - case 0: - vifRegs->r0 = data; - break; - case 1: - vifRegs->r1 = data; - break; - case 2: - vifRegs->r2 = data; - break; - case 3: - vifRegs->r3 = data; - break; - jNO_DEFAULT; +static __forceinline u32 setVifRowRegs(u32 reg, u32 data) { + switch (reg) { + case 0: vifRegs->r0 = data; break; + case 1: vifRegs->r1 = data; break; + case 2: vifRegs->r2 = data; break; + case 3: vifRegs->r3 = data; break; + jNO_DEFAULT; } return data; } -static __forceinline u32 getVifRowRegs(u32 reg) -{ - switch (reg) - { - case 0: - return vifRegs->r0; - break; - case 1: - return vifRegs->r1; - break; - case 2: - return vifRegs->r2; - break; - case 3: - return vifRegs->r3; - break; - jNO_DEFAULT; +static __forceinline u32 getVifRowRegs(u32 reg) { + switch (reg) { + case 0: return vifRegs->r0; break; + case 1: return vifRegs->r1; break; + case 2: return vifRegs->r2; break; + case 3: return vifRegs->r3; break; + jNO_DEFAULT; } - return 0; // unreachable... + return 0; // unreachable... } -static __forceinline u32 setVifColRegs(u32 reg, u32 data) -{ - switch (reg) - { - case 0: - vifRegs->c0 = data; - break; - case 1: - vifRegs->c1 = data; - break; - case 2: - vifRegs->c2 = data; - break; - case 3: - vifRegs->c3 = data; - break; - jNO_DEFAULT; +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; + default: return vifRegs->c3; break; } - 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 > -static __releaseinline void writeXYZW(u32 offnum, u32 &dest, u32 data) -{ - int n; +static __releaseinline void writeXYZW(u32 offnum, u32 &dest, u32 data) { u32 vifRowReg = getVifRowRegs(offnum); + int n = 0; - if (doMask) - { - switch (vif->cl) - { - case 0: - if (offnum == OFFSET_X) - 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; + if (doMask) { + switch (vif->cl) { + case 0: 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: - if ((vif->cmd & 0x6F) == 0x6f) - { - dest = data; - } - 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; + if ((vif->cmd & 0x6F) != 0x6f) { + switch (vifRegs->mode) { + case 1: dest = data + vifRowReg; break; + case 2: dest = setVifRowRegs(offnum, vifRowReg + data); break; + default: dest = data; break; + } } + else dest = data; // v4-5 Unpack Mode break; - case 1: - dest = vifRowReg; - break; - case 2: - dest = getVifColRegs((vif->cl > 2) ? 3 : vif->cl); - break; - case 3: - break; + case 1: dest = vifRowReg; break; + case 2: dest = getVifColRegs(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 > @@ -257,8 +170,8 @@ static __forceinline void __fastcall UNPACK_V3(u32 *dest, T *data, int size) if(vifRegs->offset == OFFSET_W) { - //V3-# does some bizzare 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 + // V3-# does some bizarre thing with alignment, every 6qw of data the W becomes 0 (strange console!) + // Ape Escape doesn't seem to like it tho (what the hell?) gonna have to investigate writeXYZW(vifRegs->offset, *dest, *data); vifRegs->offset = OFFSET_X; } @@ -333,12 +246,12 @@ static void __fastcall fUNPACK_V4_5(u32 *dest, u32 *data) // to be cast as. --air // -#define _upk (UNPACKFUNCTYPE) -#define _odd (UNPACKFUNCTYPE_ODD) -#define _unpk_s(bits) (UNPACKFUNCTYPE_S##bits) -#define _odd_s(bits) (UNPACKFUNCTYPE_ODD_S##bits) -#define _unpk_u(bits) (UNPACKFUNCTYPE_U##bits) -#define _odd_u(bits) (UNPACKFUNCTYPE_ODD_U##bits) +#define _upk (UNPACKFUNCTYPE) +#define _odd (UNPACKFUNCTYPE_ODD) +#define _unpk_s(bits) (UNPACKFUNCTYPE_S##bits) +#define _odd_s(bits) (UNPACKFUNCTYPE_ODD_S##bits) +#define _unpk_u(bits) (UNPACKFUNCTYPE_U##bits) +#define _odd_u(bits) (UNPACKFUNCTYPE_ODD_U##bits) // 32-bits versions are unsigned-only!! #define UnpackFuncPair32( sizefac, vt, doMask ) \ @@ -353,40 +266,27 @@ static void __fastcall fUNPACK_V4_5(u32 *dest, u32 *data) (UNPACKFUNCTYPE_ODD)_odd_u(bits) UNPACK_##vt, \ (UNPACKFUNCTYPE_ODD)_odd_s(bits) UNPACK_##vt, -#define UnpackFuncSet( doMask ) \ - { UnpackFuncPair32( 4, S, doMask ) /* 0x0 - S-32 */ \ - 1, 4, 4, 4 }, \ - { UnpackFuncPair ( 4, S, 16, doMask ) /* 0x1 - S-16 */ \ - 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) */ \ - \ - { UnpackFuncPair32( 2, V2, doMask ) /* 0x4 - V2-32 */ \ - 24, 4, 8, 2 }, \ - { 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) */ \ - \ - { UnpackFuncPair32( 3, V3, doMask ) /* 0x8 - V3-32 */ \ - 36, 4, 12, 3 }, \ - { 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) */ \ - \ - { UnpackFuncPair32( 4, V4, doMask ) /* 0xC - V4-32 */ \ - 48, 4, 16, 4 }, \ - { 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 */ \ - (UNPACKFUNCTYPE)_unpk_u(32) fUNPACK_V4_5, (UNPACKFUNCTYPE)_unpk_u(32) fUNPACK_V4_5, \ - (UNPACKFUNCTYPE_ODD)_odd_u(32) UNPACK_V4_5, (UNPACKFUNCTYPE_ODD)_odd_u(32) UNPACK_V4_5, \ +#define UnpackFuncSet( doMask ) \ + { UnpackFuncPair32( 4, S, doMask ) 1, 4, 4, 4 }, /* 0x0 - S-32 */ \ + { UnpackFuncPair ( 4, S, 16, doMask ) 2, 2, 2, 4 }, /* 0x1 - S-16 */ \ + { UnpackFuncPair ( 4, S, 8, doMask ) 4, 1, 1, 4 }, /* 0x2 - S-8 */ \ + { NULL, NULL, NULL, NULL, 0, 0, 0, 0 }, /* 0x3 (NULL) */ \ + { UnpackFuncPair32( 2, V2, doMask ) 24, 4, 8, 2 }, /* 0x4 - V2-32 */ \ + { UnpackFuncPair ( 2, V2, 16, doMask ) 12, 2, 4, 2 }, /* 0x5 - V2-16 */ \ + { UnpackFuncPair ( 2, V2, 8, doMask ) 6, 1, 2, 2 }, /* 0x6 - V2-8 */ \ + { NULL, NULL, NULL, NULL,0, 0, 0, 0 }, /* 0x7 (NULL) */ \ + { UnpackFuncPair32( 3, V3, doMask ) 36, 4, 12, 3 }, /* 0x8 - V3-32 */ \ + { UnpackFuncPair ( 3, V3, 16, doMask ) 18, 2, 6, 3 }, /* 0x9 - V3-16 */ \ + { UnpackFuncPair ( 3, V3, 8, doMask ) 9, 1, 3, 3 }, /* 0xA - V3-8 */ \ + { NULL, NULL, NULL, NULL,0, 0, 0, 0 }, /* 0xB (NULL) */ \ + { UnpackFuncPair32( 4, V4, doMask ) 48, 4, 16, 4 }, /* 0xC - V4-32 */ \ + { UnpackFuncPair ( 4, V4, 16, doMask ) 24, 2, 8, 4 }, /* 0xD - V4-16 */ \ + { UnpackFuncPair ( 4, V4, 8, doMask ) 12, 1, 4, 4 }, /* 0xE - V4-8 */ \ + { /* 0xF - V4-5 */ \ + (UNPACKFUNCTYPE)_unpk_u(32) fUNPACK_V4_5, \ + (UNPACKFUNCTYPE)_unpk_u(32) fUNPACK_V4_5, \ + (UNPACKFUNCTYPE_ODD)_odd_u(32) UNPACK_V4_5, \ + (UNPACKFUNCTYPE_ODD)_odd_u(32) UNPACK_V4_5, \ 6, 2, 2, 4 }, const __aligned16 VIFUnpackFuncTable VIFfuncTable[32] = diff --git a/pcsx2/x86/newVif.h b/pcsx2/x86/newVif.h index 648a300151..8a6a431577 100644 --- a/pcsx2/x86/newVif.h +++ b/pcsx2/x86/newVif.h @@ -97,7 +97,7 @@ struct nVifStruct { }; 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 u32 nVifMask[3][4][4]; // [MaskNumber][CycleNumber][Vector] diff --git a/pcsx2/x86/newVif_Unpack.cpp b/pcsx2/x86/newVif_Unpack.cpp index 4110f869e2..391c89118e 100644 --- a/pcsx2/x86/newVif_Unpack.cpp +++ b/pcsx2/x86/newVif_Unpack.cpp @@ -29,11 +29,7 @@ __aligned16 nVifStruct nVif[2]; __aligned16 nVifCall nVifUpk[(2*2*16) *4]; // ([USN][Masking][Unpack Type]) [curCycle] __aligned16 u32 nVifMask[3][4][4] = {0}; // [MaskNumber][CycleNumber][Vector] -// Contents of this table are doubled up for doMask(false) and doMask(true) lookups. -// (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] = { +__aligned16 const u8 nVifT[16] = { 4, // S-32 2, // S-16 1, // S-8 @@ -50,9 +46,6 @@ __aligned16 const u8 nVifT[32] = { 8, // V4-16 4, // V4-8 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 }; // ---------------------------------------------------------------------------- @@ -92,7 +85,7 @@ void initNewVif(int idx) { if (newVifDynaRec) dVifInit(idx); } -void closeNewVif(int idx) { if (newVifDynaRec) dVifClose(idx); } +void closeNewVif(int idx) { if (newVifDynaRec) dVifClose(idx); } void resetNewVif(int idx) { closeNewVif(idx); initNewVif(idx); } static _f u8* setVUptr(int vuidx, const u8* vuMemBase, int offset) {