Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libSDL
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
libSDL
Commits
0314fd4e
Commit
0314fd4e
authored
Feb 11, 2011
by
Sam Lantinga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated CPU detection code for SSE3 and SSE4 and removed obsolete 3DNow! and Altivec support.
parent
e8f3f1e9
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
57 additions
and
2075 deletions
+57
-2075
configure.in
configure.in
+0
-103
SDL_config.h.in
include/SDL_config.h.in
+0
-2
SDL_config_macosx.h
include/SDL_config_macosx.h
+0
-3
SDL_cpuinfo.h
include/SDL_cpuinfo.h
+8
-17
SDL_cpuinfo.c
src/cpuinfo/SDL_cpuinfo.c
+39
-118
SDL_blit.c
src/video/SDL_blit.c
+0
-34
SDL_blit.h
src/video/SDL_blit.h
+0
-6
SDL_blit_A.c
src/video/SDL_blit_A.c
+8
-918
SDL_blit_N.c
src/video/SDL_blit_N.c
+0
-869
testplatform.c
test/testplatform.c
+2
-5
No files found.
configure.in
View file @
0314fd4e
...
...
@@ -501,33 +501,6 @@ AC_HELP_STRING([--enable-mmx], [use MMX assembly routines [[default=yes]]]),
fi
fi
AC_ARG_ENABLE(3dnow,
AC_HELP_STRING([--enable-3dnow], [use MMX assembly routines [[default=yes]]]),
, enable_3dnow=yes)
if test x$enable_3dnow = xyes; then
save_CFLAGS="$CFLAGS"
have_gcc_3dnow=no
AC_MSG_CHECKING(for GCC -m3dnow option)
amd3dnow_CFLAGS="-m3dnow"
CFLAGS="$save_CFLAGS $amd3dnow_CFLAGS"
AC_TRY_COMPILE([
#include <mm3dnow.h>
#ifndef __3dNOW__
#error Assembler CPP flag not enabled
#endif
],[
],[
have_gcc_3dnow=yes
])
AC_MSG_RESULT($have_gcc_3dnow)
CFLAGS="$save_CFLAGS"
if test x$have_gcc_3dnow = xyes; then
EXTRA_CFLAGS="$EXTRA_CFLAGS $amd3dnow_CFLAGS"
fi
fi
AC_ARG_ENABLE(sse,
AC_HELP_STRING([--enable-sse], [use SSE assembly routines [[default=yes]]]),
, enable_sse=yes)
...
...
@@ -599,82 +572,6 @@ AC_HELP_STRING([--enable-sse2], [use SSE2 assembly routines [[default=no]]]),
EXTRA_CFLAGS="$EXTRA_CFLAGS $sse2_CFLAGS"
fi
fi
AC_ARG_ENABLE(altivec,
AC_HELP_STRING([--enable-altivec], [use Altivec assembly routines [[default=yes]]]),
, enable_altivec=yes)
if test x$enable_altivec = xyes; then
save_CFLAGS="$CFLAGS"
have_gcc_altivec=no
have_altivec_h_hdr=no
altivec_CFLAGS="-maltivec"
CFLAGS="$save_CFLAGS $altivec_CFLAGS"
AC_MSG_CHECKING(for Altivec with GCC altivec.h and -maltivec option)
AC_TRY_COMPILE([
#include <altivec.h>
vector unsigned int vzero() {
return vec_splat_u32(0);
}
],[
],[
have_gcc_altivec=yes
have_altivec_h_hdr=yes
])
AC_MSG_RESULT($have_gcc_altivec)
if test x$have_gcc_altivec = xno; then
AC_MSG_CHECKING(for Altivec with GCC -maltivec option)
AC_TRY_COMPILE([
vector unsigned int vzero() {
return vec_splat_u32(0);
}
],[
],[
have_gcc_altivec=yes
])
AC_MSG_RESULT($have_gcc_altivec)
fi
if test x$have_gcc_altivec = xno; then
AC_MSG_CHECKING(for Altivec with GCC altivec.h and -faltivec option)
altivec_CFLAGS="-faltivec"
CFLAGS="$save_CFLAGS $altivec_CFLAGS"
AC_TRY_COMPILE([
#include <altivec.h>
vector unsigned int vzero() {
return vec_splat_u32(0);
}
],[
],[
have_gcc_altivec=yes
have_altivec_h_hdr=yes
])
AC_MSG_RESULT($have_gcc_altivec)
fi
if test x$have_gcc_altivec = xno; then
AC_MSG_CHECKING(for Altivec with GCC -faltivec option)
AC_TRY_COMPILE([
vector unsigned int vzero() {
return vec_splat_u32(0);
}
],[
],[
have_gcc_altivec=yes
])
AC_MSG_RESULT($have_gcc_altivec)
fi
CFLAGS="$save_CFLAGS"
if test x$have_gcc_altivec = xyes; then
AC_DEFINE(SDL_ALTIVEC_BLITTERS)
if test x$have_altivec_h_hdr = xyes; then
AC_DEFINE(HAVE_ALTIVEC_H)
fi
EXTRA_CFLAGS="$EXTRA_CFLAGS $altivec_CFLAGS"
fi
fi
fi
dnl See if the OSS audio interface is supported
...
...
include/SDL_config.h.in
View file @
0314fd4e
...
...
@@ -82,7 +82,6 @@
#undef HAVE_MATH_H
#undef HAVE_ICONV_H
#undef HAVE_SIGNAL_H
#undef HAVE_ALTIVEC_H
/* C library functions */
#undef HAVE_MALLOC
...
...
@@ -303,6 +302,5 @@
/* Enable assembly routines */
#undef SDL_ASSEMBLY_ROUTINES
#undef SDL_ALTIVEC_BLITTERS
#endif /* _SDL_config_h */
include/SDL_config_macosx.h
View file @
0314fd4e
...
...
@@ -168,8 +168,5 @@
/* Enable assembly routines */
#define SDL_ASSEMBLY_ROUTINES 1
#ifdef __ppc__
#define SDL_ALTIVEC_BLITTERS 1
#endif
#endif
/* _SDL_config_macosx_h */
include/SDL_cpuinfo.h
View file @
0314fd4e
...
...
@@ -69,21 +69,6 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void);
*/
extern
DECLSPEC
SDL_bool
SDLCALL
SDL_HasMMX
(
void
);
/**
* This function returns true if the CPU has MMX Ext.\ features.
*/
extern
DECLSPEC
SDL_bool
SDLCALL
SDL_HasMMXExt
(
void
);
/**
* This function returns true if the CPU has 3DNow!\ features.
*/
extern
DECLSPEC
SDL_bool
SDLCALL
SDL_Has3DNow
(
void
);
/**
* This function returns true if the CPU has 3DNow!\ Ext.\ features.
*/
extern
DECLSPEC
SDL_bool
SDLCALL
SDL_Has3DNowExt
(
void
);
/**
* This function returns true if the CPU has SSE features.
*/
...
...
@@ -95,9 +80,15 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void);
extern
DECLSPEC
SDL_bool
SDLCALL
SDL_HasSSE2
(
void
);
/**
* This function returns true if the CPU has AltiVec features.
* This function returns true if the CPU has SSE3 features.
*/
extern
DECLSPEC
SDL_bool
SDLCALL
SDL_HasSSE3
(
void
);
/**
* This function returns true if the CPU has SSE4 features.
*/
extern
DECLSPEC
SDL_bool
SDLCALL
SDL_HasAltiVec
(
void
);
extern
DECLSPEC
SDL_bool
SDLCALL
SDL_HasSSE4
(
void
);
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
...
...
src/cpuinfo/SDL_cpuinfo.c
View file @
0314fd4e
...
...
@@ -32,36 +32,17 @@
#include <sys/types.h>
#include <sys/sysctl.h>
#endif
#if defined(__MACOSX__) && (defined(__ppc__) || defined(__ppc64__))
#include <sys/sysctl.h>
/* For AltiVec check */
#elif SDL_ALTIVEC_BLITTERS && HAVE_SETJMP
#include <signal.h>
#include <setjmp.h>
#endif
#ifdef __WIN32__
#include "../core/windows/SDL_windows.h"
#endif
#define CPU_HAS_RDTSC 0x00000001
#define CPU_HAS_MMX 0x00000002
#define CPU_HAS_MMXEXT 0x00000004
#define CPU_HAS_3DNOW 0x00000010
#define CPU_HAS_3DNOWEXT 0x00000020
#define CPU_HAS_SSE 0x00000040
#define CPU_HAS_SSE2 0x00000080
#define CPU_HAS_ALTIVEC 0x00000100
#if SDL_ALTIVEC_BLITTERS && HAVE_SETJMP && !__MACOSX__
/* This is the brute force way of detecting instruction sets...
the idea is borrowed from the libmpeg2 library - thanks!
*/
static
jmp_buf
jmpbuf
;
static
void
illegal_instruction
(
int
sig
)
{
longjmp
(
jmpbuf
,
1
);
}
#endif
/* HAVE_SETJMP */
#define CPU_HAS_SSE 0x00000010
#define CPU_HAS_SSE2 0x00000020
#define CPU_HAS_SSE3 0x00000040
#define CPU_HAS_SSE4 0x00000080
static
__inline__
int
CPU_haveCPUID
(
void
)
...
...
@@ -201,20 +182,6 @@ CPU_getCPUIDFeatures(void)
return
features
;
}
static
__inline__
int
CPU_getCPUIDFeaturesExt
(
void
)
{
int
features
=
0
;
int
a
,
b
,
c
,
d
;
cpuid
(
0x80000000
,
a
,
b
,
c
,
d
);
if
(
a
>=
0x80000001
)
{
cpuid
(
0x80000001
,
a
,
b
,
c
,
d
);
features
=
d
;
}
return
features
;
}
static
__inline__
int
CPU_haveRDTSC
(
void
)
{
...
...
@@ -234,71 +201,51 @@ CPU_haveMMX(void)
}
static
__inline__
int
CPU_have
MMXExt
(
void
)
CPU_have
SSE
(
void
)
{
if
(
CPU_haveCPUID
())
{
return
(
CPU_getCPUIDFeatures
Ext
()
&
0x004
00000
);
return
(
CPU_getCPUIDFeatures
()
&
0x020
00000
);
}
return
0
;
}
static
__inline__
int
CPU_have
3DNow
(
void
)
CPU_have
SSE2
(
void
)
{
if
(
CPU_haveCPUID
())
{
return
(
CPU_getCPUIDFeatures
Ext
()
&
0x80
000000
);
return
(
CPU_getCPUIDFeatures
()
&
0x04
000000
);
}
return
0
;
}
static
__inline__
int
CPU_have
3DNowExt
(
void
)
CPU_have
SSE3
(
void
)
{
if
(
CPU_haveCPUID
())
{
return
(
CPU_getCPUIDFeaturesExt
()
&
0x40000000
);
}
return
0
;
}
int
a
,
b
,
c
,
d
;
static
__inline__
int
CPU_haveSSE
(
void
)
{
if
(
CPU_haveCPUID
())
{
return
(
CPU_getCPUIDFeatures
()
&
0x02000000
);
cpuid
(
0
,
a
,
b
,
c
,
d
);
if
(
a
>=
1
)
{
cpuid
(
1
,
a
,
b
,
c
,
d
);
return
(
c
&
0x00000001
);
}
}
return
0
;
}
static
__inline__
int
CPU_haveSSE
2
(
void
)
CPU_haveSSE
4
(
void
)
{
if
(
CPU_haveCPUID
())
{
return
(
CPU_getCPUIDFeatures
()
&
0x04000000
);
}
return
0
;
}
int
a
,
b
,
c
,
d
;
static
__inline__
int
CPU_haveAltiVec
(
void
)
{
volatile
int
altivec
=
0
;
#if defined(__MACOSX__) && (defined(__ppc__) || defined(__ppc64__))
int
selectors
[
2
]
=
{
CTL_HW
,
HW_VECTORUNIT
};
int
hasVectorUnit
=
0
;
size_t
length
=
sizeof
(
hasVectorUnit
);
int
error
=
sysctl
(
selectors
,
2
,
&
hasVectorUnit
,
&
length
,
NULL
,
0
);
if
(
0
==
error
)
altivec
=
(
hasVectorUnit
!=
0
);
#elif SDL_ALTIVEC_BLITTERS && HAVE_SETJMP
void
(
*
handler
)
(
int
sig
);
handler
=
signal
(
SIGILL
,
illegal_instruction
);
if
(
setjmp
(
jmpbuf
)
==
0
)
{
asm
volatile
(
"mtspr 256, %0
\n\t
"
"vand %%v0, %%v0, %%v0"
::
"r"
(
-
1
));
altivec
=
1
;
cpuid
(
0
,
a
,
b
,
c
,
d
);
if
(
a
>=
1
)
{
cpuid
(
1
,
a
,
b
,
c
,
d
);
return
(
c
&
0x00000100
);
}
}
signal
(
SIGILL
,
handler
);
#endif
return
altivec
;
return
0
;
}
static
int
SDL_CPUCount
=
0
;
...
...
@@ -471,23 +418,17 @@ SDL_GetCPUFeatures(void)
if
(
CPU_haveMMX
())
{
SDL_CPUFeatures
|=
CPU_HAS_MMX
;
}
if
(
CPU_haveMMXExt
())
{
SDL_CPUFeatures
|=
CPU_HAS_MMXEXT
;
}
if
(
CPU_have3DNow
())
{
SDL_CPUFeatures
|=
CPU_HAS_3DNOW
;
}
if
(
CPU_have3DNowExt
())
{
SDL_CPUFeatures
|=
CPU_HAS_3DNOWEXT
;
}
if
(
CPU_haveSSE
())
{
SDL_CPUFeatures
|=
CPU_HAS_SSE
;
}
if
(
CPU_haveSSE2
())
{
SDL_CPUFeatures
|=
CPU_HAS_SSE2
;
}
if
(
CPU_haveAltiVec
())
{
SDL_CPUFeatures
|=
CPU_HAS_ALTIVEC
;
if
(
CPU_haveSSE3
())
{
SDL_CPUFeatures
|=
CPU_HAS_SSE3
;
}
if
(
CPU_haveSSE4
())
{
SDL_CPUFeatures
|=
CPU_HAS_SSE4
;
}
}
return
SDL_CPUFeatures
;
...
...
@@ -512,54 +453,36 @@ SDL_HasMMX(void)
}
SDL_bool
SDL_HasMMXExt
(
void
)
{
if
(
SDL_GetCPUFeatures
()
&
CPU_HAS_MMXEXT
)
{
return
SDL_TRUE
;
}
return
SDL_FALSE
;
}
SDL_bool
SDL_Has3DNow
(
void
)
{
if
(
SDL_GetCPUFeatures
()
&
CPU_HAS_3DNOW
)
{
return
SDL_TRUE
;
}
return
SDL_FALSE
;
}
SDL_bool
SDL_Has3DNowExt
(
void
)
SDL_HasSSE
(
void
)
{
if
(
SDL_GetCPUFeatures
()
&
CPU_HAS_
3DNOWEXT
)
{
if
(
SDL_GetCPUFeatures
()
&
CPU_HAS_
SSE
)
{
return
SDL_TRUE
;
}
return
SDL_FALSE
;
}
SDL_bool
SDL_HasSSE
(
void
)
SDL_HasSSE
2
(
void
)
{
if
(
SDL_GetCPUFeatures
()
&
CPU_HAS_SSE
)
{
if
(
SDL_GetCPUFeatures
()
&
CPU_HAS_SSE
2
)
{
return
SDL_TRUE
;
}
return
SDL_FALSE
;
}
SDL_bool
SDL_HasSSE
2
(
void
)
SDL_HasSSE
3
(
void
)
{
if
(
SDL_GetCPUFeatures
()
&
CPU_HAS_SSE
2
)
{
if
(
SDL_GetCPUFeatures
()
&
CPU_HAS_SSE
3
)
{
return
SDL_TRUE
;
}
return
SDL_FALSE
;
}
SDL_bool
SDL_Has
AltiVec
(
void
)
SDL_Has
SSE4
(
void
)
{
if
(
SDL_GetCPUFeatures
()
&
CPU_HAS_
ALTIVEC
)
{
if
(
SDL_GetCPUFeatures
()
&
CPU_HAS_
SSE4
)
{
return
SDL_TRUE
;
}
return
SDL_FALSE
;
...
...
@@ -578,12 +501,10 @@ main()
printf
(
"CacheLine size: %d
\n
"
,
SDL_GetCPUCacheLineSize
());
printf
(
"RDTSC: %d
\n
"
,
SDL_HasRDTSC
());
printf
(
"MMX: %d
\n
"
,
SDL_HasMMX
());
printf
(
"MMXExt: %d
\n
"
,
SDL_HasMMXExt
());
printf
(
"3DNow: %d
\n
"
,
SDL_Has3DNow
());
printf
(
"3DNowExt: %d
\n
"
,
SDL_Has3DNowExt
());
printf
(
"SSE: %d
\n
"
,
SDL_HasSSE
());
printf
(
"SSE2: %d
\n
"
,
SDL_HasSSE2
());
printf
(
"AltiVec: %d
\n
"
,
SDL_HasAltiVec
());
printf
(
"SSE3: %d
\n
"
,
SDL_HasSSE3
());
printf
(
"SSE4: %d
\n
"
,
SDL_HasSSE4
());
return
0
;
}
...
...
src/video/SDL_blit.c
View file @
0314fd4e
...
...
@@ -100,30 +100,6 @@ SDL_SoftBlit(SDL_Surface * src, SDL_Rect * srcrect,
return
(
okay
?
0
:
-
1
);
}
#ifdef __MACOSX__
#include <sys/sysctl.h>
static
SDL_bool
SDL_UseAltivecPrefetch
()
{
const
char
key
[]
=
"hw.l3cachesize"
;
u_int64_t
result
=
0
;
size_t
typeSize
=
sizeof
(
result
);
if
(
sysctlbyname
(
key
,
&
result
,
&
typeSize
,
NULL
,
0
)
==
0
&&
result
>
0
)
{
return
SDL_TRUE
;
}
else
{
return
SDL_FALSE
;
}
}
#else
static
SDL_bool
SDL_UseAltivecPrefetch
()
{
/* Just guess G4 */
return
SDL_TRUE
;
}
#endif
/* __MACOSX__ */
static
SDL_BlitFunc
SDL_ChooseBlitFunc
(
Uint32
src_format
,
Uint32
dst_format
,
int
flags
,
...
...
@@ -145,22 +121,12 @@ SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags,
if
(
SDL_HasMMX
())
{
features
|=
SDL_CPU_MMX
;
}
if
(
SDL_Has3DNow
())
{
features
|=
SDL_CPU_3DNOW
;
}
if
(
SDL_HasSSE
())
{
features
|=
SDL_CPU_SSE
;
}
if
(
SDL_HasSSE2
())
{
features
|=
SDL_CPU_SSE2
;
}
if
(
SDL_HasAltiVec
())
{
if
(
SDL_UseAltivecPrefetch
())
{
features
|=
SDL_CPU_ALTIVEC_PREFETCH
;
}
else
{
features
|=
SDL_CPU_ALTIVEC_NOPREFETCH
;
}
}
}
}
...
...
src/video/SDL_blit.h
View file @
0314fd4e
...
...
@@ -34,9 +34,6 @@
#ifdef __MMX__
#include <mmintrin.h>
#endif
#ifdef __3dNOW__
#include <mm3dnow.h>
#endif
#ifdef __SSE__
#include <xmmintrin.h>
#endif
...
...
@@ -65,11 +62,8 @@
/* SDL blit CPU flags */
#define SDL_CPU_ANY 0x00000000
#define SDL_CPU_MMX 0x00000001
#define SDL_CPU_3DNOW 0x00000002
#define SDL_CPU_SSE 0x00000004
#define SDL_CPU_SSE2 0x00000008
#define SDL_CPU_ALTIVEC_PREFETCH 0x00000010
#define SDL_CPU_ALTIVEC_NOPREFETCH 0x00000020
typedef
struct
{
...
...
src/video/SDL_blit_A.c
View file @
0314fd4e
This diff is collapsed.
Click to expand it.
src/video/SDL_blit_N.c
View file @
0314fd4e
This diff is collapsed.
Click to expand it.
test/testplatform.c
View file @
0314fd4e
...
...
@@ -143,13 +143,10 @@ TestCPUInfo(SDL_bool verbose)
printf
(
"CPU cache line size: %d
\n
"
,
SDL_GetCPUCacheLineSize
());
printf
(
"RDTSC %s
\n
"
,
SDL_HasRDTSC
()
?
"detected"
:
"not detected"
);
printf
(
"MMX %s
\n
"
,
SDL_HasMMX
()
?
"detected"
:
"not detected"
);
printf
(
"MMX Ext %s
\n
"
,
SDL_HasMMXExt
()
?
"detected"
:
"not detected"
);
printf
(
"3DNow %s
\n
"
,
SDL_Has3DNow
()
?
"detected"
:
"not detected"
);
printf
(
"3DNow Ext %s
\n
"
,
SDL_Has3DNowExt
()
?
"detected"
:
"not detected"
);
printf
(
"SSE %s
\n
"
,
SDL_HasSSE
()
?
"detected"
:
"not detected"
);
printf
(
"SSE2 %s
\n
"
,
SDL_HasSSE2
()
?
"detected"
:
"not detected"
);
printf
(
"AltiVec %s
\n
"
,
SDL_HasAltiVec
()
?
"detected"
:
"not detected"
);
printf
(
"SSE3 %s
\n
"
,
SDL_HasSSE3
()
?
"detected"
:
"not detected"
);
printf
(
"SSE4 %s
\n
"
,
SDL_HasSSE4
()
?
"detected"
:
"not detected"
);
}
return
(
0
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment