ovr_sdk
diff 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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/LibOVR/Src/Util/Util_LatencyTest2State.h Wed Jan 14 06:51:16 2015 +0200 1.3 @@ -0,0 +1,96 @@ 1.4 +/************************************************************************************ 1.5 + 1.6 +Filename : Util_LatencyTest2Reader.h 1.7 +Content : Shared functionality for the DK2 latency tester 1.8 +Created : July 8, 2014 1.9 +Authors : Volga Aksoy, Chris Taylor 1.10 + 1.11 +Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. 1.12 + 1.13 +Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); 1.14 +you may not use the Oculus VR Rift SDK except in compliance with the License, 1.15 +which is 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 +You may obtain a copy of the License at 1.19 + 1.20 +http://www.oculusvr.com/licenses/LICENSE-3.2 1.21 + 1.22 +Unless required by applicable law or agreed to in writing, the Oculus VR SDK 1.23 +distributed under the License is distributed on an "AS IS" BASIS, 1.24 +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1.25 +See the License for the specific language governing permissions and 1.26 +limitations under the License. 1.27 + 1.28 +*************************************************************************************/ 1.29 + 1.30 +#ifndef OVR_Util_LatencyTest2_State_h 1.31 +#define OVR_Util_LatencyTest2_State_h 1.32 + 1.33 +#include "../Kernel/OVR_Lockless.h" 1.34 + 1.35 +namespace OVR { namespace Util { 1.36 + 1.37 + 1.38 +enum LatencyTester2Constants 1.39 +{ 1.40 + LT2_ColorIncrement = 32, 1.41 + LT2_PixelTestThreshold = LT2_ColorIncrement / 3, 1.42 + LT2_IncrementCount = 256 / LT2_ColorIncrement, 1.43 + LT2_TimeoutWaitingForColorDetected = 1000 // 1 second 1.44 +}; 1.45 + 1.46 + 1.47 +//------------------------------------------------------------------------------------- 1.48 +// FrameTimeRecord 1.49 + 1.50 +// Describes frame scan-out time used for latency testing. 1.51 +struct FrameTimeRecord 1.52 +{ 1.53 + int ReadbackIndex; 1.54 + double TimeSeconds; 1.55 + 1.56 + // Utility functions to convert color to readBack indices and back. 1.57 + // The purpose of ReadbackIndex is to allow direct comparison by value. 1.58 + 1.59 + static bool ColorToReadbackIndex(int *readbackIndex, unsigned char color); 1.60 + static unsigned char ReadbackIndexToColor(int readbackIndex); 1.61 +}; 1.62 + 1.63 + 1.64 +//----------------------------------------------------------------------------- 1.65 +// FrameTimeRecordSet 1.66 + 1.67 +// FrameTimeRecordSet is a container holding multiple consecutive frame timing records 1.68 +// returned from the lock-less state. Used by FrameTimeManager. 1.69 +struct FrameTimeRecordSet 1.70 +{ 1.71 + enum { 1.72 + RecordCount = 4, 1.73 + RecordMask = RecordCount - 1 1.74 + }; 1.75 + FrameTimeRecord Records[RecordCount]; 1.76 + int NextWriteIndex; 1.77 + 1.78 + FrameTimeRecordSet(); 1.79 + 1.80 + void AddValue(int readValue, double timeSeconds); 1.81 + // Matching should be done starting from NextWrite index 1.82 + // until wrap-around 1.83 + 1.84 + const FrameTimeRecord& operator [] (int i) const; 1.85 + 1.86 + const FrameTimeRecord& GetMostRecentFrame(); 1.87 + 1.88 + // Advances I to absolute color index 1.89 + bool FindReadbackIndex(int* i, int readbackIndex) const; 1.90 + 1.91 + bool IsAllZeroes() const; 1.92 +}; 1.93 + 1.94 +typedef LocklessUpdater<FrameTimeRecordSet, FrameTimeRecordSet> LockessRecordUpdater; 1.95 + 1.96 + 1.97 +}} // namespace OVR::Util 1.98 + 1.99 +#endif // OVR_Util_LatencyTest2_State_h