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 <foointrin.h> 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
This commit is contained in:
Soren Jorvang 2010-07-31 14:40:01 +00:00
parent 840bd3613f
commit 824b509d2e
4 changed files with 29 additions and 12 deletions

View File

@ -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_

View File

@ -27,6 +27,19 @@
template <bool> struct CompileTimeAssert;
template<> struct CompileTimeAssert<true> {};
#if defined __GNUC__ && !defined __SSSE3__
#include <emmintrin.h>
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 <errno.h>
@ -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}

View File

@ -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),

View File

@ -15,14 +15,6 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include <cmath>
#if _M_SSE >= 0x401
#include <smmintrin.h>
#elif _M_SSE >= 0x301
#include <tmmintrin.h>
#endif
#include "Common.h"
//#include "VideoCommon.h" // to get debug logs
@ -37,6 +29,14 @@
#include "LookUpTables.h"
#include <cmath>
#if _M_SSE >= 0x401
#include <smmintrin.h>
#elif _M_SSE >= 0x301
#include <tmmintrin.h>
#endif
bool TexFmt_Overlay_Enable=false;
bool TexFmt_Overlay_Center=false;