aboutsummaryrefslogtreecommitdiffstats
path: root/LibOVR/Src/CAPI/CAPI_DistortionRenderer.cpp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2015-03-21 23:01:12 +0100
committerSven Gothel <[email protected]>2015-03-21 23:01:12 +0100
commit0c5c4be020c2d55540058a49b2a879f46d5a1e13 (patch)
tree00f84c2ca18cc233b826014094b9cad0769a3ea5 /LibOVR/Src/CAPI/CAPI_DistortionRenderer.cpp
parentcbbd775b6c754927632c333ff01424a0d2048c7c (diff)
parente490c3c7f7bb5461cfa78a214827aa534fb43a3e (diff)
Merge branch 'vanilla_0.4.4' and resolve conflicts
TODO: Validate for removed patches due to relocation Resolved Conflicts: LibOVR/Src/Kernel/OVR_ThreadsWinAPI.cpp LibOVR/Src/OVR_Linux_HMDDevice.cpp LibOVR/Src/OVR_OSX_HMDDevice.cpp LibOVR/Src/OVR_Profile.cpp LibOVR/Src/OVR_Sensor2Impl.cpp LibOVR/Src/OVR_SensorFusion.cpp LibOVR/Src/OVR_SensorImpl.cpp LibOVR/Src/OVR_Win32_DeviceStatus.cpp LibOVR/Src/OVR_Win32_HIDDevice.cpp LibOVR/Src/OVR_Win32_HIDDevice.h LibOVR/Src/OVR_Win32_HMDDevice.cpp
Diffstat (limited to 'LibOVR/Src/CAPI/CAPI_DistortionRenderer.cpp')
-rw-r--r--LibOVR/Src/CAPI/CAPI_DistortionRenderer.cpp92
1 files changed, 88 insertions, 4 deletions
diff --git a/LibOVR/Src/CAPI/CAPI_DistortionRenderer.cpp b/LibOVR/Src/CAPI/CAPI_DistortionRenderer.cpp
index 613d8fb..78e49e7 100644
--- a/LibOVR/Src/CAPI/CAPI_DistortionRenderer.cpp
+++ b/LibOVR/Src/CAPI/CAPI_DistortionRenderer.cpp
@@ -5,16 +5,16 @@ Content : Combines all of the rendering state associated with the HMD
Created : February 2, 2014
Authors : Michael Antonov
-Copyright : Copyright 2014 Oculus VR, Inc. All Rights reserved.
+Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved.
-Licensed under the Oculus VR Rift SDK License Version 3.1 (the "License");
+Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License");
you may not use the Oculus VR Rift SDK except in compliance with the License,
which is provided at the time of installation or download, or which
otherwise accompanies this software in either electronic or hard copy form.
You may obtain a copy of the License at
-http://www.oculusvr.com/licenses/LICENSE-3.1
+http://www.oculusvr.com/licenses/LICENSE-3.2
Unless required by applicable law or agreed to in writing, the Oculus VR SDK
distributed under the License is distributed on an "AS IS" BASIS,
@@ -38,7 +38,7 @@ limitations under the License.
#undef OVR_D3D_VERSION
#define OVR_D3D_VERSION 9
-#include "D3D1X/CAPI_D3D9_DistortionRenderer.h"
+#include "D3D9/CAPI_D3D9_DistortionRenderer.h"
#undef OVR_D3D_VERSION
#endif
@@ -68,6 +68,90 @@ DistortionRenderer::CreateFunc DistortionRenderer::APICreateRegistry[ovrRenderAP
#endif
};
+void DistortionRenderer::SetLatencyTestColor(unsigned char* color)
+{
+ if(color)
+ {
+ LatencyTestDrawColor[0] = color[0];
+ LatencyTestDrawColor[1] = color[1];
+ LatencyTestDrawColor[2] = color[2];
+ }
+
+ LatencyTestActive = color != NULL;
+}
+
+void DistortionRenderer::SetLatencyTest2Color(unsigned char* color)
+{
+ if(color)
+ {
+ LatencyTest2DrawColor[0] = color[0];
+ LatencyTest2DrawColor[1] = color[1];
+ LatencyTest2DrawColor[2] = color[2];
+ }
+
+ LatencyTest2Active = color != NULL;
+}
+
+void DistortionRenderer::GetOverdriveScales(float& outRiseScale, float& outFallScale)
+{
+ outRiseScale = 0.1f;
+ outFallScale = 0.05f; // falling issues are hardly visible
+}
+
+double DistortionRenderer::WaitTillTime(double absTime)
+{
+ double initialTime = ovr_GetTimeInSeconds();
+ if (initialTime >= absTime)
+ return 0.0;
+
+ double newTime = initialTime;
+
+ while (newTime < absTime)
+ {
+// TODO: Needs further testing before enabling it on all Windows configs
+#if 0 //def OVR_OS_WIN32
+ double remainingWaitTime = absTime - newTime;
+
+ // don't yield if <2ms
+ if(remainingWaitTime > 0.002)
+ {
+ // round down wait time to closest 1 ms
+ int roundedWaitTime = (remainingWaitTime * 1000);
+
+ waitableTimerInterval.QuadPart = -10000LL; // 10000 * 100 ns = 1 ms
+ waitableTimerInterval.QuadPart *= roundedWaitTime;
+
+ SetWaitableTimer(timer, &waitableTimerInterval, 0, NULL, NULL, TRUE);
+ DWORD waitResult = WaitForSingleObject(timer, roundedWaitTime + 3); // give 3 ms extra time
+ OVR_UNUSED(waitResult);
+
+#ifdef OVR_BUILD_DEBUG
+ double sleptTime = ovr_GetTimeInSeconds() - newTime;
+ // Make sure we didn't sleep too long and it is reliable, otherwise we might miss v-sync causing a stutter
+ if (sleptTime > (roundedWaitTime + 2) * 0.001)
+ {
+ OVR_DEBUG_LOG_TEXT(
+ ("[DistortionRenderer::WaitTillTime] Sleep interval too long: %f\n", sleptTime));
+ }
+ else
+ {
+ OVR_ASSERT(WAIT_OBJECT_0 == waitResult);
+ }
+#endif
+ }
+ else
+#endif
+ {
+ for (int j = 0; j < 5; j++)
+ OVR_PROCESSOR_PAUSE();
+ }
+
+ newTime = ovr_GetTimeInSeconds();
+ }
+
+ // How long we waited
+ return newTime - initialTime;
+}
}} // namespace OVR::CAPI