00001 /* 00002 ----------------------------------------------------------------------------- 00003 This source file is part of OGRE 00004 (Object-oriented Graphics Rendering Engine) 00005 For the latest info, see http://www.ogre3d.org/ 00006 00007 Copyright (c) 2000-2013 Torus Knot Software Ltd 00008 00009 Permission is hereby granted, free of charge, to any person obtaining a copy 00010 of this software and associated documentation files (the "Software"), to deal 00011 in the Software without restriction, including without limitation the rights 00012 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00013 copies of the Software, and to permit persons to whom the Software is 00014 furnished to do so, subject to the following conditions: 00015 00016 The above copyright notice and this permission notice shall be included in 00017 all copies or substantial portions of the Software. 00018 00019 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00020 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00021 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00022 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00023 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00024 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00025 THE SOFTWARE. 00026 ----------------------------------------------------------------------------- 00027 */ 00028 #ifndef __PlatformInformation_H__ 00029 #define __PlatformInformation_H__ 00030 00031 #include "OgrePrerequisites.h" 00032 00033 namespace Ogre { 00034 // 00035 // TODO: Puts following macros into OgrePlatform.h? 00036 // 00037 00038 /* Initial CPU stuff to set. 00039 */ 00040 #define OGRE_CPU_UNKNOWN 0 00041 #define OGRE_CPU_X86 1 00042 #define OGRE_CPU_PPC 2 00043 #define OGRE_CPU_ARM 3 00044 #define OGRE_CPU_MIPS 4 00045 00046 /* Find CPU type 00047 */ 00048 #if (defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))) || \ 00049 (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))) 00050 # define OGRE_CPU OGRE_CPU_X86 00051 00052 #elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE && defined(__BIG_ENDIAN__) 00053 # define OGRE_CPU OGRE_CPU_PPC 00054 #elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE 00055 # define OGRE_CPU OGRE_CPU_X86 00056 #elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS && (defined(__i386__) || defined(__x86_64__)) 00057 # define OGRE_CPU OGRE_CPU_X86 00058 #elif defined(__arm__) || defined(_M_ARM) || defined(__arm64__) || defined(_aarch64_) 00059 # define OGRE_CPU OGRE_CPU_ARM 00060 #elif defined(__mips64) || defined(__mips64_) 00061 # define OGRE_CPU OGRE_CPU_MIPS 00062 #else 00063 # define OGRE_CPU OGRE_CPU_UNKNOWN 00064 #endif 00065 00066 /* Find how to declare aligned variable. 00067 */ 00068 #if OGRE_COMPILER == OGRE_COMPILER_MSVC 00069 # define OGRE_ALIGNED_DECL(type, var, alignment) __declspec(align(alignment)) type var 00070 00071 #elif (OGRE_COMPILER == OGRE_COMPILER_GNUC) || (OGRE_COMPILER == OGRE_COMPILER_CLANG) 00072 # define OGRE_ALIGNED_DECL(type, var, alignment) type var __attribute__((__aligned__(alignment))) 00073 00074 #else 00075 # define OGRE_ALIGNED_DECL(type, var, alignment) type var 00076 #endif 00077 00080 #if OGRE_CPU == OGRE_CPU_X86 00081 # define OGRE_SIMD_ALIGNMENT 16 00082 00083 #else 00084 # define OGRE_SIMD_ALIGNMENT 16 00085 #endif 00086 00087 /* Declare variable aligned to SIMD alignment. 00088 */ 00089 #define OGRE_SIMD_ALIGNED_DECL(type, var) OGRE_ALIGNED_DECL(type, var, OGRE_SIMD_ALIGNMENT) 00090 00091 /* Define whether or not Ogre compiled with SSE supports. 00092 */ 00093 #if OGRE_DOUBLE_PRECISION == 0 && OGRE_CPU == OGRE_CPU_X86 && OGRE_COMPILER == OGRE_COMPILER_MSVC && \ 00094 OGRE_PLATFORM != OGRE_PLATFORM_NACL 00095 # define __OGRE_HAVE_SSE 1 00096 #elif OGRE_DOUBLE_PRECISION == 0 && OGRE_CPU == OGRE_CPU_X86 && (OGRE_COMPILER == OGRE_COMPILER_GNUC || OGRE_COMPILER == OGRE_COMPILER_CLANG) && \ 00097 OGRE_PLATFORM != OGRE_PLATFORM_APPLE_IOS && OGRE_PLATFORM != OGRE_PLATFORM_NACL 00098 # define __OGRE_HAVE_SSE 1 00099 #endif 00100 00101 /* Define whether or not Ogre compiled with VFP support. 00102 */ 00103 #if OGRE_DOUBLE_PRECISION == 0 && OGRE_CPU == OGRE_CPU_ARM && (OGRE_COMPILER == OGRE_COMPILER_GNUC || OGRE_COMPILER == OGRE_COMPILER_CLANG) && defined(__ARM_ARCH_6K__) && defined(__VFP_FP__) 00104 # define __OGRE_HAVE_VFP 1 00105 #endif 00106 00107 /* Define whether or not Ogre compiled with NEON support. 00108 */ 00109 #if OGRE_DOUBLE_PRECISION == 0 && OGRE_CPU == OGRE_CPU_ARM && (OGRE_COMPILER == OGRE_COMPILER_GNUC || OGRE_COMPILER == OGRE_COMPILER_CLANG) && defined(__ARM_ARCH_7A__) && defined(__ARM_NEON__) 00110 # define __OGRE_HAVE_NEON 1 00111 #endif 00112 00113 /* Define whether or not Ogre compiled with MSA support. 00114 */ 00115 #if OGRE_DOUBLE_PRECISION == 0 && OGRE_CPU == OGRE_CPU_MIPS && (OGRE_COMPILER == OGRE_COMPILER_GNUC || OGRE_COMPILER == OGRE_COMPILER_CLANG) && defined(__mips_msa) 00116 # define __OGRE_HAVE_MSA 1 00117 #endif 00118 00119 #ifndef __OGRE_HAVE_SSE 00120 # define __OGRE_HAVE_SSE 0 00121 #endif 00122 00123 #ifndef __OGRE_HAVE_VFP 00124 # define __OGRE_HAVE_VFP 0 00125 #endif 00126 00127 #ifndef __OGRE_HAVE_NEON 00128 # define __OGRE_HAVE_NEON 0 00129 #endif 00130 00131 #ifndef __OGRE_HAVE_MSA 00132 # define __OGRE_HAVE_MSA 0 00133 #endif 00134 00156 class _OgreExport PlatformInformation 00157 { 00158 public: 00159 00161 enum CpuFeatures 00162 { 00163 #if OGRE_CPU == OGRE_CPU_X86 00164 CPU_FEATURE_SSE = 1 << 0, 00165 CPU_FEATURE_SSE2 = 1 << 1, 00166 CPU_FEATURE_SSE3 = 1 << 2, 00167 CPU_FEATURE_MMX = 1 << 3, 00168 CPU_FEATURE_MMXEXT = 1 << 4, 00169 CPU_FEATURE_3DNOW = 1 << 5, 00170 CPU_FEATURE_3DNOWEXT = 1 << 6, 00171 CPU_FEATURE_CMOV = 1 << 7, 00172 CPU_FEATURE_TSC = 1 << 8, 00173 CPU_FEATURE_FPU = 1 << 9, 00174 CPU_FEATURE_PRO = 1 << 10, 00175 CPU_FEATURE_HTT = 1 << 11, 00176 #elif OGRE_CPU == OGRE_CPU_ARM 00177 CPU_FEATURE_VFP = 1 << 12, 00178 CPU_FEATURE_NEON = 1 << 13, 00179 #elif OGRE_CPU == OGRE_CPU_MIPS 00180 CPU_FEATURE_MSA = 1 << 14, 00181 #endif 00182 00183 CPU_FEATURE_NONE = 0 00184 }; 00185 00191 static const String& getCpuIdentifier(void); 00192 00198 static uint getCpuFeatures(void); 00199 00205 static bool hasCpuFeature(CpuFeatures feature); 00206 00207 00209 static void log(Log* pLog); 00210 00211 }; 00215 } 00216 00217 #endif // __PlatformInformation_H__
Copyright © 2012 Torus Knot Software Ltd

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Mon Jul 27 2020 13:40:44