29 #include "../OVR_Profile.h"
31 namespace OVR {
namespace CAPI {
38 : pHMD(device), HMDInfoW(device),
HMDInfo(HMDInfoW.h),
39 EnabledHmdCaps(0), HmdCapsAppliedToSensor(0),
40 SensorStarted(0), SensorCreated(0), SensorCaps(0),
41 AddSensorCount(0), AddLatencyTestCount(0), AddLatencyTestDisplayCount(0),
42 RenderState(getThis(), pHMD->GetProfile(), HMDInfoW.h),
43 LastFrameTimeSeconds(0.0f), LastGetFrameTimeSeconds(0.0),
44 LatencyTestActive(false),
45 LatencyTest2Active(false)
69 : pHMD(0), HMDInfoW(hmdType),
HMDInfo(HMDInfoW.h),
71 SensorStarted(0), SensorCreated(0), SensorCaps(0),
72 AddSensorCount(0), AddLatencyTestCount(0), AddLatencyTestDisplayCount(0),
73 RenderState(getThis(), 0, HMDInfoW.h),
74 LastFrameTimeSeconds(0.0), LastGetFrameTimeSeconds(0.0)
120 bool sensorCreatedJustNow =
false;
126 if (!crystalCoveOrBetter)
130 pLastError =
"ovrSensorCap_Position not supported on this HMD.";
135 supportedCaps |= requiredCaps;
143 sensorCreatedJustNow=
true;
164 pLastError =
"ovrHmdCap_YawCorrection not available.";
165 if (sensorCreatedJustNow)
176 if (
pSensor && sensorCreatedJustNow)
185 #ifdef OVR_CAPI_VISIONSUPPORT
191 pPoseTracker =
new Vision::PoseTracker(
SFusion);
194 pPoseTracker->AssociateHMD(
pSensor);
195 LogText(
"Sensor Pose tracker created.\n");
202 else if (pPoseTracker)
207 LogText(
"Sensor Pose tracker destroyed.\n");
210 #endif // OVR_CAPI_VISIONSUPPORT
226 #ifdef OVR_CAPI_VISIONSUPPORT
232 LogText(
"Sensor Pose tracker destroyed.\n");
234 #endif // OVR_CAPI_VISION_CODE
245 LogText(
"StopSensor succeeded.\n");
273 #ifdef OVR_CAPI_VISIONSUPPORT
279 LogText(
"Sensor Pose tracker destroyed.\n");
281 #endif // OVR_CAPI_VISION_CODE
331 #ifdef OVR_CAPI_VISIONSUPPORT
334 pPoseTracker =
new Vision::PoseTracker(
SFusion);
337 pPoseTracker->AssociateHMD(
pSensor);
339 LogText(
"Sensor Pose tracker created.\n");
341 #endif // OVR_CAPI_VISION_CODE
392 pSensor->GetDisplayReport(&dr);
406 pSensor->GetDisplayReport(&dr);
432 if (sensorCreatedJustNow ||
487 if (
OVR_strcmp(propertyName,
"LensSeparation") == 0)
491 else if (
OVR_strcmp(propertyName,
"CenterPupilDepth") == 0)
508 if (
OVR_strcmp(propertyName,
"CenterPupilDepth") == 0)
518 float source[],
unsigned sourceSize)
520 unsigned count =
Alg::Min(destSize, sourceSize);
521 for (
unsigned i = 0; i < count; i++)
531 if (
OVR_strcmp(propertyName,
"ScreenSize") == 0)
537 else if (
OVR_strcmp(propertyName,
"DistortionClearColor") == 0)
541 else if (
OVR_strcmp(propertyName,
"DK2Latency") == 0)
570 unsigned count = p->
GetFloatValues(propertyName, values, arraySize);
584 if (
OVR_strcmp(propertyName,
"DistortionClearColor") == 0)
620 if (pLatencyTester->IsConnected())
622 Color colorToDisplay;
626 rgbColorOut[0] = colorToDisplay.
R;
627 rgbColorOut[1] = colorToDisplay.
G;
628 rgbColorOut[2] = colorToDisplay.
B;
635 LogText(
"LATENCY SENSOR disconnected.\n");
644 EnumerateDevices<LatencyTestDevice>().CreateDevice();
648 LogText(
"LATENCY TESTER connected\n");
675 EnumerateDevices<LatencyTestDevice>().CreateDevice();
686 Color colorToDisplay;
688 rgbColorOut[0] = colorToDisplay.
R;
689 rgbColorOut[1] = colorToDisplay.
G;
690 rgbColorOut[2] = colorToDisplay.
B;
704 unsigned distortionCaps)
747 !
pRenderer->Initialize(apiConfig, distortionCaps))
766 (
"ovrHmd_BeginEyeRender eyeId out of range."));
768 (
"Multiple calls to ovrHmd_BeginEyeRender for the same eye."));
791 (
"ovrHmd_EndEyeRender called without ovrHmd_BeginEyeRender."));
SensorState GetSensorStateAtTime(double absoluteTime) const
void GetLatencyTimings(float latencies[3])
double LastFrameTimeSeconds
float GetCenterPupilDepth() const
void LogText(const char *fmt,...) OVR_LOG_VAARG_ATTRIBUTE(1
void SetCenterPupilDepth(float centerPupilDepth)
volatile bool SensorStarted
const char * GetValue(const char *key)
#define OVR_ASSERT_LOG(c, args)
Size< float > ScreenSizeInMeters
float GetFloatValue(const char *key, float default_val) const
Timing GetFrameTiming(unsigned frameIndex)
ThreadChecker RenderAPIThreadChecker
bool DisplayScreenColor(Color &colorToDisplay)
bool AttachToSensor(SensorDevice *sensor)
AtomicInt< int > AddLatencyTestCount
bool ConfigureRendering(ovrEyeRenderDesc eyeRenderDescOut[2], const ovrFovPort eyeFovIn[2], const ovrRenderAPIConfig *apiConfig, unsigned distortionCaps)
HMDRenderState RenderState
void Init(HmdRenderInfo &renderInfo)
OVR_EXPORT ovrPosef ovrHmd_GetEyePose(ovrHmd hmd, ovrEyeType eye)
bool ProcessLatencyTest(unsigned char rgbColorOut[3])
void SetVsync(bool enabled)
void updateLatencyTestForHmd(bool latencyTesting)
void BeginTest(double startTime=-1.0f)
char *OVR_CDECL OVR_strcpy(char *dest, UPInt destsize, const char *src)
void AddHMD(HMDState *hmd)
unsigned char LatencyTestDrawColor[3]
OVR_CAPI_VISION_CODE(Vision::PoseTracker *pPoseTracker;) Ptr< LatencyTestDevice > pLatencyTester
bool HasDisplayDevice() const
const char * ToCStr() const
unsigned getFloatArray(const char *propertyName, float values[], unsigned arraySize)
float LensSeparationInMeters
bool StartSensor(unsigned supportedCaps, unsigned requiredCaps)
bool setFloatArray(const char *propertyName, float values[], unsigned arraySize)
ThreadId BeginFrameThreadId
void updateDK2FeaturesTiedToSensor(bool sensorCreatedJustNow)
ovrPosef EyeRenderPoses[2]
AtomicInt< int > AddLatencyTestDisplayCount
void updateLowPersistenceMode(bool lowPersistence) const
void setupRenderDesc(ovrEyeRenderDesc eyeRenderDescOut[2], const ovrFovPort eyeFovIn[2])
void SetEnabledHmdCaps(unsigned caps)
DeviceManager * GetManager()
char LastGetStringValue[256]
Ptr< LatencyTestDevice > pLatencyTesterDisplay
void applyProfileToSensorFusion()
const char * getString(const char *propertyName, const char *defaultVal)
int GetFloatValues(const char *key, float *values, int num_vals) const
unsigned HmdCapsAppliedToSensor
int OVR_CDECL OVR_strcmp(const char *dest, const char *src)
void SetYawCorrectionEnabled(bool enable)
HMDState(HMDDevice *device)
ovrRenderAPIConfigHeader Header
Ptr< SensorDevice > pSensor
bool DisplayScreenColor(Color &colorToDisplay)
ovrPosef BeginEyeRender(ovrEyeType eye)
bool SetDevice(LatencyTestDevice *device)
Ptr< DistortionRenderer > pRenderer
void SetUserHeadDimensions(Profile const &profile, HmdRenderInfo const &hmdRenderInfo)
void checkBeginFrameScope(const char *functionName)
Util::LatencyTest LatencyUtil
void ProcessLatencyTest2(unsigned char rgbColorOut[3], double startTime)
void ResetFrameTiming(unsigned frameIndex, bool dynamicPrediction, bool sdkRender)
Util::LatencyTest2 LatencyUtil2
bool SetDisplayDevice(LatencyTestDevice *device)
OVR_FORCE_INLINE const T Min(const T a, const T b)
AtomicInt< int > AddSensorCount
void EndEyeRender(ovrEyeType eye, ovrPosef renderPose, ovrTexture *eyeTexture)
FrameTimeManager TimeManager
static unsigned CopyFloatArrayWithLimit(float dest[], unsigned destSize, float source[], unsigned sourceSize)
volatile bool SensorCreated
bool BeginFrameTimingCalled
bool SetSensorDevice(SensorDevice *device)
static GlobalState * pInstance
bool setFloatValue(const char *propertyName, float value)
bool GetSensorDesc(ovrSensorDesc *descOut)
ovrSensorState PredictedSensorState(double absTime)
static CreateFunc APICreateRegistry[ovrRenderAPI_Count]
float getFloatValue(const char *propertyName, float defaultVal)