Add check for SSE2-support.

pull/1871/head
Kim Kulling 2018-04-02 10:27:05 +02:00
parent 676e1c9565
commit 4d662c42b3
5 changed files with 43 additions and 3 deletions

View File

@ -186,6 +186,8 @@ SET( Common_SRCS
Bitmap.cpp Bitmap.cpp
Version.cpp Version.cpp
CreateAnimMesh.cpp CreateAnimMesh.cpp
simd.h
simd.cpp
) )
SOURCE_GROUP(Common FILES ${Common_SRCS}) SOURCE_GROUP(Common FILES ${Common_SRCS})

34
code/simd.cpp 100644
View File

@ -0,0 +1,34 @@
#include "simd.h"
namespace Assimp {
bool CPUSupportsSSE2() {
#if defined(__x86_64__) || defined(_M_X64)
//* x86_64 always has SSE2 instructions */
return true;
#elif defined(__GNUC__) && defined(i386)
// for GCC x86 we check cpuid
unsigned int d;
__asm__(
"pushl %%ebx\n\t"
"cpuid\n\t"
"popl %%ebx\n\t"
: "=d" ( d )
:"a" ( 1 ) );
return ( d & 0x04000000 ) != 0;
#elif (defined(_MSC_VER) && defined(_M_IX86))
// also check cpuid for MSVC x86
unsigned int d;
__asm {
xor eax, eax
inc eax
push ebx
cpuid
pop ebx
mov d, edx
}
return ( d & 0x04000000 ) != 0;
#else
return false;
#endif
}
}

5
code/simd.h 100644
View File

@ -0,0 +1,5 @@
#pragma once
namespace Assimp {
bool CPUSupportsSSE2();
}

View File

@ -53,6 +53,7 @@ endif()
LINK_DIRECTORIES( ${Assimp_BINARY_DIR} ${AssetImporter_BINARY_DIR}/lib ) LINK_DIRECTORIES( ${Assimp_BINARY_DIR} ${AssetImporter_BINARY_DIR}/lib )
SET( COMMON SET( COMMON
unit/utSimd.cpp
unit/utIOSystem.cpp unit/utIOSystem.cpp
unit/utIOStreamBuffer.cpp unit/utIOStreamBuffer.cpp
unit/utIssues.cpp unit/utIssues.cpp

View File

@ -5,8 +5,6 @@ Open Asset Import Library (assimp)
Copyright (c) 2006-2018, assimp team Copyright (c) 2006-2018, assimp team
All rights reserved. All rights reserved.
Redistribution and use of this software in source and binary forms, Redistribution and use of this software in source and binary forms,