mesa/x86: fix a typos in SSE4.1 detection
[mesa.git] / src / mesa / x86 / common_x86.c
index 910828f16d96b7ec61ded4e38f7e42bd3be07095..ac77c9d77433e0fa937e59621142089e8725a7f0 100644 (file)
@@ -1,6 +1,5 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5.1
  *
  * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
  *
@@ -48,6 +47,9 @@
 #include <sys/sysctl.h>
 #include <machine/cpu.h>
 #endif
+#if defined(USE_X86_64_ASM)
+#include <cpuid.h>
+#endif
 
 #include "main/imports.h"
 #include "common_x86_asm.h"
@@ -224,7 +226,7 @@ _mesa_get_x86_features(void)
        _mesa_debug(NULL, "CPUID not detected\n");
    }
    else {
-       GLuint cpu_features;
+       GLuint cpu_features, cpu_features_ecx;
        GLuint cpu_ext_features;
        GLuint cpu_ext_info;
        char cpu_vendor[13];
@@ -239,6 +241,7 @@ _mesa_get_x86_features(void)
 
        /* get cpu features */
        cpu_features = _mesa_x86_cpuid_edx(1);
+       cpu_features_ecx = _mesa_x86_cpuid_ecx(1);
 
        if (cpu_features & X86_CPU_FPU)
           _mesa_x86_cpu_features |= X86_FEATURE_FPU;
@@ -255,6 +258,8 @@ _mesa_get_x86_features(void)
           _mesa_x86_cpu_features |= X86_FEATURE_XMM;
        if (cpu_features & X86_CPU_XMM2)
           _mesa_x86_cpu_features |= X86_FEATURE_XMM2;
+       if (cpu_features_ecx & X86_CPU_SSE4_1)
+          _mesa_x86_cpu_features |= X86_FEATURE_SSE4_1;
 #endif
 
        /* query extended cpu features */
@@ -331,7 +336,18 @@ _mesa_get_x86_features(void)
    }
 #endif
 
-#endif /* USE_X86_ASM */
+#elif defined(USE_X86_64_ASM)
+   unsigned int uninitialized_var(eax), uninitialized_var(ebx),
+                uninitialized_var(ecx), uninitialized_var(edx);
+
+   /* Always available on x86-64. */
+   _mesa_x86_cpu_features |= X86_FEATURE_XMM | X86_FEATURE_XMM2;
+
+   __get_cpuid(1, &eax, &ebx, &ecx, &edx);
+
+   if (ecx & bit_SSE4_1)
+      _mesa_x86_cpu_features |= X86_FEATURE_SSE4_1;
+#endif /* USE_X86_64_ASM */
 
    (void) detection_debug;
 }