Vif Cleanups - did some code refactoring so things make more sense.

I need to do more later on...

I mostly separated the unpack code from the dma/transfer code in this commit.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2485 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
cottonvibes 2010-01-23 02:30:00 +00:00
parent 12200c2c10
commit 84bc805761
14 changed files with 1290 additions and 1279 deletions

View File

@ -16,8 +16,7 @@
#include "PrecompiledHeader.h"
#include "Common.h"
#include "VifDma_internal.h"
#include "VifDma.h"
#include "VUmicro.h"
#include "newVif.h"

View File

@ -16,9 +16,7 @@
#include "PrecompiledHeader.h"
#include "Common.h"
#include "VifDma_internal.h"
#include "VifDma.h"
#include "GS.h"
#include "Gif.h"
#include "VUmicro.h"

View File

@ -16,7 +16,7 @@
#include "PrecompiledHeader.h"
#include "Common.h"
#include "VifDma_internal.h"
#include "VifDma.h"
#include "VUmicro.h"
int g_vifCycles = 0;

View File

@ -12,8 +12,9 @@
* You should have received a copy of the GNU General Public License along with PCSX2.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __VIFDMA_H__
#define __VIFDMA_H__
#pragma once
#include "Vif_Unpack.h"
struct vifCode {
u32 addr;
@ -43,9 +44,10 @@ struct vifStruct {
u8 dmamode;
};
extern vifStruct vif0, vif1;
extern u8 schedulepath3msk;
static const int VifCycleVoodoo = 4;
extern vifStruct* vif;
extern vifStruct vif0, vif1;
extern u8 schedulepath3msk;
static const int VifCycleVoodoo = 4;
extern void vif0Init();
extern void vif0Interrupt();
@ -63,4 +65,20 @@ __forceinline static int _limit(int a, int max)
return ((a > max) ? max : a);
}
#endif
enum VifModes
{
VIF_NORMAL_TO_MEM_MODE = 0,
VIF_NORMAL_FROM_MEM_MODE = 1,
VIF_CHAIN_MODE = 2
};
// Generic constants
static const unsigned int VIF0intc = 4;
static const unsigned int VIF1intc = 5;
extern int g_vifCycles;
template<const u32 VIFdmanum> void vuExecMicro(u32 addr);
extern void vif0FLUSH();
extern void vif1FLUSH();

View File

@ -13,68 +13,8 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __VIFDMA_INTERNAL_H__
#define __VIFDMA_INTERNAL_H__
#pragma once
#include "VifDma.h"
enum VifModes
{
VIF_NORMAL_TO_MEM_MODE = 0,
VIF_NORMAL_FROM_MEM_MODE = 1,
VIF_CHAIN_MODE = 2
};
// Generic constants
static const unsigned int VIF0intc = 4;
static const unsigned int VIF1intc = 5;
typedef void (__fastcall *UNPACKFUNCTYPE)(u32 *dest, u32 *data);
typedef void (__fastcall *UNPACKFUNCTYPE_ODD)(u32 *dest, u32 *data, int size);
typedef int (*UNPACKPARTFUNCTYPESSE)(u32 *dest, u32 *data, int size);
#define create_unpack_u_type(bits) typedef void (__fastcall *UNPACKFUNCTYPE_U##bits)(u32 *dest, u##bits *data);
#define create_unpack_odd_u_type(bits) typedef void (__fastcall *UNPACKFUNCTYPE_ODD_U##bits)(u32 *dest, u##bits *data, int size);
#define create_unpack_s_type(bits) typedef void (__fastcall *UNPACKFUNCTYPE_S##bits)(u32 *dest, s##bits *data);
#define create_unpack_odd_s_type(bits) typedef void (__fastcall *UNPACKFUNCTYPE_ODD_S##bits)(u32 *dest, s##bits *data, int size);
#define create_some_unpacks(bits) \
create_unpack_u_type(bits); \
create_unpack_odd_u_type(bits); \
create_unpack_s_type(bits); \
create_unpack_odd_s_type(bits);
create_some_unpacks(32);
create_some_unpacks(16);
create_some_unpacks(8);
struct VIFUnpackFuncTable
{
UNPACKFUNCTYPE funcU;
UNPACKFUNCTYPE funcS;
UNPACKFUNCTYPE_ODD oddU; // needed for old-style vif only, remove when old vif is removed.
UNPACKFUNCTYPE_ODD oddS; // needed for old-style vif only, remove when old vif is removed.
u8 bsize; // currently unused
u8 dsize; // byte size of one channel
u8 gsize; // size of data in bytes used for each write cycle
u8 qsize; // used for unpack parts, num of vectors that
// will be decompressed from data for 1 cycle
};
extern const __aligned16 VIFUnpackFuncTable VIFfuncTable[32];
extern int g_vifCycles;
extern vifStruct *vif;
template<const u32 VIFdmanum> void VIFunpack(u32 *data, vifCode *v, u32 size);
template<const u32 VIFdmanum> void vuExecMicro(u32 addr);
extern void vif0FLUSH();
extern void vif1FLUSH();
extern int nVifUnpack (int idx, u8 *data);
extern void initNewVif (int idx);
extern void resetNewVif(int idx);
#endif

