[Mesa-dev] [PATCH v2 01/14] swr: [rasterizer common] workaround clang for windows __cpuid() bug
Tim Rowley
timothy.o.rowley at intel.com
Mon Jun 20 21:36:55 UTC 2016
---
src/gallium/drivers/swr/rasterizer/common/isa.hpp | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/src/gallium/drivers/swr/rasterizer/common/isa.hpp b/src/gallium/drivers/swr/rasterizer/common/isa.hpp
index ef38179..a62350f 100644
--- a/src/gallium/drivers/swr/rasterizer/common/isa.hpp
+++ b/src/gallium/drivers/swr/rasterizer/common/isa.hpp
@@ -30,7 +30,11 @@
#include <string>
#include <algorithm>
-#if defined(_WIN32)
+// Clang for Windows does supply an intrin.h with __cpuid intrinsics, however...
+// It seems to not realize that a write to "b" (ebx) will kill the value in rbx.
+// This attempts to use the "native" clang / gcc intrinsics instead of the windows
+// compatible ones.
+#if defined(_MSC_VER) && !defined(__clang__)
#include <intrin.h>
#else
#include <string.h>
@@ -128,7 +132,7 @@ private:
// Calling __cpuid with 0x0 as the function_id argument
// gets the number of the highest valid function ID.
-#if defined(_WIN32)
+#if defined(_MSC_VER) && !defined(__clang__)
__cpuid(cpui.data(), 0);
nIds_ = cpui[0];
#else
@@ -137,7 +141,7 @@ private:
for (int i = 0; i <= nIds_; ++i)
{
-#if defined(_WIN32)
+#if defined(_MSC_VER) && !defined(__clang__)
__cpuidex(cpui.data(), i, 0);
#else
int *data = cpui.data();
@@ -178,7 +182,7 @@ private:
// Calling __cpuid with 0x80000000 as the function_id argument
// gets the number of the highest valid extended ID.
-#if defined(_WIN32)
+#if defined(_MSC_VER) && !defined(__clang__)
__cpuid(cpui.data(), 0x80000000);
nExIds_ = cpui[0];
#else
@@ -190,7 +194,7 @@ private:
for (unsigned i = 0x80000000; i <= nExIds_; ++i)
{
-#if defined(_WIN32)
+#if defined(_MSC_VER) && !defined(__clang__)
__cpuidex(cpui.data(), i, 0);
#else
int *data = cpui.data();
--
1.9.1
More information about the mesa-dev
mailing list