OGRE: OgrePlatformInformation.h Source File - OGRE Documentation

# OgrePlatformInformation.h

Go to the documentation of this file.

    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-2009 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_IPHONE && (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
    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 #   define __OGRE_HAVE_SSE  1
    00092 #elif OGRE_DOUBLE_PRECISION == 0 && OGRE_CPU == OGRE_CPU_X86 && OGRE_COMPILER == OGRE_COMPILER_GNUC
    00093 #   define __OGRE_HAVE_SSE  1
    00094 #endif
    00095
    00096 /* Define whether or not Ogre compiled with VFP supports.
    00097  */
    00098 #if OGRE_DOUBLE_PRECISION == 0 && OGRE_CPU == OGRE_CPU_ARM && OGRE_COMPILER == OGRE_COMPILER_GNUC && defined(__ARM_ARCH_6K__) && defined(__VFP_FP__)
    00099 #   define __OGRE_HAVE_VFP  1
    00100 #endif
    00101
    00102 /* Define whether or not Ogre compiled with NEON supports.
    00103  */
    00104 #if OGRE_DOUBLE_PRECISION == 0 && OGRE_CPU == OGRE_CPU_ARM && OGRE_COMPILER == OGRE_COMPILER_GNUC && defined(__ARM_ARCH_7A__) && defined(__ARM_NEON__)
    00105 #   define __OGRE_HAVE_NEON  1
    00106 #endif
    00107
    00108 #ifndef __OGRE_HAVE_SSE
    00109 #   define __OGRE_HAVE_SSE  0
    00110 #endif
    00111
    00112 #ifndef __OGRE_HAVE_VFP
    00113 #   define __OGRE_HAVE_VFP  0
    00114 #endif
    00115
    00116 #ifndef __OGRE_HAVE_NEON
    00117 #   define __OGRE_HAVE_NEON  0
    00118 #endif
    00119
    00141     class _OgreExport PlatformInformation
    00142     {
    00143     public:
    00144
    00146         enum CpuFeatures
    00147         {
    00148 #if OGRE_CPU == OGRE_CPU_X86
    00149             CPU_FEATURE_SSE         = 1 << 0,
    00150             CPU_FEATURE_SSE2        = 1 << 1,
    00151             CPU_FEATURE_SSE3        = 1 << 2,
    00152             CPU_FEATURE_MMX         = 1 << 3,
    00153             CPU_FEATURE_MMXEXT      = 1 << 4,
    00154             CPU_FEATURE_3DNOW       = 1 << 5,
    00155             CPU_FEATURE_3DNOWEXT    = 1 << 6,
    00156             CPU_FEATURE_CMOV        = 1 << 7,
    00157             CPU_FEATURE_TSC         = 1 << 8,
    00158             CPU_FEATURE_FPU         = 1 << 9,
    00159             CPU_FEATURE_PRO         = 1 << 10,
    00160             CPU_FEATURE_HTT         = 1 << 11,
    00161 #elif OGRE_CPU == OGRE_CPU_ARM
    00162             CPU_FEATURE_VFP         = 1 << 12,
    00163             CPU_FEATURE_NEON        = 1 << 13,
    00164 #endif
    00165
    00166             CPU_FEATURE_NONE        = 0
    00167         };
    00168
    00174         static const String& getCpuIdentifier(void);
    00175
    00181         static uint getCpuFeatures(void);
    00182
    00188         static bool hasCpuFeature(CpuFeatures feature);
    00189
    00190
    00192         static void log(Log* pLog);
    00193
    00194     };
    00198 }
    00199
    00200 #endif  // __PlatformInformation_H__

Copyright © 2008 Torus Knot Software Ltd
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
Last modified Wed Nov 3 2010 19:24:52