aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/swr/rasterizer/common
diff options
context:
space:
mode:
authorTim Rowley <[email protected]>2016-05-26 10:51:48 -0600
committerTim Rowley <[email protected]>2016-06-23 10:49:46 -0500
commit95f21a97666d5eb112fffc4d724e54229e06ebf8 (patch)
tree8c8f748ff400ee80e8a57aecdb16562c772203f5 /src/gallium/drivers/swr/rasterizer/common
parent9ca741c64524a57f972ce050919a0e2dec3e64f3 (diff)
swr: [rasterizer common] workaround clang for windows __cpuid() bug
Reviewed-by: Bruce Cherniak <[email protected]>
Diffstat (limited to 'src/gallium/drivers/swr/rasterizer/common')
-rw-r--r--src/gallium/drivers/swr/rasterizer/common/isa.hpp14
1 files 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 ef381799bc3..a62350f2b60 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();