From b03162747cb83f1f81bdc9630801b867e389c3e8 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Tue, 6 Jan 2015 23:45:43 +0100 Subject: [PATCH] sVU: add an option to remove it The goal is to reduce the burden for new architecture port. Patch is mostly inspired from 3kinox initial patch. The diff are */ used ifdef instead of raw removal */ gui don't rely on UseMicroVU* option */ completely remove sVU_micro.* file --- cmake/BuildParameters.cmake | 11 +++++++++++ pcsx2/CMakeLists.txt | 21 ++++++++++++--------- pcsx2/System.cpp | 23 +++++++++++++++++++++-- pcsx2/System.h | 2 ++ pcsx2/gui/AppInit.cpp | 13 +++++++++++-- pcsx2/gui/Panels/CpuPanel.cpp | 16 ++++++++++++++++ pcsx2/x86/iCore.h | 2 ++ pcsx2/x86/iFPU.cpp | 6 ++++++ pcsx2/x86/iFPU.h | 3 +++ pcsx2/x86/iFPUd.cpp | 3 +++ pcsx2/x86/ix86-32/iR5900-32.cpp | 6 ++++++ pcsx2/x86/ix86-32/iR5900Templates.cpp | 4 +++- pcsx2/x86/sVU_Micro.cpp | 2 -- pcsx2/x86/sVU_Micro.h | 2 -- 14 files changed, 96 insertions(+), 18 deletions(-) diff --git a/cmake/BuildParameters.cmake b/cmake/BuildParameters.cmake index b70158ef54..ce97aa1a54 100644 --- a/cmake/BuildParameters.cmake +++ b/cmake/BuildParameters.cmake @@ -17,6 +17,11 @@ # Game DB installation path : -DGAMEINDEX_DIR="/usr/share/games/pcsx2" #------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- +# Misc option +#------------------------------------------------------------------------------- +option(DISABLE_SVU "Disable superVU (don't use it)") + #------------------------------------------------------------------------------- # Graphical option #------------------------------------------------------------------------------- @@ -129,6 +134,9 @@ elseif(${PCSX2_TARGET_ARCHITECTURES} MATCHES "x86_64") # x86_64 requires -fPIC set(CMAKE_POSITION_INDEPENDENT_CODE ON) + # SuperVU will not be ported + set(DISABLE_SVU TRUE) + if (DISABLE_ADVANCE_SIMD) set(ARCH_FLAG "-msse -msse2") else() @@ -213,6 +221,9 @@ endif() # Set some default compiler flags #------------------------------------------------------------------------------- set(COMMON_FLAG "-pipe -std=c++0x -fvisibility=hidden -pthread") +if (DISABLE_SVU) + set(COMMON_FLAG "${COMMON_FLAG} -DDISABLE_SVU") +endif() set(HARDENING_FLAG "-D_FORTIFY_SOURCE=2 -Wformat -Wformat-security") # -Wno-attributes: "always_inline function might not be inlinable" <= real spam (thousand of warnings!!!) # -Wno-missing-field-initializers: standard allow to init only the begin of struct/array in static init. Just a silly warning. diff --git a/pcsx2/CMakeLists.txt b/pcsx2/CMakeLists.txt index 71243866e6..871713e09c 100644 --- a/pcsx2/CMakeLists.txt +++ b/pcsx2/CMakeLists.txt @@ -559,11 +559,15 @@ set(pcsx2x86Sources x86/newVif_Dynarec.cpp x86/newVif_Unpack.cpp x86/newVif_UnpackSSE.cpp + ) +if (NOT DISABLE_SVU) + set(pcsx2x86Sources ${pcsx2x86Sources} x86/sVU_Lower.cpp x86/sVU_Micro.cpp x86/sVU_Upper.cpp x86/sVU_zerorec.cpp - ) + ) +endif() # x86 headers set(pcsx2x86Headers @@ -602,10 +606,6 @@ set(pcsx2x86Headers x86/newVif.h x86/newVif_HashBucket.h x86/newVif_UnpackSSE.h - x86/sVU_Compare.h - x86/sVU_Debug.h - x86/sVU_Micro.h - x86/sVU_zerorec.h ) # colect .asm files @@ -614,11 +614,14 @@ set(pcsx2AsmFiles x86/ix86-32/aVif_proc-32.asm) # collect .S files -set(pcsx2SSources - x86/aVUzerorec.S) +if (NOT DISABLE_SVU) + set(pcsx2SSources x86/aVUzerorec.S) + # change language of .S-files to c++ + set_source_files_properties(${pcsx2SSources} PROPERTIES LANGUAGE CXX) +else() + set(pcsx2SSources "") +endif() -# change language of .S-files to c++ -set_source_files_properties(${pcsx2SSources} PROPERTIES LANGUAGE CXX) # common Sources set(Common diff --git a/pcsx2/System.cpp b/pcsx2/System.cpp index 0a06a91ac1..25d15610a7 100644 --- a/pcsx2/System.cpp +++ b/pcsx2/System.cpp @@ -331,10 +331,11 @@ CpuInitializer< CpuType >::~CpuInitializer() throw() class CpuInitializerSet { public: +#ifndef DISABLE_SVU // Note: Allocate sVU first -- it's the most picky. - CpuInitializer superVU0; CpuInitializer superVU1; +#endif CpuInitializer microVU0; CpuInitializer microVU1; @@ -491,10 +492,12 @@ bool SysCpuProviderPack::IsRecAvailable_MicroVU1() const { return CpuProviders-> BaseException* SysCpuProviderPack::GetException_MicroVU0() const { return CpuProviders->microVU0.ExThrown; } BaseException* SysCpuProviderPack::GetException_MicroVU1() const { return CpuProviders->microVU1.ExThrown; } +#ifndef DISABLE_SVU bool SysCpuProviderPack::IsRecAvailable_SuperVU0() const { return CpuProviders->superVU0.IsAvailable(); } bool SysCpuProviderPack::IsRecAvailable_SuperVU1() const { return CpuProviders->superVU1.IsAvailable(); } BaseException* SysCpuProviderPack::GetException_SuperVU0() const { return CpuProviders->superVU0.ExThrown; } BaseException* SysCpuProviderPack::GetException_SuperVU1() const { return CpuProviders->superVU1.ExThrown; } +#endif void SysCpuProviderPack::CleanupMess() throw() @@ -522,10 +525,16 @@ bool SysCpuProviderPack::HadSomeFailures( const Pcsx2Config::RecompilerOptions& { return (recOpts.EnableEE && !IsRecAvailable_EE()) || (recOpts.EnableIOP && !IsRecAvailable_IOP()) || +#ifndef DISABLE_SVU (recOpts.EnableVU0 && recOpts.UseMicroVU0 && !IsRecAvailable_MicroVU0()) || (recOpts.EnableVU1 && recOpts.UseMicroVU0 && !IsRecAvailable_MicroVU1()) || (recOpts.EnableVU0 && !recOpts.UseMicroVU0 && !IsRecAvailable_SuperVU0()) || - (recOpts.EnableVU1 && !recOpts.UseMicroVU1 && !IsRecAvailable_SuperVU1()); + (recOpts.EnableVU1 && !recOpts.UseMicroVU1 && !IsRecAvailable_SuperVU1()) +#else + (recOpts.EnableVU0 && !IsRecAvailable_MicroVU0()) || + (recOpts.EnableVU1 && !IsRecAvailable_MicroVU1()) +#endif + ; } @@ -541,12 +550,21 @@ void SysCpuProviderPack::ApplyConfig() const CpuVU1 = CpuProviders->interpVU1; if( EmuConfig.Cpu.Recompiler.EnableVU0 ) +#ifndef DISABLE_SVU CpuVU0 = EmuConfig.Cpu.Recompiler.UseMicroVU0 ? (BaseVUmicroCPU*)CpuProviders->microVU0 : (BaseVUmicroCPU*)CpuProviders->superVU0; +#else + CpuVU0 = (BaseVUmicroCPU*)CpuProviders->microVU0; +#endif if( EmuConfig.Cpu.Recompiler.EnableVU1 ) +#ifndef DISABLE_SVU CpuVU1 = EmuConfig.Cpu.Recompiler.UseMicroVU1 ? (BaseVUmicroCPU*)CpuProviders->microVU1 : (BaseVUmicroCPU*)CpuProviders->superVU1; +#else + CpuVU1 = (BaseVUmicroCPU*)CpuProviders->microVU1; +#endif } +#ifndef DISABLE_SVU // This is a semi-hacky function for convenience BaseVUmicroCPU* SysCpuProviderPack::getVUprovider(int whichProvider, int vuIndex) const { switch (whichProvider) { @@ -556,6 +574,7 @@ BaseVUmicroCPU* SysCpuProviderPack::getVUprovider(int whichProvider, int vuIndex } return NULL; } +#endif // Resets all PS2 cpu execution caches, which does not affect that actual PS2 state/condition. // This can be called at any time outside the context of a Cpu->Execute() block without diff --git a/pcsx2/System.h b/pcsx2/System.h index f68dcf7905..75c855d20a 100644 --- a/pcsx2/System.h +++ b/pcsx2/System.h @@ -141,7 +141,9 @@ public: virtual ~SysCpuProviderPack() throw(); void ApplyConfig() const; +#ifndef DISABLE_SVU BaseVUmicroCPU* getVUprovider(int whichProvider, int vuIndex) const; +#endif bool HadSomeFailures( const Pcsx2Config::RecompilerOptions& recOpts ) const; diff --git a/pcsx2/gui/AppInit.cpp b/pcsx2/gui/AppInit.cpp index 2d7cc243d8..b59094025b 100644 --- a/pcsx2/gui/AppInit.cpp +++ b/pcsx2/gui/AppInit.cpp @@ -167,16 +167,25 @@ void Pcsx2App::AllocateCoreStuffs() { scrollableTextArea->AppendText( L"* microVU0\n\t" + ex->FormatDisplayMessage() + L"\n\n" ); recOps.UseMicroVU0 = false; +#ifndef DISABLE_SVU recOps.EnableVU0 = recOps.EnableVU0 && m_CpuProviders->IsRecAvailable_SuperVU0(); +#else + recOps.EnableVU1 = false; +#endif } if( BaseException* ex = m_CpuProviders->GetException_MicroVU1() ) { scrollableTextArea->AppendText( L"* microVU1\n\t" + ex->FormatDisplayMessage() + L"\n\n" ); recOps.UseMicroVU1 = false; +#ifndef DISABLE_SVU recOps.EnableVU1 = recOps.EnableVU1 && m_CpuProviders->IsRecAvailable_SuperVU1(); +#else + recOps.EnableVU1 = false; +#endif } +#ifndef DISABLE_SVU if( BaseException* ex = m_CpuProviders->GetException_SuperVU0() ) { scrollableTextArea->AppendText( L"* SuperVU0\n\t" + ex->FormatDisplayMessage() + L"\n\n" ); @@ -190,9 +199,9 @@ void Pcsx2App::AllocateCoreStuffs() recOps.UseMicroVU1 = m_CpuProviders->IsRecAvailable_MicroVU1(); recOps.EnableVU1 = recOps.EnableVU1 && recOps.UseMicroVU1; } +#endif - exconf += exconf.Heading( pxE( L"Note: Recompilers are not necessary for PCSX2 to run, however they typically improve emulation speed substantially. You may have to manually re-enable the recompilers listed above, if you resolve the errors." ) - ); + exconf += exconf.Heading(pxE( L"Note: Recompilers are not necessary for PCSX2 to run, however they typically improve emulation speed substantially. You may have to manually re-enable the recompilers listed above, if you resolve the errors." )); pxIssueConfirmation( exconf, MsgButtons().OK() ); } diff --git a/pcsx2/gui/Panels/CpuPanel.cpp b/pcsx2/gui/Panels/CpuPanel.cpp index 87d92f1000..6ec70b9e18 100644 --- a/pcsx2/gui/Panels/CpuPanel.cpp +++ b/pcsx2/gui/Panels/CpuPanel.cpp @@ -185,8 +185,10 @@ Panels::CpuPanelVU::CpuPanelVU( wxWindow* parent ) RadioPanelItem(_("microVU Recompiler")) .SetToolTip(_("New Vector Unit recompiler with much improved compatibility. Recommended.")), +#ifndef DISABLE_SVU RadioPanelItem(_("superVU Recompiler [legacy]")) .SetToolTip(_("Useful for diagnosing bugs or clamping issues in the new mVU recompiler.")) +#endif }; m_panel_VU0 = &(new pxRadioPanel( this, tbl_CpuTypes_VU )) ->SetDefaultItem( 1 ); @@ -274,8 +276,10 @@ void Panels::CpuPanelVU::Apply() recOps.EnableVU0 = m_panel_VU0->GetSelection() > 0; recOps.EnableVU1 = m_panel_VU1->GetSelection() > 0; +#ifndef DISABLE_SVU recOps.UseMicroVU0 = m_panel_VU0->GetSelection() == 1; recOps.UseMicroVU1 = m_panel_VU1->GetSelection() == 1; +#endif } void Panels::CpuPanelVU::AppStatusEvent_OnSettingsApplied() @@ -289,21 +293,33 @@ void Panels::CpuPanelVU::ApplyConfigToGui( AppConfig& configToApply, int flags ) m_panel_VU1->Enable(true); m_panel_VU0->EnableItem( 1, true); +#ifndef DISABLE_SVU m_panel_VU0->EnableItem( 2, true); +#endif m_panel_VU1->EnableItem( 1, true); +#ifndef DISABLE_SVU m_panel_VU1->EnableItem( 2, true); +#endif Pcsx2Config::RecompilerOptions& recOps( configToApply.EmuOptions.Cpu.Recompiler ); +#ifndef DISABLE_SVU if( recOps.UseMicroVU0 ) m_panel_VU0->SetSelection( recOps.EnableVU0 ? 1 : 0 ); else m_panel_VU0->SetSelection( recOps.EnableVU0 ? 2 : 0 ); +#else + m_panel_VU0->SetSelection( recOps.EnableVU0 ? 1 : 0 ); +#endif +#ifndef DISABLE_SVU if( recOps.UseMicroVU1 ) m_panel_VU1->SetSelection( recOps.EnableVU1 ? 1 : 0 ); else m_panel_VU1->SetSelection( recOps.EnableVU1 ? 2 : 0 ); +#else + m_panel_VU1->SetSelection( recOps.EnableVU1 ? 1 : 0 ); +#endif this->Enable(!configToApply.EnablePresets); m_panel_VU0->Enable(!configToApply.EnablePresets); diff --git a/pcsx2/x86/iCore.h b/pcsx2/x86/iCore.h index 388e418d7f..665cb310ee 100644 --- a/pcsx2/x86/iCore.h +++ b/pcsx2/x86/iCore.h @@ -50,7 +50,9 @@ // used in VU recs #define PROCESS_VU_UPDATEFLAGS 0x10 +#ifndef DISABLE_SVU #define PROCESS_VU_SUPER 0x40 // set if using supervu recompilation +#endif #define PROCESS_VU_COP2 0x80 // simple cop2 #define EEREC_S (((info)>>8)&0xf) diff --git a/pcsx2/x86/iFPU.cpp b/pcsx2/x86/iFPU.cpp index 1c9999c202..d069f72580 100644 --- a/pcsx2/x86/iFPU.cpp +++ b/pcsx2/x86/iFPU.cpp @@ -20,10 +20,16 @@ #include "R5900OpcodeTables.h" #include "iR5900.h" #include "iFPU.h" + +#ifndef DISABLE_SVU #include "sVU_Micro.h" +#endif using namespace x86Emitter; +const __aligned16 u32 g_minvals[4] = {0xff7fffff, 0xff7fffff, 0xff7fffff, 0xff7fffff}; +const __aligned16 u32 g_maxvals[4] = {0x7f7fffff, 0x7f7fffff, 0x7f7fffff, 0x7f7fffff}; + //------------------------------------------------------------------ namespace R5900 { namespace Dynarec { diff --git a/pcsx2/x86/iFPU.h b/pcsx2/x86/iFPU.h index 8f7e6f8816..bd5a0ae882 100644 --- a/pcsx2/x86/iFPU.h +++ b/pcsx2/x86/iFPU.h @@ -16,6 +16,9 @@ #ifndef __IFPU_H__ #define __IFPU_H__ +extern const __aligned16 u32 g_minvals[4]; +extern const __aligned16 u32 g_maxvals[4]; + namespace R5900 { namespace Dynarec { diff --git a/pcsx2/x86/iFPUd.cpp b/pcsx2/x86/iFPUd.cpp index bd89b39525..f2a20ddfb6 100644 --- a/pcsx2/x86/iFPUd.cpp +++ b/pcsx2/x86/iFPUd.cpp @@ -21,7 +21,10 @@ #include "x86emitter/x86emitter.h" #include "iR5900.h" #include "iFPU.h" + +#ifndef DISABLE_SVU #include "sVU_Micro.h" +#endif /* This is a version of the FPU that emulates an exponent of 0xff and overflow/underflow flags */ diff --git a/pcsx2/x86/ix86-32/iR5900-32.cpp b/pcsx2/x86/ix86-32/iR5900-32.cpp index c4bbfd130a..768ee5c183 100644 --- a/pcsx2/x86/ix86-32/iR5900-32.cpp +++ b/pcsx2/x86/ix86-32/iR5900-32.cpp @@ -1972,8 +1972,10 @@ StartRecomp: for(i = startpc; i < s_nEndBlock; i += 4) { +#ifndef DISABLE_SVU // superVU hack: it needs vucycles, for some reason. >_< extern int vucycle; +#endif g_pCurInstInfo++; cpuRegs.code = *(u32*)PSM(i); @@ -1983,7 +1985,9 @@ StartRecomp: if( !usecop2 ) { // init +#ifndef DISABLE_SVU vucycle = 0; +#endif usecop2 = 1; } @@ -1992,9 +1996,11 @@ StartRecomp: continue; } +#ifndef DISABLE_SVU // fixme - This should be based on the cycle count of the current EE // instruction being analyzed. if( usecop2 ) vucycle++; +#endif } // This *is* important because g_pCurInstInfo is checked a bit later on and diff --git a/pcsx2/x86/ix86-32/iR5900Templates.cpp b/pcsx2/x86/ix86-32/iR5900Templates.cpp index 07928cb88c..1d4ab4afce 100644 --- a/pcsx2/x86/ix86-32/iR5900Templates.cpp +++ b/pcsx2/x86/ix86-32/iR5900Templates.cpp @@ -22,11 +22,13 @@ #include "iMMI.h" #include "iFPU.h" #include "iCOP0.h" -#include "sVU_Micro.h" #include "VU.h" #include "VUmicro.h" +#ifndef DISABLE_SVU +#include "sVU_Micro.h" #include "sVU_zerorec.h" +#endif #include "vtlb.h" diff --git a/pcsx2/x86/sVU_Micro.cpp b/pcsx2/x86/sVU_Micro.cpp index e1021cc07f..2be3bdf1c3 100644 --- a/pcsx2/x86/sVU_Micro.cpp +++ b/pcsx2/x86/sVU_Micro.cpp @@ -88,8 +88,6 @@ int vucycle; const __aligned16 float s_fones[8] = {1.0f, 1.0f, 1.0f, 1.0f, -1.0f, -1.0f, -1.0f, -1.0f}; const __aligned16 u32 s_mask[4] = {0x007fffff, 0x007fffff, 0x007fffff, 0x007fffff}; const __aligned16 u32 s_expmask[4] = {0x7f800000, 0x7f800000, 0x7f800000, 0x7f800000}; -const __aligned16 u32 g_minvals[4] = {0xff7fffff, 0xff7fffff, 0xff7fffff, 0xff7fffff}; -const __aligned16 u32 g_maxvals[4] = {0x7f7fffff, 0x7f7fffff, 0x7f7fffff, 0x7f7fffff}; const __aligned16 u32 const_clip[8] = {0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff, 0x80000000, 0x80000000, 0x80000000, 0x80000000}; diff --git a/pcsx2/x86/sVU_Micro.h b/pcsx2/x86/sVU_Micro.h index 587f50ecb5..2a528f0980 100644 --- a/pcsx2/x86/sVU_Micro.h +++ b/pcsx2/x86/sVU_Micro.h @@ -59,8 +59,6 @@ extern vFloat vFloats4_useEAX[16]; extern const __aligned16 float s_fones[8]; extern const __aligned16 u32 s_mask[4]; extern const __aligned16 u32 s_expmask[4]; -extern const __aligned16 u32 g_minvals[4]; -extern const __aligned16 u32 g_maxvals[4]; extern const __aligned16 u32 const_clip[8]; u32 GetVIAddr(VURegs * VU, int reg, int read, int info);