Commit c71c4506 by Nicolas Capens Committed by Nicolas Capens

Remove Apple-specific CPUID queries.

Bug 18720257 Change-Id: I09c71eb4799e6531b111da7ef8d562513afb7532 Reviewed-on: https://swiftshader-review.googlesource.com/1620Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent fa0cc04a
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include <unistd.h> #include <unistd.h>
#include <sched.h> #include <sched.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/sysctl.h>
#endif #endif
namespace sw namespace sw
...@@ -171,107 +170,51 @@ namespace sw ...@@ -171,107 +170,51 @@ namespace sw
bool CPUID::detectMMX() bool CPUID::detectMMX()
{ {
#if defined(__APPLE__) int registers[4];
int MMX = false; cpuid(registers, 1);
size_t length = sizeof(MMX); return MMX = (registers[3] & 0x00800000) != 0;
sysctlbyname("hw.optional.mmx", &MMX, &length, 0, 0);
#else
int registers[4];
cpuid(registers, 1);
return MMX = (registers[3] & 0x00800000) != 0;
#endif
return MMX;
} }
bool CPUID::detectCMOV() bool CPUID::detectCMOV()
{ {
#if defined(__APPLE__) int registers[4];
int CMOV = false; cpuid(registers, 1);
size_t length = sizeof(CMOV); return CMOV = (registers[3] & 0x00008000) != 0;
sysctlbyname("hw.optional.floatingpoint", &CMOV, &length, 0, 0);
#else
int registers[4];
cpuid(registers, 1);
return CMOV = (registers[3] & 0x00008000) != 0;
#endif
return CMOV;
} }
bool CPUID::detectSSE() bool CPUID::detectSSE()
{ {
#if defined(__APPLE__) int registers[4];
int SSE = false; cpuid(registers, 1);
size_t length = sizeof(SSE); return SSE = (registers[3] & 0x02000000) != 0;
sysctlbyname("hw.optional.sse", &SSE, &length, 0, 0);
#else
int registers[4];
cpuid(registers, 1);
return SSE = (registers[3] & 0x02000000) != 0;
#endif
return SSE;
} }
bool CPUID::detectSSE2() bool CPUID::detectSSE2()
{ {
#if defined(__APPLE__) int registers[4];
int SSE2 = false; cpuid(registers, 1);
size_t length = sizeof(SSE2); return SSE2 = (registers[3] & 0x04000000) != 0;
sysctlbyname("hw.optional.sse2", &SSE2, &length, 0, 0);
#else
int registers[4];
cpuid(registers, 1);
return SSE2 = (registers[3] & 0x04000000) != 0;
#endif
return SSE2;
} }
bool CPUID::detectSSE3() bool CPUID::detectSSE3()
{ {
#if defined(__APPLE__) int registers[4];
int SSE3 = false; cpuid(registers, 1);
size_t length = sizeof(SSE3); return SSE3 = (registers[2] & 0x00000001) != 0;
sysctlbyname("hw.optional.sse3", &SSE3, &length, 0, 0);
#else
int registers[4];
cpuid(registers, 1);
return SSE3 = (registers[2] & 0x00000001) != 0;
#endif
return SSE3;
} }
bool CPUID::detectSSSE3() bool CPUID::detectSSSE3()
{ {
#if defined(__APPLE__) int registers[4];
int SSSE3 = false; cpuid(registers, 1);
size_t length = sizeof(SSSE3); return SSSE3 = (registers[2] & 0x00000200) != 0;
sysctlbyname("hw.optional.supplementalsse3", &SSSE3, &length, 0, 0);
#else
int registers[4];
cpuid(registers, 1);
return SSSE3 = (registers[2] & 0x00000200) != 0;
#endif
return SSSE3;
} }
bool CPUID::detectSSE4_1() bool CPUID::detectSSE4_1()
{ {
#if defined(__APPLE__) int registers[4];
int SSE4_1 = false; cpuid(registers, 1);
size_t length = sizeof(SSE4_1); return SSE4_1 = (registers[2] & 0x00080000) != 0;
sysctlbyname("hw.optional.sse4_1", &SSE4_1, &length, 0, 0);
#else
int registers[4];
cpuid(registers, 1);
return SSE4_1 = (registers[2] & 0x00080000) != 0;
#endif
return SSE4_1;
} }
int CPUID::detectCoreCount() int CPUID::detectCoreCount()
...@@ -293,13 +236,6 @@ namespace sw ...@@ -293,13 +236,6 @@ namespace sw
systemAffinityMask >>= 1; systemAffinityMask >>= 1;
} }
#elif defined(__APPLE__)
int MIB[2];
MIB[0] = CTL_HW;
MIB[1] = HW_NCPU;
size_t length = sizeof(cores);
sysctl(MIB, 2, &cores, &length, 0, 0);
#else #else
cores = sysconf(_SC_NPROCESSORS_ONLN); cores = sysconf(_SC_NPROCESSORS_ONLN);
#endif #endif
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
namespace egl namespace egl
{ {
typedef std::map<EGLNativeDisplayType, Display*> DisplayMap; typedef std::map<EGLNativeDisplayType, Display*> DisplayMap;
DisplayMap displays; DisplayMap displays;
egl::Display *Display::getPlatformDisplay(EGLenum platform, EGLNativeDisplayType displayId) egl::Display *Display::getPlatformDisplay(EGLenum platform, EGLNativeDisplayType displayId)
...@@ -89,16 +89,9 @@ static void cpuid(int registers[4], int info) ...@@ -89,16 +89,9 @@ static void cpuid(int registers[4], int info)
static bool detectSSE() static bool detectSSE()
{ {
#if defined(__APPLE__) int registers[4];
int SSE = false; cpuid(registers, 1);
size_t length = sizeof(SSE); return (registers[3] & 0x02000000) != 0;
sysctlbyname("hw.optional.sse", &SSE, &length, 0, 0);
return SSE;
#else
int registers[4];
cpuid(registers, 1);
return (registers[3] & 0x02000000) != 0;
#endif
} }
bool Display::initialize() bool Display::initialize()
...@@ -112,7 +105,7 @@ bool Display::initialize() ...@@ -112,7 +105,7 @@ bool Display::initialize()
{ {
return false; return false;
} }
mMinSwapInterval = 0; mMinSwapInterval = 0;
mMaxSwapInterval = 4; mMaxSwapInterval = 4;
...@@ -150,7 +143,7 @@ bool Display::initialize() ...@@ -150,7 +143,7 @@ bool Display::initialize()
for(int depthStencilIndex = 0; depthStencilIndex < sizeof(depthStencilFormats) / sizeof(sw::Format); depthStencilIndex++) for(int depthStencilIndex = 0; depthStencilIndex < sizeof(depthStencilFormats) / sizeof(sw::Format); depthStencilIndex++)
{ {
sw::Format depthStencilFormat = depthStencilFormats[depthStencilIndex]; sw::Format depthStencilFormat = depthStencilFormats[depthStencilIndex];
// FIXME: enumerate multi-sampling // FIXME: enumerate multi-sampling
configSet.add(currentDisplayMode, mMinSwapInterval, mMaxSwapInterval, renderTargetFormat, depthStencilFormat, 0); configSet.add(currentDisplayMode, mMinSwapInterval, mMaxSwapInterval, renderTargetFormat, depthStencilFormat, 0);
...@@ -512,11 +505,11 @@ DisplayMode Display::getDisplayMode() const ...@@ -512,11 +505,11 @@ DisplayMode Display::getDisplayMode() const
#if defined(_WIN32) #if defined(_WIN32)
HDC deviceContext = GetDC(0); HDC deviceContext = GetDC(0);
displayMode.width = ::GetDeviceCaps(deviceContext, HORZRES); displayMode.width = ::GetDeviceCaps(deviceContext, HORZRES);
displayMode.height = ::GetDeviceCaps(deviceContext, VERTRES); displayMode.height = ::GetDeviceCaps(deviceContext, VERTRES);
unsigned int bpp = ::GetDeviceCaps(deviceContext, BITSPIXEL); unsigned int bpp = ::GetDeviceCaps(deviceContext, BITSPIXEL);
switch(bpp) switch(bpp)
{ {
case 32: displayMode.format = sw::FORMAT_X8R8G8B8; break; case 32: displayMode.format = sw::FORMAT_X8R8G8B8; break;
...@@ -525,7 +518,7 @@ DisplayMode Display::getDisplayMode() const ...@@ -525,7 +518,7 @@ DisplayMode Display::getDisplayMode() const
default: default:
ASSERT(false); // Unexpected display mode color depth ASSERT(false); // Unexpected display mode color depth
} }
ReleaseDC(0, deviceContext); ReleaseDC(0, deviceContext);
#else #else
if(platform == EGL_PLATFORM_X11_EXT) if(platform == EGL_PLATFORM_X11_EXT)
...@@ -556,4 +549,4 @@ DisplayMode Display::getDisplayMode() const ...@@ -556,4 +549,4 @@ DisplayMode Display::getDisplayMode() const
return displayMode; return displayMode;
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment