i965: Add 2x MSAA support to Broadwell fast clear code.
[mesa.git] / src / mesa / x86 / common_x86.c
index b70ee5084dd62dce7ce329198646e816ba18e474..2a936a473ef322533a8960f0d29ce296f272be8b 100644 (file)
@@ -1,6 +1,5 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5.1
  *
  * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
  *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
  */
 
 /**
 #include <sys/sysctl.h>
 #include <machine/cpu.h>
 #endif
+#if defined(USE_X86_64_ASM)
+#include <cpuid.h>
+#if !defined(bit_SSE4_1) && defined(bit_SSE41)
+/* XXX: clang defines bit_SSE41 instead of bit_SSE4_1 */
+#define bit_SSE4_1 bit_SSE41
+#elif !defined(bit_SSE4_1) && !defined(bit_SSE41)
+#define bit_SSE4_1 0x00080000
+#endif
+#endif
 
 #include "main/imports.h"
 #include "common_x86_asm.h"
@@ -82,7 +91,7 @@ extern void _mesa_test_os_sse_support( void );
 extern void _mesa_test_os_sse_exception_support( void );
 
 
-#if defined(WIN32)
+#if defined(_WIN32)
 #ifndef STATUS_FLOAT_MULTIPLE_TRAPS
 # define STATUS_FLOAT_MULTIPLE_TRAPS (0xC00002B5L)
 #endif
@@ -110,7 +119,7 @@ static LONG WINAPI ExceptionFilter(LPEXCEPTION_POINTERS exp)
 
    return EXCEPTION_CONTINUE_EXECUTION;
 }
-#endif /* WIN32 */
+#endif /* _WIN32 */
 
 
 /**
@@ -149,7 +158,7 @@ void _mesa_check_os_sse_support( void )
       if (ret || !enabled)
          _mesa_x86_cpu_features &= ~(X86_FEATURE_XMM);
    }
-#elif defined(WIN32)
+#elif defined(_WIN32)
    LPTOP_LEVEL_EXCEPTION_FILTER oldFilter;
    
    /* Install our ExceptionFilter */
@@ -223,7 +232,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];
@@ -238,6 +247,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;
@@ -254,6 +264,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 */
@@ -330,7 +342,20 @@ _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;
 }