ovr_sdk

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