View File

@ -13,11 +13,10 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "PrecompiledHeader.h"
#include "Common.h"
#include "Vif.h"
#include "VifDma_internal.h"
#include "VifDma.h"
enum UnpackOffset {
OFFSET_X = 0,

56
pcsx2/Vif_Unpack.h Normal file
View File

@ -0,0 +1,56 @@
/* PCSX2 - PS2 Emulator for PCs
* Copyright (C) 2002-2009 PCSX2 Dev Team
*
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with PCSX2.
* If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
typedef void (__fastcall *UNPACKFUNCTYPE)(u32 *dest, u32 *data);
typedef void (__fastcall *UNPACKFUNCTYPE_ODD)(u32 *dest, u32 *data, int size);
typedef int (*UNPACKPARTFUNCTYPESSE)(u32 *dest, u32 *data, int size);
#define create_unpack_u_type(bits) typedef void (__fastcall *UNPACKFUNCTYPE_U##bits)(u32 *dest, u##bits *data);
#define create_unpack_odd_u_type(bits) typedef void (__fastcall *UNPACKFUNCTYPE_ODD_U##bits)(u32 *dest, u##bits *data, int size);
#define create_unpack_s_type(bits) typedef void (__fastcall *UNPACKFUNCTYPE_S##bits)(u32 *dest, s##bits *data);
#define create_unpack_odd_s_type(bits) typedef void (__fastcall *UNPACKFUNCTYPE_ODD_S##bits)(u32 *dest, s##bits *data, int size);
#define create_some_unpacks(bits) \
create_unpack_u_type(bits); \
create_unpack_odd_u_type(bits); \
create_unpack_s_type(bits); \
create_unpack_odd_s_type(bits);
create_some_unpacks(32);
create_some_unpacks(16);
create_some_unpacks(8);
struct VIFUnpackFuncTable
{
UNPACKFUNCTYPE funcU;
UNPACKFUNCTYPE funcS;
UNPACKFUNCTYPE_ODD oddU; // needed for old-style vif only, remove when old vif is removed.
UNPACKFUNCTYPE_ODD oddS; // needed for old-style vif only, remove when old vif is removed.
u8 bsize; // currently unused
u8 dsize; // byte size of one channel
u8 gsize; // size of data in bytes used for each write cycle
u8 qsize; // used for unpack parts, num of vectors that
// will be decompressed from data for 1 cycle
};
extern const __aligned16 VIFUnpackFuncTable VIFfuncTable[32];
extern int nVifUnpack (int idx, u8 *data);
extern void initNewVif (int idx);
extern void resetNewVif(int idx);

View File

@ -13,12 +13,10 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
// Old Vif Unpack Code
// Only here for testing/reference
// If newVif is defined and newVif1 isn't, vif1 will use this code
// same goes for vif0...
template void VIFunpack<0>(u32 *data, vifCode *v, u32 size);
template void VIFunpack<1>(u32 *data, vifCode *v, u32 size);
template<const u32 VIFdmanum> void VIFunpack(u32 *data, vifCode *v, u32 size) {
//if (!VIFdmanum) DevCon.WriteLn("vif#%d, size = %d [%x]", VIFdmanum, size, data);
VURegs * VU;

View File

@ -820,52 +820,56 @@
RelativePath="..\..\VifDma.h"
>
</File>
<File
RelativePath="..\..\VifDma_internal.h"
>
</File>
<File
RelativePath="..\..\VIFunpack.cpp"
>
</File>
<Filter
Name="newVif"
Name="Unpack"
>
<File
RelativePath="..\..\x86\newVif.h"
RelativePath="..\..\Vif_Unpack.cpp"
>
</File>
<File
RelativePath="..\..\x86\newVif_BlockBuffer.h"
RelativePath="..\..\Vif_Unpack.h"
>
</File>
<File
RelativePath="..\..\x86\newVif_HashBucket.h"
>
</File>
<File
RelativePath="..\..\x86\newVif_OldUnpack.inl"
>
</File>
<File
RelativePath="..\..\x86\newVif_Unpack.cpp"
RelativePath="..\..\Vif_Unpack.inl"
>
</File>
<Filter
Name="Dynarec"
Name="newVif"
>
<File
RelativePath="..\..\x86\VifUnpackSSE.cpp"
RelativePath="..\..\x86\newVif.h"
>
</File>
<File
RelativePath="..\..\x86\VifUnpackSSE.h"
RelativePath="..\..\x86\newVif_BlockBuffer.h"
>
</File>
<File
RelativePath="..\..\x86\VifUnpackSSE_Dynarec.cpp"
RelativePath="..\..\x86\newVif_HashBucket.h"
>
</File>
<File
RelativePath="..\..\x86\newVif_Unpack.cpp"
>
</File>
<Filter
Name="Dynarec"
>
<File
RelativePath="..\..\x86\newVif_Dynarec.cpp"
>
</File>
<File
RelativePath="..\..\x86\newVif_UnpackSSE.cpp"
>
</File>
<File
RelativePath="..\..\x86\newVif_UnpackSSE.h"
>
</File>
</Filter>
</Filter>
</Filter>
</Filter>

View File

@ -101,4 +101,3 @@ extern __aligned16 u32 nVifMask[3][4][4]; // [MaskNumber][CycleNumber][Vector]
static const bool useOldUnpack = 0; // Use code in newVif_OldUnpack.inl
static const bool newVifDynaRec = 1; // Use code in newVif_Dynarec.inl

View File

@ -18,7 +18,7 @@
// Jake.Stine (@gmail.com)
#include "PrecompiledHeader.h"
#include "VifUnpackSSE.h"
#include "newVif_UnpackSSE.h"
static __aligned16 nVifBlock _vBlock = {0};
static __pagealigned u8 nVifMemCmp[__pagesize];

View File

@ -19,9 +19,9 @@
#include "PrecompiledHeader.h"
#include "Common.h"
#include "VifDma_internal.h"
#include "VifDma.h"
#include "newVif.h"
#include "newVif_OldUnpack.inl"
#include "Vif_Unpack.inl"
__aligned16 nVifStruct nVif[2];
__aligned16 nVifCall nVifUpk[(2*2*16) *4]; // ([USN][Masking][Unpack Type]) [curCycle]

View File

@ -14,7 +14,7 @@
*/
#include "PrecompiledHeader.h"
#include "VifUnpackSSE.h"
#include "newVif_UnpackSSE.h"
#define xMOV8(regX, loc) xMOVSSZX(regX, loc)
#define xMOV16(regX, loc) xMOVSSZX(regX, loc)

View File

@ -16,7 +16,7 @@
#pragma once
#include "Common.h"
#include "VifDma_internal.h"
#include "VifDma.h"
#include "newVif.h"
#include <xmmintrin.h>