From 7d00eb7ec6a5cfbd68cc34c5e260ac526a192f87 Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Wed, 4 Mar 2009 21:32:48 +0000 Subject: [PATCH] SPU2-X: Resorted the mixer so that it's a little faster, and will be easier to apply some SSE2 opts in the future. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@680 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/spu2-x/src/Debug.cpp | 32 +++---- plugins/spu2-x/src/Mixer.cpp | 124 ++++++++++++++++------------ plugins/spu2-x/src/SaveStateSPU.cpp | 2 +- plugins/spu2-x/src/Spu2.cpp | 76 ++++++++--------- plugins/spu2-x/src/Spu2.h | 2 +- plugins/spu2-x/src/defs.h | 71 ++++++++-------- 6 files changed, 166 insertions(+), 141 deletions(-) diff --git a/plugins/spu2-x/src/Debug.cpp b/plugins/spu2-x/src/Debug.cpp index d0c3aa6319..dbf6293c91 100644 --- a/plugins/spu2-x/src/Debug.cpp +++ b/plugins/spu2-x/src/Debug.cpp @@ -135,18 +135,18 @@ void DoFullDump() fprintf(dump,"Interrupt Address: %x\n",Cores[c].IRQA); fprintf(dump,"DMA Transfer Start Address: %x\n",Cores[c].TSA); - fprintf(dump,"External Input to Direct Output (Left): %s\n",Cores[c].ExtDryL?"Yes":"No"); - fprintf(dump,"External Input to Direct Output (Right): %s\n",Cores[c].ExtDryR?"Yes":"No"); - fprintf(dump,"External Input to Effects (Left): %s\n",Cores[c].ExtWetL?"Yes":"No"); - fprintf(dump,"External Input to Effects (Right): %s\n",Cores[c].ExtWetR?"Yes":"No"); - fprintf(dump,"Sound Data Input to Direct Output (Left): %s\n",Cores[c].SndDryL?"Yes":"No"); - fprintf(dump,"Sound Data Input to Direct Output (Right): %s\n",Cores[c].SndDryR?"Yes":"No"); - fprintf(dump,"Sound Data Input to Effects (Left): %s\n",Cores[c].SndWetL?"Yes":"No"); - fprintf(dump,"Sound Data Input to Effects (Right): %s\n",Cores[c].SndWetR?"Yes":"No"); - fprintf(dump,"Voice Data Input to Direct Output (Left): %s\n",Cores[c].InpDryL?"Yes":"No"); - fprintf(dump,"Voice Data Input to Direct Output (Right): %s\n",Cores[c].InpDryR?"Yes":"No"); - fprintf(dump,"Voice Data Input to Effects (Left): %s\n",Cores[c].InpWetL?"Yes":"No"); - fprintf(dump,"Voice Data Input to Effects (Right): %s\n",Cores[c].InpWetR?"Yes":"No"); + fprintf(dump,"External Input to Direct Output (Left): %s\n",Cores[c].DryGate.ExtL?"Yes":"No"); + fprintf(dump,"External Input to Direct Output (Right): %s\n",Cores[c].DryGate.ExtR?"Yes":"No"); + fprintf(dump,"External Input to Effects (Left): %s\n",Cores[c].WetGate.ExtL?"Yes":"No"); + fprintf(dump,"External Input to Effects (Right): %s\n",Cores[c].WetGate.ExtR?"Yes":"No"); + fprintf(dump,"Sound Data Input to Direct Output (Left): %s\n",Cores[c].DryGate.SndL?"Yes":"No"); + fprintf(dump,"Sound Data Input to Direct Output (Right): %s\n",Cores[c].DryGate.SndR?"Yes":"No"); + fprintf(dump,"Sound Data Input to Effects (Left): %s\n",Cores[c].WetGate.SndL?"Yes":"No"); + fprintf(dump,"Sound Data Input to Effects (Right): %s\n",Cores[c].WetGate.SndR?"Yes":"No"); + fprintf(dump,"Voice Data Input to Direct Output (Left): %s\n",Cores[c].DryGate.InpL?"Yes":"No"); + fprintf(dump,"Voice Data Input to Direct Output (Right): %s\n",Cores[c].DryGate.InpR?"Yes":"No"); + fprintf(dump,"Voice Data Input to Effects (Left): %s\n",Cores[c].WetGate.InpL?"Yes":"No"); + fprintf(dump,"Voice Data Input to Effects (Right): %s\n",Cores[c].WetGate.InpR?"Yes":"No"); fprintf(dump,"IRQ Enabled: %s\n",Cores[c].IRQEnable?"Yes":"No"); fprintf(dump,"Effects Enabled: %s\n",Cores[c].FxEnable?"Yes":"No"); fprintf(dump,"Mute Enabled: %s\n",Cores[c].Mute?"Yes":"No"); @@ -197,10 +197,10 @@ void DoFullDump() fprintf(dump," - Pitch: %x\n",Cores[c].Voices[v].Pitch); fprintf(dump," - Modulated: %s\n",Cores[c].Voices[v].Modulated?"Yes":"No"); fprintf(dump," - Source: %s\n",Cores[c].Voices[v].Noise?"Noise":"Wave"); - fprintf(dump," - Direct Output for Left Channel: %s\n",Cores[c].Voices[v].DryL?"Yes":"No"); - fprintf(dump," - Direct Output for Right Channel: %s\n",Cores[c].Voices[v].DryR?"Yes":"No"); - fprintf(dump," - Effects Output for Left Channel: %s\n",Cores[c].Voices[v].WetL?"Yes":"No"); - fprintf(dump," - Effects Output for Right Channel: %s\n",Cores[c].Voices[v].WetR?"Yes":"No"); + fprintf(dump," - Direct Output for Left Channel: %s\n",Cores[c].VoiceGates[v].DryL?"Yes":"No"); + fprintf(dump," - Direct Output for Right Channel: %s\n",Cores[c].VoiceGates[v].DryR?"Yes":"No"); + fprintf(dump," - Effects Output for Left Channel: %s\n",Cores[c].VoiceGates[v].WetL?"Yes":"No"); + fprintf(dump," - Effects Output for Right Channel: %s\n",Cores[c].VoiceGates[v].WetR?"Yes":"No"); fprintf(dump," - Loop Start Address: %x\n",Cores[c].Voices[v].LoopStartA); fprintf(dump," - Sound Start Address: %x\n",Cores[c].Voices[v].StartA); fprintf(dump," - Next Data Address: %x\n",Cores[c].Voices[v].NextA); diff --git a/plugins/spu2-x/src/Mixer.cpp b/plugins/spu2-x/src/Mixer.cpp index d5254e6871..b02282827c 100644 --- a/plugins/spu2-x/src/Mixer.cpp +++ b/plugins/spu2-x/src/Mixer.cpp @@ -64,10 +64,12 @@ __forceinline s32 clamp_mix( s32 x, u8 bitshift ) return GetClamped( x, -0x8000<>vc) & 1) { @@ -1211,8 +1213,8 @@ void StartVoices(int core, u32 value) if(MsgKeyOnOff()) ConLog(" * SPU2: KeyOn: C%dV%02d: SSA: %8x; M: %s%s%s%s; H: %02x%02x; P: %04x V: %04x/%04x; ADSR: %04x%04x\n", core,vc,thisvc.StartA, - (thisvc.DryL)?"+":"-",(thisvc.DryR)?"+":"-", - (thisvc.WetL)?"+":"-",(thisvc.WetR)?"+":"-", + (Cores[core].VoiceGates[vc].DryL)?"+":"-",(Cores[core].VoiceGates[vc].DryR)?"+":"-", + (Cores[core].VoiceGates[vc].WetL)?"+":"-",(Cores[core].VoiceGates[vc].WetR)?"+":"-", *(u8*)GetMemPtr(thisvc.StartA),*(u8 *)GetMemPtr((thisvc.StartA)+1), thisvc.Pitch, thisvc.Volume.Left.Value>>16,thisvc.Volume.Right.Value>>16, @@ -1225,7 +1227,7 @@ void StartVoices(int core, u32 value) void StopVoices(int core, u32 value) { if( value == 0 ) return; - for( u8 vc=0; vc<24; vc++ ) + for( u8 vc=0; vc>vc) & 1) { diff --git a/plugins/spu2-x/src/Spu2.h b/plugins/spu2-x/src/Spu2.h index 3e4c593b2d..f98dc1b258 100644 --- a/plugins/spu2-x/src/Spu2.h +++ b/plugins/spu2-x/src/Spu2.h @@ -210,7 +210,7 @@ extern void __fastcall ReadInput( uint core, StereoOut32& PData ); extern void Mix(); extern s32 clamp_mix( s32 x, u8 bitshift=0 ); -extern void clamp_mix( StereoOut32& sample, u8 bitshift=0 ); +extern StereoOut32 clamp_mix( const StereoOut32& sample, u8 bitshift=0 ); extern void Reverb_AdvanceBuffer( V_Core& thiscore ); extern StereoOut32 DoReverb( V_Core& thiscore, const StereoOut32& Input ); extern s32 MulShr32( s32 srcval, s32 mulval ); diff --git a/plugins/spu2-x/src/defs.h b/plugins/spu2-x/src/defs.h index ec023ccd6b..7647ee6a7f 100644 --- a/plugins/spu2-x/src/defs.h +++ b/plugins/spu2-x/src/defs.h @@ -128,14 +128,6 @@ struct V_Voice s8 Modulated; // Source (Wave/Noise) s8 Noise; -// Direct Output for Left Channel - s32 DryL; -// Direct Output for Right Channel - s32 DryR; -// Effect Output for Left Channel - s32 WetL; -// Effect Output for Right Channel - s32 WetR; // Loop Start address (also Reg_LSAH/L) u32 LoopStartA; // Sound Start address (also Reg_SSAH/L) @@ -309,17 +301,49 @@ struct V_CoreRegs u16 _1AC; }; +struct V_VoiceGates +{ + s16 DryL; // 'AND Gate' for Direct Output to Left Channel + s16 DryR; // 'AND Gate' for Direct Output for Right Channel + s16 WetL; // 'AND Gate' for Effect Output for Left Channel + s16 WetR; // 'AND Gate' for Effect Output for Right Channel +}; + +union V_CoreGates +{ + struct + { + u64 lo; + u64 hi; + } v128; + + struct + { + s16 InpL; // Sound Data Input to Direct Output (Left) + s16 InpR; // Sound Data Input to Direct Output (Right) + s16 SndL; // Voice Data to Direct Output (Left) + s16 SndR; // Voice Data to Direct Output (Right) + s16 ExtL; // External Input to Direct Output (Left) + s16 ExtR; // External Input to Direct Output (Right) + }; +}; + struct V_Core { -// Core Voices - V_Voice Voices[24]; + static const uint NumVoices = 24; +// Core Voices + V_Voice Voices[NumVoices]; + V_VoiceGates VoiceGates[NumVoices]; V_VolumeSlideLR MasterVol;// Master Volume - + V_VolumeLR ExtVol; // Volume for External Data Input V_VolumeLR InpVol; // Volume for Sound Data Input V_VolumeLR FxVol; // Volume for Output from Effects + + V_CoreGates DryGate; + V_CoreGates WetGate; // Interrupt Address u32 IRQA; @@ -327,30 +351,7 @@ struct V_Core u32 TSA; // DMA Transfer Data Address (Internal...) u32 TDA; -// External Input to Direct Output (Left) - s32 ExtDryL; -// External Input to Direct Output (Right) - s32 ExtDryR; -// External Input to Effects (Left) - s32 ExtWetL; -// External Input to Effects (Right) - s32 ExtWetR; -// Sound Data Input to Direct Output (Left) - s32 InpDryL; -// Sound Data Input to Direct Output (Right) - s32 InpDryR; -// Sound Data Input to Effects (Left) - s32 InpWetL; -// Sound Data Input to Effects (Right) - s32 InpWetR; -// Voice Data to Direct Output (Left) - s32 SndDryL; -// Voice Data to Direct Output (Right) - s32 SndDryR; -// Voice Data to Effects (Left) - s32 SndWetL; -// Voice Data to Effects (Right) - s32 SndWetR; + // Interrupt Enable s8 IRQEnable; // DMA related?