nuclear@0: /************************************************************************************ nuclear@0: nuclear@0: Filename : Util_LatencyTest2Reader.h nuclear@0: Content : Shared functionality for the DK2 latency tester nuclear@0: Created : July 8, 2014 nuclear@0: Authors : Volga Aksoy, Chris Taylor nuclear@0: nuclear@0: Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved. nuclear@0: nuclear@0: Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License"); nuclear@0: you may not use the Oculus VR Rift SDK except in compliance with the License, nuclear@0: which is provided at the time of installation or download, or which nuclear@0: otherwise accompanies this software in either electronic or hard copy form. nuclear@0: nuclear@0: You may obtain a copy of the License at nuclear@0: nuclear@0: http://www.oculusvr.com/licenses/LICENSE-3.2 nuclear@0: nuclear@0: Unless required by applicable law or agreed to in writing, the Oculus VR SDK nuclear@0: distributed under the License is distributed on an "AS IS" BASIS, nuclear@0: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. nuclear@0: See the License for the specific language governing permissions and nuclear@0: limitations under the License. nuclear@0: nuclear@0: *************************************************************************************/ nuclear@0: nuclear@0: #ifndef OVR_Util_LatencyTest2_State_h nuclear@0: #define OVR_Util_LatencyTest2_State_h nuclear@0: nuclear@0: #include "../Kernel/OVR_Lockless.h" nuclear@0: nuclear@0: namespace OVR { namespace Util { nuclear@0: nuclear@0: nuclear@0: enum LatencyTester2Constants nuclear@0: { nuclear@0: LT2_ColorIncrement = 32, nuclear@0: LT2_PixelTestThreshold = LT2_ColorIncrement / 3, nuclear@0: LT2_IncrementCount = 256 / LT2_ColorIncrement, nuclear@0: LT2_TimeoutWaitingForColorDetected = 1000 // 1 second nuclear@0: }; nuclear@0: nuclear@0: nuclear@0: //------------------------------------------------------------------------------------- nuclear@0: // FrameTimeRecord nuclear@0: nuclear@0: // Describes frame scan-out time used for latency testing. nuclear@0: struct FrameTimeRecord nuclear@0: { nuclear@0: int ReadbackIndex; nuclear@0: double TimeSeconds; nuclear@0: nuclear@0: // Utility functions to convert color to readBack indices and back. nuclear@0: // The purpose of ReadbackIndex is to allow direct comparison by value. nuclear@0: nuclear@0: static bool ColorToReadbackIndex(int *readbackIndex, unsigned char color); nuclear@0: static unsigned char ReadbackIndexToColor(int readbackIndex); nuclear@0: }; nuclear@0: nuclear@0: nuclear@0: //----------------------------------------------------------------------------- nuclear@0: // FrameTimeRecordSet nuclear@0: nuclear@0: // FrameTimeRecordSet is a container holding multiple consecutive frame timing records nuclear@0: // returned from the lock-less state. Used by FrameTimeManager. nuclear@0: struct FrameTimeRecordSet nuclear@0: { nuclear@0: enum { nuclear@0: RecordCount = 4, nuclear@0: RecordMask = RecordCount - 1 nuclear@0: }; nuclear@0: FrameTimeRecord Records[RecordCount]; nuclear@0: int NextWriteIndex; nuclear@0: nuclear@0: FrameTimeRecordSet(); nuclear@0: nuclear@0: void AddValue(int readValue, double timeSeconds); nuclear@0: // Matching should be done starting from NextWrite index nuclear@0: // until wrap-around nuclear@0: nuclear@0: const FrameTimeRecord& operator [] (int i) const; nuclear@0: nuclear@0: const FrameTimeRecord& GetMostRecentFrame(); nuclear@0: nuclear@0: // Advances I to absolute color index nuclear@0: bool FindReadbackIndex(int* i, int readbackIndex) const; nuclear@0: nuclear@0: bool IsAllZeroes() const; nuclear@0: }; nuclear@0: nuclear@0: typedef LocklessUpdater LockessRecordUpdater; nuclear@0: nuclear@0: nuclear@0: }} // namespace OVR::Util nuclear@0: nuclear@0: #endif // OVR_Util_LatencyTest2_State_h