From 824b509d2e1b1d9964b7011174d6de0375eb350f Mon Sep 17 00:00:00 2001 From: Soren Jorvang Date: Sat, 31 Jul 2010 14:40:01 +0000 Subject: [PATCH] Make the SSE3.1 VideoCommon code available in GCC builds. The GCC model for extended instructions like these is that you compile with -msse3 etc. These affect code generation for whole compilation units, so the idea is that you have a separate .c file for each instruction set class and then indirect to the desired one at runtime. Without e.g. -msse4.1, the GCC built-ins used by are not available. However, in our specific case of compiling with -msse2 and wanting to use SSE3.1 code, enough built-ins are available that we only need to provide a little hack for pshufb. Upgrading this to also use SSE4.1 instructions doesn't appear feasible without a lot of undesirable duplication of GCC built-in functions and headers, so we'd probably have to move to the GCC model of separate source files for that. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6014 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/Common.h | 4 ++++ Source/Core/Common/Src/CommonFuncs.h | 17 +++++++++++++++-- Source/Core/Core/Src/CoreParameter.cpp | 4 ++-- Source/Core/VideoCommon/Src/TextureDecoder.cpp | 16 ++++++++-------- 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/Source/Core/Common/Src/Common.h b/Source/Core/Common/Src/Common.h index 9c197e64d6..54d3e1c950 100644 --- a/Source/Core/Common/Src/Common.h +++ b/Source/Core/Common/Src/Common.h @@ -145,4 +145,8 @@ extern const char *netplay_dolphin_ver; #define __chdir chdir #endif +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || defined __APPLE__ +#define _M_SSE 0x301 +#endif + #endif // _COMMON_H_ diff --git a/Source/Core/Common/Src/CommonFuncs.h b/Source/Core/Common/Src/CommonFuncs.h index ab6f963e99..d3692ab4d3 100644 --- a/Source/Core/Common/Src/CommonFuncs.h +++ b/Source/Core/Common/Src/CommonFuncs.h @@ -27,6 +27,19 @@ template struct CompileTimeAssert; template<> struct CompileTimeAssert {}; +#if defined __GNUC__ && !defined __SSSE3__ +#include +static __inline __m128i __attribute__((__always_inline__)) +_mm_shuffle_epi8(__m128i a, __m128i mask) +{ + __m128i result; + __asm__("pshufb %1, %0" + : "=x" (result) + : "xm" (mask), "0" (a)); + return result; +} +#endif + #ifndef _WIN32 #include @@ -44,6 +57,7 @@ size_t strnlen(const char *s, size_t n); #define Crash() {asm ("int $3");} #endif #define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0])) + inline u32 _rotl(u32 x, int shift) { shift &= 31; if (!shift) return x; @@ -65,7 +79,7 @@ inline u64 _rotr64(u64 x, unsigned int shift){ unsigned int n = shift % 64; return (x >> n) | (x << (64 - n)); } - #define SLEEP(x) usleep(x*1000) + #else // WIN32 // Function Cross-Compatibility #define strcasecmp _stricmp @@ -80,7 +94,6 @@ char* strndup (char const *s, size_t n); #define ftell _ftelli64 #define atoll _atoi64 #define stat64 _stat64 - #define SLEEP(x) Sleep(x) #if _M_IX86 #define Crash() {__asm int 3} diff --git a/Source/Core/Core/Src/CoreParameter.cpp b/Source/Core/Core/Src/CoreParameter.cpp index db048cf58b..b03704550b 100644 --- a/Source/Core/Core/Src/CoreParameter.cpp +++ b/Source/Core/Core/Src/CoreParameter.cpp @@ -45,9 +45,9 @@ SCoreStartupParameter::SCoreStartupParameter() bSkipIdle(true), bNTSC(false), bHLE_BS2(true), bUseFastMem(false), bLockThreads(false), - bEnableCheats(false), bSMC(false), + bEnableCheats(false), bRunCompareServer(false), bRunCompareClient(false), - bMMU(false), iTLBHack(0), SelectedLanguage(0), bWii(false), + bMMU(false), bSMC(false), iTLBHack(0), SelectedLanguage(0), bWii(false), bConfirmStop(false), bHideCursor(false), bAutoHideCursor(false), bUsePanicHandlers(true), iRenderWindowXPos(0), iRenderWindowYPos(0), diff --git a/Source/Core/VideoCommon/Src/TextureDecoder.cpp b/Source/Core/VideoCommon/Src/TextureDecoder.cpp index 509def5a74..0414c0e9fb 100644 --- a/Source/Core/VideoCommon/Src/TextureDecoder.cpp +++ b/Source/Core/VideoCommon/Src/TextureDecoder.cpp @@ -15,14 +15,6 @@ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ -#include - -#if _M_SSE >= 0x401 -#include -#elif _M_SSE >= 0x301 -#include -#endif - #include "Common.h" //#include "VideoCommon.h" // to get debug logs @@ -37,6 +29,14 @@ #include "LookUpTables.h" +#include + +#if _M_SSE >= 0x401 +#include +#elif _M_SSE >= 0x301 +#include +#endif + bool TexFmt_Overlay_Enable=false; bool TexFmt_Overlay_Center=false;