OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgrePlatformInformation.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4  (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2014 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef _OgrePlatformInformation_H_
29 #define _OgrePlatformInformation_H_
30 
31 #include "OgrePrerequisites.h"
32 
33 namespace Ogre {
34 //
35 // TODO: Puts following macros into OgrePlatform.h?
36 //
37 
38 /* Initial CPU stuff to set.
39 */
40 #define OGRE_CPU_UNKNOWN 0
41 #define OGRE_CPU_X86 1
42 #define OGRE_CPU_PPC 2
43 #define OGRE_CPU_ARM 3
44 #define OGRE_CPU_MIPS 4
45 
46 /* Find CPU type
47 */
48 #if (defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))) || \
49  (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)))
50 # define OGRE_CPU OGRE_CPU_X86
51 
52 #elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE && defined(__BIG_ENDIAN__)
53 # define OGRE_CPU OGRE_CPU_PPC
54 #elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE
55 # define OGRE_CPU OGRE_CPU_X86
56 #elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS && (defined(__i386__) || defined(__x86_64__))
57 # define OGRE_CPU OGRE_CPU_X86
58 #elif defined(__arm__) || defined(_M_ARM) || defined(__arm64__) || defined(_aarch64_)
59 # define OGRE_CPU OGRE_CPU_ARM
60 #elif defined(__mips64) || defined(__mips64_)
61 # define OGRE_CPU OGRE_CPU_MIPS
62 #else
63 # define OGRE_CPU OGRE_CPU_UNKNOWN
64 #endif
65 
66 /* Find how to declare aligned variable.
67 */
68 #if OGRE_COMPILER == OGRE_COMPILER_MSVC
69 # define OGRE_ALIGNED_DECL(type, var, alignment) __declspec(align(alignment)) type var
70 
71 #elif (OGRE_COMPILER == OGRE_COMPILER_GNUC) || (OGRE_COMPILER == OGRE_COMPILER_CLANG)
72 # define OGRE_ALIGNED_DECL(type, var, alignment) type var __attribute__((__aligned__(alignment)))
73 
74 #else
75 # define OGRE_ALIGNED_DECL(type, var, alignment) type var
76 #endif
77 
80 #if OGRE_CPU == OGRE_CPU_X86
81 # define OGRE_SIMD_ALIGNMENT 16
82 
83 #else
84 # define OGRE_SIMD_ALIGNMENT 16
85 #endif
86 
87 /* Declare variable aligned to SIMD alignment.
88 */
89 #define OGRE_SIMD_ALIGNED_DECL(type, var) OGRE_ALIGNED_DECL(type, var, OGRE_SIMD_ALIGNMENT)
90 
91 /* Define whether or not Ogre compiled with SSE support.
92 */
93 #if OGRE_USE_SIMD == 1
94  #if OGRE_DOUBLE_PRECISION == 0 && OGRE_CPU == OGRE_CPU_X86 && OGRE_COMPILER == OGRE_COMPILER_MSVC && \
95  OGRE_PLATFORM != OGRE_PLATFORM_NACL
96  # define __OGRE_HAVE_SSE 1
97  #elif OGRE_DOUBLE_PRECISION == 0 && OGRE_CPU == OGRE_CPU_X86 && (OGRE_COMPILER == OGRE_COMPILER_GNUC || OGRE_COMPILER == OGRE_COMPILER_CLANG) && \
98  OGRE_PLATFORM != OGRE_PLATFORM_APPLE_IOS && OGRE_PLATFORM != OGRE_PLATFORM_NACL
99  # define __OGRE_HAVE_SSE 1
100  #endif
101 
102  /* Define whether or not Ogre compiled with NEON support.
103  */
104  #if OGRE_DOUBLE_PRECISION == 0 && OGRE_CPU == OGRE_CPU_ARM && (OGRE_COMPILER == OGRE_COMPILER_GNUC || OGRE_COMPILER == OGRE_COMPILER_CLANG) && defined(__ARM_NEON__)
105  # define __OGRE_HAVE_NEON 1
106  #endif
107 #endif
108 
109 #ifndef __OGRE_HAVE_SSE
110 # define __OGRE_HAVE_SSE 0
111 #endif
112 
113 #if OGRE_USE_SIMD == 0 || !defined(__OGRE_HAVE_NEON)
114 # define __OGRE_HAVE_NEON 0
115 #endif
116 
117 #if !defined(__OGRE_HAVE_DIRECTXMATH)
118 # define __OGRE_HAVE_DIRECTXMATH 0
119 #endif
120 
143  {
144  public:
145 
148  {
149 #if OGRE_CPU == OGRE_CPU_X86
150  CPU_FEATURE_SSE = 1 << 0,
151  CPU_FEATURE_SSE2 = 1 << 1,
152  CPU_FEATURE_SSE3 = 1 << 2,
153  CPU_FEATURE_MMX = 1 << 3,
154  CPU_FEATURE_MMXEXT = 1 << 4,
155  CPU_FEATURE_3DNOW = 1 << 5,
156  CPU_FEATURE_3DNOWEXT = 1 << 6,
157  CPU_FEATURE_CMOV = 1 << 7,
158  CPU_FEATURE_TSC = 1 << 8,
159  CPU_FEATURE_FPU = 1 << 9,
160  CPU_FEATURE_PRO = 1 << 10,
161  CPU_FEATURE_HTT = 1 << 11,
162 #elif OGRE_CPU == OGRE_CPU_ARM
163  CPU_FEATURE_VFP = 1 << 12,
164  CPU_FEATURE_NEON = 1 << 13,
165 #elif OGRE_CPU == OGRE_CPU_MIPS
166  CPU_FEATURE_MSA = 1 << 14,
167 #endif
168 
169  CPU_FEATURE_NONE = 0
170  };
171 
177  static const String& getCpuIdentifier(void);
178 
184  static uint getCpuFeatures(void);
185 
191  static bool hasCpuFeature(CpuFeatures feature);
192 
197  static uint32 getNumLogicalCores(void);
198 
199 
201  static void log(Log* pLog);
202 
203  };
207 }
208 
209 #endif // _OgrePlatformInformation_H_
unsigned int uint32
Definition: OgrePlatform.h:420
#define _OgreExport
Definition: OgrePlatform.h:255
CpuFeatures
Enum describing the different CPU features we want to check for, platform-dependent.
Class which provides the run-time platform information Ogre runs on.
_StringBase String
Definition: OgreCommon.h:53
unsigned int uint