From: <man...@us...> - 2013-05-24 20:22:20
|
Revision: 2183 http://sourceforge.net/p/modplug/code/2183 Author: manxorist Date: 2013-05-24 20:22:12 +0000 (Fri, 24 May 2013) Log Message: ----------- [Mod] "Enable SSE acceleration" enabled/disabled sse (or 3dnow) inline asm exactly in two places: float<->int conversions and the equalizer. Other codepaths in OpenMPT ignored this settings probably since forever. Also, SSE acceleration of course did get automatically disabled if the CPU does not support these instructions. Remove the user visiable option alltogether and always use SSE when the CPU supports it. [Ref] Rename SysInfo to ProcSupport which describes its semantics way better. [Ref] Move the procsupport flags out of CSoundFile into a global variable in mmx_mix.cpp. Initialize it once at program startup. Also, disable use of inline asm in libopenmpt to get better test exposure of the C implementations on WIN32. [Ref] Move all these float<->int conversion functiosn into mmx_mix.cpp and export exacly one wrapper from there. [Ref] Do some related cleanups. Modified Paths: -------------- trunk/OpenMPT/common/BuildSettings.h trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/sounddsp/EQ.cpp trunk/OpenMPT/sounddsp/EQ.h trunk/OpenMPT/soundlib/Fastmix.cpp trunk/OpenMPT/soundlib/Mmx_mix.cpp trunk/OpenMPT/soundlib/Snd_defs.h trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/common/BuildSettings.h =================================================================== --- trunk/OpenMPT/common/BuildSettings.h 2013-05-24 20:01:34 UTC (rev 2182) +++ trunk/OpenMPT/common/BuildSettings.h 2013-05-24 20:22:12 UTC (rev 2183) @@ -16,18 +16,25 @@ -// Do not use precompiled headers (prevents include of commonly used headers in stdafx.h) #ifdef MODPLUG_TRACKER + //#define NO_PCH + +// Use inline assembly at all +#define ENABLE_ASM + #else + +// Do not use precompiled headers (prevents include of commonly used headers in stdafx.h) #define NO_PCH + +// Do not use inline asm in library builds. There is just about no codepath which would use it anyway. +//#define ENABLE_ASM + #endif -// Use inline assembly at all -#define ENABLE_ASM - // inline assembly requires MSVC compiler #if defined(ENABLE_ASM) && MPT_COMPILER_MSVC && defined(_M_IX86) Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-05-24 20:01:34 UTC (rev 2182) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2013-05-24 20:22:12 UTC (rev 2183) @@ -127,20 +127,6 @@ if(TrackerSettings::Instance().m_MixerSettings.MixerFlags & SNDMIX_SOFTPANNING) CheckDlgButton(IDC_CHECK2, MF_CHECKED); if(m_SoundDeviceFlags & SNDDEV_OPTIONS_EXCLUSIVE) CheckDlgButton(IDC_CHECK4, MF_CHECKED); if(m_SoundDeviceFlags & SNDDEV_OPTIONS_BOOSTTHREADPRIORITY) CheckDlgButton(IDC_CHECK5, MF_CHECKED); - // Multimedia extensions -#ifdef ENABLE_ASM - if(TrackerSettings::Instance().m_MixerSettings.MixerFlags & SNDMIX_ENABLEMMX) CheckDlgButton(IDC_CHECK3, MF_CHECKED); - ::EnableWindow(::GetDlgItem(m_hWnd, IDC_CHECK3), (CSoundFile::GetSysInfo() & PROCSUPPORT_MMX) ? TRUE : FALSE); - if(CSoundFile::GetSysInfo() & PROCSUPPORT_SSE) - { - SetDlgItemText(IDC_CHECK3, _T("Enable SSE acceleration")); - } else if (CSoundFile::GetSysInfo() & PROCSUPPORT_3DNOW) - { - SetDlgItemText(IDC_CHECK3, _T("Enable 3DNow! acceleration")); - } -#else - ::ShowWindow(::GetDlgItem(m_hWnd, IDC_CHECK3), SW_HIDE); -#endif // Sampling Rate UpdateSampleRates(m_nSoundDevice); @@ -445,9 +431,6 @@ void COptionsSoundcard::OnOK() //---------------------------- { -#ifdef ENABLE_ASM - if(IsDlgButtonChecked(IDC_CHECK3)) TrackerSettings::Instance().m_MixerSettings.MixerFlags |= SNDMIX_ENABLEMMX; else TrackerSettings::Instance().m_MixerSettings.MixerFlags &= ~SNDMIX_ENABLEMMX; -#endif if(IsDlgButtonChecked(IDC_CHECK2)) TrackerSettings::Instance().m_MixerSettings.MixerFlags |= SNDMIX_SOFTPANNING; else TrackerSettings::Instance().m_MixerSettings.MixerFlags &= ~SNDMIX_SOFTPANNING; m_SoundDeviceFlags = 0; if(IsDlgButtonChecked(IDC_CHECK4)) m_SoundDeviceFlags |= SNDDEV_OPTIONS_EXCLUSIVE; @@ -643,7 +626,7 @@ } } m_CbnReverbPreset.SetCurSel(nSel); - if (!(CSoundFile::GetSysInfo() & PROCSUPPORT_MMX)) + if(!(GetProcSupport() & PROCSUPPORT_MMX)) { ::EnableWindow(::GetDlgItem(m_hWnd, IDC_CHECK6), FALSE); m_SbReverbDepth.EnableWindow(FALSE); Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2013-05-24 20:01:34 UTC (rev 2182) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2013-05-24 20:22:12 UTC (rev 2183) @@ -868,14 +868,13 @@ // Initialize Audio #ifdef ENABLE_ASM + InitProcSupport(); // rough heuristic to select less cpu consuming defaults for old CPUs - DWORD sysinfo = CSoundFile::GetSysInfo(); - if(sysinfo & PROCSUPPORT_MMX) + if(GetProcSupport() & PROCSUPPORT_MMX) { - TrackerSettings::Instance().m_MixerSettings.MixerFlags |= SNDMIX_ENABLEMMX; TrackerSettings::Instance().m_ResamplerSettings.SrcMode = SRCMODE_SPLINE; } - if(sysinfo & PROCSUPPORT_MMXEX) + if(GetProcSupport() & PROCSUPPORT_MMXEX) { TrackerSettings::Instance().m_ResamplerSettings.SrcMode = SRCMODE_POLYPHASE; } Modified: trunk/OpenMPT/mptrack/View_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_smp.cpp 2013-05-24 20:01:34 UTC (rev 2182) +++ trunk/OpenMPT/mptrack/View_smp.cpp 2013-05-24 20:22:12 UTC (rev 2183) @@ -673,10 +673,6 @@ int32 y0 = 0, xmax, poshi; uint64 posincr, posfrac; -#ifdef ENABLE_ASM - DWORD sysinfo = CSoundFile::GetSysInfo(); -#endif - if (len <= 0) return; smplsize = (uFlags & CHN_16BIT) ? 2 : 1; if (uFlags & CHN_STEREO) smplsize *= 2; @@ -720,7 +716,7 @@ smin = 32767; smax = -32768; #ifdef ENABLE_MMX - if (sysinfo & PROCSUPPORT_MMXEX) + if(GetProcSupport() & PROCSUPPORT_MMXEX) { mmxex_findminmax16(p, scanlen, smplsize, &smin, &smax); } else @@ -743,7 +739,7 @@ smin = 127; smax = -128; #ifdef ENABLE_MMX - if (sysinfo & PROCSUPPORT_MMXEX) + if(GetProcSupport() & PROCSUPPORT_MMXEX) { mmxex_findminmax8(p, scanlen, smplsize, &smin, &smax); } else Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2013-05-24 20:01:34 UTC (rev 2182) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2013-05-24 20:22:12 UTC (rev 2183) @@ -3415,7 +3415,7 @@ #ifdef ENABLE_MMX #ifdef ENABLE_SSE - if(CSoundFile::GetSysInfo() & PROCSUPPORT_SSE) + if(GetProcSupport() & PROCSUPPORT_SSE) { SSEInterleaveFloatToInt16(inputs[0], inputs[1], samples); m_pMediaProcess->Process(samples * 2 * sizeof(int16), reinterpret_cast<BYTE *>(m_pMixBuffer), m_DataTime, DMO_INPLACE_NORMAL); Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2013-05-24 20:01:34 UTC (rev 2182) +++ trunk/OpenMPT/mptrack/mptrack.rc 2013-05-24 20:22:12 UTC (rev 2183) @@ -1267,7 +1267,6 @@ LTEXT "Max. Polyphony:",IDC_STATIC,12,102,57,12,SS_CENTERIMAGE COMBOBOX IDC_COMBO4,78,102,72,88,CBS_DROPDOWNLIST | WS_TABSTOP CONTROL "Soft Panning",IDC_CHECK2,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,138,78,12 - CONTROL "Enable MMX Acceleration",IDC_CHECK3,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,96,138,156,12 LTEXT "Stereo Separation:",IDC_STATIC,12,157,62,8 LTEXT "100%",IDC_TEXT1,80,157,20,8 RTEXT "Low",IDC_STATIC,22,168,15,14,SS_CENTERIMAGE Modified: trunk/OpenMPT/sounddsp/EQ.cpp =================================================================== --- trunk/OpenMPT/sounddsp/EQ.cpp 2013-05-24 20:01:34 UTC (rev 2182) +++ trunk/OpenMPT/sounddsp/EQ.cpp 2013-05-24 20:22:12 UTC (rev 2183) @@ -17,31 +17,8 @@ #define EQ_BANDWIDTH 2.0 #define EQ_ZERO 0.000001 -extern void C_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc); -extern void C_FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic); -extern void C_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc); -extern void C_FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic); -#ifdef ENABLE_X86 -extern void X86_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc); -extern void X86_FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic); -extern void X86_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc); -extern void X86_FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic); -#endif -#ifdef ENABLE_SSE -extern void SSE_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc); -#endif - -#ifdef ENABLE_3DNOW -extern void AMD_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc); -extern void AMD_FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic); -#endif - - - - - static const UINT gEqLinearToDB[33] = { 16, 19, 22, 25, 28, 31, 34, 37, @@ -335,25 +312,17 @@ void CEQ::ProcessMono(int *pbuffer, float *MixFloatBuffer, UINT nCount, CSoundFilePlayConfig &config) //--------------------------------------------------------------------------------------------------- { -#ifdef ENABLE_X86 - X86_MonoMixToFloat(pbuffer, MixFloatBuffer, nCount, config.getIntToFloat()); -#else - C_MonoMixToFloat(pbuffer, MixFloatBuffer, nCount, config.getIntToFloat()); -#endif + MonoMixToFloat(pbuffer, MixFloatBuffer, nCount, config.getIntToFloat()); for (UINT b=0; b<MAX_EQ_BANDS; b++) { if ((gEQ[b].bEnable) && (gEQ[b].Gain != 1.0f)) EQFilter(&gEQ[b], MixFloatBuffer, nCount); } -#ifdef ENABLE_X86 - X86_FloatToMonoMix(MixFloatBuffer, pbuffer, nCount, config.getFloatToInt()); -#else - C_FloatToMonoMix(MixFloatBuffer, pbuffer, nCount, config.getFloatToInt()); -#endif + FloatToMonoMix(MixFloatBuffer, pbuffer, nCount, config.getFloatToInt()); } -void CEQ::ProcessStereo(int *pbuffer, float *MixFloatBuffer, UINT nCount, CSoundFilePlayConfig &config, DWORD SoundSetupFlags, DWORD SysInfoFlags) -//------------------------------------------------------------------------------------------------------------------------------------------------ +void CEQ::ProcessStereo(int *pbuffer, float *MixFloatBuffer, UINT nCount, CSoundFilePlayConfig &config) +//----------------------------------------------------------------------------------------------------- { #ifdef ENABLE_SSE @@ -361,10 +330,10 @@ // Still allow the check, because the user can turn this on/off - if ((SysInfoFlags & PROCSUPPORT_SSE) && (SoundSetupFlags & SNDMIX_ENABLEMMX)) + if(GetProcSupport() & PROCSUPPORT_SSE) { int sse_state, sse_eqstate; - SSE_MonoMixToFloat(pbuffer, MixFloatBuffer, nCount*2, config.getIntToFloat()); + MonoMixToFloat(pbuffer, MixFloatBuffer, nCount*2, config.getIntToFloat()); _asm stmxcsr sse_state; sse_eqstate = sse_state | 0xFF80; @@ -376,7 +345,7 @@ } _asm ldmxcsr sse_state; - X86_FloatToMonoMix(MixFloatBuffer, pbuffer, nCount*2, config.getFloatToInt()); + FloatToMonoMix(MixFloatBuffer, pbuffer, nCount*2, config.getFloatToInt()); } else @@ -387,9 +356,9 @@ // We still perform the MMX check because the user can enable/disable this - if ((SysInfoFlags & PROCSUPPORT_3DNOW) && (SoundSetupFlags & SNDMIX_ENABLEMMX)) + if(GetProcSupport() & PROCSUPPORT_3DNOW) { - AMD_MonoMixToFloat(pbuffer, MixFloatBuffer, nCount*2, config.getIntToFloat()); + MonoMixToFloat(pbuffer, MixFloatBuffer, nCount*2, config.getIntToFloat()); for (UINT b=0; b<MAX_EQ_BANDS; b++) { @@ -398,21 +367,14 @@ AMD_StereoEQ(&gEQ[b], &gEQ[b+MAX_EQ_BANDS], MixFloatBuffer, nCount); } - AMD_FloatToMonoMix(MixFloatBuffer, pbuffer, nCount*2, config.getFloatToInt()); + FloatToMonoMix(MixFloatBuffer, pbuffer, nCount*2, config.getFloatToInt()); } else #endif // ENABLE_3DNOW { - UNREFERENCED_PARAMETER(SoundSetupFlags); - UNREFERENCED_PARAMETER(SysInfoFlags); - -#ifdef ENABLE_X86 - X86_StereoMixToFloat(pbuffer, MixFloatBuffer, MixFloatBuffer+MIXBUFFERSIZE, nCount, config.getIntToFloat()); -#else - C_StereoMixToFloat(pbuffer, MixFloatBuffer, MixFloatBuffer+MIXBUFFERSIZE, nCount, config.getIntToFloat()); -#endif + StereoMixToFloat(pbuffer, MixFloatBuffer, MixFloatBuffer+MIXBUFFERSIZE, nCount, config.getIntToFloat()); for (UINT bl=0; bl<MAX_EQ_BANDS; bl++) { @@ -423,11 +385,7 @@ if ((gEQ[br].bEnable) && (gEQ[br].Gain != 1.0f)) EQFilter(&gEQ[br], MixFloatBuffer+MIXBUFFERSIZE, nCount); } -#ifdef ENABLE_X86 - X86_FloatToStereoMix(MixFloatBuffer, MixFloatBuffer+MIXBUFFERSIZE, pbuffer, nCount, config.getFloatToInt()); -#else - C_FloatToStereoMix(MixFloatBuffer, MixFloatBuffer+MIXBUFFERSIZE, pbuffer, nCount, config.getFloatToInt()); -#endif + FloatToStereoMix(MixFloatBuffer, MixFloatBuffer+MIXBUFFERSIZE, pbuffer, nCount, config.getFloatToInt()); } } Modified: trunk/OpenMPT/sounddsp/EQ.h =================================================================== --- trunk/OpenMPT/sounddsp/EQ.h 2013-05-24 20:01:34 UTC (rev 2182) +++ trunk/OpenMPT/sounddsp/EQ.h 2013-05-24 20:22:12 UTC (rev 2183) @@ -44,7 +44,7 @@ ~CEQ() {} public: void Initialize(BOOL bReset, DWORD MixingFreq); - void ProcessStereo(int *pbuffer, float *MixFloatBuffer, UINT nCount, CSoundFilePlayConfig &config, DWORD SoundSetupFlags, DWORD SysInfoFlags); + void ProcessStereo(int *pbuffer, float *MixFloatBuffer, UINT nCount, CSoundFilePlayConfig &config); void ProcessMono(int *pbuffer, float *MixFloatBuffer, UINT nCount, CSoundFilePlayConfig &config); void SetEQGains(const UINT *pGains, UINT nGains, const UINT *pFreqs, BOOL bReset, DWORD MixingFreq); }; Modified: trunk/OpenMPT/soundlib/Fastmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Fastmix.cpp 2013-05-24 20:01:34 UTC (rev 2182) +++ trunk/OpenMPT/soundlib/Fastmix.cpp 2013-05-24 20:22:12 UTC (rev 2183) @@ -460,29 +460,12 @@ ///////////////////////////////////////////////////// // -extern void X86_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc); -extern void X86_FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic); -extern void C_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc); -extern void C_FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic); void InitMixBuffer(int *pBuffer, UINT nSamples); void EndChannelOfs(ModChannel *pChannel, int *pBuffer, UINT nSamples); void StereoFill(int *pBuffer, UINT nSamples, LPLONG lpROfs, LPLONG lpLOfs); -#ifdef ENABLE_3DNOW -extern void AMD_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc); -extern void AMD_FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic); -extern void AMD_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc); -extern void AMD_FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic); -#endif - -#ifdef ENABLE_SSE -extern void SSE_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc); -extern void SSE_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc); -#endif - - ///////////////////////////////////////////////////// // Mono samples functions @@ -1502,9 +1485,9 @@ pbuffer = MixSoundBuffer; #ifndef NO_REVERB #ifdef ENABLE_MMX - if((m_MixerSettings.DSPMask & SNDDSP_REVERB) && (gdwSysInfo & PROCSUPPORT_MMX) && !pChannel->dwFlags[CHN_NOREVERB]) + if((m_MixerSettings.DSPMask & SNDDSP_REVERB) && (GetProcSupport() & PROCSUPPORT_MMX) && !pChannel->dwFlags[CHN_NOREVERB]) pbuffer = MixReverbBuffer; - if(pChannel->dwFlags[CHN_REVERB] && (gdwSysInfo & PROCSUPPORT_MMX)) + if(pChannel->dwFlags[CHN_REVERB] && (GetProcSupport() & PROCSUPPORT_MMX)) pbuffer = MixReverbBuffer; #endif #endif @@ -1745,66 +1728,11 @@ FloatToStereoMix(pMixL, pMixR, MixSoundBuffer, nCount); } + ////////////////////////////////////////////////////////////////////////////////////////// -// -// Float <-> Int conversion -// -VOID CSoundFile::StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount) -//----------------------------------------------------------------------------------------- -{ -#ifdef ENABLE_ASM - if(m_MixerSettings.MixerFlags & SNDMIX_ENABLEMMX) - { -#ifdef ENABLE_SSE - if(gdwSysInfo & PROCSUPPORT_SSE) - { - SSE_StereoMixToFloat(pSrc, pOut1, pOut2, nCount, m_PlayConfig.getIntToFloat()); - return; - } -#endif // ENABLE_SSE -#ifdef ENABLE_3DNOW - if(gdwSysInfo & PROCSUPPORT_3DNOW) - { - AMD_StereoMixToFloat(pSrc, pOut1, pOut2, nCount, m_PlayConfig.getIntToFloat()); - return; - } -#endif // ENABLE_3DNOW - } -#endif // ENABLE_ASM #ifdef ENABLE_X86 - X86_StereoMixToFloat(pSrc, pOut1, pOut2, nCount, m_PlayConfig.getIntToFloat()); -#else // !ENABLE_X86 - C_StereoMixToFloat(pSrc, pOut1, pOut2, nCount, m_PlayConfig.getIntToFloat()); -#endif // ENABLE_X86 -} - - -VOID CSoundFile::FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount) -//--------------------------------------------------------------------------------------------- -{ -#ifdef ENABLE_ASM - if(m_MixerSettings.MixerFlags & SNDMIX_ENABLEMMX) - { -#ifdef ENABLE_3DNOW - if(gdwSysInfo & PROCSUPPORT_3DNOW) - { - AMD_FloatToStereoMix(pIn1, pIn2, pOut, nCount, m_PlayConfig.getFloatToInt()); - return; - } -#endif // ENABLE_3DNOW - } -#endif // ENABLE_ASM -#ifdef ENABLE_X86 - X86_FloatToStereoMix(pIn1, pIn2, pOut, nCount, m_PlayConfig.getFloatToInt()); -#else // !ENABLE_X86 - C_FloatToStereoMix(pIn1, pIn2, pOut, nCount, m_PlayConfig.getFloatToInt()); -#endif // ENABLE_X86 -} - - -#ifdef ENABLE_X86 static DWORD X86_Convert32To8(LPVOID lp16, int *pBuffer, DWORD lSampleCount) //-------------------------------------------------------------------------- { Modified: trunk/OpenMPT/soundlib/Mmx_mix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Mmx_mix.cpp 2013-05-24 20:01:34 UTC (rev 2182) +++ trunk/OpenMPT/soundlib/Mmx_mix.cpp 2013-05-24 20:22:12 UTC (rev 2183) @@ -25,15 +25,14 @@ #ifdef ENABLE_ASM -DWORD CSoundFile::GetSysInfo() -//---------------------------- + +static uint32 gdwSysInfo = 0; + +void InitProcSupport() +//-------------------- { #ifdef ENABLE_X86 static unsigned int fProcessorExtensions = 0; - static bool bMMXChecked = false; - - if (!bMMXChecked) - { _asm { pushfd // Store original EFLAGS on stack @@ -77,13 +76,16 @@ or fProcessorExtensions, PROCSUPPORT_MMXEX // MMX extensions supported Done: } - bMMXChecked = true; - } - return fProcessorExtensions; -#else - return 0; + gdwSysInfo = fProcessorExtensions; #endif } + +uint32 GetProcSupport() +//--------------------- +{ + return gdwSysInfo; +} + #endif @@ -93,8 +95,8 @@ #ifdef ENABLE_3DNOW // Convert integer mix to floating-point -void AMD_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc) -//---------------------------------------------------------------------------------------------------- +static void AMD_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc) +//----------------------------------------------------------------------------------------------------------- { _asm { movd mm0, _i2fc @@ -126,8 +128,8 @@ } } -void AMD_FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic) -//-------------------------------------------------------------------------------------------------------- +static void AMD_FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic) +//--------------------------------------------------------------------------------------------------------------- { _asm { movd mm0, _f2ic @@ -161,8 +163,8 @@ } -void AMD_FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic) -//---------------------------------------------------------------------------------- +static void AMD_FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic) +//----------------------------------------------------------------------------------------- { _asm { movd mm0, _f2ic @@ -191,8 +193,8 @@ } -void AMD_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc) -//----------------------------------------------------------------------------------- +static void AMD_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc) +//------------------------------------------------------------------------------------------ { _asm { movd mm0, _i2fc @@ -227,8 +229,8 @@ #ifdef ENABLE_SSE -void SSE_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc) -//---------------------------------------------------------------------------------------------------- +static void SSE_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc) +//----------------------------------------------------------------------------------------------------------- { _asm { movss xmm0, _i2fc @@ -258,8 +260,8 @@ } -void SSE_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc) -//----------------------------------------------------------------------------------- +static void SSE_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc) +//------------------------------------------------------------------------------------------ { _asm { movss xmm0, _i2fc @@ -284,17 +286,16 @@ } } -#endif +#endif // ENABLE_SSE +#ifdef ENABLE_X86 - // Convert floating-point mix to integer -#ifdef ENABLE_X86 -void X86_FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic) -//-------------------------------------------------------------------------------------------------------- +static void X86_FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic) +//--------------------------------------------------------------------------------------------------------------- { _asm { mov esi, pIn1 @@ -317,24 +318,12 @@ fstp st(0) } } -#endif -void C_FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic) -//------------------------------------------------------------------------------------------------------ -{ - for(UINT i=0; i<nCount; ++i) - { - *pOut++ = (int)(*pIn1++ * _f2ic); - *pOut++ = (int)(*pIn2++ * _f2ic); - } -} - // Convert integer mix to floating-point -#ifdef ENABLE_X86 -void X86_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc) -//---------------------------------------------------------------------------------------------------- +static void X86_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc) +//----------------------------------------------------------------------------------------------------------- { _asm { mov esi, pSrc @@ -357,22 +346,10 @@ fstp st(0) } } -#endif -void C_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc) -//-------------------------------------------------------------------------------------------------- -{ - for(UINT i=0; i<nCount; ++i) - { - *pOut1++ = *pSrc++ * _i2fc; - *pOut2++ = *pSrc++ * _i2fc; - } -} - -#ifdef ENABLE_X86 -void X86_FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic) -//---------------------------------------------------------------------------------- +static void X86_FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic) +//----------------------------------------------------------------------------------------- { _asm { mov edx, pIn @@ -391,21 +368,10 @@ fstp st(0) } } -#endif -void C_FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic) -//-------------------------------------------------------------------------------- -{ - for(UINT i=0; i<nCount; ++i) - { - *pOut++ = (int)(*pIn++ * _f2ic); - } -} - -#ifdef ENABLE_X86 -void X86_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc) -//----------------------------------------------------------------------------------- +static void X86_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc) +//------------------------------------------------------------------------------------------ { _asm { mov edx, pOut @@ -424,13 +390,144 @@ fstp st(0) } } -#endif -void C_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc) -//--------------------------------------------------------------------------------- +#endif // ENABLE_X86 + + + +static void C_FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic) +//------------------------------------------------------------------------------------------------------------- { for(UINT i=0; i<nCount; ++i) { + *pOut++ = (int)(*pIn1++ * _f2ic); + *pOut++ = (int)(*pIn2++ * _f2ic); + } +} + + +static void C_StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc) +//--------------------------------------------------------------------------------------------------------- +{ + for(UINT i=0; i<nCount; ++i) + { + *pOut1++ = *pSrc++ * _i2fc; + *pOut2++ = *pSrc++ * _i2fc; + } +} + + +static void C_FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic) +//--------------------------------------------------------------------------------------- +{ + for(UINT i=0; i<nCount; ++i) + { + *pOut++ = (int)(*pIn++ * _f2ic); + } +} + + +static void C_MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc) +//---------------------------------------------------------------------------------------- +{ + for(UINT i=0; i<nCount; ++i) + { *pOut++ = *pSrc++ * _i2fc; } } + + + +void StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc) +{ + + #ifdef ENABLE_SSE + if(gdwSysInfo & PROCSUPPORT_SSE) + { + SSE_StereoMixToFloat(pSrc, pOut1, pOut2, nCount, _i2fc); + return; + } + #endif // ENABLE_SSE + #ifdef ENABLE_3DNOW + if(gdwSysInfo & PROCSUPPORT_3DNOW) + { + AMD_StereoMixToFloat(pSrc, pOut1, pOut2, nCount, _i2fc); + return; + } + #endif // ENABLE_3DNOW + + #ifdef ENABLE_X86 + X86_StereoMixToFloat(pSrc, pOut1, pOut2, nCount, _i2fc); + #else // !ENABLE_X86 + C_StereoMixToFloat(pSrc, pOut1, pOut2, nCount, _i2fc); + #endif // ENABLE_X86 + +} + + +void FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic) +{ + + #ifdef ENABLE_3DNOW + if(gdwSysInfo & PROCSUPPORT_3DNOW) + { + AMD_FloatToStereoMix(pIn1, pIn2, pOut, nCount, _f2ic); + return; + } + #endif // ENABLE_3DNOW + + #ifdef ENABLE_X86 + X86_FloatToStereoMix(pIn1, pIn2, pOut, nCount, _f2ic); + #else // !ENABLE_X86 + C_FloatToStereoMix(pIn1, pIn2, pOut, nCount, _f2ic); + #endif // ENABLE_X86 + +} + + +void MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc) +{ + + #ifdef ENABLE_SSE + if(gdwSysInfo & PROCSUPPORT_SSE) + { + SSE_MonoMixToFloat(pSrc, pOut, nCount, _i2fc); + return; + } + #endif // ENABLE_SSE + #ifdef ENABLE_3DNOW + if(gdwSysInfo & PROCSUPPORT_3DNOW) + { + AMD_MonoMixToFloat(pSrc, pOut, nCount, _i2fc); + return; + } + #endif // ENABLE_3DNOW + + #ifdef ENABLE_X86 + X86_MonoMixToFloat(pSrc, pOut, nCount, _i2fc); + #else // !ENABLE_X86 + C_MonoMixToFloat(pSrc, pOut, nCount, _i2fc); + #endif // ENABLE_X86 + +} + + +void FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic) +{ + + #ifdef ENABLE_3DNOW + if(gdwSysInfo & PROCSUPPORT_3DNOW) + { + AMD_FloatToMonoMix(pIn, pOut, nCount, _f2ic); + return; + } + #endif // ENABLE_3DNOW + + #ifdef ENABLE_X86 + X86_FloatToMonoMix(pIn, pOut, nCount, _f2ic); + #else // !ENABLE_X86 + C_FloatToMonoMix(pIn, pOut, nCount, _f2ic); + #endif // ENABLE_X86 + +} + Modified: trunk/OpenMPT/soundlib/Snd_defs.h =================================================================== --- trunk/OpenMPT/soundlib/Snd_defs.h 2013-05-24 20:01:34 UTC (rev 2182) +++ trunk/OpenMPT/soundlib/Snd_defs.h 2013-05-24 20:22:12 UTC (rev 2183) @@ -306,10 +306,6 @@ #define SNDMIX_SOFTPANNING 0x10 // soft panning mode (this is forced with mixmode RC3 and later) // Misc Flags (can safely be turned on or off) -#ifdef ENABLE_ASM -#define SNDMIX_ENABLEMMX 0x08 // use MMX-accelerated code -#endif - //#define SNDMIX_NOBACKWARDJUMPS 0x40000 // stop when jumping back in the order (currently unused as it seems) #define SNDMIX_MAXDEFAULTPAN 0x80000 // Used by the MOD loader (currently unused) #define SNDMIX_MUTECHNMODE 0x100000 // Notes are not played on muted channels Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2013-05-24 20:01:34 UTC (rev 2182) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2013-05-24 20:22:12 UTC (rev 2183) @@ -402,11 +402,6 @@ #endif //---------------------- { -#ifdef ENABLE_ASM - gdwSysInfo = GetSysInfo(); -#else - gdwSysInfo = 0; -#endif MemsetZero(MixSoundBuffer); MemsetZero(MixRearBuffer); #ifndef NO_REVERB @@ -893,7 +888,7 @@ { #ifdef ENABLE_ASM #ifndef NO_REVERB - if(!(GetSysInfo() & PROCSUPPORT_MMX)) DSPMask &= ~SNDDSP_REVERB; + if(!(GetProcSupport() & PROCSUPPORT_MMX)) DSPMask &= ~SNDDSP_REVERB; #endif #endif m_MixerSettings.DSPMask = DSPMask; Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2013-05-24 20:01:34 UTC (rev 2182) +++ trunk/OpenMPT/soundlib/Sndfile.h 2013-05-24 20:22:12 UTC (rev 2183) @@ -184,10 +184,23 @@ #endif // MODPLUG_TRACKER +#ifdef ENABLE_ASM +void InitProcSupport(); +uint32 GetProcSupport(); +#endif + + +void StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount, const float _i2fc); +void FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount, const float _f2ic); +void MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount, const float _i2fc); +void FloatToMonoMix(const float *pIn, int *pOut, UINT nCount, const float _f2ic); + + #if MPT_COMPILER_MSVC #pragma warning(disable:4324) //structure was padded due to __declspec(align()) #endif + //============== class CSoundFile //============== @@ -271,9 +284,6 @@ FlagSet<ModSpecificFlag, uint16> m_ModFlags; private: - DWORD gdwSysInfo; - -private: // Front Mix Buffer (Also room for interleaved rear mix) int MixSoundBuffer[MIXBUFFERSIZE * 4]; int MixRearBuffer[MIXBUFFERSIZE * 2]; @@ -594,17 +604,18 @@ void InitPlayer(BOOL bReset=FALSE); void SetDspEffects(DWORD DSPMask); DWORD GetSampleRate() { return m_MixerSettings.gdwMixingFreq; } -#ifdef ENABLE_ASM - static DWORD GetSysInfo(); -#endif #ifndef NO_EQ void SetEQGains(const UINT *pGains, UINT nBands, const UINT *pFreqs=NULL, BOOL bReset=FALSE) { m_EQ.SetEQGains(pGains, nBands, pFreqs, bReset, m_MixerSettings.gdwMixingFreq); } // 0=-12dB, 32=+12dB #endif // NO_EQ // Float <-> Int conversion routines - /*static */VOID StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount); - /*static */VOID FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount); - /*static */VOID MonoMixToFloat(const int *pSrc, float *pOut, UINT nCount); - /*static */VOID FloatToMonoMix(const float *pIn, int *pOut, UINT nCount); + forceinline void StereoMixToFloat(const int *pSrc, float *pOut1, float *pOut2, UINT nCount) + { + ::StereoMixToFloat(pSrc, pOut1, pOut2, nCount, m_PlayConfig.getIntToFloat()); + } + forceinline void FloatToStereoMix(const float *pIn1, const float *pIn2, int *pOut, UINT nCount) + { + ::FloatToStereoMix(pIn1, pIn2, pOut, nCount, m_PlayConfig.getFloatToInt()); + } public: BOOL ReadNote(); Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2013-05-24 20:01:34 UTC (rev 2182) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2013-05-24 20:22:12 UTC (rev 2183) @@ -272,7 +272,7 @@ m_nMixStat += CreateStereoMix(lCount); #ifndef NO_REVERB - m_Reverb.Process(MixSoundBuffer, MixReverbBuffer, lCount, gdwSysInfo); + m_Reverb.Process(MixSoundBuffer, MixReverbBuffer, lCount, GetProcSupport()); #endif // NO_REVERB if (nMaxPlugins) ProcessPlugins(lCount); @@ -287,7 +287,7 @@ m_nMixStat += CreateStereoMix(lCount); #ifndef NO_REVERB - m_Reverb.Process(MixSoundBuffer, MixReverbBuffer, lCount, gdwSysInfo); + m_Reverb.Process(MixSoundBuffer, MixReverbBuffer, lCount, GetProcSupport()); #endif // NO_REVERB if (nMaxPlugins) ProcessPlugins(lCount); @@ -309,7 +309,7 @@ if (m_MixerSettings.DSPMask & SNDDSP_EQ) { if (m_MixerSettings.gnChannels >= 2) - m_EQ.ProcessStereo(MixSoundBuffer, MixFloatBuffer, lCount, m_PlayConfig, m_MixerSettings.MixerFlags, gdwSysInfo); + m_EQ.ProcessStereo(MixSoundBuffer, MixFloatBuffer, lCount, m_PlayConfig); else m_EQ.ProcessMono(MixSoundBuffer, MixFloatBuffer, lCount, m_PlayConfig); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |