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-2012 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 00045 /* Find CPU type 00046 */ 00047 #if (defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))) || \ 00048 (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))) 00049 # define OGRE_CPU OGRE_CPU_X86 00050 00051 #elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE && defined(__BIG_ENDIAN__) 00052 # define OGRE_CPU OGRE_CPU_PPC 00053 #elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE 00054 # define OGRE_CPU OGRE_CPU_X86 00055 #elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS && (defined(__i386__) || defined(__x86_64__)) 00056 # define OGRE_CPU OGRE_CPU_X86 00057 #elif defined(__arm__) 00058 # define OGRE_CPU OGRE_CPU_ARM 00059 #else 00060 # define OGRE_CPU OGRE_CPU_UNKNOWN 00061 #endif 00062 00063 /* Find how to declare aligned variable. 00064 */ 00065 #if OGRE_COMPILER == OGRE_COMPILER_MSVC 00066 # define OGRE_ALIGNED_DECL(type, var, alignment) __declspec(align(alignment)) type var 00067 00068 #elif (OGRE_COMPILER == OGRE_COMPILER_GNUC) || (OGRE_COMPILER == OGRE_COMPILER_CLANG) 00069 # define OGRE_ALIGNED_DECL(type, var, alignment) type var __attribute__((__aligned__(alignment))) 00070 00071 #else 00072 # define OGRE_ALIGNED_DECL(type, var, alignment) type var 00073 #endif 00074 00077 #if OGRE_CPU == OGRE_CPU_X86 00078 # define OGRE_SIMD_ALIGNMENT 16 00079 00080 #else 00081 # define OGRE_SIMD_ALIGNMENT 16 00082 #endif 00083 00084 /* Declare variable aligned to SIMD alignment. 00085 */ 00086 #define OGRE_SIMD_ALIGNED_DECL(type, var) OGRE_ALIGNED_DECL(type, var, OGRE_SIMD_ALIGNMENT) 00087 00088 /* Define whether or not Ogre compiled with SSE supports. 00089 */ 00090 #if OGRE_DOUBLE_PRECISION == 0 && OGRE_CPU == OGRE_CPU_X86 && OGRE_COMPILER == OGRE_COMPILER_MSVC && \ 00091 OGRE_PLATFORM != OGRE_PLATFORM_NACL 00092 # define __OGRE_HAVE_SSE 1 00093 #elif OGRE_DOUBLE_PRECISION == 0 && OGRE_CPU == OGRE_CPU_X86 && (OGRE_COMPILER == OGRE_COMPILER_GNUC || OGRE_COMPILER == OGRE_COMPILER_CLANG) && \ 00094 OGRE_PLATFORM != OGRE_PLATFORM_APPLE_IOS && OGRE_PLATFORM != OGRE_PLATFORM_NACL 00095 # define __OGRE_HAVE_SSE 1 00096 #endif 00097 00098 /* Define whether or not Ogre compiled with VFP supports. 00099 */ 00100 #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__) 00101 # define __OGRE_HAVE_VFP 1 00102 #endif 00103 00104 /* Define whether or not Ogre compiled with NEON supports. 00105 */ 00106 #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__) 00107 # define __OGRE_HAVE_NEON 1 00108 #endif 00109 00110 #ifndef __OGRE_HAVE_SSE 00111 # define __OGRE_HAVE_SSE 0 00112 #endif 00113 00114 #ifndef __OGRE_HAVE_VFP 00115 # define __OGRE_HAVE_VFP 0 00116 #endif 00117 00118 #ifndef __OGRE_HAVE_NEON 00119 # define __OGRE_HAVE_NEON 0 00120 #endif 00121 00143 class _OgreExport PlatformInformation 00144 { 00145 public: 00146 00148 enum CpuFeatures 00149 { 00150 #if OGRE_CPU == OGRE_CPU_X86 00151 CPU_FEATURE_SSE = 1 << 0, 00152 CPU_FEATURE_SSE2 = 1 << 1, 00153 CPU_FEATURE_SSE3 = 1 << 2, 00154 CPU_FEATURE_MMX = 1 << 3, 00155 CPU_FEATURE_MMXEXT = 1 << 4, 00156 CPU_FEATURE_3DNOW = 1 << 5, 00157 CPU_FEATURE_3DNOWEXT = 1 << 6, 00158 CPU_FEATURE_CMOV = 1 << 7, 00159 CPU_FEATURE_TSC = 1 << 8, 00160 CPU_FEATURE_FPU = 1 << 9, 00161 CPU_FEATURE_PRO = 1 << 10, 00162 CPU_FEATURE_HTT = 1 << 11, 00163 #elif OGRE_CPU == OGRE_CPU_ARM 00164 CPU_FEATURE_VFP = 1 << 12, 00165 CPU_FEATURE_NEON = 1 << 13, 00166 #endif 00167 00168 CPU_FEATURE_NONE = 0 00169 }; 00170 00176 static const String& getCpuIdentifier(void); 00177 00183 static uint getCpuFeatures(void); 00184 00190 static bool hasCpuFeature(CpuFeatures feature); 00191 00192 00194 static void log(Log* pLog); 00195 00196 }; 00200 } 00201 00202 #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 Fri May 25 23:36:25 2012