1.1 --- a/src/cpuinfo/SDL_cpuinfo.c Thu Jan 30 20:29:58 2014 -0300
1.2 +++ b/src/cpuinfo/SDL_cpuinfo.c Sun Feb 02 00:33:31 2014 -0800
1.3 @@ -18,7 +18,11 @@
1.4 misrepresented as being the original software.
1.5 3. This notice may not be removed or altered from any source distribution.
1.6 */
1.7 +#ifdef TEST_MAIN
1.8 +#include "SDL_config.h"
1.9 +#else
1.10 #include "../SDL_internal.h"
1.11 +#endif
1.12
1.13 #if defined(__WIN32__)
1.14 #include "../core/windows/SDL_windows.h"
1.15 @@ -55,6 +59,7 @@
1.16 #define CPU_HAS_SSE3 0x00000040
1.17 #define CPU_HAS_SSE41 0x00000100
1.18 #define CPU_HAS_SSE42 0x00000200
1.19 +#define CPU_HAS_AVX 0x00000400
1.20
1.21 #if SDL_ALTIVEC_BLITTERS && HAVE_SETJMP && !__MACOSX__ && !__OpenBSD__
1.22 /* This is the brute force way of detecting instruction sets...
1.23 @@ -329,6 +334,21 @@
1.24 return 0;
1.25 }
1.26
1.27 +static SDL_INLINE int
1.28 +CPU_haveAVX(void)
1.29 +{
1.30 + if (CPU_haveCPUID()) {
1.31 + int a, b, c, d;
1.32 +
1.33 + cpuid(1, a, b, c, d);
1.34 + if (a >= 1) {
1.35 + cpuid(1, a, b, c, d);
1.36 + return (c & 0x10000000);
1.37 + }
1.38 + }
1.39 + return 0;
1.40 +}
1.41 +
1.42 static int SDL_CPUCount = 0;
1.43
1.44 int
1.45 @@ -523,6 +543,9 @@
1.46 if (CPU_haveSSE42()) {
1.47 SDL_CPUFeatures |= CPU_HAS_SSE42;
1.48 }
1.49 + if (CPU_haveAVX()) {
1.50 + SDL_CPUFeatures |= CPU_HAS_AVX;
1.51 + }
1.52 }
1.53 return SDL_CPUFeatures;
1.54 }
1.55 @@ -608,6 +631,15 @@
1.56 return SDL_FALSE;
1.57 }
1.58
1.59 +SDL_bool
1.60 +SDL_HasAVX(void)
1.61 +{
1.62 + if (SDL_GetCPUFeatures() & CPU_HAS_AVX) {
1.63 + return SDL_TRUE;
1.64 + }
1.65 + return SDL_FALSE;
1.66 +}
1.67 +
1.68 static int SDL_SystemRAM = 0;
1.69
1.70 int
1.71 @@ -673,6 +705,7 @@
1.72 printf("SSE3: %d\n", SDL_HasSSE3());
1.73 printf("SSE4.1: %d\n", SDL_HasSSE41());
1.74 printf("SSE4.2: %d\n", SDL_HasSSE42());
1.75 + printf("AVX: %d\n", SDL_HasAVX());
1.76 printf("RAM: %d MB\n", SDL_GetSystemRAM());
1.77 return 0;
1.78 }