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-2006 Torus Knot Software Ltd 00008 Also see acknowledgements in Readme.html 00009 00010 This program is free software; you can redistribute it and/or modify it under 00011 the terms of the GNU Lesser General Public License as published by the Free Software 00012 Foundation; either version 2 of the License, or (at your option) any later 00013 version. 00014 00015 This program is distributed in the hope that it will be useful, but WITHOUT 00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public License along with 00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple 00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to 00022 http://www.gnu.org/copyleft/lesser.txt. 00023 00024 You may alternatively use this source under the terms of a specific version of 00025 the OGRE Unrestricted License provided you have obtained such a license from 00026 Torus Knot Software Ltd. 00027 ----------------------------------------------------------------------------- 00028 */ 00029 #ifndef __PlatformInformation_H__ 00030 #define __PlatformInformation_H__ 00031 00032 #include "OgrePrerequisites.h" 00033 00034 namespace Ogre { 00035 // 00036 // TODO: Puts following macros into OgrePlatform.h? 00037 // 00038 00039 /* Initial CPU stuff to set. 00040 */ 00041 #define OGRE_CPU_UNKNOWN 0 00042 #define OGRE_CPU_X86 1 00043 #define OGRE_CPU_PPC 2 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 00056 #else 00057 # define OGRE_CPU OGRE_CPU_UNKNOWN 00058 #endif 00059 00060 /* Find how to declare aligned variable. 00061 */ 00062 #if OGRE_COMPILER == OGRE_COMPILER_MSVC 00063 # define OGRE_ALIGNED_DECL(type, var, alignment) __declspec(align(alignment)) type var 00064 00065 #elif OGRE_COMPILER == OGRE_COMPILER_GNUC 00066 # define OGRE_ALIGNED_DECL(type, var, alignment) type var __attribute__((__aligned__(alignment))) 00067 00068 #else 00069 # define OGRE_ALIGNED_DECL(type, var, alignment) type var 00070 #endif 00071 00074 #if OGRE_CPU == OGRE_CPU_X86 00075 # define OGRE_SIMD_ALIGNMENT 16 00076 00077 #else 00078 # define OGRE_SIMD_ALIGNMENT 16 00079 #endif 00080 00081 /* Declare variable aligned to SIMD alignment. 00082 */ 00083 #define OGRE_SIMD_ALIGNED_DECL(type, var) OGRE_ALIGNED_DECL(type, var, OGRE_SIMD_ALIGNMENT) 00084 00085 /* Define whether or not Ogre compiled with SSE supports. 00086 */ 00087 #if OGRE_DOUBLE_PRECISION == 0 && OGRE_CPU == OGRE_CPU_X86 && OGRE_COMPILER == OGRE_COMPILER_MSVC 00088 # define __OGRE_HAVE_SSE 1 00089 #elif OGRE_DOUBLE_PRECISION == 0 && OGRE_CPU == OGRE_CPU_X86 && OGRE_COMPILER == OGRE_COMPILER_GNUC 00090 # define __OGRE_HAVE_SSE 1 00091 #endif 00092 00093 00094 #ifndef __OGRE_HAVE_SSE 00095 # define __OGRE_HAVE_SSE 0 00096 #endif 00097 00098 00099 00100 00114 class _OgreExport PlatformInformation 00115 { 00116 public: 00117 00119 enum CpuFeatures 00120 { 00121 #if OGRE_CPU == OGRE_CPU_X86 00122 CPU_FEATURE_SSE = 1 << 0, 00123 CPU_FEATURE_SSE2 = 1 << 1, 00124 CPU_FEATURE_SSE3 = 1 << 2, 00125 CPU_FEATURE_MMX = 1 << 3, 00126 CPU_FEATURE_MMXEXT = 1 << 4, 00127 CPU_FEATURE_3DNOW = 1 << 5, 00128 CPU_FEATURE_3DNOWEXT = 1 << 6, 00129 CPU_FEATURE_CMOV = 1 << 7, 00130 CPU_FEATURE_TSC = 1 << 8, 00131 CPU_FEATURE_FPU = 1 << 9, 00132 CPU_FEATURE_PRO = 1 << 10, 00133 CPU_FEATURE_HTT = 1 << 11, 00134 #endif 00135 00136 CPU_FEATURE_NONE = 0 00137 }; 00138 00144 static const String& getCpuIdentifier(void); 00145 00151 static uint getCpuFeatures(void); 00152 00158 static bool hasCpuFeature(CpuFeatures feature); 00159 00160 00162 static void log(Log* pLog); 00163 00164 }; 00165 00166 } 00167 00168 #endif // __PlatformInformation_H__
Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Sep 27 22:02:24 2009