Commit ccd5ecb4 by Nicolas Capens

Detect SSE4.1 support for Subzero.

Bug swiftshader:20 Change-Id: I20c2ab7cb4c00c365520ff8b8500f7594127498b Reviewed-on: https://swiftshader-review.googlesource.com/8468Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 22e18bcc
...@@ -14,8 +14,6 @@ ...@@ -14,8 +14,6 @@
#include "Math.hpp" #include "Math.hpp"
#include "CPUID.hpp"
namespace sw namespace sw
{ {
inline uint64_t FNV_1a(uint64_t hash, unsigned char data) inline uint64_t FNV_1a(uint64_t hash, unsigned char data)
...@@ -26,7 +24,7 @@ namespace sw ...@@ -26,7 +24,7 @@ namespace sw
uint64_t FNV_1a(const unsigned char *data, int size) uint64_t FNV_1a(const unsigned char *data, int size)
{ {
int64_t hash = 0xCBF29CE484222325; int64_t hash = 0xCBF29CE484222325;
for(int i = 0; i < size; i++) for(int i = 0; i < size; i++)
{ {
hash = FNV_1a(hash, data[i]); hash = FNV_1a(hash, data[i]);
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include "FrameBuffer.hpp" #include "FrameBuffer.hpp"
#include "Timer.hpp" #include "Timer.hpp"
#include "CPUID.hpp"
#include "Renderer/Surface.hpp" #include "Renderer/Surface.hpp"
#include "Reactor/Reactor.hpp" #include "Reactor/Reactor.hpp"
#include "Common/Debug.hpp" #include "Common/Debug.hpp"
......
...@@ -57,6 +57,34 @@ namespace ...@@ -57,6 +57,34 @@ namespace
Ice::Fdstream *out = nullptr; Ice::Fdstream *out = nullptr;
} }
namespace
{
class CPUID
{
public:
const static bool SSE4_1;
private:
static void cpuid(int registers[4], int info)
{
#if defined(_WIN32)
__cpuid(registers, info);
#else
__asm volatile("cpuid": "=a" (registers[0]), "=b" (registers[1]), "=c" (registers[2]), "=d" (registers[3]): "a" (info));
#endif
}
static bool detectSSE4_1()
{
int registers[4];
cpuid(registers, 1);
return (registers[2] & 0x00080000) != 0;
}
};
const bool CPUID::SSE4_1 = CPUID::detectSSE4_1();
}
namespace sw namespace sw
{ {
enum EmulatedType enum EmulatedType
...@@ -402,7 +430,7 @@ namespace sw ...@@ -402,7 +430,7 @@ namespace sw
Flags.setOutFileType(Ice::FT_Elf); Flags.setOutFileType(Ice::FT_Elf);
Flags.setOptLevel(Ice::Opt_2); Flags.setOptLevel(Ice::Opt_2);
Flags.setApplicationBinaryInterface(Ice::ABI_Platform); Flags.setApplicationBinaryInterface(Ice::ABI_Platform);
Flags.setTargetInstructionSet(Ice::X86InstructionSet_SSE4_1); Flags.setTargetInstructionSet(CPUID::SSE4_1 ? Ice::X86InstructionSet_SSE4_1 : Ice::X86InstructionSet_SSE2);
Flags.setVerbose(false ? Ice::IceV_All : Ice::IceV_None); Flags.setVerbose(false ? Ice::IceV_All : Ice::IceV_None);
static llvm::raw_os_ostream cout(std::cout); static llvm::raw_os_ostream cout(std::cout);
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "Primitive.hpp" #include "Primitive.hpp"
#include "Surface.hpp" #include "Surface.hpp"
#include "Memory.hpp" #include "Memory.hpp"
#include "CPUID.hpp"
#include "Debug.hpp" #include "Debug.hpp"
#include <string.h> #include <string.h>
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "Context.hpp" #include "Context.hpp"
#include "Surface.hpp" #include "Surface.hpp"
#include "CPUID.hpp"
#include "PixelRoutine.hpp" #include "PixelRoutine.hpp"
#include "Debug.hpp" #include "Debug.hpp"
......
...@@ -1068,7 +1068,7 @@ namespace sw ...@@ -1068,7 +1068,7 @@ namespace sw
if(!routine) // Create one if(!routine) // Create one
{ {
VertexRoutine *generator = 0; VertexRoutine *generator = nullptr;
if(state.fixedFunction) if(state.fixedFunction)
{ {
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include "QuadRasterizer.hpp" #include "QuadRasterizer.hpp"
#include "Surface.hpp" #include "Surface.hpp"
#include "Primitive.hpp" #include "Primitive.hpp"
#include "CPUID.hpp"
#include "SamplerCore.hpp" #include "SamplerCore.hpp"
#include "Constants.hpp" #include "Constants.hpp"
#include "Debug.hpp" #include "Debug.hpp"
......
pnacl-subzero @ dbf81e0c
Subproject commit 4e679e51f645b99940f43c80fec7f146d59eb00f Subproject commit dbf81e0c0e364173176159e0e2548e9948b197a4
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