oculus1

diff libovr/Src/Kernel/OVR_Timer.h @ 3:b069a5c27388

added a couple more stuff, fixed all the LibOVR line endings
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 15 Sep 2013 04:10:05 +0300
parents e2f9e4603129
children
line diff
     1.1 --- a/libovr/Src/Kernel/OVR_Timer.h	Sat Sep 14 17:51:03 2013 +0300
     1.2 +++ b/libovr/Src/Kernel/OVR_Timer.h	Sun Sep 15 04:10:05 2013 +0300
     1.3 @@ -1,1 +1,100 @@
     1.4 -/************************************************************************************
     1.5 
     1.6 PublicHeader:   OVR
     1.7 Filename    :   OVR_Timer.h
     1.8 Content     :   Provides static functions for precise timing
     1.9 Created     :   September 19, 2012
    1.10 Notes       : 
    1.11 
    1.12 Copyright   :   Copyright 2012 Oculus VR, Inc. All Rights reserved.
    1.13 
    1.14 Use of this software is subject to the terms of the Oculus license
    1.15 agreement provided at the time of installation or download, or which
    1.16 otherwise accompanies this software in either electronic or hard copy form.
    1.17 
    1.18 ************************************************************************************/
    1.19 
    1.20 #ifndef OVR_Timer_h
    1.21 #define OVR_Timer_h
    1.22 
    1.23 #include "OVR_Types.h"
    1.24 
    1.25 namespace OVR {
    1.26     
    1.27 //-----------------------------------------------------------------------------------
    1.28 // ***** Timer
    1.29 
    1.30 // Timer class defines a family of static functions used for application
    1.31 // timing and profiling.
    1.32 
    1.33 class Timer
    1.34 {
    1.35 public:
    1.36     enum {
    1.37         MsPerSecond     = 1000, // Milliseconds in one second.
    1.38         MksPerMs        = 1000, // Microseconds in one millisecond.
    1.39         MksPerSecond    = MsPerSecond * MksPerMs
    1.40     };
    1.41 
    1.42 
    1.43     // ***** Timing APIs for Application    
    1.44     // These APIs should be used to guide animation and other program functions
    1.45     // that require precision.
    1.46 
    1.47     // Returns ticks in milliseconds, as a 32-bit number. May wrap around every
    1.48     // 49.2 days. Use either time difference of two values of GetTicks to avoid
    1.49     // wrap-around.  GetTicksMs may perform better then GetTicks.
    1.50     static UInt32  OVR_STDCALL GetTicksMs();
    1.51 
    1.52     // GetTicks returns general-purpose high resolution application timer value,
    1.53     // measured in microseconds (mks, or 1/1000000 of a second). The actual precision
    1.54     // is system-specific and may be much lower, such as 1 ms.
    1.55     static UInt64  OVR_STDCALL GetTicks();
    1.56 
    1.57     
    1.58     // ***** Profiling APIs.
    1.59     // These functions should be used for profiling, but may have system specific
    1.60     // artifacts that make them less appropriate for general system use.
    1.61     // On Win32, for example these rely on QueryPerformanceConter  may have
    1.62     // problems with thread-core switching and power modes.
    1.63 
    1.64     // Return a hi-res timer value in mks (1/1000000 of a sec).
    1.65     // Generally you want to call this at the start and end of an
    1.66     // operation, and pass the difference to
    1.67     // TicksToSeconds() to find out how long the operation took. 
    1.68     static UInt64  OVR_STDCALL GetProfileTicks();
    1.69 
    1.70     // More convenient zero-based profile timer in seconds. First call initializes 
    1.71     // the "zero" value; future calls return the difference. Not thread safe for first call.
    1.72     // Due to low precision of Double, may malfunction after long runtime.
    1.73     static double  OVR_STDCALL GetProfileSeconds();
    1.74 
    1.75     // Get the raw cycle counter value, providing the maximum possible timer resolution.
    1.76     static UInt64  OVR_STDCALL GetRawTicks();
    1.77     static UInt64  OVR_STDCALL GetRawFrequency();
    1.78 
    1.79     
    1.80     // ***** Tick and time unit conversion.
    1.81 
    1.82     // Convert micro-second ticks value into seconds value.
    1.83     static inline double TicksToSeconds(UInt64 ticks)
    1.84     {
    1.85         return static_cast<double>(ticks) * (1.0 / (double)MksPerSecond);
    1.86     }
    1.87     // Convert Raw or frequency-unit ticks to seconds based on specified frequency.
    1.88     static inline double RawTicksToSeconds(UInt64 rawTicks, UInt64 rawFrequency)
    1.89     {
    1.90         return static_cast<double>(rawTicks) * rawFrequency;
    1.91     }
    1.92 
    1.93 private:
    1.94     friend class System;
    1.95     // System called during program startup/shutdown.
    1.96     static void initializeTimerSystem();
    1.97     static void shutdownTimerSystem();
    1.98 };
    1.99 
   1.100 
   1.101 } // Scaleform::Timer
   1.102 
   1.103 #endif
   1.104 \ No newline at end of file
   1.105 +/************************************************************************************
   1.106 +
   1.107 +PublicHeader:   OVR
   1.108 +Filename    :   OVR_Timer.h
   1.109 +Content     :   Provides static functions for precise timing
   1.110 +Created     :   September 19, 2012
   1.111 +Notes       : 
   1.112 +
   1.113 +Copyright   :   Copyright 2012 Oculus VR, Inc. All Rights reserved.
   1.114 +
   1.115 +Use of this software is subject to the terms of the Oculus license
   1.116 +agreement provided at the time of installation or download, or which
   1.117 +otherwise accompanies this software in either electronic or hard copy form.
   1.118 +
   1.119 +************************************************************************************/
   1.120 +
   1.121 +#ifndef OVR_Timer_h
   1.122 +#define OVR_Timer_h
   1.123 +
   1.124 +#include "OVR_Types.h"
   1.125 +
   1.126 +namespace OVR {
   1.127 +    
   1.128 +//-----------------------------------------------------------------------------------
   1.129 +// ***** Timer
   1.130 +
   1.131 +// Timer class defines a family of static functions used for application
   1.132 +// timing and profiling.
   1.133 +
   1.134 +class Timer
   1.135 +{
   1.136 +public:
   1.137 +    enum {
   1.138 +        MsPerSecond     = 1000, // Milliseconds in one second.
   1.139 +        MksPerMs        = 1000, // Microseconds in one millisecond.
   1.140 +        MksPerSecond    = MsPerSecond * MksPerMs
   1.141 +    };
   1.142 +
   1.143 +
   1.144 +    // ***** Timing APIs for Application    
   1.145 +    // These APIs should be used to guide animation and other program functions
   1.146 +    // that require precision.
   1.147 +
   1.148 +    // Returns ticks in milliseconds, as a 32-bit number. May wrap around every
   1.149 +    // 49.2 days. Use either time difference of two values of GetTicks to avoid
   1.150 +    // wrap-around.  GetTicksMs may perform better then GetTicks.
   1.151 +    static UInt32  OVR_STDCALL GetTicksMs();
   1.152 +
   1.153 +    // GetTicks returns general-purpose high resolution application timer value,
   1.154 +    // measured in microseconds (mks, or 1/1000000 of a second). The actual precision
   1.155 +    // is system-specific and may be much lower, such as 1 ms.
   1.156 +    static UInt64  OVR_STDCALL GetTicks();
   1.157 +
   1.158 +    
   1.159 +    // ***** Profiling APIs.
   1.160 +    // These functions should be used for profiling, but may have system specific
   1.161 +    // artifacts that make them less appropriate for general system use.
   1.162 +    // On Win32, for example these rely on QueryPerformanceConter  may have
   1.163 +    // problems with thread-core switching and power modes.
   1.164 +
   1.165 +    // Return a hi-res timer value in mks (1/1000000 of a sec).
   1.166 +    // Generally you want to call this at the start and end of an
   1.167 +    // operation, and pass the difference to
   1.168 +    // TicksToSeconds() to find out how long the operation took. 
   1.169 +    static UInt64  OVR_STDCALL GetProfileTicks();
   1.170 +
   1.171 +    // More convenient zero-based profile timer in seconds. First call initializes 
   1.172 +    // the "zero" value; future calls return the difference. Not thread safe for first call.
   1.173 +    // Due to low precision of Double, may malfunction after long runtime.
   1.174 +    static double  OVR_STDCALL GetProfileSeconds();
   1.175 +
   1.176 +    // Get the raw cycle counter value, providing the maximum possible timer resolution.
   1.177 +    static UInt64  OVR_STDCALL GetRawTicks();
   1.178 +    static UInt64  OVR_STDCALL GetRawFrequency();
   1.179 +
   1.180 +    
   1.181 +    // ***** Tick and time unit conversion.
   1.182 +
   1.183 +    // Convert micro-second ticks value into seconds value.
   1.184 +    static inline double TicksToSeconds(UInt64 ticks)
   1.185 +    {
   1.186 +        return static_cast<double>(ticks) * (1.0 / (double)MksPerSecond);
   1.187 +    }
   1.188 +    // Convert Raw or frequency-unit ticks to seconds based on specified frequency.
   1.189 +    static inline double RawTicksToSeconds(UInt64 rawTicks, UInt64 rawFrequency)
   1.190 +    {
   1.191 +        return static_cast<double>(rawTicks) * rawFrequency;
   1.192 +    }
   1.193 +
   1.194 +private:
   1.195 +    friend class System;
   1.196 +    // System called during program startup/shutdown.
   1.197 +    static void initializeTimerSystem();
   1.198 +    static void shutdownTimerSystem();
   1.199 +};
   1.200 +
   1.201 +
   1.202 +} // Scaleform::Timer
   1.203 +
   1.204 +#endif