ovr_sdk

view LibOVR/Src/Util/Util_LatencyTest2State.h @ 0:1b39a1b46319

initial 0.4.4
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 14 Jan 2015 06:51:16 +0200
parents
children
line source
1 /************************************************************************************
3 Filename : Util_LatencyTest2Reader.h
4 Content : Shared functionality for the DK2 latency tester
5 Created : July 8, 2014
6 Authors : Volga Aksoy, Chris Taylor
8 Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved.
10 Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License");
11 you may not use the Oculus VR Rift SDK except in compliance with the License,
12 which is provided at the time of installation or download, or which
13 otherwise accompanies this software in either electronic or hard copy form.
15 You may obtain a copy of the License at
17 http://www.oculusvr.com/licenses/LICENSE-3.2
19 Unless required by applicable law or agreed to in writing, the Oculus VR SDK
20 distributed under the License is distributed on an "AS IS" BASIS,
21 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 See the License for the specific language governing permissions and
23 limitations under the License.
25 *************************************************************************************/
27 #ifndef OVR_Util_LatencyTest2_State_h
28 #define OVR_Util_LatencyTest2_State_h
30 #include "../Kernel/OVR_Lockless.h"
32 namespace OVR { namespace Util {
35 enum LatencyTester2Constants
36 {
37 LT2_ColorIncrement = 32,
38 LT2_PixelTestThreshold = LT2_ColorIncrement / 3,
39 LT2_IncrementCount = 256 / LT2_ColorIncrement,
40 LT2_TimeoutWaitingForColorDetected = 1000 // 1 second
41 };
44 //-------------------------------------------------------------------------------------
45 // FrameTimeRecord
47 // Describes frame scan-out time used for latency testing.
48 struct FrameTimeRecord
49 {
50 int ReadbackIndex;
51 double TimeSeconds;
53 // Utility functions to convert color to readBack indices and back.
54 // The purpose of ReadbackIndex is to allow direct comparison by value.
56 static bool ColorToReadbackIndex(int *readbackIndex, unsigned char color);
57 static unsigned char ReadbackIndexToColor(int readbackIndex);
58 };
61 //-----------------------------------------------------------------------------
62 // FrameTimeRecordSet
64 // FrameTimeRecordSet is a container holding multiple consecutive frame timing records
65 // returned from the lock-less state. Used by FrameTimeManager.
66 struct FrameTimeRecordSet
67 {
68 enum {
69 RecordCount = 4,
70 RecordMask = RecordCount - 1
71 };
72 FrameTimeRecord Records[RecordCount];
73 int NextWriteIndex;
75 FrameTimeRecordSet();
77 void AddValue(int readValue, double timeSeconds);
78 // Matching should be done starting from NextWrite index
79 // until wrap-around
81 const FrameTimeRecord& operator [] (int i) const;
83 const FrameTimeRecord& GetMostRecentFrame();
85 // Advances I to absolute color index
86 bool FindReadbackIndex(int* i, int readbackIndex) const;
88 bool IsAllZeroes() const;
89 };
91 typedef LocklessUpdater<FrameTimeRecordSet, FrameTimeRecordSet> LockessRecordUpdater;
94 }} // namespace OVR::Util
96 #endif // OVR_Util_LatencyTest2_State_h