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-2013 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 __PlatformInformation_H__
29 #define __PlatformInformation_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 
45 /* Find CPU type
46 */
47 #if (defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))) || \
48  (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)))
49 # define OGRE_CPU OGRE_CPU_X86
50 
51 #elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE && defined(__BIG_ENDIAN__)
52 # define OGRE_CPU OGRE_CPU_PPC
53 #elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE
54 # define OGRE_CPU OGRE_CPU_X86
55 #elif OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS && (defined(__i386__) || defined(__x86_64__))
56 # define OGRE_CPU OGRE_CPU_X86
57 #elif defined(__arm__) || defined(_M_ARM)
58 # define OGRE_CPU OGRE_CPU_ARM
59 #else
60 # define OGRE_CPU OGRE_CPU_UNKNOWN
61 #endif
62 
63 /* Find how to declare aligned variable.
64 */
65 #if OGRE_COMPILER == OGRE_COMPILER_MSVC
66 # define OGRE_ALIGNED_DECL(type, var, alignment) __declspec(align(alignment)) type var
67 
68 #elif (OGRE_COMPILER == OGRE_COMPILER_GNUC) || (OGRE_COMPILER == OGRE_COMPILER_CLANG)
69 # define OGRE_ALIGNED_DECL(type, var, alignment) type var __attribute__((__aligned__(alignment)))
70 
71 #else
72 # define OGRE_ALIGNED_DECL(type, var, alignment) type var
73 #endif
74 
77 #if OGRE_CPU == OGRE_CPU_X86
78 # define OGRE_SIMD_ALIGNMENT 16
79 
80 #else
81 # define OGRE_SIMD_ALIGNMENT 16
82 #endif
83 
84 /* Declare variable aligned to SIMD alignment.
85 */
86 #define OGRE_SIMD_ALIGNED_DECL(type, var) OGRE_ALIGNED_DECL(type, var, OGRE_SIMD_ALIGNMENT)
87 
88 /* Define whether or not Ogre compiled with SSE supports.
89 */
90 #if OGRE_DOUBLE_PRECISION == 0 && OGRE_CPU == OGRE_CPU_X86 && OGRE_COMPILER == OGRE_COMPILER_MSVC && \
91  OGRE_PLATFORM != OGRE_PLATFORM_NACL
92 # define __OGRE_HAVE_SSE 1
93 #elif OGRE_DOUBLE_PRECISION == 0 && OGRE_CPU == OGRE_CPU_X86 && (OGRE_COMPILER == OGRE_COMPILER_GNUC || OGRE_COMPILER == OGRE_COMPILER_CLANG) && \
94  OGRE_PLATFORM != OGRE_PLATFORM_APPLE_IOS && OGRE_PLATFORM != OGRE_PLATFORM_NACL
95 # define __OGRE_HAVE_SSE 1
96 #endif
97 
98 /* Define whether or not Ogre compiled with VFP supports.
99  */
100 #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__)
101 # define __OGRE_HAVE_VFP 1
102 #endif
103 
104 /* Define whether or not Ogre compiled with NEON supports.
105  */
106 #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__)
107 # define __OGRE_HAVE_NEON 1
108 #endif
109 
110 #ifndef __OGRE_HAVE_SSE
111 # define __OGRE_HAVE_SSE 0
112 #endif
113 
114 #ifndef __OGRE_HAVE_VFP
115 # define __OGRE_HAVE_VFP 0
116 #endif
117 
118 #ifndef __OGRE_HAVE_NEON
119 # define __OGRE_HAVE_NEON 0
120 #endif
121 
144  {
145  public:
146 
149  {
150 #if OGRE_CPU == OGRE_CPU_X86
151  CPU_FEATURE_SSE = 1 << 0,
152  CPU_FEATURE_SSE2 = 1 << 1,
153  CPU_FEATURE_SSE3 = 1 << 2,
154  CPU_FEATURE_MMX = 1 << 3,
155  CPU_FEATURE_MMXEXT = 1 << 4,
156  CPU_FEATURE_3DNOW = 1 << 5,
157  CPU_FEATURE_3DNOWEXT = 1 << 6,
158  CPU_FEATURE_CMOV = 1 << 7,
159  CPU_FEATURE_TSC = 1 << 8,
160  CPU_FEATURE_FPU = 1 << 9,
161  CPU_FEATURE_PRO = 1 << 10,
162  CPU_FEATURE_HTT = 1 << 11,
163 #elif OGRE_CPU == OGRE_CPU_ARM
164  CPU_FEATURE_VFP = 1 << 12,
165  CPU_FEATURE_NEON = 1 << 13,
166 #endif
167 
168  CPU_FEATURE_NONE = 0
169  };
170 
176  static const String& getCpuIdentifier(void);
177 
183  static uint getCpuFeatures(void);
184 
190  static bool hasCpuFeature(CpuFeatures feature);
191 
192 
194  static void log(Log* pLog);
195 
196  };
200 }
201 
202 #endif // __PlatformInformation_H__

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Wed Oct 16 2013 14:35:43