gallium/util: Fix detection of AVX cpu caps
authorAndre Heider <a.heider@gmail.com>
Tue, 23 Jul 2013 17:08:45 +0000 (19:08 +0200)
committerJosé Fonseca <jfonseca@vmware.com>
Tue, 23 Jul 2013 22:12:58 +0000 (23:12 +0100)
commit0acf3a8407fbeaa9d61731ce83fbe6de529e303c
tree6b52f6855eeead08bdc7e7449d19e675b27dda59
parent5a7bdd4b4173958c53109517b7c95f1039623e7e
gallium/util: Fix detection of AVX cpu caps

For AVX it's not sufficient to only rely on the cpuid flags. If the CPU
supports these extensions, but the OS doesn't, issuing these insns will
trigger an undefined opcode exception.

In addition to the AVX cpuid bit we also need to:
* test cpuid for OSXSAVE support
* XGETBV to check if the OS saves/restores AVX regs on context switches

See "Detecting Availability and Support" at
http://software.intel.com/en-us/articles/introduction-to-intel-advanced-vector-extensions

Signed-off-by: Andre Heider <a.heider@gmail.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: José Fonseca <jfonseca@vmware.com>
src/gallium/auxiliary/util/u_cpu_detect.c