1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Mesa 3-D graphics library 3bf215546Sopenharmony_ci * 4bf215546Sopenharmony_ci * Copyright (C) 1999-2006 Brian Paul All Rights Reserved. 5bf215546Sopenharmony_ci * 6bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 7bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 8bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 9bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 11bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 12bf215546Sopenharmony_ci * 13bf215546Sopenharmony_ci * The above copyright notice and this permission notice shall be included 14bf215546Sopenharmony_ci * in all copies or substantial portions of the Software. 15bf215546Sopenharmony_ci * 16bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 17bf215546Sopenharmony_ci * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20bf215546Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21bf215546Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22bf215546Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE. 23bf215546Sopenharmony_ci */ 24bf215546Sopenharmony_ci 25bf215546Sopenharmony_ci/** 26bf215546Sopenharmony_ci * \file common_x86.c 27bf215546Sopenharmony_ci * 28bf215546Sopenharmony_ci * Check CPU capabilities & initialize optimized funtions for this particular 29bf215546Sopenharmony_ci * processor. 30bf215546Sopenharmony_ci * 31bf215546Sopenharmony_ci * Changed by Andre Werthmann for using the new SSE functions. 32bf215546Sopenharmony_ci * 33bf215546Sopenharmony_ci * \author Holger Waechtler <holger@akaflieg.extern.tu-berlin.de> 34bf215546Sopenharmony_ci * \author Andre Werthmann <wertmann@cs.uni-potsdam.de> 35bf215546Sopenharmony_ci */ 36bf215546Sopenharmony_ci 37bf215546Sopenharmony_ci/* XXX these includes should probably go into imports.h or glheader.h */ 38bf215546Sopenharmony_ci#if defined(USE_SSE_ASM) && defined(__FreeBSD__) 39bf215546Sopenharmony_ci#include <sys/types.h> 40bf215546Sopenharmony_ci#include <sys/sysctl.h> 41bf215546Sopenharmony_ci#endif 42bf215546Sopenharmony_ci#if defined(USE_SSE_ASM) && (defined(__OpenBSD__) || defined(__NetBSD__)) 43bf215546Sopenharmony_ci#include <sys/param.h> 44bf215546Sopenharmony_ci#include <sys/sysctl.h> 45bf215546Sopenharmony_ci#include <machine/cpu.h> 46bf215546Sopenharmony_ci#endif 47bf215546Sopenharmony_ci#if defined(USE_X86_64_ASM) 48bf215546Sopenharmony_ci#include <cpuid.h> 49bf215546Sopenharmony_ci#if !defined(bit_SSE4_1) && defined(bit_SSE41) 50bf215546Sopenharmony_ci/* XXX: clang defines bit_SSE41 instead of bit_SSE4_1 */ 51bf215546Sopenharmony_ci#define bit_SSE4_1 bit_SSE41 52bf215546Sopenharmony_ci#elif !defined(bit_SSE4_1) && !defined(bit_SSE41) 53bf215546Sopenharmony_ci#define bit_SSE4_1 0x00080000 54bf215546Sopenharmony_ci#endif 55bf215546Sopenharmony_ci#endif 56bf215546Sopenharmony_ci 57bf215546Sopenharmony_ci#include <stdlib.h> 58bf215546Sopenharmony_ci 59bf215546Sopenharmony_ci#include "main/errors.h" 60bf215546Sopenharmony_ci 61bf215546Sopenharmony_ci#include "common_x86_asm.h" 62bf215546Sopenharmony_ci 63bf215546Sopenharmony_ci 64bf215546Sopenharmony_ci/** Bitmask of X86_FEATURE_x bits */ 65bf215546Sopenharmony_ciint _mesa_x86_cpu_features = 0x0; 66bf215546Sopenharmony_ci 67bf215546Sopenharmony_cistatic int detection_debug = GL_FALSE; 68bf215546Sopenharmony_ci 69bf215546Sopenharmony_ci/* No reason for this to be public. 70bf215546Sopenharmony_ci */ 71bf215546Sopenharmony_ciextern GLuint _mesa_x86_has_cpuid(void); 72bf215546Sopenharmony_ciextern void _mesa_x86_cpuid(GLuint op, GLuint *reg_eax, GLuint *reg_ebx, GLuint *reg_ecx, GLuint *reg_edx); 73bf215546Sopenharmony_ciextern GLuint _mesa_x86_cpuid_eax(GLuint op); 74bf215546Sopenharmony_ciextern GLuint _mesa_x86_cpuid_ebx(GLuint op); 75bf215546Sopenharmony_ciextern GLuint _mesa_x86_cpuid_ecx(GLuint op); 76bf215546Sopenharmony_ciextern GLuint _mesa_x86_cpuid_edx(GLuint op); 77bf215546Sopenharmony_ci 78bf215546Sopenharmony_ci 79bf215546Sopenharmony_ci#if defined(USE_SSE_ASM) 80bf215546Sopenharmony_ci/* 81bf215546Sopenharmony_ci * We must verify that the Streaming SIMD Extensions are truly supported 82bf215546Sopenharmony_ci * on this processor before we go ahead and hook out the optimized code. 83bf215546Sopenharmony_ci * 84bf215546Sopenharmony_ci * However, I have been told by Alan Cox that all 2.4 (and later) Linux 85bf215546Sopenharmony_ci * kernels provide full SSE support on all processors that expose SSE via 86bf215546Sopenharmony_ci * the CPUID mechanism. 87bf215546Sopenharmony_ci */ 88bf215546Sopenharmony_ci 89bf215546Sopenharmony_ci/* These are assembly functions: */ 90bf215546Sopenharmony_ciextern void _mesa_test_os_sse_support( void ); 91bf215546Sopenharmony_ciextern void _mesa_test_os_sse_exception_support( void ); 92bf215546Sopenharmony_ci 93bf215546Sopenharmony_ci 94bf215546Sopenharmony_ci#if defined(_WIN32) 95bf215546Sopenharmony_ci#ifndef STATUS_FLOAT_MULTIPLE_TRAPS 96bf215546Sopenharmony_ci# define STATUS_FLOAT_MULTIPLE_TRAPS (0xC00002B5L) 97bf215546Sopenharmony_ci#endif 98bf215546Sopenharmony_cistatic LONG WINAPI ExceptionFilter(LPEXCEPTION_POINTERS exp) 99bf215546Sopenharmony_ci{ 100bf215546Sopenharmony_ci PEXCEPTION_RECORD rec = exp->ExceptionRecord; 101bf215546Sopenharmony_ci PCONTEXT ctx = exp->ContextRecord; 102bf215546Sopenharmony_ci 103bf215546Sopenharmony_ci if ( rec->ExceptionCode == EXCEPTION_ILLEGAL_INSTRUCTION ) { 104bf215546Sopenharmony_ci _mesa_debug(NULL, "EXCEPTION_ILLEGAL_INSTRUCTION\n" ); 105bf215546Sopenharmony_ci _mesa_x86_cpu_features &= ~(X86_FEATURE_XMM); 106bf215546Sopenharmony_ci } else if ( rec->ExceptionCode == STATUS_FLOAT_MULTIPLE_TRAPS ) { 107bf215546Sopenharmony_ci _mesa_debug(NULL, "STATUS_FLOAT_MULTIPLE_TRAPS\n"); 108bf215546Sopenharmony_ci /* Windows seems to clear the exception flag itself, we just have to increment Eip */ 109bf215546Sopenharmony_ci } else { 110bf215546Sopenharmony_ci _mesa_debug(NULL, "UNEXPECTED EXCEPTION (0x%08x), terminating!\n" ); 111bf215546Sopenharmony_ci return EXCEPTION_EXECUTE_HANDLER; 112bf215546Sopenharmony_ci } 113bf215546Sopenharmony_ci 114bf215546Sopenharmony_ci if ( (ctx->ContextFlags & CONTEXT_CONTROL) != CONTEXT_CONTROL ) { 115bf215546Sopenharmony_ci _mesa_debug(NULL, "Context does not contain control registers, terminating!\n"); 116bf215546Sopenharmony_ci return EXCEPTION_EXECUTE_HANDLER; 117bf215546Sopenharmony_ci } 118bf215546Sopenharmony_ci ctx->Eip += 3; 119bf215546Sopenharmony_ci 120bf215546Sopenharmony_ci return EXCEPTION_CONTINUE_EXECUTION; 121bf215546Sopenharmony_ci} 122bf215546Sopenharmony_ci#endif /* _WIN32 */ 123bf215546Sopenharmony_ci 124bf215546Sopenharmony_ci 125bf215546Sopenharmony_ci/** 126bf215546Sopenharmony_ci * Check if SSE is supported. 127bf215546Sopenharmony_ci * If not, turn off the X86_FEATURE_XMM flag in _mesa_x86_cpu_features. 128bf215546Sopenharmony_ci */ 129bf215546Sopenharmony_civoid _mesa_check_os_sse_support( void ) 130bf215546Sopenharmony_ci{ 131bf215546Sopenharmony_ci#if defined(__FreeBSD__) 132bf215546Sopenharmony_ci { 133bf215546Sopenharmony_ci int ret, enabled; 134bf215546Sopenharmony_ci unsigned int len; 135bf215546Sopenharmony_ci len = sizeof(enabled); 136bf215546Sopenharmony_ci ret = sysctlbyname("hw.instruction_sse", &enabled, &len, NULL, 0); 137bf215546Sopenharmony_ci if (ret || !enabled) 138bf215546Sopenharmony_ci _mesa_x86_cpu_features &= ~(X86_FEATURE_XMM); 139bf215546Sopenharmony_ci } 140bf215546Sopenharmony_ci#elif defined (__NetBSD__) 141bf215546Sopenharmony_ci { 142bf215546Sopenharmony_ci int ret, enabled; 143bf215546Sopenharmony_ci size_t len = sizeof(enabled); 144bf215546Sopenharmony_ci ret = sysctlbyname("machdep.sse", &enabled, &len, (void *)NULL, 0); 145bf215546Sopenharmony_ci if (ret || !enabled) 146bf215546Sopenharmony_ci _mesa_x86_cpu_features &= ~(X86_FEATURE_XMM); 147bf215546Sopenharmony_ci } 148bf215546Sopenharmony_ci#elif defined(__OpenBSD__) 149bf215546Sopenharmony_ci { 150bf215546Sopenharmony_ci int mib[2]; 151bf215546Sopenharmony_ci int ret, enabled; 152bf215546Sopenharmony_ci size_t len = sizeof(enabled); 153bf215546Sopenharmony_ci 154bf215546Sopenharmony_ci mib[0] = CTL_MACHDEP; 155bf215546Sopenharmony_ci mib[1] = CPU_SSE; 156bf215546Sopenharmony_ci 157bf215546Sopenharmony_ci ret = sysctl(mib, 2, &enabled, &len, NULL, 0); 158bf215546Sopenharmony_ci if (ret || !enabled) 159bf215546Sopenharmony_ci _mesa_x86_cpu_features &= ~(X86_FEATURE_XMM); 160bf215546Sopenharmony_ci } 161bf215546Sopenharmony_ci#elif defined(_WIN32) 162bf215546Sopenharmony_ci LPTOP_LEVEL_EXCEPTION_FILTER oldFilter; 163bf215546Sopenharmony_ci 164bf215546Sopenharmony_ci /* Install our ExceptionFilter */ 165bf215546Sopenharmony_ci oldFilter = SetUnhandledExceptionFilter( ExceptionFilter ); 166bf215546Sopenharmony_ci 167bf215546Sopenharmony_ci if ( cpu_has_xmm ) { 168bf215546Sopenharmony_ci _mesa_debug(NULL, "Testing OS support for SSE...\n"); 169bf215546Sopenharmony_ci 170bf215546Sopenharmony_ci _mesa_test_os_sse_support(); 171bf215546Sopenharmony_ci 172bf215546Sopenharmony_ci if ( cpu_has_xmm ) { 173bf215546Sopenharmony_ci _mesa_debug(NULL, "Yes.\n"); 174bf215546Sopenharmony_ci } else { 175bf215546Sopenharmony_ci _mesa_debug(NULL, "No!\n"); 176bf215546Sopenharmony_ci } 177bf215546Sopenharmony_ci } 178bf215546Sopenharmony_ci 179bf215546Sopenharmony_ci if ( cpu_has_xmm ) { 180bf215546Sopenharmony_ci _mesa_debug(NULL, "Testing OS support for SSE unmasked exceptions...\n"); 181bf215546Sopenharmony_ci 182bf215546Sopenharmony_ci _mesa_test_os_sse_exception_support(); 183bf215546Sopenharmony_ci 184bf215546Sopenharmony_ci if ( cpu_has_xmm ) { 185bf215546Sopenharmony_ci _mesa_debug(NULL, "Yes.\n"); 186bf215546Sopenharmony_ci } else { 187bf215546Sopenharmony_ci _mesa_debug(NULL, "No!\n"); 188bf215546Sopenharmony_ci } 189bf215546Sopenharmony_ci } 190bf215546Sopenharmony_ci 191bf215546Sopenharmony_ci /* Restore previous exception filter */ 192bf215546Sopenharmony_ci SetUnhandledExceptionFilter( oldFilter ); 193bf215546Sopenharmony_ci 194bf215546Sopenharmony_ci if ( cpu_has_xmm ) { 195bf215546Sopenharmony_ci _mesa_debug(NULL, "Tests of OS support for SSE passed.\n"); 196bf215546Sopenharmony_ci } else { 197bf215546Sopenharmony_ci _mesa_debug(NULL, "Tests of OS support for SSE failed!\n"); 198bf215546Sopenharmony_ci } 199bf215546Sopenharmony_ci#else 200bf215546Sopenharmony_ci /* Do nothing on other platforms for now. 201bf215546Sopenharmony_ci */ 202bf215546Sopenharmony_ci if (detection_debug) 203bf215546Sopenharmony_ci _mesa_debug(NULL, "Not testing OS support for SSE, leaving enabled.\n"); 204bf215546Sopenharmony_ci#endif /* __FreeBSD__ */ 205bf215546Sopenharmony_ci} 206bf215546Sopenharmony_ci 207bf215546Sopenharmony_ci#endif /* USE_SSE_ASM */ 208bf215546Sopenharmony_ci 209bf215546Sopenharmony_ci 210bf215546Sopenharmony_ci/** 211bf215546Sopenharmony_ci * Initialize the _mesa_x86_cpu_features bitfield. 212bf215546Sopenharmony_ci * This is a no-op if called more than once. 213bf215546Sopenharmony_ci */ 214bf215546Sopenharmony_civoid 215bf215546Sopenharmony_ci_mesa_get_x86_features(void) 216bf215546Sopenharmony_ci{ 217bf215546Sopenharmony_ci static int called = 0; 218bf215546Sopenharmony_ci 219bf215546Sopenharmony_ci if (called) 220bf215546Sopenharmony_ci return; 221bf215546Sopenharmony_ci 222bf215546Sopenharmony_ci called = 1; 223bf215546Sopenharmony_ci 224bf215546Sopenharmony_ci#ifdef USE_X86_ASM 225bf215546Sopenharmony_ci _mesa_x86_cpu_features = 0x0; 226bf215546Sopenharmony_ci 227bf215546Sopenharmony_ci if (getenv( "MESA_NO_ASM")) { 228bf215546Sopenharmony_ci return; 229bf215546Sopenharmony_ci } 230bf215546Sopenharmony_ci 231bf215546Sopenharmony_ci if (!_mesa_x86_has_cpuid()) { 232bf215546Sopenharmony_ci _mesa_debug(NULL, "CPUID not detected\n"); 233bf215546Sopenharmony_ci } 234bf215546Sopenharmony_ci else { 235bf215546Sopenharmony_ci GLuint cpu_features, cpu_features_ecx; 236bf215546Sopenharmony_ci GLuint cpu_ext_features; 237bf215546Sopenharmony_ci GLuint cpu_ext_info; 238bf215546Sopenharmony_ci char cpu_vendor[13]; 239bf215546Sopenharmony_ci GLuint result; 240bf215546Sopenharmony_ci 241bf215546Sopenharmony_ci /* get vendor name */ 242bf215546Sopenharmony_ci _mesa_x86_cpuid(0, &result, (GLuint *)(cpu_vendor + 0), (GLuint *)(cpu_vendor + 8), (GLuint *)(cpu_vendor + 4)); 243bf215546Sopenharmony_ci cpu_vendor[12] = '\0'; 244bf215546Sopenharmony_ci 245bf215546Sopenharmony_ci if (detection_debug) 246bf215546Sopenharmony_ci _mesa_debug(NULL, "CPU vendor: %s\n", cpu_vendor); 247bf215546Sopenharmony_ci 248bf215546Sopenharmony_ci /* get cpu features */ 249bf215546Sopenharmony_ci cpu_features = _mesa_x86_cpuid_edx(1); 250bf215546Sopenharmony_ci cpu_features_ecx = _mesa_x86_cpuid_ecx(1); 251bf215546Sopenharmony_ci 252bf215546Sopenharmony_ci if (cpu_features & X86_CPU_FPU) 253bf215546Sopenharmony_ci _mesa_x86_cpu_features |= X86_FEATURE_FPU; 254bf215546Sopenharmony_ci if (cpu_features & X86_CPU_CMOV) 255bf215546Sopenharmony_ci _mesa_x86_cpu_features |= X86_FEATURE_CMOV; 256bf215546Sopenharmony_ci 257bf215546Sopenharmony_ci#ifdef USE_MMX_ASM 258bf215546Sopenharmony_ci if (cpu_features & X86_CPU_MMX) 259bf215546Sopenharmony_ci _mesa_x86_cpu_features |= X86_FEATURE_MMX; 260bf215546Sopenharmony_ci#endif 261bf215546Sopenharmony_ci 262bf215546Sopenharmony_ci#ifdef USE_SSE_ASM 263bf215546Sopenharmony_ci if (cpu_features & X86_CPU_XMM) 264bf215546Sopenharmony_ci _mesa_x86_cpu_features |= X86_FEATURE_XMM; 265bf215546Sopenharmony_ci if (cpu_features & X86_CPU_XMM2) 266bf215546Sopenharmony_ci _mesa_x86_cpu_features |= X86_FEATURE_XMM2; 267bf215546Sopenharmony_ci if (cpu_features_ecx & X86_CPU_SSE4_1) 268bf215546Sopenharmony_ci _mesa_x86_cpu_features |= X86_FEATURE_SSE4_1; 269bf215546Sopenharmony_ci#endif 270bf215546Sopenharmony_ci 271bf215546Sopenharmony_ci /* query extended cpu features */ 272bf215546Sopenharmony_ci if ((cpu_ext_info = _mesa_x86_cpuid_eax(0x80000000)) > 0x80000000) { 273bf215546Sopenharmony_ci if (cpu_ext_info >= 0x80000001) { 274bf215546Sopenharmony_ci 275bf215546Sopenharmony_ci cpu_ext_features = _mesa_x86_cpuid_edx(0x80000001); 276bf215546Sopenharmony_ci 277bf215546Sopenharmony_ci if (cpu_features & X86_CPU_MMX) { 278bf215546Sopenharmony_ci 279bf215546Sopenharmony_ci#ifdef USE_3DNOW_ASM 280bf215546Sopenharmony_ci if (cpu_ext_features & X86_CPUEXT_3DNOW) 281bf215546Sopenharmony_ci _mesa_x86_cpu_features |= X86_FEATURE_3DNOW; 282bf215546Sopenharmony_ci if (cpu_ext_features & X86_CPUEXT_3DNOW_EXT) 283bf215546Sopenharmony_ci _mesa_x86_cpu_features |= X86_FEATURE_3DNOWEXT; 284bf215546Sopenharmony_ci#endif 285bf215546Sopenharmony_ci 286bf215546Sopenharmony_ci#ifdef USE_MMX_ASM 287bf215546Sopenharmony_ci if (cpu_ext_features & X86_CPUEXT_MMX_EXT) 288bf215546Sopenharmony_ci _mesa_x86_cpu_features |= X86_FEATURE_MMXEXT; 289bf215546Sopenharmony_ci#endif 290bf215546Sopenharmony_ci } 291bf215546Sopenharmony_ci } 292bf215546Sopenharmony_ci 293bf215546Sopenharmony_ci /* query cpu name */ 294bf215546Sopenharmony_ci if (cpu_ext_info >= 0x80000002) { 295bf215546Sopenharmony_ci GLuint ofs; 296bf215546Sopenharmony_ci char cpu_name[49]; 297bf215546Sopenharmony_ci for (ofs = 0; ofs < 3; ofs++) 298bf215546Sopenharmony_ci _mesa_x86_cpuid(0x80000002+ofs, (GLuint *)(cpu_name + (16*ofs)+0), (GLuint *)(cpu_name + (16*ofs)+4), (GLuint *)(cpu_name + (16*ofs)+8), (GLuint *)(cpu_name + (16*ofs)+12)); 299bf215546Sopenharmony_ci cpu_name[48] = '\0'; /* the name should be NULL terminated, but just to be sure */ 300bf215546Sopenharmony_ci 301bf215546Sopenharmony_ci if (detection_debug) 302bf215546Sopenharmony_ci _mesa_debug(NULL, "CPU name: %s\n", cpu_name); 303bf215546Sopenharmony_ci } 304bf215546Sopenharmony_ci } 305bf215546Sopenharmony_ci 306bf215546Sopenharmony_ci } 307bf215546Sopenharmony_ci 308bf215546Sopenharmony_ci#ifdef USE_MMX_ASM 309bf215546Sopenharmony_ci if ( cpu_has_mmx ) { 310bf215546Sopenharmony_ci if ( getenv( "MESA_NO_MMX" ) == 0 ) { 311bf215546Sopenharmony_ci if (detection_debug) 312bf215546Sopenharmony_ci _mesa_debug(NULL, "MMX cpu detected.\n"); 313bf215546Sopenharmony_ci } else { 314bf215546Sopenharmony_ci _mesa_x86_cpu_features &= ~(X86_FEATURE_MMX); 315bf215546Sopenharmony_ci } 316bf215546Sopenharmony_ci } 317bf215546Sopenharmony_ci#endif 318bf215546Sopenharmony_ci 319bf215546Sopenharmony_ci#ifdef USE_3DNOW_ASM 320bf215546Sopenharmony_ci if ( cpu_has_3dnow ) { 321bf215546Sopenharmony_ci if ( getenv( "MESA_NO_3DNOW" ) == 0 ) { 322bf215546Sopenharmony_ci if (detection_debug) 323bf215546Sopenharmony_ci _mesa_debug(NULL, "3DNow! cpu detected.\n"); 324bf215546Sopenharmony_ci } else { 325bf215546Sopenharmony_ci _mesa_x86_cpu_features &= ~(X86_FEATURE_3DNOW); 326bf215546Sopenharmony_ci } 327bf215546Sopenharmony_ci } 328bf215546Sopenharmony_ci#endif 329bf215546Sopenharmony_ci 330bf215546Sopenharmony_ci#ifdef USE_SSE_ASM 331bf215546Sopenharmony_ci if ( cpu_has_xmm ) { 332bf215546Sopenharmony_ci if ( getenv( "MESA_NO_SSE" ) == 0 ) { 333bf215546Sopenharmony_ci if (detection_debug) 334bf215546Sopenharmony_ci _mesa_debug(NULL, "SSE cpu detected.\n"); 335bf215546Sopenharmony_ci if ( getenv( "MESA_FORCE_SSE" ) == 0 ) { 336bf215546Sopenharmony_ci _mesa_check_os_sse_support(); 337bf215546Sopenharmony_ci } 338bf215546Sopenharmony_ci } else { 339bf215546Sopenharmony_ci _mesa_debug(NULL, "SSE cpu detected, but switched off by user.\n"); 340bf215546Sopenharmony_ci _mesa_x86_cpu_features &= ~(X86_FEATURE_XMM); 341bf215546Sopenharmony_ci } 342bf215546Sopenharmony_ci } 343bf215546Sopenharmony_ci#endif 344bf215546Sopenharmony_ci 345bf215546Sopenharmony_ci#elif defined(USE_X86_64_ASM) 346bf215546Sopenharmony_ci { 347bf215546Sopenharmony_ci unsigned int eax, ebx, ecx, edx; 348bf215546Sopenharmony_ci 349bf215546Sopenharmony_ci /* Always available on x86-64. */ 350bf215546Sopenharmony_ci _mesa_x86_cpu_features |= X86_FEATURE_XMM | X86_FEATURE_XMM2; 351bf215546Sopenharmony_ci 352bf215546Sopenharmony_ci if (!__get_cpuid(1, &eax, &ebx, &ecx, &edx)) 353bf215546Sopenharmony_ci return; 354bf215546Sopenharmony_ci 355bf215546Sopenharmony_ci if (ecx & bit_SSE4_1) 356bf215546Sopenharmony_ci _mesa_x86_cpu_features |= X86_FEATURE_SSE4_1; 357bf215546Sopenharmony_ci } 358bf215546Sopenharmony_ci#endif /* USE_X86_64_ASM */ 359bf215546Sopenharmony_ci 360bf215546Sopenharmony_ci (void) detection_debug; 361bf215546Sopenharmony_ci} 362