aboutsummaryrefslogtreecommitdiffstats
path: root/LibOVR/Src/CAPI
diff options
context:
space:
mode:
authorBrad Davis <[email protected]>2014-05-23 01:49:32 -0700
committerBrad Davis <[email protected]>2014-05-23 01:49:32 -0700
commit46acc0e194ff3c1f120199eeca8324b4502118e9 (patch)
treeb1030198d3ee4698445d1fc5161cebe4158e45d1 /LibOVR/Src/CAPI
parent07d0f4d0bbf3477ac6a9584f726e8ec6ab285707 (diff)
Updating to 0.3.2 (windows version)
Diffstat (limited to 'LibOVR/Src/CAPI')
-rw-r--r--LibOVR/Src/CAPI/CAPI_DistortionRenderer.cpp10
-rw-r--r--LibOVR/Src/CAPI/CAPI_DistortionRenderer.h22
-rw-r--r--LibOVR/Src/CAPI/CAPI_FrameTimeManager.cpp9
-rw-r--r--LibOVR/Src/CAPI/CAPI_FrameTimeManager.h4
-rw-r--r--LibOVR/Src/CAPI/CAPI_HMDRenderState.cpp38
-rw-r--r--LibOVR/Src/CAPI/CAPI_HMDRenderState.h8
-rw-r--r--LibOVR/Src/CAPI/CAPI_HMDState.cpp268
-rw-r--r--LibOVR/Src/CAPI/CAPI_HMDState.h29
-rw-r--r--LibOVR/Src/CAPI/D3D1X/CAPI_D3D1X_DistortionRenderer.cpp113
-rw-r--r--LibOVR/Src/CAPI/D3D1X/CAPI_D3D1X_DistortionRenderer.h19
-rw-r--r--LibOVR/Src/CAPI/D3D1X/CAPI_D3D1X_Util.h2
-rw-r--r--LibOVR/Src/CAPI/D3D1X/CAPI_D3D9_DistortionRenderer.cpp182
-rw-r--r--LibOVR/Src/CAPI/D3D1X/CAPI_D3D9_DistortionRenderer.h53
-rw-r--r--LibOVR/Src/CAPI/D3D1X/CAPI_D3D9_Util.cpp93
-rw-r--r--LibOVR/Src/CAPI/GL/CAPI_GL_DistortionRenderer.cpp868
-rw-r--r--LibOVR/Src/CAPI/GL/CAPI_GL_DistortionRenderer.h73
-rw-r--r--LibOVR/Src/CAPI/GL/CAPI_GL_DistortionShaders.h326
-rw-r--r--LibOVR/Src/CAPI/GL/CAPI_GL_Util.cpp210
-rw-r--r--LibOVR/Src/CAPI/GL/CAPI_GL_Util.h65
-rw-r--r--LibOVR/Src/CAPI/Shaders/DistortionChroma_ps.h84
-rw-r--r--LibOVR/Src/CAPI/Shaders/DistortionChroma_ps.psh6
-rw-r--r--LibOVR/Src/CAPI/Shaders/DistortionChroma_ps_refl.h1
-rw-r--r--LibOVR/Src/CAPI/Shaders/DistortionChroma_vs.h106
-rw-r--r--LibOVR/Src/CAPI/Shaders/DistortionChroma_vs_refl.h9
-rw-r--r--LibOVR/Src/CAPI/Shaders/DistortionTimewarpChroma_vs.h219
-rw-r--r--LibOVR/Src/CAPI/Shaders/DistortionTimewarpChroma_vs_refl.h11
-rw-r--r--LibOVR/Src/CAPI/Shaders/DistortionTimewarp_vs.h169
-rw-r--r--LibOVR/Src/CAPI/Shaders/DistortionTimewarp_vs_refl.h11
-rw-r--r--LibOVR/Src/CAPI/Shaders/Distortion_ps.h66
-rw-r--r--LibOVR/Src/CAPI/Shaders/Distortion_ps.psh2
-rw-r--r--LibOVR/Src/CAPI/Shaders/Distortion_ps_refl.h1
-rw-r--r--LibOVR/Src/CAPI/Shaders/Distortion_vs.h84
-rw-r--r--LibOVR/Src/CAPI/Shaders/Distortion_vs_refl.h9
-rw-r--r--LibOVR/Src/CAPI/Shaders/SimpleQuad_ps.h51
-rw-r--r--LibOVR/Src/CAPI/Shaders/SimpleQuad_ps_refl.h8
-rw-r--r--LibOVR/Src/CAPI/Shaders/SimpleQuad_vs.h64
-rw-r--r--LibOVR/Src/CAPI/Shaders/SimpleQuad_vs_refl.h9
37 files changed, 2246 insertions, 1056 deletions
diff --git a/LibOVR/Src/CAPI/CAPI_DistortionRenderer.cpp b/LibOVR/Src/CAPI/CAPI_DistortionRenderer.cpp
index 8c0f8b8..613d8fb 100644
--- a/LibOVR/Src/CAPI/CAPI_DistortionRenderer.cpp
+++ b/LibOVR/Src/CAPI/CAPI_DistortionRenderer.cpp
@@ -26,6 +26,8 @@ limitations under the License.
#include "CAPI_DistortionRenderer.h"
+#if defined (OVR_OS_WIN32)
+
// TBD: Move to separate config file that handles back-ends.
#define OVR_D3D_VERSION 11
#include "D3D1X/CAPI_D3D1X_DistortionRenderer.h"
@@ -39,6 +41,8 @@ limitations under the License.
#include "D3D1X/CAPI_D3D9_DistortionRenderer.h"
#undef OVR_D3D_VERSION
+#endif
+
#include "GL/CAPI_GL_DistortionRenderer.h"
namespace OVR { namespace CAPI {
@@ -53,9 +57,15 @@ DistortionRenderer::CreateFunc DistortionRenderer::APICreateRegistry[ovrRenderAP
0, // None
&GL::DistortionRenderer::Create,
0, // Android_GLES
+#if defined (OVR_OS_WIN32)
&D3D9::DistortionRenderer::Create,
&D3D10::DistortionRenderer::Create,
&D3D11::DistortionRenderer::Create
+#else
+ 0,
+ 0,
+ 0
+#endif
};
diff --git a/LibOVR/Src/CAPI/CAPI_DistortionRenderer.h b/LibOVR/Src/CAPI/CAPI_DistortionRenderer.h
index d1b8011..a256bc6 100644
--- a/LibOVR/Src/CAPI/CAPI_DistortionRenderer.h
+++ b/LibOVR/Src/CAPI/CAPI_DistortionRenderer.h
@@ -60,7 +60,7 @@ public:
// Under D3D, apiConfig includes D3D Device pointer, back buffer and other
// needed structures.
virtual bool Initialize(const ovrRenderAPIConfig* apiConfig,
- unsigned hmdCaps, unsigned distortionCaps) = 0;
+ unsigned distortionCaps) = 0;
// Submits one eye texture for rendering. This is in the separate method to
// allow "submit as you render" scenarios on horizontal screens where one
@@ -72,7 +72,11 @@ public:
virtual void EndFrame(bool swapBuffers, unsigned char* latencyTesterDrawColor,
unsigned char* latencyTester2DrawColor) = 0;
+ // Stores the current graphics pipeline state so it can be restored later.
+ void SaveGraphicsState() { if (!(RState.EnabledHmdCaps & ovrHmdCap_NoRestore)) GfxState->Save(); }
+ // Restores the saved graphics pipeline state.
+ void RestoreGraphicsState() { if (!(RState.EnabledHmdCaps & ovrHmdCap_NoRestore)) GfxState->Restore(); }
// *** Creation Factory logic
@@ -86,10 +90,24 @@ public:
static CreateFunc APICreateRegistry[ovrRenderAPI_Count];
protected:
+
+ class GraphicsState : public RefCountBase<GraphicsState>
+ {
+ public:
+ GraphicsState() : IsValid(false) {}
+ virtual ~GraphicsState() {}
+ virtual void Save() = 0;
+ virtual void Restore() = 0;
+
+ protected:
+ bool IsValid;
+ };
+
const ovrRenderAPIType RenderAPI;
const ovrHmd HMD;
FrameTimeManager& TimeManager;
- const HMDRenderState& RState;
+ const HMDRenderState& RState;
+ Ptr<GraphicsState> GfxState;
};
}} // namespace OVR::CAPI
diff --git a/LibOVR/Src/CAPI/CAPI_FrameTimeManager.cpp b/LibOVR/Src/CAPI/CAPI_FrameTimeManager.cpp
index de7eeeb..3e776c3 100644
--- a/LibOVR/Src/CAPI/CAPI_FrameTimeManager.cpp
+++ b/LibOVR/Src/CAPI/CAPI_FrameTimeManager.cpp
@@ -233,10 +233,9 @@ void FrameTimeManager::Init(HmdRenderInfo& renderInfo)
}
void FrameTimeManager::ResetFrameTiming(unsigned frameIndex,
- bool vsyncEnabled, bool dynamicPrediction,
+ bool dynamicPrediction,
bool sdkRender)
-{
- VsyncEnabled = vsyncEnabled;
+{
DynamicPrediction = dynamicPrediction;
SdkRender = sdkRender;
@@ -397,6 +396,8 @@ void FrameTimeManager::Timing::InitTimingFromInputs(const FrameTimeManager::Timi
TimeWarpStartEndTimes[1][0] = MidpointTime;
TimeWarpStartEndTimes[1][1] = MidpointTime;
break;
+ default:
+ break;
}
}
@@ -474,7 +475,7 @@ double FrameTimeManager::GetEyePredictionTime(ovrEyeType eye)
return ovr_GetTimeInSeconds() + ScreenSwitchingDelay + NoVSyncToScanoutDelay;
}
-Posef FrameTimeManager::GetEyePredictionPose(ovrHmd hmd, ovrEyeType eye)
+Transformf FrameTimeManager::GetEyePredictionPose(ovrHmd hmd, ovrEyeType eye)
{
double eyeRenderTime = GetEyePredictionTime(eye);
ovrSensorState eyeState = ovrHmd_GetSensorState(hmd, eyeRenderTime);
diff --git a/LibOVR/Src/CAPI/CAPI_FrameTimeManager.h b/LibOVR/Src/CAPI/CAPI_FrameTimeManager.h
index 07a2963..4693697 100644
--- a/LibOVR/Src/CAPI/CAPI_FrameTimeManager.h
+++ b/LibOVR/Src/CAPI/CAPI_FrameTimeManager.h
@@ -179,7 +179,7 @@ public:
// Called with each new ConfigureRendering.
void ResetFrameTiming(unsigned frameIndex,
- bool vsyncEnabled, bool dynamicPrediction, bool sdkRender);
+ bool dynamicPrediction, bool sdkRender);
void SetVsync(bool enabled) { VsyncEnabled = enabled; }
@@ -192,7 +192,7 @@ public:
Timing GetFrameTiming(unsigned frameIndex);
double GetEyePredictionTime(ovrEyeType eye);
- Posef GetEyePredictionPose(ovrHmd hmd, ovrEyeType eye);
+ Transformf GetEyePredictionPose(ovrHmd hmd, ovrEyeType eye);
void GetTimewarpPredictions(ovrEyeType eye, double timewarpStartEnd[2]);
void GetTimewarpMatrices(ovrHmd hmd, ovrEyeType eye, ovrPosef renderPose, ovrMatrix4f twmOut[2]);
diff --git a/LibOVR/Src/CAPI/CAPI_HMDRenderState.cpp b/LibOVR/Src/CAPI/CAPI_HMDRenderState.cpp
index bdfa0c7..00bdea2 100644
--- a/LibOVR/Src/CAPI/CAPI_HMDRenderState.cpp
+++ b/LibOVR/Src/CAPI/CAPI_HMDRenderState.cpp
@@ -24,16 +24,11 @@ limitations under the License.
************************************************************************************/
-
-
-
#include "CAPI_HMDRenderState.h"
-
namespace OVR { namespace CAPI {
-
//-------------------------------------------------------------------------------------
// ***** HMDRenderState
@@ -47,14 +42,14 @@ HMDRenderState::HMDRenderState(ovrHmd hmd, Profile* userProfile, const OVR::HMDI
Distortion[1] = CalculateDistortionRenderDesc(StereoEye_Right, RenderInfo, 0);
ClearColor[0] = ClearColor[1] = ClearColor[2] = ClearColor[3] =0.0f;
+
+ EnabledHmdCaps = 0;
}
HMDRenderState::~HMDRenderState()
{
-
}
-
ovrHmdDesc HMDRenderState::GetDesc()
{
ovrHmdDesc d;
@@ -71,7 +66,9 @@ ovrHmdDesc HMDRenderState::GetDesc()
d.DisplayDeviceName = HMDInfo.DisplayDeviceName;
d.DisplayId = HMDInfo.DisplayId;
- d.Caps = ovrHmdCap_YawCorrection | ovrHmdCap_Orientation | ovrHmdCap_Present;
+ d.HmdCaps = ovrHmdCap_Present | ovrHmdCap_NoVSync;
+ d.SensorCaps = ovrSensorCap_YawCorrection | ovrSensorCap_Orientation;
+ d.DistortionCaps = ovrDistortionCap_Chromatic | ovrDistortionCap_TimeWarp | ovrDistortionCap_Vignette;
if (strstr(HMDInfo.ProductName, "DK1"))
{
@@ -79,8 +76,10 @@ ovrHmdDesc HMDRenderState::GetDesc()
}
else if (strstr(HMDInfo.ProductName, "DK2"))
{
- d.Type = ovrHmd_DK2;
- d.Caps |= ovrHmdCap_Position | ovrHmdCap_LowPersistence;
+ d.Type = ovrHmd_DK2;
+ d.HmdCaps |= ovrHmdCap_LowPersistence |
+ ovrHmdCap_LatencyTest | ovrHmdCap_DynamicPrediction;
+ d.SensorCaps |= ovrSensorCap_Position;
}
DistortionRenderDesc& leftDistortion = Distortion[0];
@@ -116,30 +115,27 @@ ovrSizei HMDRenderState::GetFOVTextureSize(int eye, ovrFovPort fov, float pixels
return CalculateIdealPixelSize(seye, Distortion[eye], fov, pixelsPerDisplayPixel);
}
-ovrEyeRenderDesc HMDRenderState::calcRenderDesc(const ovrEyeDesc& eyeDesc)
+ovrEyeRenderDesc HMDRenderState::calcRenderDesc(ovrEyeType eyeType, const ovrFovPort& fov)
{
HmdRenderInfo& hmdri = RenderInfo;
- StereoEye eye = (eyeDesc.Eye == ovrEye_Left) ? StereoEye_Left : StereoEye_Right;
+ StereoEye eye = (eyeType == ovrEye_Left) ? StereoEye_Left : StereoEye_Right;
ovrEyeRenderDesc e0;
-
- e0.Desc = eyeDesc;
+
+ e0.Eye = eyeType;
+ e0.Fov = fov;
e0.ViewAdjust = CalculateEyeVirtualCameraOffset(hmdri, eye, false);
e0.DistortedViewport = GetFramebufferViewport(eye, hmdri);
e0.PixelsPerTanAngleAtCenter = Distortion[0].PixelsPerTanAngleAtCenter;
- // If RenderViewport is uninitialized, set it to texture size.
- if (Sizei(e0.Desc.RenderViewport.Size) == Sizei(0))
- e0.Desc.RenderViewport.Size = e0.Desc.TextureSize;
-
return e0;
}
void HMDRenderState::setupRenderDesc( ovrEyeRenderDesc eyeRenderDescOut[2],
- const ovrEyeDesc eyeDescIn[2] )
+ const ovrFovPort eyeFovIn[2] )
{
- eyeRenderDescOut[0] = EyeRenderDesc[0] = calcRenderDesc(eyeDescIn[0]);
- eyeRenderDescOut[1] = EyeRenderDesc[1] = calcRenderDesc(eyeDescIn[1]);
+ eyeRenderDescOut[0] = EyeRenderDesc[0] = calcRenderDesc(ovrEye_Left, eyeFovIn[0]);
+ eyeRenderDescOut[1] = EyeRenderDesc[1] = calcRenderDesc(ovrEye_Right, eyeFovIn[1]);
}
diff --git a/LibOVR/Src/CAPI/CAPI_HMDRenderState.h b/LibOVR/Src/CAPI/CAPI_HMDRenderState.h
index 408af51..a4e8d21 100644
--- a/LibOVR/Src/CAPI/CAPI_HMDRenderState.h
+++ b/LibOVR/Src/CAPI/CAPI_HMDRenderState.h
@@ -57,10 +57,10 @@ public:
ovrHmdDesc GetDesc();
ovrSizei GetFOVTextureSize(int eye, ovrFovPort fov, float pixelsPerDisplayPixel);
- ovrEyeRenderDesc calcRenderDesc(const ovrEyeDesc& eyeDesc);
+ ovrEyeRenderDesc calcRenderDesc(ovrEyeType eyeType, const ovrFovPort& fov);
void setupRenderDesc(ovrEyeRenderDesc eyeRenderDescOut[2],
- const ovrEyeDesc eyeDescIn[2]);
+ const ovrFovPort eyeFovIn[2]);
public:
// HMDInfo shouldn't change, as its string pointers are passed out.
@@ -71,7 +71,7 @@ public:
HmdRenderInfo RenderInfo;
DistortionRenderDesc Distortion[2];
- ovrEyeRenderDesc EyeRenderDesc[2];
+ ovrEyeRenderDesc EyeRenderDesc[2];
// Clear color used for distortion
float ClearColor[4];
@@ -80,7 +80,7 @@ public:
ovrPosef EyeRenderPoses[2];
// Capabilities passed to Configure.
- unsigned HMDCaps;
+ unsigned EnabledHmdCaps;
unsigned DistortionCaps;
};
diff --git a/LibOVR/Src/CAPI/CAPI_HMDState.cpp b/LibOVR/Src/CAPI/CAPI_HMDState.cpp
index 156b84a..fd98225 100644
--- a/LibOVR/Src/CAPI/CAPI_HMDState.cpp
+++ b/LibOVR/Src/CAPI/CAPI_HMDState.cpp
@@ -35,7 +35,8 @@ namespace OVR { namespace CAPI {
HMDState::HMDState(HMDDevice* device)
- : pHMD(device), HMDInfoW(device), HMDInfo(HMDInfoW.h),
+ : pHMD(device), HMDInfoW(device), HMDInfo(HMDInfoW.h),
+ EnabledHmdCaps(0), HmdCapsAppliedToSensor(0),
SensorStarted(0), SensorCreated(0), SensorCaps(0),
AddSensorCount(0), AddLatencyTestCount(0), AddLatencyTestDisplayCount(0),
RenderState(getThis(), pHMD->GetProfile(), HMDInfoW.h),
@@ -66,6 +67,7 @@ HMDState::HMDState(HMDDevice* device)
HMDState::HMDState(ovrHmdType hmdType)
: pHMD(0), HMDInfoW(hmdType), HMDInfo(HMDInfoW.h),
+ EnabledHmdCaps(0),
SensorStarted(0), SensorCreated(0), SensorCaps(0),
AddSensorCount(0), AddLatencyTestCount(0), AddLatencyTestDisplayCount(0),
RenderState(getThis(), 0, HMDInfoW.h), // No profile.
@@ -97,7 +99,7 @@ HMDState::~HMDState()
OVR_ASSERT(GlobalState::pInstance);
StopSensor();
- ConfigureRendering(0,0,0,0,0);
+ ConfigureRendering(0,0,0,0);
OVR_CAPI_VISION_CODE( OVR_ASSERT(pPoseTracker == 0); )
@@ -105,6 +107,7 @@ HMDState::~HMDState()
}
+
//-------------------------------------------------------------------------------------
// *** Sensor
@@ -112,143 +115,102 @@ bool HMDState::StartSensor(unsigned supportedCaps, unsigned requiredCaps)
{
Lock::Locker lockScope(&DevicesLock);
- // TBD: Implement an optimized path that allows you to change caps such as yaw.
- if (SensorStarted)
- {
-
- if ((SensorCaps ^ ovrHmdCap_LowPersistence) == supportedCaps)
- {
- // TBD: Fast persistance switching; redesign to make this better.
- if (HMDInfo.HmdType == HmdType_CrystalCoveProto || HMDInfo.HmdType == HmdType_DK2)
- {
- // switch to full persistence
- updateLowPersistenceMode((supportedCaps & ovrHmdCap_LowPersistence) != 0);
- SensorCaps = supportedCaps;
- return true;
- }
- }
-
- if ((SensorCaps ^ ovrHmdCap_DynamicPrediction) == supportedCaps)
- {
- // TBD: Fast persistance switching; redesign to make this better.
- if (HMDInfo.HmdType == HmdType_DK2)
- {
- // switch to full persistence
- TimeManager.ResetFrameTiming(TimeManager.GetFrameTiming().FrameIndex,
- (supportedCaps & ovrHmdCap_NoVSync) ? false : true,
- (supportedCaps & ovrHmdCap_DynamicPrediction) ? true : false,
- RenderingConfigured);
- SensorCaps = supportedCaps;
- return true;
- }
- }
-
- StopSensor();
- }
-
- supportedCaps |= requiredCaps;
+ bool crystalCoveOrBetter = (HMDInfo.HmdType == HmdType_CrystalCoveProto) ||
+ (HMDInfo.HmdType == HmdType_DK2);
+ bool sensorCreatedJustNow = false;
// TBD: In case of sensor not being immediately available, it would be good to check
// yaw config availability to match it with ovrHmdCap_YawCorrection requirement.
//
- if (requiredCaps & ovrHmdCap_Position)
+ if (!crystalCoveOrBetter)
{
- if (HMDInfo.HmdType != HmdType_CrystalCoveProto && HMDInfo.HmdType != HmdType_DK2)
+ if (requiredCaps & ovrSensorCap_Position)
{
- pLastError = "ovrHmdCap_Position not supported on this HMD.";
- return false;
+ pLastError = "ovrSensorCap_Position not supported on this HMD.";
+ return false;
}
}
- if (requiredCaps & ovrHmdCap_LowPersistence)
- {
- if (HMDInfo.HmdType != HmdType_CrystalCoveProto && HMDInfo.HmdType != HmdType_DK2)
- {
- pLastError = "ovrHmdCap_LowPersistence not supported on this HMD.";
- return false;
- }
- }
+ supportedCaps |= requiredCaps;
- SensorCreated = false;
- pSensor.Clear();
- if (pHMD)
+ if (pHMD && !pSensor)
{
// Zero AddSensorCount before creation, in case it fails (or succeeds but then
// immediately gets disconnected) followed by another Add notification.
- AddSensorCount = 0;
- pSensor = *pHMD->GetSensor();
- }
+ AddSensorCount = 0;
+ pSensor = *pHMD->GetSensor();
+ sensorCreatedJustNow= true;
- if (!pSensor)
- {
- if (requiredCaps & ovrHmdCap_Orientation)
+ if (pSensor)
{
- pLastError = "Failed to create sensor.";
- return false;
- }
- // Succeed, waiting for sensor become available later.
- LogText("StartSensor succeeded - waiting for sensor.\n");
- }
- else
- {
- pSensor->SetReportRate(500);
- SFusion.AttachToSensor(pSensor);
- applyProfileToSensorFusion();
-
- if (requiredCaps & ovrHmdCap_YawCorrection)
+ pSensor->SetReportRate(500);
+ SFusion.AttachToSensor(pSensor);
+ applyProfileToSensorFusion();
+ }
+ else
{
- if (!SFusion.HasMagCalibration())
+ if (requiredCaps & ovrSensorCap_Orientation)
{
- pLastError = "ovrHmdCap_YawCorrection not available.";
- SFusion.AttachToSensor(0);
- SFusion.Reset();
- pSensor.Clear();
+ pLastError = "Failed to create sensor.";
return false;
}
- }
+ }
+ }
- SFusion.SetYawCorrectionEnabled((supportedCaps & ovrHmdCap_YawCorrection) != 0);
- LogText("Sensor created.\n");
- if (supportedCaps & ovrHmdCap_LowPersistence)
- {
- updateLowPersistenceMode(true);
- }
- else
- {
- if (HMDInfo.HmdType == HmdType_CrystalCoveProto || HMDInfo.HmdType == HmdType_DK2)
- {
- // switch to full persistence
- updateLowPersistenceMode(false);
- }
- }
-
- if (HMDInfo.HmdType == HmdType_DK2)
+ if ((requiredCaps & ovrSensorCap_YawCorrection) && !pSensor->IsMagCalibrated())
+ {
+ pLastError = "ovrHmdCap_YawCorrection not available.";
+ if (sensorCreatedJustNow)
{
- updateLatencyTestForHmd((supportedCaps & ovrHmdCap_LatencyTest) != 0);
- }
+ SFusion.AttachToSensor(0);
+ SFusion.Reset();
+ pSensor.Clear();
+ }
+ return false;
+ }
+
+ SFusion.SetYawCorrectionEnabled((supportedCaps & ovrSensorCap_YawCorrection) != 0);
+
+ if (pSensor && sensorCreatedJustNow)
+ {
+ LogText("Sensor created.\n");
+ SensorCreated = true;
+ }
+
+ updateDK2FeaturesTiedToSensor(sensorCreatedJustNow);
+
#ifdef OVR_CAPI_VISIONSUPPORT
- if (supportedCaps & ovrHmdCap_Position)
+
+ if (crystalCoveOrBetter && (supportedCaps & ovrSensorCap_Position))
+ {
+ if (!pPoseTracker)
{
pPoseTracker = new Vision::PoseTracker(SFusion);
if (pPoseTracker)
{
pPoseTracker->AssociateHMD(pSensor);
+ LogText("Sensor Pose tracker created.\n");
}
- LogText("Sensor Pose tracker created.\n");
}
+
// TBD: How do we verify that position tracking is actually available
// i.e. camera is plugged in?
+ }
+ else if (pPoseTracker)
+ {
+ // TBD: Internals not thread safe - must fix!!
+ delete pPoseTracker;
+ pPoseTracker = 0;
+ LogText("Sensor Pose tracker destroyed.\n");
+ }
#endif // OVR_CAPI_VISIONSUPPORT
- SensorCreated = true;
- }
-
SensorCaps = supportedCaps;
- SensorStarted = true;
+ SensorStarted = true;
return true;
}
@@ -274,6 +236,7 @@ void HMDState::StopSensor()
SFusion.AttachToSensor(0);
SFusion.Reset();
pSensor.Clear();
+ HmdCapsAppliedToSensor = 0;
AddSensorCount = 0;
SensorCaps = 0;
SensorCreated = false;
@@ -319,7 +282,8 @@ ovrSensorState HMDState::PredictedSensorState(double absTime)
// Not needed yet; SFusion.AttachToSensor(0);
// This seems to reset orientation anyway...
pSensor.Clear();
- SensorCreated = false;
+ SensorCreated = false;
+ HmdCapsAppliedToSensor = 0;
}
}
else
@@ -361,11 +325,11 @@ bool HMDState::checkCreateSensor()
{
pSensor->SetReportRate(500);
SFusion.AttachToSensor(pSensor);
- SFusion.SetYawCorrectionEnabled((SensorCaps & ovrHmdCap_YawCorrection) != 0);
+ SFusion.SetYawCorrectionEnabled((SensorCaps & ovrSensorCap_YawCorrection) != 0);
applyProfileToSensorFusion();
#ifdef OVR_CAPI_VISIONSUPPORT
- if (SensorCaps & ovrHmdCap_Position)
+ if (SensorCaps & ovrSensorCap_Position)
{
pPoseTracker = new Vision::PoseTracker(SFusion);
if (pPoseTracker)
@@ -407,20 +371,31 @@ bool HMDState::GetSensorDesc(ovrSensorDesc* descOut)
void HMDState::applyProfileToSensorFusion()
{
- Profile* profile = pHMD ? pHMD->GetProfile() : 0;
- SFusion.SetUserHeadDimensions ( profile, RenderState.RenderInfo );
+ if (!pHMD)
+ return;
+ Profile* profile = pHMD->GetProfile();
+ if (!profile)
+ {
+ OVR_ASSERT(false);
+ return;
+ }
+ SFusion.SetUserHeadDimensions ( *profile, RenderState.RenderInfo );
}
void HMDState::updateLowPersistenceMode(bool lowPersistence) const
{
OVR_ASSERT(pSensor);
DisplayReport dr;
- pSensor->GetDisplayReport(&dr);
+
+ if (pSensor.GetPtr())
+ {
+ pSensor->GetDisplayReport(&dr);
- dr.Persistence = (UInt16) (dr.TotalRows * (lowPersistence ? 0.18f : 1.0f));
- dr.Brightness = lowPersistence ? 255 : 0;
+ dr.Persistence = (UInt16) (dr.TotalRows * (lowPersistence ? 0.18f : 1.0f));
+ dr.Brightness = lowPersistence ? 255 : 0;
- pSensor->SetDisplayReport(dr);
+ pSensor->SetDisplayReport(dr);
+ }
}
void HMDState::updateLatencyTestForHmd(bool latencyTesting)
@@ -445,6 +420,63 @@ void HMDState::updateLatencyTestForHmd(bool latencyTesting)
}
}
+
+void HMDState::updateDK2FeaturesTiedToSensor(bool sensorCreatedJustNow)
+{
+ Lock::Locker lockScope(&DevicesLock);
+
+ if (!SensorCreated || (HMDInfo.HmdType != HmdType_DK2))
+ return;
+
+ // Only send display reports if state changed or sensor initializing first time.
+ if (sensorCreatedJustNow ||
+ ((HmdCapsAppliedToSensor ^ EnabledHmdCaps) & ovrHmdCap_LowPersistence))
+ {
+ updateLowPersistenceMode((EnabledHmdCaps & ovrHmdCap_LowPersistence) ? true : false);
+ }
+
+ if (sensorCreatedJustNow || ((HmdCapsAppliedToSensor ^ EnabledHmdCaps) & ovrHmdCap_LatencyTest))
+ {
+ updateLatencyTestForHmd((EnabledHmdCaps & ovrHmdCap_LatencyTest) != 0);
+ }
+
+ HmdCapsAppliedToSensor = EnabledHmdCaps & (ovrHmdCap_LowPersistence|ovrHmdCap_LatencyTest);
+}
+
+
+
+void HMDState::SetEnabledHmdCaps(unsigned hmdCaps)
+{
+
+ if (HMDInfo.HmdType == HmdType_DK2)
+ {
+ if ((EnabledHmdCaps ^ hmdCaps) & ovrHmdCap_DynamicPrediction)
+ {
+ // DynamicPrediction change
+ TimeManager.ResetFrameTiming(TimeManager.GetFrameTiming().FrameIndex,
+ (hmdCaps & ovrHmdCap_DynamicPrediction) ? true : false,
+ RenderingConfigured);
+ }
+ }
+
+ if ((EnabledHmdCaps ^ hmdCaps) & ovrHmdCap_NoVSync)
+ {
+ TimeManager.SetVsync((hmdCaps & ovrHmdCap_NoVSync) ? false : true);
+ }
+
+
+ EnabledHmdCaps = hmdCaps & ovrHmdCap_Writable_Mask;
+ RenderState.EnabledHmdCaps = EnabledHmdCaps;
+
+ // Unfortunately, LowPersistance and other flags are tied to sensor.
+ // This flag will apply the state of sensor is created; otherwise this will be delayed
+ // till StartSensor.
+ // Such behavior is less then ideal, but should be resolved with the service model.
+
+ updateDK2FeaturesTiedToSensor(false);
+}
+
+
//-------------------------------------------------------------------------------------
// ***** Property Access
@@ -623,7 +655,7 @@ bool HMDState::ProcessLatencyTest(unsigned char rgbColorOut[3])
void HMDState::ProcessLatencyTest2(unsigned char rgbColorOut[3], double startTime)
{
// Check create.
- if (!(SensorCaps & ovrHmdCap_LatencyTest))
+ if (!(EnabledHmdCaps & ovrHmdCap_LatencyTest))
return;
if (pLatencyTesterDisplay && !LatencyUtil2.HasDisplayDevice())
@@ -667,9 +699,8 @@ void HMDState::ProcessLatencyTest2(unsigned char rgbColorOut[3], double startTim
// *** Rendering
bool HMDState::ConfigureRendering(ovrEyeRenderDesc eyeRenderDescOut[2],
- const ovrEyeDesc eyeDescIn[2],
- const ovrRenderAPIConfig* apiConfig,
- unsigned hmdCaps,
+ const ovrFovPort eyeFovIn[2],
+ const ovrRenderAPIConfig* apiConfig,
unsigned distortionCaps)
{
ThreadChecker::Scope checkScope(&RenderAPIThreadChecker, "ovrHmd_ConfigureRendering");
@@ -693,13 +724,12 @@ bool HMDState::ConfigureRendering(ovrEyeRenderDesc eyeRenderDescOut[2],
// Step 1: do basic setup configuration
- RenderState.setupRenderDesc(eyeRenderDescOut, eyeDescIn);
- RenderState.HMDCaps = hmdCaps; // Any cleaner way?
+ RenderState.setupRenderDesc(eyeRenderDescOut, eyeFovIn);
+ RenderState.EnabledHmdCaps = EnabledHmdCaps; // This is a copy... Any cleaner way?
RenderState.DistortionCaps = distortionCaps;
TimeManager.ResetFrameTiming(0,
- (hmdCaps & ovrHmdCap_NoVSync) ? false : true,
- (hmdCaps & ovrHmdCap_DynamicPrediction) ? true : false,
+ (EnabledHmdCaps & ovrHmdCap_DynamicPrediction) ? true : false,
true);
LastFrameTimeSeconds = 0.0f;
@@ -714,7 +744,7 @@ bool HMDState::ConfigureRendering(ovrEyeRenderDesc eyeRenderDescOut[2],
}
if (!pRenderer ||
- !pRenderer->Initialize(apiConfig, hmdCaps, distortionCaps))
+ !pRenderer->Initialize(apiConfig, distortionCaps))
{
RenderingConfigured = false;
return false;
diff --git a/LibOVR/Src/CAPI/CAPI_HMDState.h b/LibOVR/Src/CAPI/CAPI_HMDState.h
index d178042..0a1466f 100644
--- a/LibOVR/Src/CAPI/CAPI_HMDState.h
+++ b/LibOVR/Src/CAPI/CAPI_HMDState.h
@@ -94,7 +94,7 @@ public:
{
// pFunctionName may be not null here if function is called internally on the same thread.
OVR_ASSERT_LOG((FirstThread == GetCurrentThreadId()),
- ("%s (threadId=%d) called at the same times as %s (threadId=%d)\n",
+ ("%s (threadId=%p) called at the same times as %s (threadId=%p)\n",
functionName, GetCurrentThreadId(), pFunctionName, FirstThread) );
}
}
@@ -146,6 +146,12 @@ public:
ovrSensorState PredictedSensorState(double absTime);
bool GetSensorDesc(ovrSensorDesc* descOut);
+ // Changes HMD Caps.
+ // Capability bits that are not directly or logically tied to one system (such as sensor)
+ // are grouped here. ovrHmdCap_VSync, for example, affects rendering and timing.
+ void SetEnabledHmdCaps(unsigned caps);
+
+
bool ProcessLatencyTest(unsigned char rgbColorOut[3]);
void ProcessLatencyTest2(unsigned char rgbColorOut[3], double startTime);
@@ -153,9 +159,8 @@ public:
// *** Rendering Setup
bool ConfigureRendering(ovrEyeRenderDesc eyeRenderDescOut[2],
- const ovrEyeDesc eyeDescIn[2],
- const ovrRenderAPIConfig* apiConfig,
- unsigned hmdCaps,
+ const ovrFovPort eyeFovIn[2],
+ const ovrRenderAPIConfig* apiConfig,
unsigned distortionCaps);
ovrPosef BeginEyeRender(ovrEyeType eye);
@@ -191,23 +196,23 @@ public:
{
OVR_UNUSED1(functionName); // for Release build.
OVR_ASSERT_LOG(BeginFrameCalled == true,
- ("%s called outside ovrHmd_BeginFrame."));
+ ("%s called outside ovrHmd_BeginFrame.", functionName));
OVR_ASSERT_LOG(BeginFrameThreadId == OVR::GetCurrentThreadId(),
- ("%s called on a different thread then ovrHmd_BeginFrame."));
+ ("%s called on a different thread then ovrHmd_BeginFrame.", functionName));
}
void checkRenderingConfigured(const char* functionName)
{
OVR_UNUSED1(functionName); // for Release build.
OVR_ASSERT_LOG(RenderingConfigured == true,
- ("%s called without ovrHmd_ConfigureRendering."));
+ ("%s called without ovrHmd_ConfigureRendering.", functionName));
}
void checkBeginFrameTimingScope(const char* functionName)
{
OVR_UNUSED1(functionName); // for Release build.
OVR_ASSERT_LOG(BeginFrameTimingCalled == true,
- ("%s called outside ovrHmd_BeginFrameTiming."));
+ ("%s called outside ovrHmd_BeginFrameTiming.", functionName));
}
@@ -215,6 +220,8 @@ public:
void updateLowPersistenceMode(bool lowPersistence) const;
void updateLatencyTestForHmd(bool latencyTesting);
+
+ void updateDK2FeaturesTiedToSensor(bool sensorCreatedJustNow);
// Get properties by name.
float getFloatValue(const char* propertyName, float defaultVal);
@@ -251,6 +258,12 @@ public:
const char* pLastError;
+ // Caps enabled for the HMD.
+ unsigned EnabledHmdCaps;
+ // These are the flags actually applied to the Sensor device,
+ // used to track whether SetDisplayReport calls are necessary.
+ unsigned HmdCapsAppliedToSensor;
+
// *** Sensor
diff --git a/LibOVR/Src/CAPI/D3D1X/CAPI_D3D1X_DistortionRenderer.cpp b/LibOVR/Src/CAPI/D3D1X/CAPI_D3D1X_DistortionRenderer.cpp
index 53f8948..878d777 100644
--- a/LibOVR/Src/CAPI/D3D1X/CAPI_D3D1X_DistortionRenderer.cpp
+++ b/LibOVR/Src/CAPI/D3D1X/CAPI_D3D1X_DistortionRenderer.cpp
@@ -88,8 +88,8 @@ static PrecompiledShader DistortionPixelShaderLookup[DistortionPixelShaderCount]
void DistortionShaderBitIndexCheck()
{
- OVR_COMPILER_ASSERT(ovrDistortion_Chromatic == 1);
- OVR_COMPILER_ASSERT(ovrDistortion_TimeWarp == 2);
+ OVR_COMPILER_ASSERT(ovrDistortionCap_Chromatic == 1);
+ OVR_COMPILER_ASSERT(ovrDistortionCap_TimeWarp == 2);
}
@@ -135,6 +135,10 @@ DistortionRenderer::DistortionRenderer(ovrHmd hmd, FrameTimeManager& timeManager
const HMDRenderState& renderState)
: CAPI::DistortionRenderer(ovrRenderAPI_D3D11, hmd, timeManager, renderState)
{
+ EyeTextureSize[0] = Sizei(0);
+ EyeRenderViewport[0] = Recti();
+ EyeTextureSize[1] = Sizei(0);
+ EyeRenderViewport[1] = Recti();
}
DistortionRenderer::~DistortionRenderer()
@@ -152,11 +156,8 @@ CAPI::DistortionRenderer* DistortionRenderer::Create(ovrHmd hmd,
bool DistortionRenderer::Initialize(const ovrRenderAPIConfig* apiConfig,
- unsigned hmdCaps, unsigned distortionCaps)
+ unsigned distortionCaps)
{
- // TBD: Decide if hmdCaps are needed here or are a part of RenderState
- OVR_UNUSED(hmdCaps);
-
const ovrD3D1X(Config)* config = (const ovrD3D1X(Config)*)apiConfig;
if (!config)
@@ -178,6 +179,8 @@ bool DistortionRenderer::Initialize(const ovrRenderAPIConfig* apiConfig,
RParams.RTSize = config->D3D_NS.Header.RTSize;
RParams.Multisample = config->D3D_NS.Header.Multisample;
+ GfxState = *new GraphicsState(RParams.pContext);
+
DistortionCaps = distortionCaps;
//DistortionWarper.SetVsync((hmdCaps & ovrHmdCap_NoVSync) ? false : true);
@@ -217,11 +220,14 @@ void DistortionRenderer::SubmitEye(int eyeId, ovrTexture* eyeTexture)
{
// Use tex->D3D_NS.Header.RenderViewport to update UVs for rendering in case they changed.
// TBD: This may be optimized through some caching.
- ovrEyeDesc ed = RState.EyeRenderDesc[eyeId].Desc;
- ed.TextureSize = tex->D3D_NS.Header.TextureSize;
- ed.RenderViewport = tex->D3D_NS.Header.RenderViewport;
+ EyeTextureSize[eyeId] = tex->D3D_NS.Header.TextureSize;
+ EyeRenderViewport[eyeId] = tex->D3D_NS.Header.RenderViewport;
+
+ const ovrEyeRenderDesc& erd = RState.EyeRenderDesc[eyeId];
- ovrHmd_GetRenderScaleAndOffset(HMD, ed, DistortionCaps, UVScaleOffset[eyeId]);
+ ovrHmd_GetRenderScaleAndOffset(erd.Fov,
+ EyeTextureSize[eyeId], EyeRenderViewport[eyeId],
+ UVScaleOffset[eyeId]);
pEyeTextures[eyeId]->UpdatePlaceholderTexture(tex->D3D_NS.pTexture, tex->D3D_NS.pSRView,
tex->D3D_NS.Header.TextureSize);
@@ -231,32 +237,9 @@ void DistortionRenderer::SubmitEye(int eyeId, ovrTexture* eyeTexture)
void DistortionRenderer::EndFrame(bool swapBuffers, unsigned char* latencyTesterDrawColor,
unsigned char* latencyTester2DrawColor)
{
-
-#if 0
-
- // MA: This causes orientation and positional stutter!! NOT USABLE.
- if (!TimeManager.NeedDistortionTimeMeasurement() &&
- (RState.DistortionCaps & ovrDistortion_TimeWarp))
- {
- // Wait for timewarp distortion if it is time
- FlushGpuAndWaitTillTime(TimeManager.GetFrameTiming().TimewarpPointTime);
- }
-
- // Always measure distortion time so that TimeManager can better
- // estimate latency-reducing time-warp wait timing.
- {
- GpuProfiler.BeginQuery();
-
- renderDistortion(pEyeTextures[0], pEyeTextures[1]);
-
- GpuProfiler.EndQuery();
- TimeManager.AddDistortionTimeMeasurement(GpuProfiler.GetTiming(false));
- }
-#else
-
if (!TimeManager.NeedDistortionTimeMeasurement())
{
- if (RState.DistortionCaps & ovrDistortion_TimeWarp)
+ if (RState.DistortionCaps & ovrDistortionCap_TimeWarp)
{
// Wait for timewarp distortion if it is time and Gpu idle
FlushGpuAndWaitTillTime(TimeManager.GetFrameTiming().TimewarpPointTime);
@@ -276,7 +259,6 @@ void DistortionRenderer::EndFrame(bool swapBuffers, unsigned char* latencyTester
WaitUntilGpuIdle();
TimeManager.AddDistortionTimeMeasurement(ovr_GetTimeInSeconds() - distortionStartTime);
}
-#endif
if(latencyTesterDrawColor)
{
@@ -291,7 +273,7 @@ void DistortionRenderer::EndFrame(bool swapBuffers, unsigned char* latencyTester
{
if (RParams.pSwapChain)
{
- UINT swapInterval = (RState.HMDCaps & ovrHmdCap_NoVSync) ? 0 : 1;
+ UINT swapInterval = (RState.EnabledHmdCaps & ovrHmdCap_NoVSync) ? 0 : 1;
RParams.pSwapChain->Present(swapInterval, 0);
// Force GPU to flush the scene, resulting in the lowest possible latency.
@@ -380,9 +362,11 @@ void DistortionRenderer::initBuffersAndShaders()
// double startT = ovr_GetTimeInSeconds();
- if (!ovrHmd_CreateDistortionMesh( HMD, RState.EyeRenderDesc[eyeNum].Desc,
+ if (!ovrHmd_CreateDistortionMesh( HMD,
+ RState.EyeRenderDesc[eyeNum].Eye,
+ RState.EyeRenderDesc[eyeNum].Fov,
RState.DistortionCaps,
- UVScaleOffset[eyeNum], &meshData) )
+ &meshData) )
{
OVR_ASSERT(false);
continue;
@@ -413,9 +397,9 @@ void DistortionRenderer::initBuffersAndShaders()
}
DistortionMeshVBs[eyeNum] = *new Buffer(&RParams);
- DistortionMeshVBs[eyeNum]->Data ( Buffer_Vertex, pVBVerts, sizeof(DistortionVertex) * meshData.VertexCount );
+ DistortionMeshVBs[eyeNum]->Data(Buffer_Vertex | Buffer_ReadOnly, pVBVerts, sizeof(DistortionVertex)* meshData.VertexCount);
DistortionMeshIBs[eyeNum] = *new Buffer(&RParams);
- DistortionMeshIBs[eyeNum]->Data ( Buffer_Index, meshData.pIndexData, ( sizeof(INT16) * meshData.IndexCount ) );
+ DistortionMeshIBs[eyeNum]->Data(Buffer_Index | Buffer_ReadOnly, meshData.pIndexData, (sizeof(INT16)* meshData.IndexCount));
OVR_FREE ( pVBVerts );
ovrHmd_DestroyDistortionMesh( &meshData );
@@ -451,7 +435,7 @@ void DistortionRenderer::renderDistortion(Texture* leftEyeTexture, Texture* righ
DistortionShader->SetUniform2f("EyeToSourceUVScale", UVScaleOffset[eyeNum][0].x, UVScaleOffset[eyeNum][0].y);
DistortionShader->SetUniform2f("EyeToSourceUVOffset", UVScaleOffset[eyeNum][1].x, UVScaleOffset[eyeNum][1].y);
- if (DistortionCaps & ovrDistortion_TimeWarp)
+ if (DistortionCaps & ovrDistortionCap_TimeWarp)
{
ovrMatrix4f timeWarpMatrices[2];
ovrHmd_GetEyeTimewarpMatrices(HMD, (ovrEyeType)eyeNum,
@@ -770,4 +754,51 @@ void DistortionRenderer::destroy()
LatencyTesterQuadVB.Clear();
}
+
+DistortionRenderer::GraphicsState::GraphicsState(ID3D1xDeviceContext* c)
+: context(c)
+, rasterizerState(NULL)
+{
+ for (int i = 0; i < 8; ++i)
+ samplerStates[i] = NULL;
+}
+
+
+void DistortionRenderer::GraphicsState::Save()
+{
+ if (rasterizerState != NULL)
+ rasterizerState->Release();
+
+ context->RSGetState(&rasterizerState);
+
+ for (int i = 0; i < 8; ++i)
+ {
+ if (samplerStates[i] != NULL)
+ samplerStates[i]->Release();
+ }
+
+ context->PSGetSamplers(0, 8, samplerStates);
+}
+
+
+void DistortionRenderer::GraphicsState::Restore()
+{
+ if (rasterizerState != NULL)
+ {
+ context->RSSetState(rasterizerState);
+ rasterizerState->Release();
+ rasterizerState = NULL;
+ }
+
+ for (int i = 0; i < 8; ++i)
+ {
+ if (samplerStates[i] == NULL)
+ continue;
+
+ context->PSSetSamplers(0, 1, &samplerStates[i]);
+ samplerStates[i]->Release();
+ samplerStates[i] = NULL;
+ }
+}
+
}}} // OVR::CAPI::D3D1X
diff --git a/LibOVR/Src/CAPI/D3D1X/CAPI_D3D1X_DistortionRenderer.h b/LibOVR/Src/CAPI/D3D1X/CAPI_D3D1X_DistortionRenderer.h
index f151d73..c4d2619 100644
--- a/LibOVR/Src/CAPI/D3D1X/CAPI_D3D1X_DistortionRenderer.h
+++ b/LibOVR/Src/CAPI/D3D1X/CAPI_D3D1X_DistortionRenderer.h
@@ -57,7 +57,7 @@ public:
// ***** Public DistortionRenderer interface
virtual bool Initialize(const ovrRenderAPIConfig* apiConfig,
- unsigned hmdCaps, unsigned distortionCaps);
+ unsigned distortionCaps);
virtual void SubmitEye(int eyeId, ovrTexture* eyeTexture);
@@ -70,6 +70,21 @@ public:
// Note, it exits when time expires, even if GPU is not in idle state yet.
double FlushGpuAndWaitTillTime(double absTime);
+protected:
+
+ class GraphicsState : public CAPI::DistortionRenderer::GraphicsState
+ {
+ public:
+ GraphicsState(ID3D1xDeviceContext* context);
+ virtual void Save();
+ virtual void Restore();
+
+ protected:
+ ID3D1xRasterizerState* rasterizerState;
+ ID3D1xSamplerState* samplerStates[8];
+ ID3D1xDeviceContext* context;
+ };
+
private:
// Helpers
void initBuffersAndShaders();
@@ -102,6 +117,8 @@ private:
// U,V scale and offset needed for timewarp.
ovrVector2f UVScaleOffset[2][2];
+ ovrSizei EyeTextureSize[2];
+ ovrRecti EyeRenderViewport[2];
//Ptr<Buffer> mpFullScreenVertexBuffer;
diff --git a/LibOVR/Src/CAPI/D3D1X/CAPI_D3D1X_Util.h b/LibOVR/Src/CAPI/D3D1X/CAPI_D3D1X_Util.h
index f8d7bd3..7bbc685 100644
--- a/LibOVR/Src/CAPI/D3D1X/CAPI_D3D1X_Util.h
+++ b/LibOVR/Src/CAPI/D3D1X/CAPI_D3D1X_Util.h
@@ -41,6 +41,7 @@ limitations under the License.
#include "../../Kernel/OVR_Array.h"
#include "../../Kernel/OVR_Math.h"
+#if defined(OVR_OS_WIN32)
#include <Windows.h>
#include <comdef.h> // for _COM_SMARTPTR_TYPEDEF()
@@ -78,6 +79,7 @@ limitations under the License.
#include <d3d11.h>
#include <D3D11Shader.h>
#endif
+#endif
namespace OVR { namespace CAPI { namespace D3D_NS {
diff --git a/LibOVR/Src/CAPI/D3D1X/CAPI_D3D9_DistortionRenderer.cpp b/LibOVR/Src/CAPI/D3D1X/CAPI_D3D9_DistortionRenderer.cpp
index 21b885e..e8cf767 100644
--- a/LibOVR/Src/CAPI/D3D1X/CAPI_D3D9_DistortionRenderer.cpp
+++ b/LibOVR/Src/CAPI/D3D1X/CAPI_D3D9_DistortionRenderer.cpp
@@ -57,11 +57,8 @@ DistortionRenderer::~DistortionRenderer()
/******************************************************************************/
bool DistortionRenderer::Initialize(const ovrRenderAPIConfig* apiConfig,
- unsigned hmdCaps, unsigned arg_distortionCaps)
+ unsigned arg_distortionCaps)
{
- // TBD: Decide if hmdCaps are needed here or are a part of RenderState
- OVR_UNUSED(hmdCaps);
-
///QUESTION - what is returned bool for??? Are we happy with this true, if not config.
const ovrD3D9Config * config = (const ovrD3D9Config*)apiConfig;
if (!config) return true;
@@ -69,14 +66,17 @@ bool DistortionRenderer::Initialize(const ovrRenderAPIConfig* apiConfig,
//Glean all the required variables from the input structures
device = config->D3D9.pDevice;
+ swapChain = config->D3D9.pSwapChain;
screenSize = config->D3D9.Header.RTSize;
distortionCaps = arg_distortionCaps;
+ GfxState = *new GraphicsState(device);
+
CreateVertexDeclaration();
CreateDistortionShaders();
Create_Distortion_Models();
- return (true);
+ return true;
}
@@ -89,23 +89,22 @@ void DistortionRenderer::SubmitEye(int eyeId, ovrTexture* eyeTexture)
//Write in values
eachEye[eyeId].texture = tex->D3D9.pTexture;
- //Its only at this point we discover what the viewport of the texture is.
- //because presumably we allow users to realtime adjust the resolution.
- //Which begs the question - why did we ask them what viewport they were
- //using before, which gave them a set of UV offsets. In fact, our
- //asking for eye mesh must be entirely independed of these viewports,
- //presumably only to get the parameters.
-
- ovrEyeDesc ed = RState.EyeRenderDesc[eyeId].Desc;
- ed.TextureSize = tex->D3D9.Header.TextureSize;
- ed.RenderViewport = tex->D3D9.Header.RenderViewport;
+ // Its only at this point we discover what the viewport of the texture is.
+ // because presumably we allow users to realtime adjust the resolution.
+ eachEye[eyeId].TextureSize = tex->D3D9.Header.TextureSize;
+ eachEye[eyeId].RenderViewport = tex->D3D9.Header.RenderViewport;
- ovrHmd_GetRenderScaleAndOffset(HMD, ed, distortionCaps, eachEye[eyeId].UVScaleOffset);
+ const ovrEyeRenderDesc& erd = RState.EyeRenderDesc[eyeId];
+
+ ovrHmd_GetRenderScaleAndOffset( erd.Fov,
+ eachEye[eyeId].TextureSize, eachEye[eyeId].RenderViewport,
+ eachEye[eyeId].UVScaleOffset );
}
/******************************************************************/
-void DistortionRenderer::EndFrame(bool swapBuffers, unsigned char* latencyTesterDrawColor, unsigned char* latencyTester2DrawColor)
+void DistortionRenderer::EndFrame(bool swapBuffers,
+ unsigned char* latencyTesterDrawColor, unsigned char* latencyTester2DrawColor)
{
OVR_UNUSED(swapBuffers);
OVR_UNUSED(latencyTesterDrawColor);
@@ -115,7 +114,7 @@ void DistortionRenderer::EndFrame(bool swapBuffers, unsigned char* latencyTester
if (!TimeManager.NeedDistortionTimeMeasurement())
{
- if (RState.DistortionCaps & ovrDistortion_TimeWarp)
+ if (RState.DistortionCaps & ovrDistortionCap_TimeWarp)
{
// Wait for timewarp distortion if it is time and Gpu idle
WaitTillTimeAndFlushGpu(TimeManager.GetFrameTiming().TimewarpPointTime);
@@ -149,101 +148,130 @@ void DistortionRenderer::EndFrame(bool swapBuffers, unsigned char* latencyTester
if (swapBuffers)
{
- device->Present( NULL, NULL, NULL, NULL );
-
- /// if (RParams.pSwapChain)
+ if (swapChain)
{
- /// UINT swapInterval = (RState.HMDCaps & ovrHmdCap_NoVSync) ? 0 : 1;
- /// RParams.pSwapChain->Present(swapInterval, 0);
-
- // Force GPU to flush the scene, resulting in the lowest possible latency.
- // It's critical that this flush is *after* present.
- /// WaitUntilGpuIdle();
+ swapChain->Present(NULL, NULL, NULL, NULL, 0);
}
- /// else
+ else
{
- // TBD: Generate error - swapbuffer option used with null swapchain.
+ device->Present( NULL, NULL, NULL, NULL );
}
+
+ // Force GPU to flush the scene, resulting in the lowest possible latency.
+ // It's critical that this flush is *after* present.
+ WaitUntilGpuIdle();
}
}
void DistortionRenderer::WaitUntilGpuIdle()
{
-#if 0
- // Flush and Stall CPU while waiting for GPU to complete rendering all of the queued draw calls
- D3D1x_QUERY_DESC queryDesc = { D3D1X_(QUERY_EVENT), 0 };
- Ptr<ID3D1xQuery> query;
- BOOL done = FALSE;
-
- if (RParams.pDevice->CreateQuery(&queryDesc, &query.GetRawRef()) == S_OK)
+ if(device)
{
- D3DSELECT_10_11(query->End(),
- RParams.pContext->End(query));
-
- // GetData will returns S_OK for both done == TRUE or FALSE.
- // Exit on failure to avoid infinite loop.
- do { }
- while(!done &&
- !FAILED(D3DSELECT_10_11(query->GetData(&done, sizeof(BOOL), 0),
- RParams.pContext->GetData(query, &done, sizeof(BOOL), 0)))
- );
- }
-#endif
+ IDirect3DQuery9* pEventQuery=NULL ;
+ device->CreateQuery(D3DQUERYTYPE_EVENT, &pEventQuery) ;
+
+ if(pEventQuery!=NULL)
+ {
+ pEventQuery->Issue(D3DISSUE_END) ;
+ while(S_FALSE == pEventQuery->GetData(NULL, 0, D3DGETDATA_FLUSH)) ;
+ }
+ }
}
double DistortionRenderer::WaitTillTimeAndFlushGpu(double absTime)
{
-
-OVR_UNUSED(absTime);
-#if 0
double initialTime = ovr_GetTimeInSeconds();
if (initialTime >= absTime)
return 0.0;
- // Flush and Stall CPU while waiting for GPU to complete rendering all of the queued draw calls
- D3D1x_QUERY_DESC queryDesc = { D3D1X_(QUERY_EVENT), 0 };
- Ptr<ID3D1xQuery> query;
- BOOL done = FALSE;
- bool callGetData = false;
-
- if (RParams.pDevice->CreateQuery(&queryDesc, &query.GetRawRef()) == S_OK)
- {
- D3DSELECT_10_11(query->End(),
- RParams.pContext->End(query));
- callGetData = true;
- }
+ WaitUntilGpuIdle();
double newTime = initialTime;
volatile int i;
while (newTime < absTime)
{
- if (callGetData)
- {
- // GetData will returns S_OK for both done == TRUE or FALSE.
- // Stop calling GetData on failure.
- callGetData = !FAILED(D3DSELECT_10_11(query->GetData(&done, sizeof(BOOL), 0),
- RParams.pContext->GetData(query, &done, sizeof(BOOL), 0))) && !done;
- }
- else
- {
- for (int j = 0; j < 50; j++)
- i = 0;
- }
+ for (int j = 0; j < 50; j++)
+ i = 0;
newTime = ovr_GetTimeInSeconds();
}
// How long we waited
return newTime - initialTime;
-#endif
- return 0; //dummy
}
+DistortionRenderer::GraphicsState::GraphicsState(IDirect3DDevice9* d)
+: device(d)
+, numSavedStates(0)
+{
+}
+
+void DistortionRenderer::GraphicsState::RecordAndSetState(int which, int type, DWORD newValue)
+{
+ SavedStateType * sst = &savedState[numSavedStates++];
+ sst->which = which;
+ sst->type = type;
+ if (which == 0)
+ {
+ device->GetSamplerState(0, (D3DSAMPLERSTATETYPE)type, &sst->valueToRevertTo);
+ device->SetSamplerState(0, (D3DSAMPLERSTATETYPE)type, newValue);
+ }
+ else
+ {
+ device->GetRenderState((D3DRENDERSTATETYPE)type, &sst->valueToRevertTo);
+ device->SetRenderState((D3DRENDERSTATETYPE)type, newValue);
+ }
+}
+
+void DistortionRenderer::GraphicsState::Save()
+{
+ //Record and set rasterizer and sampler states.
+
+ numSavedStates=0;
+
+ RecordAndSetState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
+ RecordAndSetState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
+ RecordAndSetState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR );
+ RecordAndSetState(0, D3DSAMP_BORDERCOLOR, 0x000000 );
+ RecordAndSetState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_BORDER );
+ RecordAndSetState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_BORDER );
+
+ RecordAndSetState(1, D3DRS_MULTISAMPLEANTIALIAS, FALSE );
+ RecordAndSetState(1, D3DRS_DITHERENABLE, FALSE );
+ RecordAndSetState(1, D3DRS_ZENABLE, FALSE );
+ RecordAndSetState(1, D3DRS_ZWRITEENABLE, TRUE );
+ RecordAndSetState(1, D3DRS_ZFUNC, D3DCMP_LESSEQUAL );
+ RecordAndSetState(1, D3DRS_CULLMODE , D3DCULL_CCW );
+ RecordAndSetState(1, D3DRS_ALPHABLENDENABLE , FALSE );
+ RecordAndSetState(1, D3DRS_DEPTHBIAS , 0 );
+ RecordAndSetState(1, D3DRS_SRCBLEND , D3DBLEND_SRCALPHA );
+ RecordAndSetState(1, D3DRS_DESTBLEND , D3DBLEND_INVSRCALPHA );
+ RecordAndSetState(1, D3DRS_FILLMODE, D3DFILL_SOLID );
+ RecordAndSetState(1, D3DRS_ALPHATESTENABLE, FALSE);
+ RecordAndSetState(1, D3DRS_DEPTHBIAS , 0 );
+ RecordAndSetState(1, D3DRS_LIGHTING, FALSE );
+ RecordAndSetState(1, D3DRS_FOGENABLE, FALSE );
+}
+void DistortionRenderer::GraphicsState::Restore()
+{
+ for (int i = 0; i<numSavedStates; i++)
+ {
+ SavedStateType * sst = &savedState[i];
+ if (sst->which == 0)
+ {
+ device->SetSamplerState(0, (D3DSAMPLERSTATETYPE)sst->type, sst->valueToRevertTo);
+ }
+ else
+ {
+ device->SetRenderState((D3DRENDERSTATETYPE)sst->type, sst->valueToRevertTo);
+ }
+ }
+}
}}} // OVR::CAPI::D3D1X
diff --git a/LibOVR/Src/CAPI/D3D1X/CAPI_D3D9_DistortionRenderer.h b/LibOVR/Src/CAPI/D3D1X/CAPI_D3D9_DistortionRenderer.h
index 9332b83..f24eb31 100644
--- a/LibOVR/Src/CAPI/D3D1X/CAPI_D3D9_DistortionRenderer.h
+++ b/LibOVR/Src/CAPI/D3D1X/CAPI_D3D9_DistortionRenderer.h
@@ -24,13 +24,17 @@ limitations under the License.
************************************************************************************/
+#include "../../Kernel/OVR_Types.h"
+
#undef new
+#if defined (OVR_OS_WIN32)
#if _MSC_VER < 1700
#include <d3dx9.h>
#else
#include <d3d9.h>
#endif
+#endif
#if defined(OVR_DEFINE_NEW)
#define new OVR_DEFINE_NEW
@@ -57,7 +61,7 @@ public:
// ***** Public DistortionRenderer interface
virtual bool Initialize(const ovrRenderAPIConfig* apiConfig,
- unsigned hmdCaps, unsigned distortionCaps);
+ unsigned distortionCaps);
virtual void SubmitEye(int eyeId, ovrTexture* eyeTexture);
@@ -70,6 +74,32 @@ public:
// Note, it exits when time expires, even if GPU is not in idle state yet.
double WaitTillTimeAndFlushGpu(double absTime);
+protected:
+
+ class GraphicsState : public CAPI::DistortionRenderer::GraphicsState
+ {
+ public:
+ GraphicsState(IDirect3DDevice9* d);
+ virtual void Save();
+ virtual void Restore();
+
+ protected:
+ void RecordAndSetState(int which, int type, DWORD newValue);
+
+ //Structure to store our state changes
+ static const int MAX_SAVED_STATES=100;
+ struct SavedStateType
+ {
+ int which; //0 for samplerstate, 1 for renderstate
+ int type;
+ DWORD valueToRevertTo;
+ } savedState[MAX_SAVED_STATES];
+
+ //Keep track of how many we've done, for reverting
+ int numSavedStates;
+ IDirect3DDevice9* device;
+ };
+
private:
//Functions
@@ -83,6 +113,7 @@ private:
//Data, structures and pointers
IDirect3DDevice9 * device;
+ IDirect3DSwapChain9 * swapChain;
IDirect3DVertexDeclaration9 * vertexDecl;
IDirect3DPixelShader9 * pixelShader;
IDirect3DVertexShader9 * vertexShader;
@@ -92,29 +123,17 @@ private:
struct FOR_EACH_EYE
{
+ FOR_EACH_EYE() : TextureSize(0), RenderViewport(Sizei(0)) { }
+
IDirect3DVertexBuffer9 * dxVerts;
IDirect3DIndexBuffer9 * dxIndices;
int numVerts;
int numIndices;
IDirect3DTexture9 * texture;
ovrVector2f UVScaleOffset[2];
+ Sizei TextureSize;
+ Recti RenderViewport;
} eachEye[2];
-
-
- //Structure to store our state changes
- #define MAX_SAVED_STATES 100
- struct SavedStateType
- {
- int which; //0 for samplerstate, 1 for renderstate
- int type;
- DWORD valueToRevertTo;
- } savedState[MAX_SAVED_STATES];
-
- //Keep track of how many we've done, for reverting
- int numSavedStates;
-
-
-
};
}}} // OVR::CAPI::D3D9
diff --git a/LibOVR/Src/CAPI/D3D1X/CAPI_D3D9_Util.cpp b/LibOVR/Src/CAPI/D3D1X/CAPI_D3D9_Util.cpp
index ea36100..e6bdcb6 100644
--- a/LibOVR/Src/CAPI/D3D1X/CAPI_D3D9_Util.cpp
+++ b/LibOVR/Src/CAPI/D3D1X/CAPI_D3D9_Util.cpp
@@ -32,7 +32,6 @@ limitations under the License.
namespace OVR { namespace CAPI { namespace D3D9 {
-
#define PRECOMPILE_FLAG 0
#if !PRECOMPILE_FLAG
//To make these, you need to run it with PRECOMPILE_FLAG, which also uses them, so good for debugging.
@@ -182,21 +181,25 @@ void DistortionRenderer::Create_Distortion_Models(void)
{
//Make the distortion models
for (int eye=0;eye<2;eye++)
- {
- ovrVector2f dummy_UVScaleOffset[2]; //because it needs to be updated by a later call
+ {
FOR_EACH_EYE * e = &eachEye[eye];
ovrDistortionMesh meshData;
- ovrHmd_CreateDistortionMesh(HMD, RState.EyeRenderDesc[eye].Desc, distortionCaps,
- dummy_UVScaleOffset, &meshData);
+ ovrHmd_CreateDistortionMesh(HMD,
+ RState.EyeRenderDesc[eye].Eye,
+ RState.EyeRenderDesc[eye].Fov,
+ distortionCaps,
+ &meshData);
e->numVerts = meshData.VertexCount;
e->numIndices = meshData.IndexCount;
- device->CreateVertexBuffer( (e->numVerts)*sizeof(ovrDistortionVertex),0, 0,D3DPOOL_MANAGED, &e->dxVerts, NULL );
+ device->CreateVertexBuffer( (e->numVerts)*sizeof(ovrDistortionVertex),0, 0,
+ D3DPOOL_MANAGED, &e->dxVerts, NULL );
ovrDistortionVertex * dxv; e->dxVerts->Lock( 0, 0, (void**)&dxv, 0 );
for (int v=0;v<e->numVerts;v++) dxv[v] = meshData.pVertexData[v];
- device->CreateIndexBuffer( (e->numIndices)*sizeof(u_short),0, D3DFMT_INDEX16,D3DPOOL_MANAGED, &e->dxIndices, NULL );
+ device->CreateIndexBuffer( (e->numIndices)*sizeof(u_short),0, D3DFMT_INDEX16,
+ D3DPOOL_MANAGED, &e->dxIndices, NULL );
unsigned short* dxi; e->dxIndices->Lock( 0, 0, (void**)&dxi, 0 );
for (int i=0;i<e->numIndices;i++) dxi[i] = meshData.pIndexData[i];
@@ -207,30 +210,6 @@ void DistortionRenderer::Create_Distortion_Models(void)
/**********************************************************/
void DistortionRenderer::RenderBothDistortionMeshes(void)
{
- //Record and set render state
- numSavedStates=0;
- RecordAndSetState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR );
- RecordAndSetState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR );
- RecordAndSetState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR );
- RecordAndSetState(0, D3DSAMP_BORDERCOLOR, 0x000000 );
- RecordAndSetState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_BORDER );
- RecordAndSetState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_BORDER );
- RecordAndSetState(1, D3DRS_MULTISAMPLEANTIALIAS, FALSE );
- RecordAndSetState(1, D3DRS_DITHERENABLE, FALSE );
- RecordAndSetState(1, D3DRS_ZENABLE, FALSE );
- RecordAndSetState(1, D3DRS_ZWRITEENABLE, TRUE );
- RecordAndSetState(1, D3DRS_ZFUNC, D3DCMP_LESSEQUAL );
- RecordAndSetState(1, D3DRS_CULLMODE , D3DCULL_CCW );
- RecordAndSetState(1, D3DRS_ALPHABLENDENABLE , FALSE );
- RecordAndSetState(1, D3DRS_DEPTHBIAS , 0 );
- RecordAndSetState(1, D3DRS_SRCBLEND , D3DBLEND_SRCALPHA );
- RecordAndSetState(1, D3DRS_DESTBLEND , D3DBLEND_INVSRCALPHA );
- RecordAndSetState(1, D3DRS_FILLMODE, D3DFILL_SOLID );
- RecordAndSetState(1, D3DRS_ALPHATESTENABLE, FALSE);
- RecordAndSetState(1, D3DRS_DEPTHBIAS , 0 );
- RecordAndSetState(1, D3DRS_LIGHTING, FALSE );
- RecordAndSetState(1, D3DRS_FOGENABLE, FALSE );
-
for (int eye=0; eye<2; eye++)
{
FOR_EACH_EYE * e = &eachEye[eye];
@@ -243,7 +222,7 @@ void DistortionRenderer::RenderBothDistortionMeshes(void)
device->SetTexture( 0, e->texture);
//Choose which vertex shader, with associated additional inputs
- if (distortionCaps & ovrDistortion_TimeWarp)
+ if (distortionCaps & ovrDistortionCap_TimeWarp)
{
device->SetVertexShader( vertexShaderTimewarp );
@@ -251,6 +230,10 @@ void DistortionRenderer::RenderBothDistortionMeshes(void)
ovrHmd_GetEyeTimewarpMatrices(HMD, (ovrEyeType)eye,
RState.EyeRenderPoses[eye], timeWarpMatrices);
+ //Need to transpose the matrices
+ timeWarpMatrices[0] = Matrix4f(timeWarpMatrices[0]).Transposed();
+ timeWarpMatrices[1] = Matrix4f(timeWarpMatrices[1]).Transposed();
+
// Feed identity like matrices in until we get proper timewarp calculation going on
device->SetVertexShaderConstantF(4, (float *) &timeWarpMatrices[0],4);
device->SetVertexShaderConstantF(20,(float *) &timeWarpMatrices[1],4);
@@ -260,58 +243,12 @@ void DistortionRenderer::RenderBothDistortionMeshes(void)
device->SetVertexShader( vertexShader );
}
-
//Set up vertex shader constants
device->SetVertexShaderConstantF( 0, ( FLOAT* )&(e->UVScaleOffset[0]), 1 );
device->SetVertexShaderConstantF( 2, ( FLOAT* )&(e->UVScaleOffset[1]), 1 );
device->DrawIndexedPrimitive( D3DPT_TRIANGLELIST,0,0,e->numVerts,0,e->numIndices/3);
}
-
- //Revert render state
- RevertAllStates();
-
-}
-
-/*********************************************************************************/
-void DistortionRenderer::RecordAndSetState(int which, int type, DWORD newValue)
-{
- SavedStateType * sst = &savedState[numSavedStates++];
- sst->which = which;
- sst->type = type;
- if (which==0)
- {
- device->GetSamplerState( 0, (D3DSAMPLERSTATETYPE)type, &sst->valueToRevertTo);
- device->SetSamplerState( 0, (D3DSAMPLERSTATETYPE)type, newValue);
- }
- else
- {
- device->GetRenderState( (D3DRENDERSTATETYPE)type, &sst->valueToRevertTo);
- device->SetRenderState( (D3DRENDERSTATETYPE)type, newValue);
- }
-}
-/*********************************************************************************/
-void DistortionRenderer::RevertAllStates(void)
-{
- for (int i=0;i<numSavedStates;i++)
- {
- SavedStateType * sst = &savedState[i];
- if (sst->which==0)
- {
- device->SetSamplerState( 0, (D3DSAMPLERSTATETYPE)sst->type, sst->valueToRevertTo);
- }
- else
- {
- device->SetRenderState( (D3DRENDERSTATETYPE)sst->type, sst->valueToRevertTo);
- }
- }
}
-
-
-
-
-
-
-
}}} \ No newline at end of file
diff --git a/LibOVR/Src/CAPI/GL/CAPI_GL_DistortionRenderer.cpp b/LibOVR/Src/CAPI/GL/CAPI_GL_DistortionRenderer.cpp
index a953d73..21b6509 100644
--- a/LibOVR/Src/CAPI/GL/CAPI_GL_DistortionRenderer.cpp
+++ b/LibOVR/Src/CAPI/GL/CAPI_GL_DistortionRenderer.cpp
@@ -15,422 +15,12 @@ otherwise accompanies this software in either electronic or hard copy form.
#include "CAPI_GL_DistortionRenderer.h"
+#include "CAPI_GL_DistortionShaders.h"
+
#include "../../OVR_CAPI_GL.h"
namespace OVR { namespace CAPI { namespace GL {
-
-static const char SimpleQuad_vs[] =
- "uniform vec2 PositionOffset;\n"
- "uniform vec2 Scale;\n"
-
- "attribute vec3 Position;\n"
-
- "void main()\n"
- "{\n"
- " gl_Position = vec4(Position.xy * Scale + PositionOffset, 0.5, 1.0);\n"
- "}\n";
-
-const OVR::CAPI::GL::ShaderBase::Uniform SimpleQuad_vs_refl[] =
-{
- { "PositionOffset", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 0, 8 },
- { "Scale", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 8, 8 },
-};
-
-static const char SimpleQuad_fs[] =
- "uniform vec4 Color;\n"
-
- "void main()\n"
- "{\n"
- " gl_FragColor = Color;\n"
- "}\n";
-
-const OVR::CAPI::GL::ShaderBase::Uniform SimpleQuad_fs_refl[] =
-{
- { "Color", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 0, 16 },
-};
-
-
-static const char Distortion_vs[] =
- "uniform vec2 EyeToSourceUVScale;\n"
- "uniform vec2 EyeToSourceUVOffset;\n"
-
- "attribute vec2 Position;\n"
- "attribute vec4 Color;\n"
- "attribute vec2 TexCoord0;\n"
-
- "varying vec4 oColor;\n"
- "varying vec2 oTexCoord0;\n"
-
- "void main()\n"
- "{\n"
- " gl_Position.x = Position.x;\n"
- " gl_Position.y = Position.y;\n"
- " gl_Position.z = 0.5;\n"
- " gl_Position.w = 1.0;\n"
- // Vertex inputs are in TanEyeAngle space for the R,G,B channels (i.e. after chromatic aberration and distortion).
- // Scale them into the correct [0-1],[0-1] UV lookup space (depending on eye)
- " oTexCoord0 = TexCoord0 * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
- " oTexCoord0.y = 1-oTexCoord0.y;\n"
- " oColor = Color;\n" // Used for vignette fade.
- "}\n";
-
-const OVR::CAPI::GL::ShaderBase::Uniform Distortion_vs_refl[] =
-{
- { "EyeToSourceUVScale", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 0, 8 },
- { "EyeToSourceUVOffset", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 8, 8 },
-};
-
-static const char Distortion_fs[] =
- "uniform sampler2D Texture0;\n"
-
- "varying vec4 oColor;\n"
- "varying vec2 oTexCoord0;\n"
-
- "void main()\n"
- "{\n"
- " gl_FragColor = texture2D(Texture0, oTexCoord0);\n"
- " gl_FragColor.a = 1.0;\n"
- "}\n";
-
-
-static const char DistortionTimewarp_vs[] =
- "uniform vec2 EyeToSourceUVScale;\n"
- "uniform vec2 EyeToSourceUVOffset;\n"
- "uniform mat4 EyeRotationStart;\n"
- "uniform mat4 EyeRotationEnd;\n"
-
- "attribute vec2 Position;\n"
- "attribute vec4 Color;\n"
- "attribute vec2 TexCoord0;\n"
-
- "varying vec4 oColor;\n"
- "varying vec2 oTexCoord0;\n"
-
- "void main()\n"
- "{\n"
- " gl_Position.x = Position.x;\n"
- " gl_Position.y = Position.y;\n"
- " gl_Position.z = 0.0;\n"
- " gl_Position.w = 1.0;\n"
-
- // Vertex inputs are in TanEyeAngle space for the R,G,B channels (i.e. after chromatic aberration and distortion).
- // These are now "real world" vectors in direction (x,y,1) relative to the eye of the HMD.
- " vec3 TanEyeAngle = vec3 ( TexCoord0.x, TexCoord0.y, 1.0 );\n"
-
- // Accurate time warp lerp vs. faster
-#if 1
- // Apply the two 3x3 timewarp rotations to these vectors.
- " vec3 TransformedStart = (EyeRotationStart * vec4(TanEyeAngle, 0)).xyz;\n"
- " vec3 TransformedEnd = (EyeRotationEnd * vec4(TanEyeAngle, 0)).xyz;\n"
- // And blend between them.
- " vec3 Transformed = mix ( TransformedStart, TransformedEnd, Color.a );\n"
-#else
- " mat3 EyeRotation = mix ( EyeRotationStart, EyeRotationEnd, Color.a );\n"
- " vec3 Transformed = EyeRotation * TanEyeAngle;\n"
-#endif
-
- // Project them back onto the Z=1 plane of the rendered images.
- " float RecipZ = 1.0 / Transformed.z;\n"
- " vec2 Flattened = vec2 ( Transformed.x * RecipZ, Transformed.y * RecipZ );\n"
-
- // These are now still in TanEyeAngle space.
- // Scale them into the correct [0-1],[0-1] UV lookup space (depending on eye)
- " vec2 SrcCoord = Flattened * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
- " oTexCoord0 = SrcCoord;\n"
- " oTexCoord0.y = 1-oTexCoord0.y;\n"
- " oColor = Color.r;\n" // Used for vignette fade.
- "}\n";
-
-const OVR::CAPI::GL::ShaderBase::Uniform DistortionTimewarp_vs_refl[] =
-{
- { "EyeToSourceUVScale", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 0, 8 },
- { "EyeToSourceUVOffset", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 8, 8 },
-};
-
-
-static const char DistortionPositionalTimewarp_vs[] =
- "#version 150\n"
-
- "uniform sampler2D Texture0;\n"
- "uniform vec2 EyeToSourceUVScale;\n"
- "uniform vec2 EyeToSourceUVOffset;\n"
- "uniform vec2 DepthProjector;\n"
- "uniform vec2 DepthDimSize;\n"
- "uniform mat4 EyeRotationStart;\n"
- "uniform mat4 EyeRotationEnd;\n"
-
- "in vec2 Position;\n"
- "in vec4 Color;\n"
- "in vec2 TexCoord0;\n"
- "in vec2 TexCoord1;\n"
- "in vec2 TexCoord2;\n"
-
- "out vec4 oColor;\n"
- "out vec2 oTexCoord0;\n"
-
- "vec4 PositionFromDepth(vec2 inTexCoord)\n"
- "{\n"
- " vec2 eyeToSourceTexCoord = inTexCoord * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
- " eyeToSourceTexCoord.y = 1 - eyeToSourceTexCoord.y;\n"
- " float depth = texelFetch(Texture0, ivec2(eyeToSourceTexCoord * DepthDimSize), 0).x;\n"
- " float linearDepth = DepthProjector.y / (depth - DepthProjector.x);\n"
- " vec4 retVal = vec4(inTexCoord, 1, 1);\n"
- " retVal.xyz *= linearDepth;\n"
- " return retVal;\n"
- "}\n"
-
- "vec2 TimewarpTexCoordToWarpedPos(vec2 inTexCoord, float a)\n"
- "{\n"
- // Vertex inputs are in TanEyeAngle space for the R,G,B channels (i.e. after chromatic aberration and distortion).
- // These are now "real world" vectors in direction (x,y,1) relative to the eye of the HMD.
- // Apply the 4x4 timewarp rotation to these vectors.
- " vec4 inputPos = PositionFromDepth(inTexCoord);\n"
- " vec3 transformed = mix ( EyeRotationStart * inputPos, EyeRotationEnd * inputPos, a ).xyz;\n"
- // Project them back onto the Z=1 plane of the rendered images.
- " vec2 flattened = transformed.xy / transformed.z;\n"
- // Scale them into ([0,0.5],[0,1]) or ([0.5,0],[0,1]) UV lookup space (depending on eye)
- " vec2 noDepthUV = flattened * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
- //" float depth = texture2DLod(Texture0, noDepthUV, 0).r;\n"
- " return noDepthUV.xy;\n"
- "}\n"
-
- "void main()\n"
- "{\n"
- " gl_Position.x = Position.x;\n"
- " gl_Position.y = Position.y;\n"
- " gl_Position.z = 0.0;\n"
- " gl_Position.w = 1.0;\n"
-
- // warped positions are a bit more involved, hence a separate function
- " oTexCoord0 = TimewarpTexCoordToWarpedPos(TexCoord0, Color.a);\n"
- " oTexCoord0.y = 1-oTexCoord0.y;\n"
-
- " oColor = vec4(Color.r); // Used for vignette fade.\n"
- "}\n";
-
-const OVR::CAPI::GL::ShaderBase::Uniform DistortionPositionalTimewarp_vs_refl[] =
-{
- { "EyeToSourceUVScale", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 0, 8 },
- { "EyeToSourceUVOffset", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 8, 8 },
-};
-
-
-static const char DistortionChroma_vs[] =
- "uniform vec2 EyeToSourceUVScale;\n"
- "uniform vec2 EyeToSourceUVOffset;\n"
-
- "attribute vec2 Position;\n"
- "attribute vec4 Color;\n"
- "attribute vec2 TexCoord0;\n"
- "attribute vec2 TexCoord1;\n"
- "attribute vec2 TexCoord2;\n"
-
- "varying vec4 oColor;\n"
- "varying vec2 oTexCoord0;\n"
- "varying vec2 oTexCoord1;\n"
- "varying vec2 oTexCoord2;\n"
-
- "void main()\n"
- "{\n"
- " gl_Position.x = Position.x;\n"
- " gl_Position.y = Position.y;\n"
- " gl_Position.z = 0.5;\n"
- " gl_Position.w = 1.0;\n"
-
- // Vertex inputs are in TanEyeAngle space for the R,G,B channels (i.e. after chromatic aberration and distortion).
- // Scale them into the correct [0-1],[0-1] UV lookup space (depending on eye)
- " oTexCoord0 = TexCoord0 * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
- " oTexCoord0.y = 1-oTexCoord0.y;\n"
- " oTexCoord1 = TexCoord1 * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
- " oTexCoord1.y = 1-oTexCoord1.y;\n"
- " oTexCoord2 = TexCoord2 * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
- " oTexCoord2.y = 1-oTexCoord2.y;\n"
-
- " oColor = Color;\n" // Used for vignette fade.
- "}\n";
-
-const OVR::CAPI::GL::ShaderBase::Uniform DistortionChroma_vs_refl[] =
-{
- { "EyeToSourceUVScale", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 0, 8 },
- { "EyeToSourceUVOffset", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 8, 8 },
-};
-
-static const char DistortionChroma_fs[] =
- "uniform sampler2D Texture0;\n"
-
- "varying vec4 oColor;\n"
- "varying vec2 oTexCoord0;\n"
- "varying vec2 oTexCoord1;\n"
- "varying vec2 oTexCoord2;\n"
-
- "void main()\n"
- "{\n"
- " float ResultR = texture2D(Texture0, oTexCoord0).r;\n"
- " float ResultG = texture2D(Texture0, oTexCoord1).g;\n"
- " float ResultB = texture2D(Texture0, oTexCoord2).b;\n"
-
- " gl_FragColor = vec4(ResultR * oColor.r, ResultG * oColor.g, ResultB * oColor.b, 1.0);\n"
- "}\n";
-
-
-static const char DistortionTimewarpChroma_vs[] =
- "uniform vec2 EyeToSourceUVScale;\n"
- "uniform vec2 EyeToSourceUVOffset;\n"
- "uniform mat4 EyeRotationStart;\n"
- "uniform mat4 EyeRotationEnd;\n"
-
- "attribute vec2 Position;\n"
- "attribute vec4 Color;\n"
- "attribute vec2 TexCoord0;\n"
- "attribute vec2 TexCoord1;\n"
- "attribute vec2 TexCoord2;\n"
-
- "varying vec4 oColor;\n"
- "varying vec2 oTexCoord0;\n"
- "varying vec2 oTexCoord1;\n"
- "varying vec2 oTexCoord2;\n"
-
- "void main()\n"
- "{\n"
- " gl_Position.x = Position.x;\n"
- " gl_Position.y = Position.y;\n"
- " gl_Position.z = 0.0;\n"
- " gl_Position.w = 1.0;\n"
-
- // Vertex inputs are in TanEyeAngle space for the R,G,B channels (i.e. after chromatic aberration and distortion).
- // These are now "real world" vectors in direction (x,y,1) relative to the eye of the HMD.
- " vec3 TanEyeAngleR = vec3 ( TexCoord0.x, TexCoord0.y, 1.0 );\n"
- " vec3 TanEyeAngleG = vec3 ( TexCoord1.x, TexCoord1.y, 1.0 );\n"
- " vec3 TanEyeAngleB = vec3 ( TexCoord2.x, TexCoord2.y, 1.0 );\n"
-
- // Accurate time warp lerp vs. faster
-#if 1
- // Apply the two 3x3 timewarp rotations to these vectors.
- " vec3 TransformedRStart = (EyeRotationStart * vec4(TanEyeAngleR, 0)).xyz;\n"
- " vec3 TransformedGStart = (EyeRotationStart * vec4(TanEyeAngleG, 0)).xyz;\n"
- " vec3 TransformedBStart = (EyeRotationStart * vec4(TanEyeAngleB, 0)).xyz;\n"
- " vec3 TransformedREnd = (EyeRotationEnd * vec4(TanEyeAngleR, 0)).xyz;\n"
- " vec3 TransformedGEnd = (EyeRotationEnd * vec4(TanEyeAngleG, 0)).xyz;\n"
- " vec3 TransformedBEnd = (EyeRotationEnd * vec4(TanEyeAngleB, 0)).xyz;\n"
-
- // And blend between them.
- " vec3 TransformedR = mix ( TransformedRStart, TransformedREnd, Color.a );\n"
- " vec3 TransformedG = mix ( TransformedGStart, TransformedGEnd, Color.a );\n"
- " vec3 TransformedB = mix ( TransformedBStart, TransformedBEnd, Color.a );\n"
-#else
- " mat3 EyeRotation = mix ( EyeRotationStart, EyeRotationEnd, Color.a );\n"
- " vec3 TransformedR = EyeRotation * TanEyeAngleR;\n"
- " vec3 TransformedG = EyeRotation * TanEyeAngleG;\n"
- " vec3 TransformedB = EyeRotation * TanEyeAngleB;\n"
-#endif
-
- // Project them back onto the Z=1 plane of the rendered images.
- " float RecipZR = 1.0 / TransformedR.z;\n"
- " float RecipZG = 1.0 / TransformedG.z;\n"
- " float RecipZB = 1.0 / TransformedB.z;\n"
- " vec2 FlattenedR = vec2 ( TransformedR.x * RecipZR, TransformedR.y * RecipZR );\n"
- " vec2 FlattenedG = vec2 ( TransformedG.x * RecipZG, TransformedG.y * RecipZG );\n"
- " vec2 FlattenedB = vec2 ( TransformedB.x * RecipZB, TransformedB.y * RecipZB );\n"
-
- // These are now still in TanEyeAngle space.
- // Scale them into the correct [0-1],[0-1] UV lookup space (depending on eye)
- " vec2 SrcCoordR = FlattenedR * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
- " vec2 SrcCoordG = FlattenedG * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
- " vec2 SrcCoordB = FlattenedB * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
-
- " oTexCoord0 = SrcCoordR;\n"
- " oTexCoord0.y = 1-oTexCoord0.y;\n"
- " oTexCoord1 = SrcCoordG;\n"
- " oTexCoord1.y = 1-oTexCoord1.y;\n"
- " oTexCoord2 = SrcCoordB;\n"
- " oTexCoord2.y = 1-oTexCoord2.y;\n"
-
- " oColor = Color.r;\n" // Used for vignette fade.
- "}\n";
-
-const OVR::CAPI::GL::ShaderBase::Uniform DistortionTimewarpChroma_vs_refl[] =
-{
- { "EyeToSourceUVScale", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 0, 8 },
- { "EyeToSourceUVOffset", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 8, 8 },
- { "EyeRotationStart", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 16, 64 },
- { "EyeRotationEnd", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 80, 64 },
-};
-
-
-static const char DistortionPositionalTimewarpChroma_vs[] =
- "#version 150\n"
- "uniform sampler2D Texture0;\n"
- "uniform sampler2D Texture1;\n"
- "uniform vec2 EyeToSourceUVScale;\n"
- "uniform vec2 EyeToSourceUVOffset;\n"
- "uniform vec2 DepthProjector;\n"
- "uniform vec2 DepthDimSize;\n"
- "uniform mat4 EyeRotationStart;\n"
- "uniform mat4 EyeRotationEnd;\n"
-
- "in vec2 Position;\n"
- "in vec4 Color;\n"
- "in vec2 TexCoord0;\n"
- "in vec2 TexCoord1;\n"
- "in vec2 TexCoord2;\n"
-
- "out vec4 oColor;\n"
- "out vec2 oTexCoord0;\n"
- "out vec2 oTexCoord1;\n"
- "out vec2 oTexCoord2;\n"
-
- "vec4 PositionFromDepth(vec2 inTexCoord)\n"
- "{\n"
- " vec2 eyeToSourceTexCoord = inTexCoord * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
- " eyeToSourceTexCoord.y = 1 - eyeToSourceTexCoord.y;\n"
- " float depth = texelFetch(Texture1, ivec2(eyeToSourceTexCoord * DepthDimSize), 0).x;\n"
- " float linearDepth = DepthProjector.y / (depth - DepthProjector.x);\n"
- " vec4 retVal = vec4(inTexCoord, 1, 1);\n"
- " retVal.xyz *= linearDepth;\n"
- " return retVal;\n"
- "}\n"
-
- "vec2 TimewarpTexCoordToWarpedPos(vec2 inTexCoord, float a)\n"
- "{\n"
- // Vertex inputs are in TanEyeAngle space for the R,G,B channels (i.e. after chromatic aberration and distortion).
- // These are now "real world" vectors in direction (x,y,1) relative to the eye of the HMD.
- // Apply the 4x4 timewarp rotation to these vectors.
- " vec4 inputPos = PositionFromDepth(inTexCoord);\n"
- " vec3 transformed = mix ( EyeRotationStart * inputPos, EyeRotationEnd * inputPos, a ).xyz;\n"
- // Project them back onto the Z=1 plane of the rendered images.
- " vec2 flattened = transformed.xy / transformed.z;\n"
- // Scale them into ([0,0.5],[0,1]) or ([0.5,0],[0,1]) UV lookup space (depending on eye)
- " vec2 noDepthUV = flattened * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
- //" float depth = texture2DLod(Texture1, noDepthUV, 0).r;\n"
- " return noDepthUV.xy;\n"
- "}\n"
-
- "void main()\n"
- "{\n"
- " gl_Position.x = Position.x;\n"
- " gl_Position.y = Position.y;\n"
- " gl_Position.z = 0.0;\n"
- " gl_Position.w = 1.0;\n"
-
- // warped positions are a bit more involved, hence a separate function
- " oTexCoord0 = TimewarpTexCoordToWarpedPos(TexCoord0, Color.a);\n"
- " oTexCoord0.y = 1-oTexCoord0.y;\n"
- " oTexCoord1 = TimewarpTexCoordToWarpedPos(TexCoord1, Color.a);\n"
- " oTexCoord1.y = 1-oTexCoord1.y;\n"
- " oTexCoord2 = TimewarpTexCoordToWarpedPos(TexCoord2, Color.a);\n"
- " oTexCoord2.y = 1-oTexCoord2.y;\n"
-
- " oColor = vec4(Color.r); // Used for vignette fade.\n"
- "}\n";
-
-const OVR::CAPI::GL::ShaderBase::Uniform DistortionPositionalTimewarpChroma_vs_refl[] =
-{
- { "EyeToSourceUVScale", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 0, 8 },
- { "EyeToSourceUVOffset", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 8, 8 },
-};
-
-
// Distortion pixel shader lookup.
// Bit 0: Chroma Correction
// Bit 1: Timewarp
@@ -461,8 +51,6 @@ static ShaderInfo DistortionVertexShaderLookup[DistortionVertexShaderCount] =
SI_REFL__(DistortionChroma_vs),
SI_REFL__(DistortionTimewarp_vs),
SI_REFL__(DistortionTimewarpChroma_vs)
- //SI_REFL__(DistortionPositionalTimewarp_vs),
- //SI_REFL__(DistortionPositionalTimewarpChroma_vs)
};
static ShaderInfo DistortionPixelShaderLookup[DistortionPixelShaderCount] =
@@ -473,8 +61,8 @@ static ShaderInfo DistortionPixelShaderLookup[DistortionPixelShaderCount] =
void DistortionShaderBitIndexCheck()
{
- OVR_COMPILER_ASSERT(ovrDistortion_Chromatic == 1);
- OVR_COMPILER_ASSERT(ovrDistortion_TimeWarp == 2);
+ OVR_COMPILER_ASSERT(ovrDistortionCap_Chromatic == 1);
+ OVR_COMPILER_ASSERT(ovrDistortionCap_TimeWarp == 2);
}
@@ -504,7 +92,10 @@ struct LatencyVertex
DistortionRenderer::DistortionRenderer(ovrHmd hmd, FrameTimeManager& timeManager,
const HMDRenderState& renderState)
: CAPI::DistortionRenderer(ovrRenderAPI_OpenGL, hmd, timeManager, renderState)
+ , LatencyVAO(0)
{
+ DistortionMeshVAOs[0] = 0;
+ DistortionMeshVAOs[1] = 0;
}
DistortionRenderer::~DistortionRenderer()
@@ -517,17 +108,17 @@ CAPI::DistortionRenderer* DistortionRenderer::Create(ovrHmd hmd,
FrameTimeManager& timeManager,
const HMDRenderState& renderState)
{
+#if !defined(OVR_OS_MAC)
InitGLExtensions();
-
+#endif
return new DistortionRenderer(hmd, timeManager, renderState);
}
bool DistortionRenderer::Initialize(const ovrRenderAPIConfig* apiConfig,
- unsigned hmdCaps, unsigned distortionCaps)
+ unsigned distortionCaps)
{
- // TBD: Decide if hmdCaps are needed here or are a part of RenderState
- OVR_UNUSED(hmdCaps);
+ GfxState = *new GraphicsState();
const ovrGLConfig* config = (const ovrGLConfig*)apiConfig;
@@ -539,15 +130,20 @@ bool DistortionRenderer::Initialize(const ovrRenderAPIConfig* apiConfig,
memset(&RParams, 0, sizeof(RParams));
return true;
}
-
- if (!config->OGL.WglContext || !config->OGL.GdiDc)
- return false;
- RParams.GdiDc = config->OGL.GdiDc;
RParams.Multisample = config->OGL.Header.Multisample;
RParams.RTSize = config->OGL.Header.RTSize;
- RParams.WglContext = config->OGL.WglContext;
- RParams.Window = config->OGL.Window;
+#if defined(OVR_OS_WIN32)
+ RParams.Window = (config->OGL.Window) ? config->OGL.Window : GetActiveWindow();
+#elif defined(OVR_OS_LINUX)
+ RParams.Disp = (config->OGL.Disp) ? config->OGL.Disp : XOpenDisplay(NULL);
+ RParams.Win = config->OGL.Win;
+ if (!RParams.Win)
+ {
+ int unused;
+ XGetInputFocus(RParams.Disp, &RParams.Win, &unused);
+ }
+#endif
DistortionCaps = distortionCaps;
@@ -564,37 +160,36 @@ bool DistortionRenderer::Initialize(const ovrRenderAPIConfig* apiConfig,
void DistortionRenderer::SubmitEye(int eyeId, ovrTexture* eyeTexture)
{
- //Doesn't do a lot in here??
+ // Doesn't do a lot in here??
const ovrGLTexture* tex = (const ovrGLTexture*)eyeTexture;
- //Write in values
+ // Write in values
eachEye[eyeId].texture = tex->OGL.TexId;
if (tex)
{
- //Its only at this point we discover what the viewport of the texture is.
- //because presumably we allow users to realtime adjust the resolution.
- //Which begs the question - why did we ask them what viewport they were
- //using before, which gave them a set of UV offsets. In fact, our
- //asking for eye mesh must be entirely independed of these viewports,
- //presumably only to get the parameters.
-
- ovrEyeDesc ed = RState.EyeRenderDesc[eyeId].Desc;
- ed.TextureSize = tex->OGL.Header.TextureSize;
- ed.RenderViewport = tex->OGL.Header.RenderViewport;
-
- ovrHmd_GetRenderScaleAndOffset(HMD, ed, DistortionCaps, eachEye[eyeId].UVScaleOffset);
-
+ // Its only at this point we discover what the viewport of the texture is.
+ // because presumably we allow users to realtime adjust the resolution.
+ eachEye[eyeId].TextureSize = tex->OGL.Header.TextureSize;
+ eachEye[eyeId].RenderViewport = tex->OGL.Header.RenderViewport;
+
+ const ovrEyeRenderDesc& erd = RState.EyeRenderDesc[eyeId];
+
+ ovrHmd_GetRenderScaleAndOffset( erd.Fov,
+ eachEye[eyeId].TextureSize, eachEye[eyeId].RenderViewport,
+ eachEye[eyeId].UVScaleOffset );
+
pEyeTextures[eyeId]->UpdatePlaceholderTexture(tex->OGL.TexId,
tex->OGL.Header.TextureSize);
}
}
-void DistortionRenderer::EndFrame(bool swapBuffers, unsigned char* latencyTesterDrawColor, unsigned char* latencyTester2DrawColor)
-{
+void DistortionRenderer::EndFrame(bool swapBuffers,
+ unsigned char* latencyTesterDrawColor, unsigned char* latencyTester2DrawColor)
+{
if (!TimeManager.NeedDistortionTimeMeasurement())
{
- if (RState.DistortionCaps & ovrDistortion_TimeWarp)
+ if (RState.DistortionCaps & ovrDistortionCap_TimeWarp)
{
// Wait for timewarp distortion if it is time and Gpu idle
FlushGpuAndWaitTillTime(TimeManager.GetFrameTiming().TimewarpPointTime);
@@ -626,18 +221,38 @@ void DistortionRenderer::EndFrame(bool swapBuffers, unsigned char* latencyTester
if (swapBuffers)
{
- bool useVsync = ((RState.HMDCaps & ovrHmdCap_NoVSync) == 0);
- BOOL success;
+ bool useVsync = ((RState.EnabledHmdCaps & ovrHmdCap_NoVSync) == 0);
int swapInterval = (useVsync) ? 1 : 0;
+#if defined(OVR_OS_WIN32)
if (wglGetSwapIntervalEXT() != swapInterval)
- wglSwapIntervalEXT(swapInterval);
+ wglSwapIntervalEXT(swapInterval);
- success = SwapBuffers(RParams.GdiDc);
+ HDC dc = GetDC(RParams.Window);
+ BOOL success = SwapBuffers(dc);
+ ReleaseDC(RParams.Window, dc);
OVR_ASSERT(success);
+ OVR_UNUSED(success);
+#elif defined(OVR_OS_MAC)
+ CGLContextObj context = CGLGetCurrentContext();
+ GLint currentSwapInterval = 0;
+ CGLGetParameter(context, kCGLCPSwapInterval, &currentSwapInterval);
+ if (currentSwapInterval != swapInterval)
+ CGLSetParameter(context, kCGLCPSwapInterval, &swapInterval);
+
+ CGLFlushDrawable(context);
+#elif defined(OVR_OS_LINUX)
+ static const char* extensions = glXQueryExtensionsString(RParams.Disp, 0);
+ static bool supportsVSync = (extensions != NULL && strstr(extensions, "GLX_EXT_swap_control"));
+ if (supportsVSync)
+ {
+ GLuint currentSwapInterval = 0;
+ glXQueryDrawable(RParams.Disp, RParams.Win, GLX_SWAP_INTERVAL_EXT, &currentSwapInterval);
+ if (currentSwapInterval != swapInterval)
+ glXSwapIntervalEXT(RParams.Disp, RParams.Win, swapInterval);
+ }
- // Force GPU to flush the scene, resulting in the lowest possible latency.
- // It's critical that this flush is *after* present.
- WaitUntilGpuIdle();
+ glXSwapBuffers(RParams.Disp, RParams.Win);
+#endif
}
}
@@ -670,6 +285,109 @@ double DistortionRenderer::FlushGpuAndWaitTillTime(double absTime)
// How long we waited
return newTime - initialTime;
}
+
+
+DistortionRenderer::GraphicsState::GraphicsState()
+{
+ const char* glVersionString = (const char*)glGetString(GL_VERSION);
+ OVR_DEBUG_LOG(("GL_VERSION STRING: %s", (const char*)glVersionString));
+ char prefix[64];
+ bool foundVersion = false;
+
+ for (int i = 10; i < 30; ++i)
+ {
+ int major = i / 10;
+ int minor = i % 10;
+ OVR_sprintf(prefix, 64, "%d.%d", major, minor);
+ if (strstr(glVersionString, prefix) == glVersionString)
+ {
+ GlMajorVersion = major;
+ GlMinorVersion = minor;
+ foundVersion = true;
+ break;
+ }
+ }
+
+ if (!foundVersion)
+ {
+ glGetIntegerv(GL_MAJOR_VERSION, &GlMajorVersion);
+ glGetIntegerv(GL_MAJOR_VERSION, &GlMinorVersion);
+ }
+
+ OVR_ASSERT(GlMajorVersion >= 2);
+
+ if (GlMajorVersion >= 3)
+ {
+ SupportsVao = true;
+ }
+ else
+ {
+ const char* extensions = (const char*)glGetString(GL_EXTENSIONS);
+ SupportsVao = (strstr("GL_ARB_vertex_array_object", extensions) != NULL);
+ }
+}
+
+
+void DistortionRenderer::GraphicsState::ApplyBool(GLenum Name, GLint Value)
+{
+ if (Value != 0)
+ glEnable(Name);
+ else
+ glDisable(Name);
+}
+
+
+void DistortionRenderer::GraphicsState::Save()
+{
+ glGetIntegerv(GL_VIEWPORT, Viewport);
+ glGetFloatv(GL_COLOR_CLEAR_VALUE, ClearColor);
+ glGetIntegerv(GL_DEPTH_TEST, &DepthTest);
+ glGetIntegerv(GL_CULL_FACE, &CullFace);
+ glGetIntegerv(GL_CURRENT_PROGRAM, &Program);
+ glGetIntegerv(GL_ACTIVE_TEXTURE, &ActiveTexture);
+ glGetIntegerv(GL_TEXTURE_BINDING_2D, &TextureBinding);
+ glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &VertexArray);
+ glGetIntegerv(GL_FRAMEBUFFER_BINDING, &FrameBufferBinding);
+ glGetIntegerv(GL_BLEND, &Blend);
+ glGetIntegerv(GL_COLOR_WRITEMASK, ColorWritemask);
+ glGetIntegerv(GL_DITHER, &Dither);
+ glGetIntegerv(GL_RASTERIZER_DISCARD, &RasterizerDiscard);
+ if (GlMajorVersion >= 3 && GlMajorVersion >= 2)
+ glGetIntegerv(GL_SAMPLE_MASK, &SampleMask);
+ glGetIntegerv(GL_SCISSOR_TEST, &ScissorTest);
+
+ IsValid = true;
+}
+
+
+void DistortionRenderer::GraphicsState::Restore()
+{
+ // Don't allow restore-before-save.
+ if (!IsValid)
+ return;
+
+ glViewport(Viewport[0], Viewport[1], Viewport[2], Viewport[3]);
+ glClearColor(ClearColor[0], ClearColor[1], ClearColor[2], ClearColor[3]);
+
+ ApplyBool(GL_DEPTH_TEST, DepthTest);
+ ApplyBool(GL_CULL_FACE, CullFace);
+
+ glUseProgram(Program);
+ glActiveTexture(ActiveTexture);
+ glBindTexture(GL_TEXTURE_2D, TextureBinding);
+ if (SupportsVao)
+ glBindVertexArray(VertexArray);
+ glBindFramebuffer(GL_FRAMEBUFFER, FrameBufferBinding);
+
+ ApplyBool(GL_BLEND, Blend);
+
+ glColorMask((GLboolean)ColorWritemask[0], (GLboolean)ColorWritemask[1], (GLboolean)ColorWritemask[2], (GLboolean)ColorWritemask[3]);
+ ApplyBool(GL_DITHER, Dither);
+ ApplyBool(GL_RASTERIZER_DISCARD, RasterizerDiscard);
+ if (GlMajorVersion >= 3 && GlMajorVersion >= 2)
+ ApplyBool(GL_SAMPLE_MASK, SampleMask);
+ ApplyBool(GL_SCISSOR_TEST, ScissorTest);
+}
void DistortionRenderer::initBuffersAndShaders()
@@ -681,9 +399,11 @@ void DistortionRenderer::initBuffersAndShaders()
// double startT = ovr_GetTimeInSeconds();
- if (!ovrHmd_CreateDistortionMesh( HMD, RState.EyeRenderDesc[eyeNum].Desc,
+ if (!ovrHmd_CreateDistortionMesh( HMD,
+ RState.EyeRenderDesc[eyeNum].Eye,
+ RState.EyeRenderDesc[eyeNum].Fov,
RState.DistortionCaps,
- UVScaleOffset[eyeNum], &meshData) )
+ &meshData) )
{
OVR_ASSERT(false);
continue;
@@ -711,9 +431,9 @@ void DistortionRenderer::initBuffersAndShaders()
}
DistortionMeshVBs[eyeNum] = *new Buffer(&RParams);
- DistortionMeshVBs[eyeNum]->Data ( Buffer_Vertex, pVBVerts, sizeof(DistortionVertex) * meshData.VertexCount );
+ DistortionMeshVBs[eyeNum]->Data ( Buffer_Vertex | Buffer_ReadOnly, pVBVerts, sizeof(DistortionVertex) * meshData.VertexCount );
DistortionMeshIBs[eyeNum] = *new Buffer(&RParams);
- DistortionMeshIBs[eyeNum]->Data ( Buffer_Index, meshData.pIndexData, ( sizeof(INT16) * meshData.IndexCount ) );
+ DistortionMeshIBs[eyeNum]->Data ( Buffer_Index | Buffer_ReadOnly, meshData.pIndexData, ( sizeof(SInt16) * meshData.IndexCount ) );
OVR_FREE ( pVBVerts );
ovrHmd_DestroyDistortionMesh( &meshData );
@@ -723,8 +443,22 @@ void DistortionRenderer::initBuffersAndShaders()
}
void DistortionRenderer::renderDistortion(Texture* leftEyeTexture, Texture* rightEyeTexture)
-{
+{
+ GraphicsState* glState = (GraphicsState*)GfxState.GetPtr();
+
+ glBindFramebuffer(GL_FRAMEBUFFER, 0);
setViewport( Recti(0,0, RParams.RTSize.w, RParams.RTSize.h) );
+
+ glDisable(GL_CULL_FACE);
+ glDisable(GL_DEPTH_TEST);
+ glDisable(GL_BLEND);
+
+ glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE);
+ glDisable(GL_DITHER);
+ glDisable(GL_RASTERIZER_DISCARD);
+ if (glState->GlMajorVersion >= 3 && glState->GlMajorVersion >= 2)
+ glDisable(GL_SAMPLE_MASK);
+ glDisable(GL_SCISSOR_TEST);
glClearColor(
RState.ClearColor[0],
@@ -732,19 +466,17 @@ void DistortionRenderer::renderDistortion(Texture* leftEyeTexture, Texture* righ
RState.ClearColor[2],
RState.ClearColor[3] );
- glClearDepth(0);
-
- glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+ glClear(GL_COLOR_BUFFER_BIT);
for (int eyeNum = 0; eyeNum < 2; eyeNum++)
{
ShaderFill distortionShaderFill(DistortionShader);
distortionShaderFill.SetTexture(0, eyeNum == 0 ? leftEyeTexture : rightEyeTexture);
- DistortionShader->SetUniform2f("EyeToSourceUVScale", UVScaleOffset[eyeNum][0].x, UVScaleOffset[eyeNum][0].y);
- DistortionShader->SetUniform2f("EyeToSourceUVOffset", UVScaleOffset[eyeNum][1].x, UVScaleOffset[eyeNum][1].y);
+ DistortionShader->SetUniform2f("EyeToSourceUVScale", eachEye[eyeNum].UVScaleOffset[0].x, eachEye[eyeNum].UVScaleOffset[0].y);
+ DistortionShader->SetUniform2f("EyeToSourceUVOffset", eachEye[eyeNum].UVScaleOffset[1].x, eachEye[eyeNum].UVScaleOffset[1].y);
- if (DistortionCaps & ovrDistortion_TimeWarp)
+ if (DistortionCaps & ovrDistortionCap_TimeWarp)
{
ovrMatrix4f timeWarpMatrices[2];
ovrHmd_GetEyeTimewarpMatrices(HMD, (ovrEyeType)eyeNum,
@@ -755,12 +487,12 @@ void DistortionRenderer::renderDistortion(Texture* leftEyeTexture, Texture* righ
DistortionShader->SetUniform4x4f("EyeRotationEnd", Matrix4f(timeWarpMatrices[1]).Transposed());
renderPrimitives(&distortionShaderFill, DistortionMeshVBs[eyeNum], DistortionMeshIBs[eyeNum],
- NULL, 0, (int)DistortionMeshVBs[eyeNum]->GetSize(), Prim_Triangles, true);
+ 0, (int)DistortionMeshIBs[eyeNum]->GetSize()/2, Prim_Triangles, &DistortionMeshVAOs[eyeNum], true);
}
else
{
renderPrimitives(&distortionShaderFill, DistortionMeshVBs[eyeNum], DistortionMeshIBs[eyeNum],
- NULL, 0, (int)DistortionMeshVBs[eyeNum]->GetSize(), Prim_Triangles, true);
+ 0, (int)DistortionMeshIBs[eyeNum]->GetSize()/2, Prim_Triangles, &DistortionMeshVAOs[eyeNum], true);
}
}
}
@@ -818,7 +550,7 @@ void DistortionRenderer::renderLatencyQuad(unsigned char* latencyTesterDrawColor
for(int eyeNum = 0; eyeNum < 2; eyeNum++)
{
SimpleQuadShader->SetUniform2f("PositionOffset", eyeNum == 0 ? -0.4f : 0.4f, 0.0f);
- renderPrimitives(&quadFill, LatencyTesterQuadVB, NULL, NULL, 0, numQuadVerts, Prim_TriangleStrip, false);
+ renderPrimitives(&quadFill, LatencyTesterQuadVB, NULL, 0, numQuadVerts, Prim_TriangleStrip, &LatencyVAO, false);
}
}
@@ -843,16 +575,16 @@ void DistortionRenderer::renderLatencyPixel(unsigned char* latencyTesterPixelCol
Vector2f scale(2.0f / RParams.RTSize.w, 2.0f / RParams.RTSize.h);
SimpleQuadShader->SetUniform2f("Scale", scale.x, scale.y);
SimpleQuadShader->SetUniform2f("PositionOffset", 1.0f, 1.0f);
- renderPrimitives(&quadFill, LatencyTesterQuadVB, NULL, NULL, 0, numQuadVerts, Prim_TriangleStrip, false);
+ renderPrimitives(&quadFill, LatencyTesterQuadVB, NULL, 0, numQuadVerts, Prim_TriangleStrip, &LatencyVAO, false);
}
void DistortionRenderer::renderPrimitives(
const ShaderFill* fill,
Buffer* vertices, Buffer* indices,
- Matrix4f* viewMatrix, int offset, int count,
- PrimitiveType rprim, bool useDistortionVertex)
+ int offset, int count,
+ PrimitiveType rprim, GLuint* vao, bool isDistortionMesh)
{
- ShaderSet* shaders = (ShaderSet*) ((ShaderFill*)fill)->GetShaders();
+ GraphicsState* glState = (GraphicsState*)GfxState.GetPtr();
GLenum prim;
switch (rprim)
@@ -867,128 +599,173 @@ void DistortionRenderer::renderPrimitives(
prim = GL_TRIANGLE_STRIP;
break;
default:
- assert(0);
+ OVR_ASSERT(false);
return;
}
fill->Set();
- if (shaders->ProjLoc >= 0)
- glUniformMatrix4fv(shaders->ProjLoc, 1, 0, &StdUniforms.Proj.M[0][0]);
- if (shaders->ViewLoc >= 0 && viewMatrix != NULL)
- glUniformMatrix4fv(shaders->ViewLoc, 1, 0, &viewMatrix->Transposed().M[0][0]);
-
- //if (shaders->UsesLighting && Lighting->Version != shaders->LightingVer)
- //{
- // shaders->LightingVer = Lighting->Version;
- // Lighting->Set(shaders);
- //}
-
- glBindBuffer(GL_ARRAY_BUFFER, ((Buffer*)vertices)->GLBuffer);
- for (int i = 0; i < 5; i++)
- glEnableVertexAttribArray(i);
GLuint prog = fill->GetShaders()->Prog;
- if (useDistortionVertex)
+ if (vao != NULL)
{
- GLint posLoc = glGetAttribLocation(prog, "Position");
- GLint colLoc = glGetAttribLocation(prog, "Color");
- GLint tc0Loc = glGetAttribLocation(prog, "TexCoord0");
- GLint tc1Loc = glGetAttribLocation(prog, "TexCoord1");
- GLint tc2Loc = glGetAttribLocation(prog, "TexCoord2");
-
- glVertexAttribPointer(posLoc, 2, GL_FLOAT, false, sizeof(DistortionVertex), (char*)offset + offsetof(DistortionVertex, Pos));
- glVertexAttribPointer(colLoc, 4, GL_UNSIGNED_BYTE, true, sizeof(DistortionVertex), (char*)offset + offsetof(DistortionVertex, Col));
- glVertexAttribPointer(tc0Loc, 2, GL_FLOAT, false, sizeof(DistortionVertex), (char*)offset + offsetof(DistortionVertex, TexR));
- glVertexAttribPointer(tc1Loc, 2, GL_FLOAT, false, sizeof(DistortionVertex), (char*)offset + offsetof(DistortionVertex, TexG));
- glVertexAttribPointer(tc2Loc, 2, GL_FLOAT, false, sizeof(DistortionVertex), (char*)offset + offsetof(DistortionVertex, TexB));
- }
- else
- {
- GLint posLoc = glGetAttribLocation(prog, "Position");
+ if (*vao != 0)
+ {
+ glBindVertexArray(*vao);
- glVertexAttribPointer(posLoc, 3, GL_FLOAT, false, sizeof(LatencyVertex), (char*)offset + offsetof(LatencyVertex, Pos));
+ if (isDistortionMesh)
+ glDrawElements(prim, count, GL_UNSIGNED_SHORT, NULL);
+ else
+ glDrawArrays(prim, 0, count);
+ }
+ else
+ {
+ if (glState->SupportsVao)
+ {
+ glGenVertexArrays(1, vao);
+ glBindVertexArray(*vao);
+ }
+
+ int attributeCount = (isDistortionMesh) ? 5 : 1;
+ int* locs = new int[attributeCount];
+
+ glBindBuffer(GL_ARRAY_BUFFER, ((Buffer*)vertices)->GLBuffer);
+
+ if (isDistortionMesh)
+ {
+ glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ((Buffer*)indices)->GLBuffer);
+
+ locs[0] = glGetAttribLocation(prog, "Position");
+ locs[1] = glGetAttribLocation(prog, "Color");
+ locs[2] = glGetAttribLocation(prog, "TexCoord0");
+ locs[3] = glGetAttribLocation(prog, "TexCoord1");
+ locs[4] = glGetAttribLocation(prog, "TexCoord2");
+
+ glVertexAttribPointer(locs[0], 2, GL_FLOAT, false, sizeof(DistortionVertex), reinterpret_cast<char*>(offset)+offsetof(DistortionVertex, Pos));
+ glVertexAttribPointer(locs[1], 4, GL_UNSIGNED_BYTE, true, sizeof(DistortionVertex), reinterpret_cast<char*>(offset)+offsetof(DistortionVertex, Col));
+ glVertexAttribPointer(locs[2], 2, GL_FLOAT, false, sizeof(DistortionVertex), reinterpret_cast<char*>(offset)+offsetof(DistortionVertex, TexR));
+ glVertexAttribPointer(locs[3], 2, GL_FLOAT, false, sizeof(DistortionVertex), reinterpret_cast<char*>(offset)+offsetof(DistortionVertex, TexG));
+ glVertexAttribPointer(locs[4], 2, GL_FLOAT, false, sizeof(DistortionVertex), reinterpret_cast<char*>(offset)+offsetof(DistortionVertex, TexB));
+ }
+ else
+ {
+ locs[0] = glGetAttribLocation(prog, "Position");
+
+ glVertexAttribPointer(locs[0], 3, GL_FLOAT, false, sizeof(LatencyVertex), reinterpret_cast<char*>(offset)+offsetof(LatencyVertex, Pos));
+ }
+
+ for (int i = 0; i < attributeCount; ++i)
+ glEnableVertexAttribArray(locs[i]);
+
+ if (isDistortionMesh)
+ glDrawElements(prim, count, GL_UNSIGNED_SHORT, NULL);
+ else
+ glDrawArrays(prim, 0, count);
+
+
+ if (!glState->SupportsVao)
+ {
+ for (int i = 0; i < attributeCount; ++i)
+ glDisableVertexAttribArray(locs[i]);
+ }
+
+ delete[] locs;
+ }
}
-
- if (indices)
- {
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ((Buffer*)indices)->GLBuffer);
- glDrawElements(prim, count, GL_UNSIGNED_SHORT, NULL);
- glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
- }
- else
- {
- glDrawArrays(prim, 0, count);
- }
-
- for (int i = 0; i < 5; i++)
- glDisableVertexAttribArray(i);
}
void DistortionRenderer::setViewport(const Recti& vp)
{
- int wh;
- if (CurRenderTarget)
- wh = CurRenderTarget->Height;
- else
- {
- RECT rect;
- BOOL success = GetWindowRect(RParams.Window, &rect);
- OVR_ASSERT(success);
- OVR_UNUSED(success);
- wh = rect.bottom - rect.top;
- }
- glViewport(vp.x, wh-vp.y-vp.h, vp.w, vp.h);
-
- //glEnable(GL_SCISSOR_TEST);
- //glScissor(vp.x, wh-vp.y-vp.h, vp.w, vp.h);
+ glViewport(vp.x, vp.y, vp.w, vp.h);
}
void DistortionRenderer::initShaders()
{
+ GraphicsState* glState = (GraphicsState*)GfxState.GetPtr();
+
+ const char* shaderPrefix =
+ (glState->GlMajorVersion < 3 || (glState->GlMajorVersion == 3 && glState->GlMinorVersion < 2)) ?
+ glsl2Prefix : glsl3Prefix;
+
{
- ShaderInfo vsShaderByteCode = DistortionVertexShaderLookup[DistortionVertexShaderBitMask & DistortionCaps];
- Ptr<GL::VertexShader> vtxShader = *new GL::VertexShader(
+ ShaderInfo vsInfo = DistortionVertexShaderLookup[DistortionVertexShaderBitMask & DistortionCaps];
+
+ size_t vsSize = strlen(shaderPrefix)+vsInfo.ShaderSize;
+ char* vsSource = new char[vsSize];
+ OVR_strcpy(vsSource, vsSize, shaderPrefix);
+ OVR_strcat(vsSource, vsSize, vsInfo.ShaderData);
+
+ Ptr<GL::VertexShader> vs = *new GL::VertexShader(
&RParams,
- (void*)vsShaderByteCode.ShaderData, vsShaderByteCode.ShaderSize,
- vsShaderByteCode.ReflectionData, vsShaderByteCode.ReflectionSize);
+ (void*)vsSource, vsSize,
+ vsInfo.ReflectionData, vsInfo.ReflectionSize);
DistortionShader = *new ShaderSet;
- DistortionShader->SetShader(vtxShader);
+ DistortionShader->SetShader(vs);
- ShaderInfo psShaderByteCode = DistortionPixelShaderLookup[DistortionPixelShaderBitMask & DistortionCaps];
+ delete[](vsSource);
+
+ ShaderInfo psInfo = DistortionPixelShaderLookup[DistortionPixelShaderBitMask & DistortionCaps];
+
+ size_t psSize = strlen(shaderPrefix)+psInfo.ShaderSize;
+ char* psSource = new char[psSize];
+ OVR_strcpy(psSource, psSize, shaderPrefix);
+ OVR_strcat(psSource, psSize, psInfo.ShaderData);
Ptr<GL::FragmentShader> ps = *new GL::FragmentShader(
&RParams,
- (void*)psShaderByteCode.ShaderData, psShaderByteCode.ShaderSize,
- psShaderByteCode.ReflectionData, psShaderByteCode.ReflectionSize);
+ (void*)psSource, psSize,
+ psInfo.ReflectionData, psInfo.ReflectionSize);
DistortionShader->SetShader(ps);
+
+ delete[](psSource);
}
- {
- Ptr<GL::VertexShader> vtxShader = *new GL::VertexShader(
+ {
+ size_t vsSize = strlen(shaderPrefix)+sizeof(SimpleQuad_vs);
+ char* vsSource = new char[vsSize];
+ OVR_strcpy(vsSource, vsSize, shaderPrefix);
+ OVR_strcat(vsSource, vsSize, SimpleQuad_vs);
+
+ Ptr<GL::VertexShader> vs = *new GL::VertexShader(
&RParams,
- (void*)SimpleQuad_vs, sizeof(SimpleQuad_vs),
- SimpleQuad_vs_refl, sizeof(SimpleQuad_vs_refl) / sizeof(SimpleQuad_vs_refl[0]));
+ (void*)vsSource, vsSize,
+ SimpleQuad_vs_refl, sizeof(SimpleQuad_vs_refl) / sizeof(SimpleQuad_vs_refl[0]));
SimpleQuadShader = *new ShaderSet;
- SimpleQuadShader->SetShader(vtxShader);
+ SimpleQuadShader->SetShader(vs);
+
+ delete[](vsSource);
+
+ size_t psSize = strlen(shaderPrefix)+sizeof(SimpleQuad_fs);
+ char* psSource = new char[psSize];
+ OVR_strcpy(psSource, psSize, shaderPrefix);
+ OVR_strcat(psSource, psSize, SimpleQuad_fs);
Ptr<GL::FragmentShader> ps = *new GL::FragmentShader(
&RParams,
- (void*)SimpleQuad_fs, sizeof(SimpleQuad_fs),
+ (void*)psSource, psSize,
SimpleQuad_fs_refl, sizeof(SimpleQuad_fs_refl) / sizeof(SimpleQuad_fs_refl[0]));
- SimpleQuadShader->SetShader(ps);
+ SimpleQuadShader->SetShader(ps);
+
+ delete[](psSource);
}
}
void DistortionRenderer::destroy()
{
+ GraphicsState* glState = (GraphicsState*)GfxState.GetPtr();
+
for(int eyeNum = 0; eyeNum < 2; eyeNum++)
{
+ if (glState->SupportsVao)
+ glDeleteVertexArrays(1, &DistortionMeshVAOs[eyeNum]);
+
+ DistortionMeshVAOs[eyeNum] = 0;
+
DistortionMeshVBs[eyeNum].Clear();
DistortionMeshIBs[eyeNum].Clear();
}
@@ -1001,6 +778,7 @@ void DistortionRenderer::destroy()
}
LatencyTesterQuadVB.Clear();
+ LatencyVAO = 0;
}
}}} // OVR::CAPI::GL
diff --git a/LibOVR/Src/CAPI/GL/CAPI_GL_DistortionRenderer.h b/LibOVR/Src/CAPI/GL/CAPI_GL_DistortionRenderer.h
index 8e0b72e..60f1a9f 100644
--- a/LibOVR/Src/CAPI/GL/CAPI_GL_DistortionRenderer.h
+++ b/LibOVR/Src/CAPI/GL/CAPI_GL_DistortionRenderer.h
@@ -45,7 +45,7 @@ public:
// ***** Public DistortionRenderer interface
virtual bool Initialize(const ovrRenderAPIConfig* apiConfig,
- unsigned hmdCaps, unsigned distortionCaps);
+ unsigned distortionCaps);
virtual void SubmitEye(int eyeId, ovrTexture* eyeTexture);
@@ -57,12 +57,54 @@ public:
// Note, it exits when time expires, even if GPU is not in idle state yet.
double FlushGpuAndWaitTillTime(double absTime);
-private:
+protected:
+
+
+ class GraphicsState : public CAPI::DistortionRenderer::GraphicsState
+ {
+ public:
+ GraphicsState();
+ virtual void Save();
+ virtual void Restore();
+
+ protected:
+ void ApplyBool(GLenum Name, GLint Value);
+
+ public:
+ GLint GlMajorVersion;
+ GLint GlMinorVersion;
+ bool SupportsVao;
+
+ GLint Viewport[4];
+ GLfloat ClearColor[4];
+ GLint DepthTest;
+ GLint CullFace;
+ GLint Program;
+ GLint ActiveTexture;
+ GLint TextureBinding;
+ GLint VertexArray;
+ GLint FrameBufferBinding;
+
+ GLint Blend;
+ GLint ColorWritemask[4];
+ GLint Dither;
+ GLint Fog;
+ GLint Lighting;
+ GLint RasterizerDiscard;
+ GLint RenderMode;
+ GLint SampleMask;
+ GLint ScissorTest;
+ GLfloat ZoomX;
+ GLfloat ZoomY;
+ };
+
// TBD: Should we be using oe from RState instead?
unsigned DistortionCaps;
struct FOR_EACH_EYE
{
+ FOR_EACH_EYE() : TextureSize(0), RenderViewport(Sizei(0)) { }
+
#if 0
IDirect3DVertexBuffer9 * dxVerts;
IDirect3DIndexBuffer9 * dxIndices;
@@ -70,9 +112,11 @@ private:
int numVerts;
int numIndices;
- GLuint texture;
+ GLuint texture;
- ovrVector2f UVScaleOffset[2];
+ ovrVector2f UVScaleOffset[2];
+ Sizei TextureSize;
+ Recti RenderViewport;
} eachEye[2];
// GL context and utility variables.
@@ -89,8 +133,8 @@ private:
void renderDistortion(Texture* leftEyeTexture, Texture* rightEyeTexture);
void renderPrimitives(const ShaderFill* fill, Buffer* vertices, Buffer* indices,
- Matrix4f* viewMatrix, int offset, int count,
- PrimitiveType rprim, bool useDistortionVertex);
+ int offset, int count,
+ PrimitiveType rprim, GLuint* vao, bool isDistortionMesh);
void createDrawQuad();
void renderLatencyQuad(unsigned char* latencyTesterDrawColor);
@@ -98,11 +142,9 @@ private:
Ptr<Texture> pEyeTextures[2];
- // U,V scale and offset needed for timewarp.
- ovrVector2f UVScaleOffset[2][2];
-
Ptr<Buffer> DistortionMeshVBs[2]; // one per-eye
Ptr<Buffer> DistortionMeshIBs[2]; // one per-eye
+ GLuint DistortionMeshVAOs[2]; // one per-eye
Ptr<ShaderSet> DistortionShader;
@@ -111,13 +153,24 @@ private:
Matrix4f Proj;
Matrix4f View;
} StdUniforms;
-
+
+ GLuint LatencyVAO;
Ptr<Buffer> LatencyTesterQuadVB;
Ptr<ShaderSet> SimpleQuadShader;
Ptr<Texture> CurRenderTarget;
Array<Ptr<Texture> > DepthBuffers;
GLuint CurrentFbo;
+
+ GLint SavedViewport[4];
+ GLfloat SavedClearColor[4];
+ GLint SavedDepthTest;
+ GLint SavedCullFace;
+ GLint SavedProgram;
+ GLint SavedActiveTexture;
+ GLint SavedBoundTexture;
+ GLint SavedVertexArray;
+ GLint SavedBoundFrameBuffer;
};
}}} // OVR::CAPI::GL
diff --git a/LibOVR/Src/CAPI/GL/CAPI_GL_DistortionShaders.h b/LibOVR/Src/CAPI/GL/CAPI_GL_DistortionShaders.h
new file mode 100644
index 0000000..03fd174
--- /dev/null
+++ b/LibOVR/Src/CAPI/GL/CAPI_GL_DistortionShaders.h
@@ -0,0 +1,326 @@
+/************************************************************************************
+
+ Filename : CAPI_GL_Shaders.h
+ Content : Distortion shader header for GL
+ Created : November 11, 2013
+ Authors : David Borel, Volga Aksoy
+
+ Copyright : Copyright 2013 Oculus VR, Inc. All Rights reserved.
+
+ Use of this software is subject to the terms of the Oculus Inc license
+ agreement provided at the time of installation or download, or which
+ otherwise accompanies this software in either electronic or hard copy form.
+
+ ************************************************************************************/
+
+
+#ifndef OVR_CAPI_GL_Shaders_h
+#define OVR_CAPI_GL_Shaders_h
+
+
+#include "CAPI_GL_Util.h"
+
+namespace OVR { namespace CAPI { namespace GL {
+
+ static const char glsl2Prefix[] =
+ "#version 110\n"
+ "#extension GL_ARB_shader_texture_lod : enable\n"
+ "#define _FRAGCOLOR_DECLARATION\n"
+ "#define _VS_IN attribute\n"
+ "#define _VS_OUT varying\n"
+ "#define _FS_IN varying\n"
+ "#define _TEXTURELOD texture2DLod\n"
+ "#define _FRAGCOLOR gl_FragColor\n";
+
+ static const char glsl3Prefix[] =
+ "#version 150\n"
+ "#define _FRAGCOLOR_DECLARATION out vec4 FragColor;\n"
+ "#define _VS_IN in\n"
+ "#define _VS_OUT out\n"
+ "#define _FS_IN in\n"
+ "#define _TEXTURELOD textureLod\n"
+ "#define _FRAGCOLOR FragColor\n";
+
+ static const char SimpleQuad_vs[] =
+ "uniform vec2 PositionOffset;\n"
+ "uniform vec2 Scale;\n"
+
+ "_VS_IN vec3 Position;\n"
+
+ "void main()\n"
+ "{\n"
+ " gl_Position = vec4(Position.xy * Scale + PositionOffset, 0.5, 1.0);\n"
+ "}\n";
+
+ const OVR::CAPI::GL::ShaderBase::Uniform SimpleQuad_vs_refl[] =
+ {
+ { "PositionOffset", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 0, 8 },
+ { "Scale", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 8, 8 },
+ };
+
+ static const char SimpleQuad_fs[] =
+ "uniform vec4 Color;\n"
+
+ "_FRAGCOLOR_DECLARATION\n"
+
+ "void main()\n"
+ "{\n"
+ " _FRAGCOLOR = Color;\n"
+ "}\n";
+
+ const OVR::CAPI::GL::ShaderBase::Uniform SimpleQuad_fs_refl[] =
+ {
+ { "Color", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 0, 16 },
+ };
+
+
+ static const char Distortion_vs[] =
+ "uniform vec2 EyeToSourceUVScale;\n"
+ "uniform vec2 EyeToSourceUVOffset;\n"
+
+ "_VS_IN vec2 Position;\n"
+ "_VS_IN vec4 Color;\n"
+ "_VS_IN vec2 TexCoord0;\n"
+
+ "_VS_OUT vec4 oColor;\n"
+ "_VS_OUT vec2 oTexCoord0;\n"
+
+ "void main()\n"
+ "{\n"
+ " gl_Position.x = Position.x;\n"
+ " gl_Position.y = Position.y;\n"
+ " gl_Position.z = 0.5;\n"
+ " gl_Position.w = 1.0;\n"
+ // Vertex inputs are in TanEyeAngle space for the R,G,B channels (i.e. after chromatic aberration and distortion).
+ // Scale them into the correct [0-1],[0-1] UV lookup space (depending on eye)
+ " oTexCoord0 = TexCoord0 * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
+ " oTexCoord0.y = 1.0 - oTexCoord0.y;\n"
+ " oColor = Color;\n" // Used for vignette fade.
+ "}\n";
+
+ const OVR::CAPI::GL::ShaderBase::Uniform Distortion_vs_refl[] =
+ {
+ { "EyeToSourceUVScale", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 0, 8 },
+ { "EyeToSourceUVOffset", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 8, 8 },
+ };
+
+ static const char Distortion_fs[] =
+ "uniform sampler2D Texture0;\n"
+
+ "_FS_IN vec4 oColor;\n"
+ "_FS_IN vec2 oTexCoord0;\n"
+
+ "_FRAGCOLOR_DECLARATION\n"
+
+ "void main()\n"
+ "{\n"
+ " _FRAGCOLOR = _TEXTURELOD(Texture0, oTexCoord0, 0.0);\n"
+ " _FRAGCOLOR.a = 1.0;\n"
+ "}\n";
+
+
+ static const char DistortionTimewarp_vs[] =
+ "uniform vec2 EyeToSourceUVScale;\n"
+ "uniform vec2 EyeToSourceUVOffset;\n"
+ "uniform mat4 EyeRotationStart;\n"
+ "uniform mat4 EyeRotationEnd;\n"
+
+ "_VS_IN vec2 Position;\n"
+ "_VS_IN vec4 Color;\n"
+ "_VS_IN vec2 TexCoord0;\n"
+
+ "_FS_IN vec4 oColor;\n"
+ "_FS_IN vec2 oTexCoord0;\n"
+
+ "void main()\n"
+ "{\n"
+ " gl_Position.x = Position.x;\n"
+ " gl_Position.y = Position.y;\n"
+ " gl_Position.z = 0.0;\n"
+ " gl_Position.w = 1.0;\n"
+
+ // Vertex inputs are in TanEyeAngle space for the R,G,B channels (i.e. after chromatic aberration and distortion).
+ // These are now "real world" vectors in direction (x,y,1) relative to the eye of the HMD.
+ " vec3 TanEyeAngle = vec3 ( TexCoord0.x, TexCoord0.y, 1.0 );\n"
+
+ // Accurate time warp lerp vs. faster
+#if 1
+ // Apply the two 3x3 timewarp rotations to these vectors.
+ " vec3 TransformedStart = (EyeRotationStart * vec4(TanEyeAngle, 0)).xyz;\n"
+ " vec3 TransformedEnd = (EyeRotationEnd * vec4(TanEyeAngle, 0)).xyz;\n"
+ // And blend between them.
+ " vec3 Transformed = mix ( TransformedStart, TransformedEnd, Color.a );\n"
+#else
+ " mat4 EyeRotation = mix ( EyeRotationStart, EyeRotationEnd, Color.a );\n"
+ " vec3 Transformed = EyeRotation * TanEyeAngle;\n"
+#endif
+
+ // Project them back onto the Z=1 plane of the rendered images.
+ " float RecipZ = 1.0 / Transformed.z;\n"
+ " vec2 Flattened = vec2 ( Transformed.x * RecipZ, Transformed.y * RecipZ );\n"
+
+ // These are now still in TanEyeAngle space.
+ // Scale them into the correct [0-1],[0-1] UV lookup space (depending on eye)
+ " vec2 SrcCoord = Flattened * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
+ " oTexCoord0 = SrcCoord;\n"
+ " oTexCoord0.y = 1.0-oTexCoord0.y;\n"
+ " oColor = vec4(Color.r, Color.r, Color.r, Color.r);\n" // Used for vignette fade.
+ "}\n";
+
+
+ const OVR::CAPI::GL::ShaderBase::Uniform DistortionTimewarp_vs_refl[] =
+ {
+ { "EyeToSourceUVScale", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 0, 8 },
+ { "EyeToSourceUVOffset", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 8, 8 },
+ };
+
+ static const char DistortionChroma_vs[] =
+ "uniform vec2 EyeToSourceUVScale;\n"
+ "uniform vec2 EyeToSourceUVOffset;\n"
+
+ "_VS_IN vec2 Position;\n"
+ "_VS_IN vec4 Color;\n"
+ "_VS_IN vec2 TexCoord0;\n"
+ "_VS_IN vec2 TexCoord1;\n"
+ "_VS_IN vec2 TexCoord2;\n"
+
+ "_VS_OUT vec4 oColor;\n"
+ "_VS_OUT vec2 oTexCoord0;\n"
+ "_VS_OUT vec2 oTexCoord1;\n"
+ "_VS_OUT vec2 oTexCoord2;\n"
+
+ "void main()\n"
+ "{\n"
+ " gl_Position.x = Position.x;\n"
+ " gl_Position.y = Position.y;\n"
+ " gl_Position.z = 0.5;\n"
+ " gl_Position.w = 1.0;\n"
+
+ // Vertex inputs are in TanEyeAngle space for the R,G,B channels (i.e. after chromatic aberration and distortion).
+ // Scale them into the correct [0-1],[0-1] UV lookup space (depending on eye)
+ " oTexCoord0 = TexCoord0 * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
+ " oTexCoord0.y = 1.0-oTexCoord0.y;\n"
+ " oTexCoord1 = TexCoord1 * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
+ " oTexCoord1.y = 1.0-oTexCoord1.y;\n"
+ " oTexCoord2 = TexCoord2 * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
+ " oTexCoord2.y = 1.0-oTexCoord2.y;\n"
+
+ " oColor = Color;\n" // Used for vignette fade.
+ "}\n";
+
+ const OVR::CAPI::GL::ShaderBase::Uniform DistortionChroma_vs_refl[] =
+ {
+ { "EyeToSourceUVScale", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 0, 8 },
+ { "EyeToSourceUVOffset", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 8, 8 },
+ };
+
+ static const char DistortionChroma_fs[] =
+ "uniform sampler2D Texture0;\n"
+
+ "_FS_IN vec4 oColor;\n"
+ "_FS_IN vec2 oTexCoord0;\n"
+ "_FS_IN vec2 oTexCoord1;\n"
+ "_FS_IN vec2 oTexCoord2;\n"
+
+ "_FRAGCOLOR_DECLARATION\n"
+
+ "void main()\n"
+ "{\n"
+ " float ResultR = _TEXTURELOD(Texture0, oTexCoord0, 0.0).r;\n"
+ " float ResultG = _TEXTURELOD(Texture0, oTexCoord1, 0.0).g;\n"
+ " float ResultB = _TEXTURELOD(Texture0, oTexCoord2, 0.0).b;\n"
+
+ " _FRAGCOLOR = vec4(ResultR * oColor.r, ResultG * oColor.g, ResultB * oColor.b, 1.0);\n"
+ "}\n";
+
+
+ static const char DistortionTimewarpChroma_vs[] =
+ "uniform vec2 EyeToSourceUVScale;\n"
+ "uniform vec2 EyeToSourceUVOffset;\n"
+ "uniform mat4 EyeRotationStart;\n"
+ "uniform mat4 EyeRotationEnd;\n"
+
+ "_VS_IN vec2 Position;\n"
+ "_VS_IN vec4 Color;\n"
+ "_VS_IN vec2 TexCoord0;\n"
+ "_VS_IN vec2 TexCoord1;\n"
+ "_VS_IN vec2 TexCoord2;\n"
+
+ "_VS_OUT vec4 oColor;\n"
+ "_VS_OUT vec2 oTexCoord0;\n"
+ "_VS_OUT vec2 oTexCoord1;\n"
+ "_VS_OUT vec2 oTexCoord2;\n"
+
+ "void main()\n"
+ "{\n"
+ " gl_Position.x = Position.x;\n"
+ " gl_Position.y = Position.y;\n"
+ " gl_Position.z = 0.0;\n"
+ " gl_Position.w = 1.0;\n"
+
+ // Vertex inputs are in TanEyeAngle space for the R,G,B channels (i.e. after chromatic aberration and distortion).
+ // These are now "real world" vectors in direction (x,y,1) relative to the eye of the HMD.
+ " vec3 TanEyeAngleR = vec3 ( TexCoord0.x, TexCoord0.y, 1.0 );\n"
+ " vec3 TanEyeAngleG = vec3 ( TexCoord1.x, TexCoord1.y, 1.0 );\n"
+ " vec3 TanEyeAngleB = vec3 ( TexCoord2.x, TexCoord2.y, 1.0 );\n"
+
+ // Accurate time warp lerp vs. faster
+#if 1
+ // Apply the two 3x3 timewarp rotations to these vectors.
+ " vec3 TransformedRStart = (EyeRotationStart * vec4(TanEyeAngleR, 0)).xyz;\n"
+ " vec3 TransformedGStart = (EyeRotationStart * vec4(TanEyeAngleG, 0)).xyz;\n"
+ " vec3 TransformedBStart = (EyeRotationStart * vec4(TanEyeAngleB, 0)).xyz;\n"
+ " vec3 TransformedREnd = (EyeRotationEnd * vec4(TanEyeAngleR, 0)).xyz;\n"
+ " vec3 TransformedGEnd = (EyeRotationEnd * vec4(TanEyeAngleG, 0)).xyz;\n"
+ " vec3 TransformedBEnd = (EyeRotationEnd * vec4(TanEyeAngleB, 0)).xyz;\n"
+
+ // And blend between them.
+ " vec3 TransformedR = mix ( TransformedRStart, TransformedREnd, Color.a );\n"
+ " vec3 TransformedG = mix ( TransformedGStart, TransformedGEnd, Color.a );\n"
+ " vec3 TransformedB = mix ( TransformedBStart, TransformedBEnd, Color.a );\n"
+#else
+ " mat3 EyeRotation;\n"
+ " EyeRotation[0] = mix ( EyeRotationStart[0], EyeRotationEnd[0], Color.a ).xyz;\n"
+ " EyeRotation[1] = mix ( EyeRotationStart[1], EyeRotationEnd[1], Color.a ).xyz;\n"
+ " EyeRotation[2] = mix ( EyeRotationStart[2], EyeRotationEnd[2], Color.a ).xyz;\n"
+ " vec3 TransformedR = EyeRotation * TanEyeAngleR;\n"
+ " vec3 TransformedG = EyeRotation * TanEyeAngleG;\n"
+ " vec3 TransformedB = EyeRotation * TanEyeAngleB;\n"
+#endif
+
+ // Project them back onto the Z=1 plane of the rendered images.
+ " float RecipZR = 1.0 / TransformedR.z;\n"
+ " float RecipZG = 1.0 / TransformedG.z;\n"
+ " float RecipZB = 1.0 / TransformedB.z;\n"
+ " vec2 FlattenedR = vec2 ( TransformedR.x * RecipZR, TransformedR.y * RecipZR );\n"
+ " vec2 FlattenedG = vec2 ( TransformedG.x * RecipZG, TransformedG.y * RecipZG );\n"
+ " vec2 FlattenedB = vec2 ( TransformedB.x * RecipZB, TransformedB.y * RecipZB );\n"
+
+ // These are now still in TanEyeAngle space.
+ // Scale them into the correct [0-1],[0-1] UV lookup space (depending on eye)
+ " vec2 SrcCoordR = FlattenedR * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
+ " vec2 SrcCoordG = FlattenedG * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
+ " vec2 SrcCoordB = FlattenedB * EyeToSourceUVScale + EyeToSourceUVOffset;\n"
+
+ " oTexCoord0 = SrcCoordR;\n"
+ " oTexCoord0.y = 1.0-oTexCoord0.y;\n"
+ " oTexCoord1 = SrcCoordG;\n"
+ " oTexCoord1.y = 1.0-oTexCoord1.y;\n"
+ " oTexCoord2 = SrcCoordB;\n"
+ " oTexCoord2.y = 1.0-oTexCoord2.y;\n"
+
+ " oColor = vec4(Color.r, Color.r, Color.r, Color.r);\n" // Used for vignette fade.
+ "}\n";
+
+
+ const OVR::CAPI::GL::ShaderBase::Uniform DistortionTimewarpChroma_vs_refl[] =
+ {
+ { "EyeToSourceUVScale", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 0, 8 },
+ { "EyeToSourceUVOffset", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 8, 8 },
+ { "EyeRotationStart", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 16, 64 },
+ { "EyeRotationEnd", OVR::CAPI::GL::ShaderBase::VARTYPE_FLOAT, 80, 64 },
+ };
+
+}}} // OVR::CAPI::GL
+
+#endif // OVR_CAPI_GL_Shaders_h
diff --git a/LibOVR/Src/CAPI/GL/CAPI_GL_Util.cpp b/LibOVR/Src/CAPI/GL/CAPI_GL_Util.cpp
index b82939a..910e28c 100644
--- a/LibOVR/Src/CAPI/GL/CAPI_GL_Util.cpp
+++ b/LibOVR/Src/CAPI/GL/CAPI_GL_Util.cpp
@@ -23,16 +23,25 @@ limitations under the License.
#include "CAPI_GL_Util.h"
#include "../../Kernel/OVR_Log.h"
+#include <string.h>
namespace OVR { namespace CAPI { namespace GL {
-// GL Hooks for PC.
+// GL Hooks for non-Mac.
+#if !defined(OVR_OS_MAC)
+
#if defined(OVR_OS_WIN32)
PFNWGLGETPROCADDRESS wglGetProcAddress;
+PFNGLENABLEPROC glEnable;
+PFNGLDISABLEPROC glDisable;
+PFNGLGETFLOATVPROC glGetFloatv;
+PFNGLGETINTEGERVPROC glGetIntegerv;
+PFNGLGETSTRINGPROC glGetString;
+PFNGLCOLORMASKPROC glColorMask;
PFNGLCLEARPROC glClear;
PFNGLCLEARCOLORPROC glClearColor;
PFNGLCLEARDEPTHPROC glClearDepth;
@@ -48,12 +57,15 @@ PFNGLBINDTEXTUREPROC glBindTexture;
PFNWGLGETSWAPINTERVALEXTPROC wglGetSwapIntervalEXT;
PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT;
-PFNGLGENFRAMEBUFFERSEXTPROC glGenFramebuffersEXT;
+
+#elif defined(OVR_OS_LINUX)
+
+PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT;
+
+#endif
+
PFNGLDELETESHADERPROC glDeleteShader;
-PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glCheckFramebufferStatusEXT;
-PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC glFramebufferRenderbufferEXT;
-PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glFramebufferTexture2DEXT;
-PFNGLBINDFRAMEBUFFEREXTPROC glBindFramebufferEXT;
+PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer;
PFNGLACTIVETEXTUREPROC glActiveTexture;
PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray;
PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer;
@@ -88,92 +100,108 @@ PFNGLUNIFORM4FVPROC glUniform4fv;
PFNGLUNIFORM3FVPROC glUniform3fv;
PFNGLUNIFORM2FVPROC glUniform2fv;
PFNGLUNIFORM1FVPROC glUniform1fv;
-PFNGLCOMPRESSEDTEXIMAGE2DPROC glCompressedTexImage2D;
-PFNGLRENDERBUFFERSTORAGEEXTPROC glRenderbufferStorageEXT;
-PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT;
-PFNGLGENRENDERBUFFERSEXTPROC glGenRenderbuffersEXT;
-PFNGLDELETERENDERBUFFERSEXTPROC glDeleteRenderbuffersEXT;
-
PFNGLGENVERTEXARRAYSPROC glGenVertexArrays;
+PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays;
+PFNGLBINDVERTEXARRAYPROC glBindVertexArray;
+
+
+#if defined(OVR_OS_WIN32)
+
+void* GetFunction(const char* functionName)
+{
+ return wglGetProcAddress(functionName);
+}
+
+#else
+
+void (*GetFunction(const char *functionName))( void )
+{
+ return glXGetProcAddress((GLubyte*)functionName);
+}
+
+#endif
void InitGLExtensions()
{
- HINSTANCE hInst = LoadLibrary( L"Opengl32.dll" );
+ if (glGenVertexArrays)
+ return;
+
+#if defined(OVR_OS_WIN32)
+ HINSTANCE hInst = LoadLibrary(L"Opengl32.dll");
if (!hInst)
return;
- glClear = (PFNGLCLEARPROC)GetProcAddress( hInst, "glClear" );
- glClearColor = (PFNGLCLEARCOLORPROC)GetProcAddress( hInst, "glClearColor" );
- glClearDepth = (PFNGLCLEARDEPTHPROC)GetProcAddress( hInst, "glClearDepth" );
- glViewport = (PFNGLVIEWPORTPROC)GetProcAddress( hInst, "glViewport" );
- glDrawElements = (PFNGLDRAWELEMENTSPROC)GetProcAddress( hInst, "glDrawElements" );
- glTexParameteri = (PFNGLTEXPARAMETERIPROC)GetProcAddress( hInst, "glTexParameteri" );
- glFlush = (PFNGLFLUSHPROC)GetProcAddress( hInst, "glFlush" );
- glFinish = (PFNGLFINISHPROC)GetProcAddress( hInst, "glFinish" );
- glDrawArrays = (PFNGLDRAWARRAYSPROC)GetProcAddress( hInst, "glDrawArrays" );
- glGenTextures = (PFNGLGENTEXTURESPROC)GetProcAddress( hInst,"glGenTextures" );
- glDeleteTextures = (PFNGLDELETETEXTURESPROC)GetProcAddress( hInst,"glDeleteTextures" );
- glBindTexture = (PFNGLBINDTEXTUREPROC)GetProcAddress( hInst,"glBindTexture" );
-
- wglGetProcAddress = (PFNWGLGETPROCADDRESS)GetProcAddress( hInst, "wglGetProcAddress" );
-
- if (glGenFramebuffersEXT)
- return;
-
- wglGetSwapIntervalEXT = (PFNWGLGETSWAPINTERVALEXTPROC) wglGetProcAddress("wglGetSwapIntervalEXT");
- wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC) wglGetProcAddress("wglSwapIntervalEXT");
- glGenFramebuffersEXT = (PFNGLGENFRAMEBUFFERSEXTPROC) wglGetProcAddress("glGenFramebuffersEXT");
- glDeleteShader = (PFNGLDELETESHADERPROC) wglGetProcAddress("glDeleteShader");
- glCheckFramebufferStatusEXT = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) wglGetProcAddress("glCheckFramebufferStatusEXT");
- glFramebufferRenderbufferEXT = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) wglGetProcAddress("glFramebufferRenderbufferEXT");
- glFramebufferTexture2DEXT = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) wglGetProcAddress("glFramebufferTexture2DEXT");
- glBindFramebufferEXT = (PFNGLBINDFRAMEBUFFEREXTPROC) wglGetProcAddress("glBindFramebufferEXT");
- glActiveTexture = (PFNGLACTIVETEXTUREPROC) wglGetProcAddress("glActiveTexture");
- glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC) wglGetProcAddress("glDisableVertexAttribArray");
- glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC) wglGetProcAddress("glVertexAttribPointer");
- glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC) wglGetProcAddress("glEnableVertexAttribArray");
- glBindBuffer = (PFNGLBINDBUFFERPROC) wglGetProcAddress("glBindBuffer");
- glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC) wglGetProcAddress("glUniformMatrix3fv");
- glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC) wglGetProcAddress("glUniformMatrix4fv");
- glDeleteBuffers = (PFNGLDELETEBUFFERSPROC) wglGetProcAddress("glDeleteBuffers");
- glBufferData = (PFNGLBUFFERDATAPROC) wglGetProcAddress("glBufferData");
- glGenBuffers = (PFNGLGENBUFFERSPROC) wglGetProcAddress("glGenBuffers");
- glMapBuffer = (PFNGLMAPBUFFERPROC) wglGetProcAddress("glMapBuffer");
- glUnmapBuffer = (PFNGLUNMAPBUFFERPROC) wglGetProcAddress("glUnmapBuffer");
- glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC) wglGetProcAddress("glGetShaderInfoLog");
- glGetShaderiv = (PFNGLGETSHADERIVPROC) wglGetProcAddress("glGetShaderiv");
- glCompileShader = (PFNGLCOMPILESHADERPROC) wglGetProcAddress("glCompileShader");
- glShaderSource = (PFNGLSHADERSOURCEPROC) wglGetProcAddress("glShaderSource");
- glCreateShader = (PFNGLCREATESHADERPROC) wglGetProcAddress("glCreateShader");
- glCreateProgram = (PFNGLCREATEPROGRAMPROC) wglGetProcAddress("glCreateProgram");
- glAttachShader = (PFNGLATTACHSHADERPROC) wglGetProcAddress("glAttachShader");
- glDetachShader = (PFNGLDETACHSHADERPROC) wglGetProcAddress("glDetachShader");
- glDeleteProgram = (PFNGLDELETEPROGRAMPROC) wglGetProcAddress("glDeleteProgram");
- glUniform1i = (PFNGLUNIFORM1IPROC) wglGetProcAddress("glUniform1i");
- glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC) wglGetProcAddress("glGetUniformLocation");
- glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC) wglGetProcAddress("glGetActiveUniform");
- glUseProgram = (PFNGLUSEPROGRAMPROC) wglGetProcAddress("glUseProgram");
- glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC) wglGetProcAddress("glGetProgramInfoLog");
- glGetProgramiv = (PFNGLGETPROGRAMIVPROC) wglGetProcAddress("glGetProgramiv");
- glLinkProgram = (PFNGLLINKPROGRAMPROC) wglGetProcAddress("glLinkProgram");
- glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC) wglGetProcAddress("glBindAttribLocation");
- glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC) wglGetProcAddress("glGetAttribLocation");
- glUniform4fv = (PFNGLUNIFORM4FVPROC) wglGetProcAddress("glUniform4fv");
- glUniform3fv = (PFNGLUNIFORM3FVPROC) wglGetProcAddress("glUniform3fv");
- glUniform2fv = (PFNGLUNIFORM2FVPROC) wglGetProcAddress("glUniform2fv");
- glUniform1fv = (PFNGLUNIFORM1FVPROC) wglGetProcAddress("glUniform1fv");
- glCompressedTexImage2D = (PFNGLCOMPRESSEDTEXIMAGE2DPROC) wglGetProcAddress("glCompressedTexImage2D");
- glRenderbufferStorageEXT = (PFNGLRENDERBUFFERSTORAGEEXTPROC) wglGetProcAddress("glRenderbufferStorageEXT");
- glBindRenderbufferEXT = (PFNGLBINDRENDERBUFFEREXTPROC) wglGetProcAddress("glBindRenderbufferEXT");
- glGenRenderbuffersEXT = (PFNGLGENRENDERBUFFERSEXTPROC) wglGetProcAddress("glGenRenderbuffersEXT");
- glDeleteRenderbuffersEXT = (PFNGLDELETERENDERBUFFERSEXTPROC) wglGetProcAddress("glDeleteRenderbuffersEXT");
-
-
- glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC) wglGetProcAddress("glGenVertexArrays");
-}
-
+ glGetFloatv = (PFNGLGETFLOATVPROC) GetProcAddress(hInst, "glGetFloatv");
+ glGetIntegerv = (PFNGLGETINTEGERVPROC) GetProcAddress(hInst, "glGetIntegerv");
+ glGetString = (PFNGLGETSTRINGPROC) GetProcAddress(hInst, "glGetString");
+ glEnable = (PFNGLENABLEPROC) GetProcAddress(hInst, "glEnable");
+ glDisable = (PFNGLDISABLEPROC) GetProcAddress(hInst, "glDisable");
+ glColorMask = (PFNGLCOLORMASKPROC) GetProcAddress(hInst, "glColorMask");
+ glClear = (PFNGLCLEARPROC) GetProcAddress(hInst, "glClear" );
+ glClearColor = (PFNGLCLEARCOLORPROC) GetProcAddress(hInst, "glClearColor");
+ glClearDepth = (PFNGLCLEARDEPTHPROC) GetProcAddress(hInst, "glClearDepth");
+ glViewport = (PFNGLVIEWPORTPROC) GetProcAddress(hInst, "glViewport");
+ glFlush = (PFNGLFLUSHPROC) GetProcAddress(hInst, "glFlush");
+ glFinish = (PFNGLFINISHPROC) GetProcAddress(hInst, "glFinish");
+ glDrawArrays = (PFNGLDRAWARRAYSPROC) GetProcAddress(hInst, "glDrawArrays");
+ glDrawElements = (PFNGLDRAWELEMENTSPROC) GetProcAddress(hInst, "glDrawElements");
+ glGenTextures = (PFNGLGENTEXTURESPROC) GetProcAddress(hInst,"glGenTextures");
+ glDeleteTextures = (PFNGLDELETETEXTURESPROC) GetProcAddress(hInst,"glDeleteTextures");
+ glBindTexture = (PFNGLBINDTEXTUREPROC) GetProcAddress(hInst,"glBindTexture");
+ glTexParameteri = (PFNGLTEXPARAMETERIPROC) GetProcAddress(hInst, "glTexParameteri");
+
+ wglGetProcAddress = (PFNWGLGETPROCADDRESS) GetProcAddress(hInst, "wglGetProcAddress");
+
+ wglGetSwapIntervalEXT = (PFNWGLGETSWAPINTERVALEXTPROC) GetFunction("wglGetSwapIntervalEXT");
+ wglSwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC) GetFunction("wglSwapIntervalEXT");
+#elif defined(OVR_OS_LINUX)
+ glXSwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC) GetFunction("glXSwapIntervalEXT");
#endif
+ glBindFramebuffer = (PFNGLBINDFRAMEBUFFERPROC) GetFunction("glBindFramebufferEXT");
+ glGenVertexArrays = (PFNGLGENVERTEXARRAYSPROC) GetFunction("glGenVertexArrays");
+ glDeleteVertexArrays = (PFNGLDELETEVERTEXARRAYSPROC) GetFunction("glDeleteVertexArrays");
+ glBindVertexArray = (PFNGLBINDVERTEXARRAYPROC) GetFunction("glBindVertexArray");
+ glGenBuffers = (PFNGLGENBUFFERSPROC) GetFunction("glGenBuffers");
+ glDeleteBuffers = (PFNGLDELETEBUFFERSPROC) GetFunction("glDeleteBuffers");
+ glBindBuffer = (PFNGLBINDBUFFERPROC) GetFunction("glBindBuffer");
+ glBufferData = (PFNGLBUFFERDATAPROC) GetFunction("glBufferData");
+ glMapBuffer = (PFNGLMAPBUFFERPROC) GetFunction("glMapBuffer");
+ glUnmapBuffer = (PFNGLUNMAPBUFFERPROC) GetFunction("glUnmapBuffer");
+ glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC) GetFunction("glDisableVertexAttribArray");
+ glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC) GetFunction("glVertexAttribPointer");
+ glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC) GetFunction("glEnableVertexAttribArray");
+ glActiveTexture = (PFNGLACTIVETEXTUREPROC) GetFunction("glActiveTexture");
+ glUniformMatrix3fv = (PFNGLUNIFORMMATRIX3FVPROC) GetFunction("glUniformMatrix3fv");
+ glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC) GetFunction("glUniformMatrix4fv");
+ glUniform1i = (PFNGLUNIFORM1IPROC) GetFunction("glUniform1i");
+ glUniform1fv = (PFNGLUNIFORM1FVPROC) GetFunction("glUniform1fv");
+ glUniform2fv = (PFNGLUNIFORM2FVPROC) GetFunction("glUniform2fv");
+ glUniform3fv = (PFNGLUNIFORM3FVPROC) GetFunction("glUniform3fv");
+ glUniform2fv = (PFNGLUNIFORM2FVPROC) GetFunction("glUniform2fv");
+ glUniform4fv = (PFNGLUNIFORM4FVPROC) GetFunction("glUniform4fv");
+ glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC) GetFunction("glGetUniformLocation");
+ glGetActiveUniform = (PFNGLGETACTIVEUNIFORMPROC) GetFunction("glGetActiveUniform");
+ glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC) GetFunction("glGetShaderInfoLog");
+ glGetShaderiv = (PFNGLGETSHADERIVPROC) GetFunction("glGetShaderiv");
+ glCompileShader = (PFNGLCOMPILESHADERPROC) GetFunction("glCompileShader");
+ glShaderSource = (PFNGLSHADERSOURCEPROC) GetFunction("glShaderSource");
+ glCreateShader = (PFNGLCREATESHADERPROC) GetFunction("glCreateShader");
+ glDeleteShader = (PFNGLDELETESHADERPROC) GetFunction("glDeleteShader");
+ glCreateProgram = (PFNGLCREATEPROGRAMPROC) GetFunction("glCreateProgram");
+ glDeleteProgram = (PFNGLDELETEPROGRAMPROC) GetFunction("glDeleteProgram");
+ glUseProgram = (PFNGLUSEPROGRAMPROC) GetFunction("glUseProgram");
+ glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC) GetFunction("glGetProgramInfoLog");
+ glGetProgramiv = (PFNGLGETPROGRAMIVPROC) GetFunction("glGetProgramiv");
+ glLinkProgram = (PFNGLLINKPROGRAMPROC) GetFunction("glLinkProgram");
+ glAttachShader = (PFNGLATTACHSHADERPROC) GetFunction("glAttachShader");
+ glDetachShader = (PFNGLDETACHSHADERPROC) GetFunction("glDetachShader");
+ glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC) GetFunction("glBindAttribLocation");
+ glGetAttribLocation = (PFNGLGETATTRIBLOCATIONPROC) GetFunction("glGetAttribLocation");
+}
+
+#endif
+
Buffer::Buffer(RenderParams* rp) : pParams(rp), Size(0), Use(0), GLBuffer(0)
{
}
@@ -203,7 +231,6 @@ bool Buffer::Data(int use, const void* buffer, size_t size)
glBindBuffer(Use, GLBuffer);
glBufferData(Use, size, buffer, mode);
- glBindBuffer(Use, 0);
return 1;
}
@@ -215,7 +242,6 @@ void* Buffer::Map(size_t, size_t, int)
glBindBuffer(Use, GLBuffer);
void* v = glMapBuffer(Use, mode);
- glBindBuffer(Use, 0);
return v;
}
@@ -223,7 +249,6 @@ bool Buffer::Unmap(void*)
{
glBindBuffer(Use, GLBuffer);
int r = glUnmapBuffer(Use);
- glBindBuffer(Use, 0);
return r != 0;
}
@@ -248,6 +273,7 @@ GLint ShaderSet::GetGLShader(Shader* s)
ShaderImpl<Shader_Fragment, GL_FRAGMENT_SHADER>* gls = (ShaderImpl<Shader_Fragment, GL_FRAGMENT_SHADER>*)s;
return gls->GLShader;
} break;
+ default: break;
}
return -1;
@@ -271,8 +297,6 @@ void ShaderSet::UnsetShader(int stage)
glDetachShader(Prog, GLShader);
Shaders[stage] = NULL;
-
- //Link();
}
bool ShaderSet::SetUniform(const char* name, int n, const float* v)
@@ -430,14 +454,6 @@ void ShaderBase::InitUniforms(const Uniform* refl, size_t reflSize)
UniformData = (unsigned char*)OVR_ALLOC(UniformsSize);
}
-void ShaderBase::UpdateBuffer(Buffer* buf)
-{
- if (UniformsSize)
- {
- buf->Data(Buffer_Uniform, UniformData, UniformsSize);
- }
-}
-
Texture::Texture(RenderParams* rp, int w, int h) : IsUserAllocated(true), pParams(rp), TexId(0), Width(w), Height(h)
{
if (w && h)
@@ -454,7 +470,6 @@ void Texture::Set(int slot, ShaderStage) const
{
glActiveTexture(GL_TEXTURE0 + slot);
glBindTexture(GL_TEXTURE_2D, TexId);
- glActiveTexture(GL_TEXTURE0);
}
void Texture::SetSampleMode(int sm)
@@ -498,7 +513,6 @@ void Texture::SetSampleMode(int sm)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
break;
}
- glBindTexture(GL_TEXTURE_2D, 0);
}
void Texture::UpdatePlaceholderTexture(GLuint texId, const Sizei& textureSize)
diff --git a/LibOVR/Src/CAPI/GL/CAPI_GL_Util.h b/LibOVR/Src/CAPI/GL/CAPI_GL_Util.h
index 5e694cc..a410f17 100644
--- a/LibOVR/Src/CAPI/GL/CAPI_GL_Util.h
+++ b/LibOVR/Src/CAPI/GL/CAPI_GL_Util.h
@@ -30,14 +30,15 @@ limitations under the License.
#include "../../Kernel/OVR_RefCount.h"
#include "../../Kernel/OVR_String.h"
#include "../../Kernel/OVR_Types.h"
+#include "../../Kernel/OVR_Log.h"
#if defined(OVR_OS_WIN32)
#include <Windows.h>
#endif
#if defined(OVR_OS_MAC)
-#include <OpenGL/gl.h>
-#include <OpenGL/glext.h>
+#include <OpenGL/gl3.h>
+#include <OpenGL/gl3ext.h>
#else
#ifndef GL_GLEXT_PROTOTYPES
#define GL_GLEXT_PROTOTYPES
@@ -46,19 +47,30 @@ limitations under the License.
#include <GL/glext.h>
#if defined(OVR_OS_WIN32)
#include <GL/wglext.h>
+#elif defined(OVR_OS_LINUX)
+#include <GL/glx.h>
#endif
#endif
namespace OVR { namespace CAPI { namespace GL {
-// GL extension Hooks for PC.
+// GL extension Hooks for Non-Mac.
+#if !defined(OVR_OS_MAC)
+
+// Let Windows apps build without linking GL.
#if defined(OVR_OS_WIN32)
+typedef void (__stdcall *PFNGLENABLEPROC) (GLenum);
+typedef void (__stdcall *PFNGLDISABLEPROC) (GLenum);
+typedef void (__stdcall *PFNGLGETFLOATVPROC) (GLenum, GLfloat*);
+typedef const GLubyte * (__stdcall *PFNGLGETSTRINGPROC) (GLenum);
+typedef void (__stdcall *PFNGLGETINTEGERVPROC) (GLenum, GLint*);
typedef PROC (__stdcall *PFNWGLGETPROCADDRESS) (LPCSTR);
typedef void (__stdcall *PFNGLFLUSHPROC) ();
typedef void (__stdcall *PFNGLFINISHPROC) ();
typedef void (__stdcall *PFNGLDRAWARRAYSPROC) (GLenum mode, GLint first, GLsizei count);
typedef void (__stdcall *PFNGLCLEARPROC) (GLbitfield);
+typedef void (__stdcall *PFNGLCOLORMASKPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
typedef void (__stdcall *PFNGLDRAWELEMENTSPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
typedef void (__stdcall *PFNGLGENTEXTURESPROC) (GLsizei n, GLuint *textures);
typedef void (__stdcall *PFNGLDELETETEXTURESPROC) (GLsizei n, GLuint *textures);
@@ -69,6 +81,15 @@ typedef void (__stdcall *PFNGLTEXPARAMETERIPROC) (GLenum target, GLenum pname, G
typedef void (__stdcall *PFNGLVIEWPORTPROC) (GLint x, GLint y, GLsizei width, GLsizei height);
extern PFNWGLGETPROCADDRESS wglGetProcAddress;
+extern PFNWGLGETSWAPINTERVALEXTPROC wglGetSwapIntervalEXT;
+extern PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT;
+
+extern PFNGLENABLEPROC glEnable;
+extern PFNGLDISABLEPROC glDisable;
+extern PFNGLCOLORMASKPROC glColorMask;
+extern PFNGLGETFLOATVPROC glGetFloatv;
+extern PFNGLGETSTRINGPROC glGetString;
+extern PFNGLGETINTEGERVPROC glGetIntegerv;
extern PFNGLCLEARPROC glClear;
extern PFNGLCLEARCOLORPROC glClearColor;
extern PFNGLCLEARDEPTHPROC glClearDepth;
@@ -82,14 +103,14 @@ extern PFNGLTEXPARAMETERIPROC glTexParameteri;
extern PFNGLFLUSHPROC glFlush;
extern PFNGLFINISHPROC glFinish;
-extern PFNWGLGETSWAPINTERVALEXTPROC wglGetSwapIntervalEXT;
-extern PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT;
-extern PFNGLGENFRAMEBUFFERSEXTPROC glGenFramebuffersEXT;
+#elif defined(OVR_OS_LINUX)
+
+extern PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT;
+
+#endif // defined(OVR_OS_WIN32)
+
extern PFNGLDELETESHADERPROC glDeleteShader;
-extern PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC glCheckFramebufferStatusEXT;
-extern PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC glFramebufferRenderbufferEXT;
-extern PFNGLFRAMEBUFFERTEXTURE2DEXTPROC glFramebufferTexture2DEXT;
-extern PFNGLBINDFRAMEBUFFEREXTPROC glBindFramebufferEXT;
+extern PFNGLBINDFRAMEBUFFERPROC glBindFramebuffer;
extern PFNGLACTIVETEXTUREPROC glActiveTexture;
extern PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray;
extern PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer;
@@ -123,18 +144,13 @@ extern PFNGLUNIFORM4FVPROC glUniform4fv;
extern PFNGLUNIFORM3FVPROC glUniform3fv;
extern PFNGLUNIFORM2FVPROC glUniform2fv;
extern PFNGLUNIFORM1FVPROC glUniform1fv;
-extern PFNGLCOMPRESSEDTEXIMAGE2DPROC glCompressedTexImage2D;
-extern PFNGLRENDERBUFFERSTORAGEEXTPROC glRenderbufferStorageEXT;
-extern PFNGLBINDRENDERBUFFEREXTPROC glBindRenderbufferEXT;
-extern PFNGLGENRENDERBUFFERSEXTPROC glGenRenderbuffersEXT;
-extern PFNGLDELETERENDERBUFFERSEXTPROC glDeleteRenderbuffersEXT;
-
-// For testing
extern PFNGLGENVERTEXARRAYSPROC glGenVertexArrays;
+extern PFNGLDELETEVERTEXARRAYSPROC glDeleteVertexArrays;
+extern PFNGLBINDVERTEXARRAYPROC glBindVertexArray;
extern void InitGLExtensions();
-#endif
+#endif // !defined(OVR_OS_MAC)
// Rendering primitive type used to render Model.
@@ -205,10 +221,11 @@ enum SampleMode
// Rendering parameters/pointers describing GL rendering setup.
struct RenderParams
{
-#ifdef OVR_OS_WIN32
+#if defined(OVR_OS_WIN32)
HWND Window;
- HGLRC WglContext;
- HDC GdiDc;
+#elif defined(OVR_OS_LINUX)
+ Display* Disp;
+ Window Win;
#endif
ovrSizei RTSize;
@@ -301,7 +318,7 @@ protected:
Array<Uniform> UniformInfo;
public:
- GLuint Prog;
+ GLuint Prog;
GLint ProjLoc, ViewLoc;
GLint TexLoc[8];
bool UsesLighting;
@@ -455,8 +472,6 @@ public:
void InitUniforms(const Uniform* refl, size_t reflSize);
bool SetUniform(const char* name, int n, const float* v);
bool SetUniformBool(const char* name, int n, const bool* v);
-
- void UpdateBuffer(Buffer* b);
};
@@ -470,7 +485,7 @@ public:
: ShaderBase(rp, SStage)
, GLShader(0)
{
- BOOL success;
+ bool success;
OVR_UNUSED(size);
success = Compile((const char*) s);
OVR_ASSERT(success);
diff --git a/LibOVR/Src/CAPI/Shaders/DistortionChroma_ps.h b/LibOVR/Src/CAPI/Shaders/DistortionChroma_ps.h
new file mode 100644
index 0000000..20d0f67
--- /dev/null
+++ b/LibOVR/Src/CAPI/Shaders/DistortionChroma_ps.h
@@ -0,0 +1,84 @@
+#ifndef DISTORTIONCHROMA_PS_H
+#define DISTORTIONCHROMA_PS_H
+
+static const unsigned char DistortionChroma_ps[] = {
+ 0x44, 0x58, 0x42, 0x43, 0xf8, 0x80, 0xa6, 0xb4, 0xd3, 0xf2, 0xe4, 0x8b,
+ 0xd1, 0x64, 0x65, 0x3a, 0x55, 0xe3, 0xdf, 0xc9, 0x01, 0x00, 0x00, 0x00,
+ 0x90, 0x03, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00,
+ 0xdc, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0xb4, 0x01, 0x00, 0x00,
+ 0x14, 0x03, 0x00, 0x00, 0x52, 0x44, 0x45, 0x46, 0xa0, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x1c, 0x00, 0x00, 0x00, 0x00, 0x04, 0xff, 0xff, 0x00, 0x01, 0x00, 0x00,
+ 0x6b, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x63, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
+ 0x04, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x4c, 0x69, 0x6e, 0x65,
+ 0x61, 0x72, 0x00, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x00, 0x4d,
+ 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29,
+ 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72,
+ 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x36, 0x2e,
+ 0x33, 0x2e, 0x39, 0x36, 0x30, 0x30, 0x2e, 0x31, 0x36, 0x33, 0x38, 0x34,
+ 0x00, 0xab, 0xab, 0xab, 0x49, 0x53, 0x47, 0x4e, 0x9c, 0x00, 0x00, 0x00,
+ 0x05, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x0f, 0x07, 0x00, 0x00, 0x92, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x07, 0x03, 0x00, 0x00, 0x92, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0x07, 0x03, 0x00, 0x00, 0x92, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x04, 0x00, 0x00, 0x00, 0x07, 0x03, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x50,
+ 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x43, 0x4f, 0x4c, 0x4f,
+ 0x52, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x00, 0xab,
+ 0x4f, 0x53, 0x47, 0x4e, 0x2c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x08, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x0f, 0x00, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x54, 0x61, 0x72, 0x67, 0x65,
+ 0x74, 0x00, 0xab, 0xab, 0x53, 0x48, 0x44, 0x52, 0x58, 0x01, 0x00, 0x00,
+ 0x40, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x03,
+ 0x00, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x18, 0x00, 0x04,
+ 0x00, 0x70, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00,
+ 0x62, 0x10, 0x00, 0x03, 0x72, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x62, 0x10, 0x00, 0x03, 0x32, 0x10, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x62, 0x10, 0x00, 0x03, 0x32, 0x10, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x62, 0x10, 0x00, 0x03, 0x32, 0x10, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x65, 0x00, 0x00, 0x03, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x68, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x0b,
+ 0xf2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x10, 0x10, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x12, 0x20, 0x10, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x0a, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x0b,
+ 0xf2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x10, 0x10, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x22, 0x20, 0x10, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x1a, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x0b,
+ 0xf2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x10, 0x10, 0x00,
+ 0x04, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x42, 0x20, 0x10, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x2a, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05,
+ 0x82, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00,
+ 0x00, 0x00, 0x80, 0x3f, 0x3e, 0x00, 0x00, 0x01, 0x53, 0x54, 0x41, 0x54,
+ 0x74, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+
+};
+
+#endif
diff --git a/LibOVR/Src/CAPI/Shaders/DistortionChroma_ps.psh b/LibOVR/Src/CAPI/Shaders/DistortionChroma_ps.psh
index 5c95ade..1102524 100644
--- a/LibOVR/Src/CAPI/Shaders/DistortionChroma_ps.psh
+++ b/LibOVR/Src/CAPI/Shaders/DistortionChroma_ps.psh
@@ -4,9 +4,9 @@ SamplerState Linear : register(s0);
float4 main(in float4 oPosition : SV_Position, in float4 oColor : COLOR,
in float3 oTexCoord0 : TEXCOORD0, in float3 oTexCoord1 : TEXCOORD1, in float3 oTexCoord2 : TEXCOORD2) : SV_Target
{
- float ResultR = Texture.Sample(Linear, oTexCoord0.xy).r;
- float ResultG = Texture.Sample(Linear, oTexCoord1.xy).g;
- float ResultB = Texture.Sample(Linear, oTexCoord2.xy).b;
+ float ResultR = Texture.SampleLevel(Linear, oTexCoord0.xy, 0.0).r;
+ float ResultG = Texture.SampleLevel(Linear, oTexCoord1.xy, 0.0).g;
+ float ResultB = Texture.SampleLevel(Linear, oTexCoord2.xy, 0.0).b;
return float4(ResultR * oColor.r, ResultG * oColor.g, ResultB * oColor.b, 1.0);
//" return oColor.rrrr;
}
diff --git a/LibOVR/Src/CAPI/Shaders/DistortionChroma_ps_refl.h b/LibOVR/Src/CAPI/Shaders/DistortionChroma_ps_refl.h
new file mode 100644
index 0000000..a306aa5
--- /dev/null
+++ b/LibOVR/Src/CAPI/Shaders/DistortionChroma_ps_refl.h
@@ -0,0 +1 @@
+// No data available for shader reflection DistortionChroma_ps_refl \ No newline at end of file
diff --git a/LibOVR/Src/CAPI/Shaders/DistortionChroma_vs.h b/LibOVR/Src/CAPI/Shaders/DistortionChroma_vs.h
new file mode 100644
index 0000000..5f2aedb
--- /dev/null
+++ b/LibOVR/Src/CAPI/Shaders/DistortionChroma_vs.h
@@ -0,0 +1,106 @@
+#ifndef DISTORTIONCHROMA_VS_H
+#define DISTORTIONCHROMA_VS_H
+
+static const unsigned char DistortionChroma_vs[] = {
+ 0x44, 0x58, 0x42, 0x43, 0xaf, 0x53, 0xeb, 0x12, 0x64, 0x0d, 0xd1, 0xaa,
+ 0x9c, 0x9d, 0x13, 0x42, 0x57, 0x7b, 0x4c, 0xb4, 0x01, 0x00, 0x00, 0x00,
+ 0xa0, 0x04, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00,
+ 0x38, 0x01, 0x00, 0x00, 0xd8, 0x01, 0x00, 0x00, 0x7c, 0x02, 0x00, 0x00,
+ 0x24, 0x04, 0x00, 0x00, 0x52, 0x44, 0x45, 0x46, 0xfc, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x1c, 0x00, 0x00, 0x00, 0x00, 0x04, 0xfe, 0xff, 0x00, 0x01, 0x00, 0x00,
+ 0xc8, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x24, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x73, 0x00, 0xab, 0xab, 0xab,
+ 0x3c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00,
+ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0xa4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xb4, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0xa4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x45, 0x79, 0x65, 0x54, 0x6f, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x55,
+ 0x56, 0x53, 0x63, 0x61, 0x6c, 0x65, 0x00, 0xab, 0x01, 0x00, 0x03, 0x00,
+ 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x45, 0x79, 0x65, 0x54, 0x6f, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x55,
+ 0x56, 0x4f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x00, 0x4d, 0x69, 0x63, 0x72,
+ 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c,
+ 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f,
+ 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x36, 0x2e, 0x33, 0x2e, 0x39,
+ 0x36, 0x30, 0x30, 0x2e, 0x31, 0x36, 0x33, 0x38, 0x34, 0x00, 0xab, 0xab,
+ 0x49, 0x53, 0x47, 0x4e, 0x98, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
+ 0x08, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x03, 0x03, 0x00, 0x00, 0x89, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x0f, 0x0f, 0x00, 0x00, 0x8f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x03, 0x03, 0x00, 0x00, 0x8f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x03, 0x03, 0x00, 0x00, 0x8f, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x03, 0x03, 0x00, 0x00, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e,
+ 0x00, 0x43, 0x4f, 0x4c, 0x4f, 0x52, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4f,
+ 0x4f, 0x52, 0x44, 0x00, 0x4f, 0x53, 0x47, 0x4e, 0x9c, 0x00, 0x00, 0x00,
+ 0x05, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x92, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x07, 0x08, 0x00, 0x00, 0x92, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0x07, 0x08, 0x00, 0x00, 0x92, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x04, 0x00, 0x00, 0x00, 0x07, 0x08, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x50,
+ 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x43, 0x4f, 0x4c, 0x4f,
+ 0x52, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x00, 0xab,
+ 0x53, 0x48, 0x44, 0x52, 0xa0, 0x01, 0x00, 0x00, 0x40, 0x00, 0x01, 0x00,
+ 0x68, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x04, 0x46, 0x8e, 0x20, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x03,
+ 0x32, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x03,
+ 0xf2, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x03,
+ 0x32, 0x10, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x03,
+ 0x32, 0x10, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x03,
+ 0x32, 0x10, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x04,
+ 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x65, 0x00, 0x00, 0x03, 0xf2, 0x20, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x65, 0x00, 0x00, 0x03, 0x72, 0x20, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x65, 0x00, 0x00, 0x03, 0x72, 0x20, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x65, 0x00, 0x00, 0x03, 0x72, 0x20, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x36, 0x00, 0x00, 0x05, 0x32, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x46, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x08,
+ 0xc2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f,
+ 0x00, 0x00, 0x80, 0x3f, 0x36, 0x00, 0x00, 0x05, 0xf2, 0x20, 0x10, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x46, 0x1e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x32, 0x00, 0x00, 0x0b, 0x32, 0x20, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x46, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x46, 0x10, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xe6, 0x8a, 0x20, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05,
+ 0x42, 0x20, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00,
+ 0x00, 0x00, 0x80, 0x3f, 0x32, 0x00, 0x00, 0x0b, 0x32, 0x20, 0x10, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0x46, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x46, 0x10, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0xe6, 0x8a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x36, 0x00, 0x00, 0x05, 0x42, 0x20, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x32, 0x00, 0x00, 0x0b,
+ 0x32, 0x20, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x46, 0x80, 0x20, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x10, 0x10, 0x00,
+ 0x04, 0x00, 0x00, 0x00, 0xe6, 0x8a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x42, 0x20, 0x10, 0x00,
+ 0x04, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f,
+ 0x3e, 0x00, 0x00, 0x01, 0x53, 0x54, 0x41, 0x54, 0x74, 0x00, 0x00, 0x00,
+ 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x0a, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+#endif
diff --git a/LibOVR/Src/CAPI/Shaders/DistortionChroma_vs_refl.h b/LibOVR/Src/CAPI/Shaders/DistortionChroma_vs_refl.h
new file mode 100644
index 0000000..cb9767d
--- /dev/null
+++ b/LibOVR/Src/CAPI/Shaders/DistortionChroma_vs_refl.h
@@ -0,0 +1,9 @@
+#ifndef DistortionChroma_vs_refl
+
+const OVR::CAPI::D3D_NS::ShaderBase::Uniform DistortionChroma_vs_refl[] =
+{
+ { "EyeToSourceUVScale", OVR::CAPI::D3D_NS::ShaderBase::VARTYPE_FLOAT, 0, 8 },
+ { "EyeToSourceUVOffset", OVR::CAPI::D3D_NS::ShaderBase::VARTYPE_FLOAT, 8, 8 },
+};
+
+#endif
diff --git a/LibOVR/Src/CAPI/Shaders/DistortionTimewarpChroma_vs.h b/LibOVR/Src/CAPI/Shaders/DistortionTimewarpChroma_vs.h
new file mode 100644
index 0000000..6660f0c
--- /dev/null
+++ b/LibOVR/Src/CAPI/Shaders/DistortionTimewarpChroma_vs.h
@@ -0,0 +1,219 @@
+#ifndef DISTORTIONTIMEWARPCHROMA_VS_H
+#define DISTORTIONTIMEWARPCHROMA_VS_H
+
+static const unsigned char DistortionTimewarpChroma_vs[] = {
+ 0x44, 0x58, 0x42, 0x43, 0x03, 0x43, 0xb6, 0xcd, 0xb7, 0xe5, 0xeb, 0x34,
+ 0x11, 0x77, 0xf9, 0xfc, 0x49, 0xa0, 0x5a, 0x69, 0x01, 0x00, 0x00, 0x00,
+ 0xec, 0x09, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00,
+ 0x9c, 0x01, 0x00, 0x00, 0x3c, 0x02, 0x00, 0x00, 0xe0, 0x02, 0x00, 0x00,
+ 0x70, 0x09, 0x00, 0x00, 0x52, 0x44, 0x45, 0x46, 0x60, 0x01, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x1c, 0x00, 0x00, 0x00, 0x00, 0x04, 0xfe, 0xff, 0x00, 0x01, 0x00, 0x00,
+ 0x2b, 0x01, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x24, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x73, 0x00, 0xab, 0xab, 0xab,
+ 0x3c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00,
+ 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0xd4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xe4, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0xd4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xf8, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x0c, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x1c, 0x01, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x0c, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x45, 0x79, 0x65, 0x54, 0x6f, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x55,
+ 0x56, 0x53, 0x63, 0x61, 0x6c, 0x65, 0x00, 0xab, 0x01, 0x00, 0x03, 0x00,
+ 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x45, 0x79, 0x65, 0x54, 0x6f, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x55,
+ 0x56, 0x4f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x00, 0x45, 0x79, 0x65, 0x52,
+ 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x72, 0x74,
+ 0x00, 0xab, 0xab, 0xab, 0x03, 0x00, 0x03, 0x00, 0x04, 0x00, 0x04, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x45, 0x79, 0x65, 0x52,
+ 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x6e, 0x64, 0x00, 0x4d,
+ 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29,
+ 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72,
+ 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x36, 0x2e,
+ 0x33, 0x2e, 0x39, 0x36, 0x30, 0x30, 0x2e, 0x31, 0x36, 0x33, 0x38, 0x34,
+ 0x00, 0xab, 0xab, 0xab, 0x49, 0x53, 0x47, 0x4e, 0x98, 0x00, 0x00, 0x00,
+ 0x05, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x89, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x0f, 0x09, 0x00, 0x00, 0x8f, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x8f, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x8f, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x04, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x50, 0x4f, 0x53, 0x49,
+ 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x43, 0x4f, 0x4c, 0x4f, 0x52, 0x00, 0x54,
+ 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x00, 0x4f, 0x53, 0x47, 0x4e,
+ 0x9c, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
+ 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
+ 0x8c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
+ 0x92, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x07, 0x08, 0x00, 0x00,
+ 0x92, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x08, 0x00, 0x00,
+ 0x92, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x07, 0x08, 0x00, 0x00,
+ 0x53, 0x56, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x00,
+ 0x43, 0x4f, 0x4c, 0x4f, 0x52, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f,
+ 0x52, 0x44, 0x00, 0xab, 0x53, 0x48, 0x44, 0x52, 0x88, 0x06, 0x00, 0x00,
+ 0x40, 0x00, 0x01, 0x00, 0xa2, 0x01, 0x00, 0x00, 0x59, 0x00, 0x00, 0x04,
+ 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
+ 0x5f, 0x00, 0x00, 0x03, 0x32, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x5f, 0x00, 0x00, 0x03, 0x92, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x5f, 0x00, 0x00, 0x03, 0x32, 0x10, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x5f, 0x00, 0x00, 0x03, 0x32, 0x10, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x5f, 0x00, 0x00, 0x03, 0x32, 0x10, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x67, 0x00, 0x00, 0x04, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0xf2, 0x20, 0x10, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0x72, 0x20, 0x10, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0x72, 0x20, 0x10, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0x72, 0x20, 0x10, 0x00,
+ 0x04, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x02, 0x05, 0x00, 0x00, 0x00,
+ 0x36, 0x00, 0x00, 0x05, 0x32, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x46, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x08,
+ 0xc2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f,
+ 0x00, 0x00, 0x80, 0x3f, 0x36, 0x00, 0x00, 0x05, 0xf2, 0x20, 0x10, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x06, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x36, 0x00, 0x00, 0x05, 0x42, 0x20, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x36, 0x00, 0x00, 0x06,
+ 0x12, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x80, 0x20, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09,
+ 0x12, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x80,
+ 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x80, 0x20, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x06,
+ 0x22, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x80, 0x20, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09,
+ 0x22, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x80,
+ 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x80, 0x20, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x06,
+ 0x42, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x80, 0x20, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09,
+ 0x42, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x80,
+ 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x80, 0x20, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x06,
+ 0x82, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x80, 0x20, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09,
+ 0x82, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x80,
+ 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x80, 0x20, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x09,
+ 0xf2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, 0x1f, 0x10, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x46, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05,
+ 0x32, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x10, 0x10, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x08, 0xc2, 0x00, 0x10, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0x3f,
+ 0x11, 0x00, 0x00, 0x07, 0x42, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x46, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x32, 0x00, 0x10, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x46, 0x80, 0x20, 0x80, 0x41, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x80, 0x20, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a,
+ 0x12, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3a, 0x10, 0x10, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x1a, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x32, 0x00, 0x00, 0x0a, 0x12, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x3a, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x0a, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x32, 0x00, 0x10, 0x00,
+ 0x04, 0x00, 0x00, 0x00, 0x16, 0x85, 0x20, 0x80, 0x41, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x16, 0x85, 0x20, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a,
+ 0x22, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3a, 0x10, 0x10, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x1a, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x32, 0x00, 0x00, 0x0a, 0x22, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x3a, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x00,
+ 0x04, 0x00, 0x00, 0x00, 0x0a, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x52, 0x00, 0x10, 0x00,
+ 0x04, 0x00, 0x00, 0x00, 0x56, 0x84, 0x20, 0x80, 0x41, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x56, 0x84, 0x20, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a,
+ 0x42, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3a, 0x10, 0x10, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x1a, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x32, 0x00, 0x00, 0x0a, 0x42, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x3a, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00,
+ 0x04, 0x00, 0x00, 0x00, 0x0a, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x92, 0x00, 0x10, 0x00,
+ 0x04, 0x00, 0x00, 0x00, 0x56, 0x81, 0x20, 0x80, 0x41, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x56, 0x81, 0x20, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a,
+ 0x82, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3a, 0x10, 0x10, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x1a, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x32, 0x00, 0x00, 0x0a, 0x82, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x3a, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00,
+ 0x04, 0x00, 0x00, 0x00, 0x0a, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x04, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x07, 0x12, 0x00, 0x10, 0x00,
+ 0x04, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x46, 0x0f, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x07,
+ 0x22, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0x46, 0x0f, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x0e, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x46, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0xa6, 0x0a, 0x10, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0b, 0x32, 0x20, 0x10, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x46, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xe6, 0x8a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x36, 0x00, 0x00, 0x05, 0x32, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x46, 0x10, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x08,
+ 0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f,
+ 0x00, 0x00, 0x80, 0x3f, 0x11, 0x00, 0x00, 0x07, 0x12, 0x00, 0x10, 0x00,
+ 0x04, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x46, 0x0f, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x07,
+ 0x22, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0x46, 0x0f, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x11, 0x00, 0x00, 0x07, 0x12, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x46, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x06, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0b,
+ 0x32, 0x20, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x46, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xe6, 0x8a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x42, 0x20, 0x10, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f,
+ 0x36, 0x00, 0x00, 0x05, 0x32, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x46, 0x10, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x08,
+ 0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f,
+ 0x00, 0x00, 0x80, 0x3f, 0x11, 0x00, 0x00, 0x07, 0x12, 0x00, 0x10, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x46, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x07,
+ 0x22, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x11, 0x00, 0x00, 0x07, 0x12, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x46, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x06, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0b,
+ 0x32, 0x20, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x46, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xe6, 0x8a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x42, 0x20, 0x10, 0x00,
+ 0x04, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f,
+ 0x3e, 0x00, 0x00, 0x01, 0x53, 0x54, 0x41, 0x54, 0x74, 0x00, 0x00, 0x00,
+ 0x31, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x0a, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+#endif
diff --git a/LibOVR/Src/CAPI/Shaders/DistortionTimewarpChroma_vs_refl.h b/LibOVR/Src/CAPI/Shaders/DistortionTimewarpChroma_vs_refl.h
new file mode 100644
index 0000000..ef6847a
--- /dev/null
+++ b/LibOVR/Src/CAPI/Shaders/DistortionTimewarpChroma_vs_refl.h
@@ -0,0 +1,11 @@
+#ifndef DistortionTimewarpChroma_vs_refl
+
+const OVR::CAPI::D3D_NS::ShaderBase::Uniform DistortionTimewarpChroma_vs_refl[] =
+{
+ { "EyeToSourceUVScale", OVR::CAPI::D3D_NS::ShaderBase::VARTYPE_FLOAT, 0, 8 },
+ { "EyeToSourceUVOffset", OVR::CAPI::D3D_NS::ShaderBase::VARTYPE_FLOAT, 8, 8 },
+ { "EyeRotationStart", OVR::CAPI::D3D_NS::ShaderBase::VARTYPE_FLOAT, 16, 64 },
+ { "EyeRotationEnd", OVR::CAPI::D3D_NS::ShaderBase::VARTYPE_FLOAT, 80, 64 },
+};
+
+#endif
diff --git a/LibOVR/Src/CAPI/Shaders/DistortionTimewarp_vs.h b/LibOVR/Src/CAPI/Shaders/DistortionTimewarp_vs.h
new file mode 100644
index 0000000..13b5a11
--- /dev/null
+++ b/LibOVR/Src/CAPI/Shaders/DistortionTimewarp_vs.h
@@ -0,0 +1,169 @@
+#ifndef DISTORTIONTIMEWARP_VS_H
+#define DISTORTIONTIMEWARP_VS_H
+
+static const unsigned char DistortionTimewarp_vs[] = {
+ 0x44, 0x58, 0x42, 0x43, 0xef, 0x5d, 0x05, 0x24, 0x51, 0x13, 0x68, 0xcf,
+ 0x6d, 0x7a, 0xa5, 0x09, 0x84, 0xf9, 0x6c, 0xfc, 0x01, 0x00, 0x00, 0x00,
+ 0x94, 0x07, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00,
+ 0x9c, 0x01, 0x00, 0x00, 0x0c, 0x02, 0x00, 0x00, 0x80, 0x02, 0x00, 0x00,
+ 0x18, 0x07, 0x00, 0x00, 0x52, 0x44, 0x45, 0x46, 0x60, 0x01, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x1c, 0x00, 0x00, 0x00, 0x00, 0x04, 0xfe, 0xff, 0x00, 0x01, 0x00, 0x00,
+ 0x2b, 0x01, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x24, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x73, 0x00, 0xab, 0xab, 0xab,
+ 0x3c, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00,
+ 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0xd4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xe4, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0xd4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xf8, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x0c, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x1c, 0x01, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x0c, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x45, 0x79, 0x65, 0x54, 0x6f, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x55,
+ 0x56, 0x53, 0x63, 0x61, 0x6c, 0x65, 0x00, 0xab, 0x01, 0x00, 0x03, 0x00,
+ 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x45, 0x79, 0x65, 0x54, 0x6f, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x55,
+ 0x56, 0x4f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x00, 0x45, 0x79, 0x65, 0x52,
+ 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x72, 0x74,
+ 0x00, 0xab, 0xab, 0xab, 0x03, 0x00, 0x03, 0x00, 0x04, 0x00, 0x04, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x45, 0x79, 0x65, 0x52,
+ 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x45, 0x6e, 0x64, 0x00, 0x4d,
+ 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29,
+ 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72,
+ 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x36, 0x2e,
+ 0x33, 0x2e, 0x39, 0x36, 0x30, 0x30, 0x2e, 0x31, 0x36, 0x33, 0x38, 0x34,
+ 0x00, 0xab, 0xab, 0xab, 0x49, 0x53, 0x47, 0x4e, 0x68, 0x00, 0x00, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x59, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x0f, 0x09, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x50, 0x4f, 0x53, 0x49,
+ 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x43, 0x4f, 0x4c, 0x4f, 0x52, 0x00, 0x54,
+ 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x00, 0x4f, 0x53, 0x47, 0x4e,
+ 0x6c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
+ 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
+ 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
+ 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x07, 0x08, 0x00, 0x00,
+ 0x53, 0x56, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x00,
+ 0x43, 0x4f, 0x4c, 0x4f, 0x52, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f,
+ 0x52, 0x44, 0x00, 0xab, 0x53, 0x48, 0x44, 0x52, 0x90, 0x04, 0x00, 0x00,
+ 0x40, 0x00, 0x01, 0x00, 0x24, 0x01, 0x00, 0x00, 0x59, 0x00, 0x00, 0x04,
+ 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00,
+ 0x5f, 0x00, 0x00, 0x03, 0x32, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x5f, 0x00, 0x00, 0x03, 0x92, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x5f, 0x00, 0x00, 0x03, 0x32, 0x10, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x67, 0x00, 0x00, 0x04, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0xf2, 0x20, 0x10, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0x72, 0x20, 0x10, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x02, 0x05, 0x00, 0x00, 0x00,
+ 0x36, 0x00, 0x00, 0x05, 0x32, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x46, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x08,
+ 0xc2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f,
+ 0x00, 0x00, 0x80, 0x3f, 0x36, 0x00, 0x00, 0x05, 0xf2, 0x20, 0x10, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x06, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x36, 0x00, 0x00, 0x06, 0x12, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x2a, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x09, 0x12, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x0a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x2a, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
+ 0x36, 0x00, 0x00, 0x06, 0x22, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x2a, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x09, 0x22, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x1a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x2a, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
+ 0x36, 0x00, 0x00, 0x06, 0x42, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x2a, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x09, 0x42, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x2a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x2a, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
+ 0x36, 0x00, 0x00, 0x06, 0x82, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x2a, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x09, 0x82, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x3a, 0x00, 0x10, 0x80, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x2a, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
+ 0x32, 0x00, 0x00, 0x09, 0xf2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xf6, 0x1f, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x36, 0x00, 0x00, 0x05, 0x32, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x46, 0x10, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x08,
+ 0xc2, 0x00, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f,
+ 0x00, 0x00, 0x80, 0x3f, 0x11, 0x00, 0x00, 0x07, 0x12, 0x00, 0x10, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x46, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a,
+ 0x62, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x81, 0x20, 0x80,
+ 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x06, 0x81, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
+ 0x32, 0x00, 0x00, 0x0a, 0x12, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x3a, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x10, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x1a, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0x12, 0x00, 0x10, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0x3a, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x1a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x80, 0x20, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a,
+ 0x62, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x56, 0x84, 0x20, 0x80,
+ 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x56, 0x84, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
+ 0x32, 0x00, 0x00, 0x0a, 0x22, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x3a, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x10, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x1a, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0x22, 0x00, 0x10, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0x3a, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x2a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x80, 0x20, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a,
+ 0x52, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x56, 0x84, 0x20, 0x80,
+ 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x56, 0x84, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
+ 0x32, 0x00, 0x00, 0x0a, 0x42, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x3a, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00,
+ 0x04, 0x00, 0x00, 0x00, 0x1a, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0x42, 0x00, 0x10, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0x3a, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x2a, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0a, 0x80, 0x20, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a,
+ 0x92, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00, 0x56, 0x81, 0x20, 0x80,
+ 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x56, 0x81, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
+ 0x32, 0x00, 0x00, 0x0a, 0x82, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x3a, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x10, 0x00,
+ 0x04, 0x00, 0x00, 0x00, 0x1a, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x04, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x07, 0x22, 0x00, 0x10, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x46, 0x0e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a,
+ 0x82, 0x00, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x3a, 0x10, 0x10, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x0a, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x11, 0x00, 0x00, 0x07, 0x12, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x46, 0x0e, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x07, 0x32, 0x00, 0x10, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x06, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0b,
+ 0x32, 0x20, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x46, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xe6, 0x8a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x42, 0x20, 0x10, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f,
+ 0x3e, 0x00, 0x00, 0x01, 0x53, 0x54, 0x41, 0x54, 0x74, 0x00, 0x00, 0x00,
+ 0x21, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x06, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+#endif
diff --git a/LibOVR/Src/CAPI/Shaders/DistortionTimewarp_vs_refl.h b/LibOVR/Src/CAPI/Shaders/DistortionTimewarp_vs_refl.h
new file mode 100644
index 0000000..dd1569f
--- /dev/null
+++ b/LibOVR/Src/CAPI/Shaders/DistortionTimewarp_vs_refl.h
@@ -0,0 +1,11 @@
+#ifndef DistortionTimewarp_vs_refl
+
+const OVR::CAPI::D3D_NS::ShaderBase::Uniform DistortionTimewarp_vs_refl[] =
+{
+ { "EyeToSourceUVScale", OVR::CAPI::D3D_NS::ShaderBase::VARTYPE_FLOAT, 0, 8 },
+ { "EyeToSourceUVOffset", OVR::CAPI::D3D_NS::ShaderBase::VARTYPE_FLOAT, 8, 8 },
+ { "EyeRotationStart", OVR::CAPI::D3D_NS::ShaderBase::VARTYPE_FLOAT, 16, 64 },
+ { "EyeRotationEnd", OVR::CAPI::D3D_NS::ShaderBase::VARTYPE_FLOAT, 80, 64 },
+};
+
+#endif
diff --git a/LibOVR/Src/CAPI/Shaders/Distortion_ps.h b/LibOVR/Src/CAPI/Shaders/Distortion_ps.h
new file mode 100644
index 0000000..2aa92f5
--- /dev/null
+++ b/LibOVR/Src/CAPI/Shaders/Distortion_ps.h
@@ -0,0 +1,66 @@
+#ifndef DISTORTION_PS_H
+#define DISTORTION_PS_H
+
+static const unsigned char Distortion_ps[] = {
+ 0x44, 0x58, 0x42, 0x43, 0xc9, 0x40, 0x1a, 0xf6, 0x24, 0x65, 0x62, 0xf5,
+ 0x0a, 0x75, 0x65, 0xc3, 0x5e, 0x8d, 0xb8, 0x56, 0x01, 0x00, 0x00, 0x00,
+ 0xb8, 0x02, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00,
+ 0xdc, 0x00, 0x00, 0x00, 0x50, 0x01, 0x00, 0x00, 0x84, 0x01, 0x00, 0x00,
+ 0x3c, 0x02, 0x00, 0x00, 0x52, 0x44, 0x45, 0x46, 0xa0, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x1c, 0x00, 0x00, 0x00, 0x00, 0x04, 0xff, 0xff, 0x00, 0x01, 0x00, 0x00,
+ 0x6b, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x63, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
+ 0x04, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x4c, 0x69, 0x6e, 0x65,
+ 0x61, 0x72, 0x00, 0x54, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x00, 0x4d,
+ 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29,
+ 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72,
+ 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x36, 0x2e,
+ 0x33, 0x2e, 0x39, 0x36, 0x30, 0x30, 0x2e, 0x31, 0x36, 0x33, 0x38, 0x34,
+ 0x00, 0xab, 0xab, 0xab, 0x49, 0x53, 0x47, 0x4e, 0x6c, 0x00, 0x00, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x0f, 0x07, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x07, 0x03, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x50,
+ 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x43, 0x4f, 0x4c, 0x4f,
+ 0x52, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x00, 0xab,
+ 0x4f, 0x53, 0x47, 0x4e, 0x2c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x08, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x0f, 0x00, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x54, 0x61, 0x72, 0x67, 0x65,
+ 0x74, 0x00, 0xab, 0xab, 0x53, 0x48, 0x44, 0x52, 0xb0, 0x00, 0x00, 0x00,
+ 0x40, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x03,
+ 0x00, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x18, 0x00, 0x04,
+ 0x00, 0x70, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00,
+ 0x62, 0x10, 0x00, 0x03, 0x72, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x62, 0x10, 0x00, 0x03, 0x32, 0x10, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x65, 0x00, 0x00, 0x03, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x68, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x0b,
+ 0xf2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x10, 0x10, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0x72, 0x20, 0x10, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x46, 0x12, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05,
+ 0x82, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00,
+ 0x00, 0x00, 0x80, 0x3f, 0x3e, 0x00, 0x00, 0x01, 0x53, 0x54, 0x41, 0x54,
+ 0x74, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+
+};
+
+#endif
diff --git a/LibOVR/Src/CAPI/Shaders/Distortion_ps.psh b/LibOVR/Src/CAPI/Shaders/Distortion_ps.psh
index 4a33de5..36a7dc7 100644
--- a/LibOVR/Src/CAPI/Shaders/Distortion_ps.psh
+++ b/LibOVR/Src/CAPI/Shaders/Distortion_ps.psh
@@ -4,6 +4,6 @@ SamplerState Linear : register(s0);
float4 main(in float4 oPosition : SV_Position, in float4 oColor : COLOR,
in float3 oTexCoord0 : TEXCOORD0) : SV_Target
{
- float3 Result = Texture.Sample(Linear, oTexCoord0.xy).rgb;
+ float3 Result = Texture.SampleLevel(Linear, oTexCoord0.xy, 0.0).rgb;
return float4(Result.r * oColor.r, Result.g * oColor.g, Result.b * oColor.b, 1.0);
}
diff --git a/LibOVR/Src/CAPI/Shaders/Distortion_ps_refl.h b/LibOVR/Src/CAPI/Shaders/Distortion_ps_refl.h
new file mode 100644
index 0000000..8a613f5
--- /dev/null
+++ b/LibOVR/Src/CAPI/Shaders/Distortion_ps_refl.h
@@ -0,0 +1 @@
+// No data available for shader reflection Distortion_ps_refl \ No newline at end of file
diff --git a/LibOVR/Src/CAPI/Shaders/Distortion_vs.h b/LibOVR/Src/CAPI/Shaders/Distortion_vs.h
new file mode 100644
index 0000000..91e2046
--- /dev/null
+++ b/LibOVR/Src/CAPI/Shaders/Distortion_vs.h
@@ -0,0 +1,84 @@
+#ifndef DISTORTION_VS_H
+#define DISTORTION_VS_H
+
+static const unsigned char Distortion_vs[] = {
+ 0x44, 0x58, 0x42, 0x43, 0x69, 0x55, 0x09, 0xe1, 0x88, 0x43, 0xa7, 0xcb,
+ 0xe6, 0xdf, 0x06, 0x37, 0x5b, 0xc1, 0x8c, 0xa1, 0x01, 0x00, 0x00, 0x00,
+ 0x90, 0x03, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00,
+ 0x38, 0x01, 0x00, 0x00, 0xa8, 0x01, 0x00, 0x00, 0x1c, 0x02, 0x00, 0x00,
+ 0x14, 0x03, 0x00, 0x00, 0x52, 0x44, 0x45, 0x46, 0xfc, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x1c, 0x00, 0x00, 0x00, 0x00, 0x04, 0xfe, 0xff, 0x00, 0x01, 0x00, 0x00,
+ 0xc8, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x24, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x73, 0x00, 0xab, 0xab, 0xab,
+ 0x3c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00,
+ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0xa4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xb4, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0xa4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x45, 0x79, 0x65, 0x54, 0x6f, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x55,
+ 0x56, 0x53, 0x63, 0x61, 0x6c, 0x65, 0x00, 0xab, 0x01, 0x00, 0x03, 0x00,
+ 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x45, 0x79, 0x65, 0x54, 0x6f, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x55,
+ 0x56, 0x4f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x00, 0x4d, 0x69, 0x63, 0x72,
+ 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c,
+ 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f,
+ 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x36, 0x2e, 0x33, 0x2e, 0x39,
+ 0x36, 0x30, 0x30, 0x2e, 0x31, 0x36, 0x33, 0x38, 0x34, 0x00, 0xab, 0xab,
+ 0x49, 0x53, 0x47, 0x4e, 0x68, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x08, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x03, 0x03, 0x00, 0x00, 0x59, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x0f, 0x0f, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x03, 0x03, 0x00, 0x00, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e,
+ 0x00, 0x43, 0x4f, 0x4c, 0x4f, 0x52, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4f,
+ 0x4f, 0x52, 0x44, 0x00, 0x4f, 0x53, 0x47, 0x4e, 0x6c, 0x00, 0x00, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x07, 0x08, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x50,
+ 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x43, 0x4f, 0x4c, 0x4f,
+ 0x52, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x00, 0xab,
+ 0x53, 0x48, 0x44, 0x52, 0xf0, 0x00, 0x00, 0x00, 0x40, 0x00, 0x01, 0x00,
+ 0x3c, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x04, 0x46, 0x8e, 0x20, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x03,
+ 0x32, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x03,
+ 0xf2, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x03,
+ 0x32, 0x10, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x04,
+ 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x65, 0x00, 0x00, 0x03, 0xf2, 0x20, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x65, 0x00, 0x00, 0x03, 0x72, 0x20, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x36, 0x00, 0x00, 0x05, 0x32, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x46, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x08,
+ 0xc2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f,
+ 0x00, 0x00, 0x80, 0x3f, 0x36, 0x00, 0x00, 0x05, 0xf2, 0x20, 0x10, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x46, 0x1e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x32, 0x00, 0x00, 0x0b, 0x32, 0x20, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x46, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x46, 0x10, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0xe6, 0x8a, 0x20, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05,
+ 0x42, 0x20, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x40, 0x00, 0x00,
+ 0x00, 0x00, 0x80, 0x3f, 0x3e, 0x00, 0x00, 0x01, 0x53, 0x54, 0x41, 0x54,
+ 0x74, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+
+};
+
+#endif
diff --git a/LibOVR/Src/CAPI/Shaders/Distortion_vs_refl.h b/LibOVR/Src/CAPI/Shaders/Distortion_vs_refl.h
new file mode 100644
index 0000000..0e7d4fa
--- /dev/null
+++ b/LibOVR/Src/CAPI/Shaders/Distortion_vs_refl.h
@@ -0,0 +1,9 @@
+#ifndef Distortion_vs_refl
+
+const OVR::CAPI::D3D_NS::ShaderBase::Uniform Distortion_vs_refl[] =
+{
+ { "EyeToSourceUVScale", OVR::CAPI::D3D_NS::ShaderBase::VARTYPE_FLOAT, 0, 8 },
+ { "EyeToSourceUVOffset", OVR::CAPI::D3D_NS::ShaderBase::VARTYPE_FLOAT, 8, 8 },
+};
+
+#endif
diff --git a/LibOVR/Src/CAPI/Shaders/SimpleQuad_ps.h b/LibOVR/Src/CAPI/Shaders/SimpleQuad_ps.h
new file mode 100644
index 0000000..2c01e6c
--- /dev/null
+++ b/LibOVR/Src/CAPI/Shaders/SimpleQuad_ps.h
@@ -0,0 +1,51 @@
+#ifndef SIMPLEQUAD_PS_H
+#define SIMPLEQUAD_PS_H
+
+static const unsigned char SimpleQuad_ps[] = {
+ 0x44, 0x58, 0x42, 0x43, 0xc5, 0x64, 0xa2, 0x55, 0x15, 0x24, 0x7d, 0xe6,
+ 0x27, 0xd2, 0xf4, 0x4e, 0x42, 0xb6, 0xba, 0x78, 0x01, 0x00, 0x00, 0x00,
+ 0x08, 0x02, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00,
+ 0x00, 0x01, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, 0x44, 0x01, 0x00, 0x00,
+ 0x8c, 0x01, 0x00, 0x00, 0x52, 0x44, 0x45, 0x46, 0xc4, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x1c, 0x00, 0x00, 0x00, 0x00, 0x04, 0xff, 0xff, 0x00, 0x01, 0x00, 0x00,
+ 0x90, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x24, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x73, 0x00, 0xab, 0xab, 0xab,
+ 0x3c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00,
+ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0xab, 0xab, 0x01, 0x00, 0x03, 0x00,
+ 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52,
+ 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65,
+ 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x36,
+ 0x2e, 0x33, 0x2e, 0x39, 0x36, 0x30, 0x30, 0x2e, 0x31, 0x36, 0x33, 0x38,
+ 0x34, 0x00, 0xab, 0xab, 0x49, 0x53, 0x47, 0x4e, 0x08, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x4f, 0x53, 0x47, 0x4e,
+ 0x2c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
+ 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
+ 0x53, 0x56, 0x5f, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x00, 0xab, 0xab,
+ 0x53, 0x48, 0x44, 0x52, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
+ 0x10, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x04, 0x46, 0x8e, 0x20, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03,
+ 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x06,
+ 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x01,
+ 0x53, 0x54, 0x41, 0x54, 0x74, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00
+};
+
+#endif
diff --git a/LibOVR/Src/CAPI/Shaders/SimpleQuad_ps_refl.h b/LibOVR/Src/CAPI/Shaders/SimpleQuad_ps_refl.h
new file mode 100644
index 0000000..21595d1
--- /dev/null
+++ b/LibOVR/Src/CAPI/Shaders/SimpleQuad_ps_refl.h
@@ -0,0 +1,8 @@
+#ifndef SimpleQuad_ps_refl
+
+const OVR::CAPI::D3D_NS::ShaderBase::Uniform SimpleQuad_ps_refl[] =
+{
+ { "Color", OVR::CAPI::D3D_NS::ShaderBase::VARTYPE_FLOAT, 0, 16 },
+};
+
+#endif
diff --git a/LibOVR/Src/CAPI/Shaders/SimpleQuad_vs.h b/LibOVR/Src/CAPI/Shaders/SimpleQuad_vs.h
new file mode 100644
index 0000000..510c200
--- /dev/null
+++ b/LibOVR/Src/CAPI/Shaders/SimpleQuad_vs.h
@@ -0,0 +1,64 @@
+#ifndef SIMPLEQUAD_VS_H
+#define SIMPLEQUAD_VS_H
+
+static const unsigned char SimpleQuad_vs[] = {
+ 0x44, 0x58, 0x42, 0x43, 0xb2, 0x87, 0xff, 0xa1, 0x41, 0xd7, 0x0e, 0x94,
+ 0x59, 0xd6, 0x1b, 0x8c, 0x94, 0x3d, 0xb9, 0x46, 0x01, 0x00, 0x00, 0x00,
+ 0xa8, 0x02, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00,
+ 0x38, 0x01, 0x00, 0x00, 0x6c, 0x01, 0x00, 0x00, 0xa0, 0x01, 0x00, 0x00,
+ 0x2c, 0x02, 0x00, 0x00, 0x52, 0x44, 0x45, 0x46, 0xfc, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x1c, 0x00, 0x00, 0x00, 0x00, 0x04, 0xfe, 0xff, 0x00, 0x01, 0x00, 0x00,
+ 0xc8, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x24, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x73, 0x00, 0xab, 0xab, 0xab,
+ 0x3c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00,
+ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0xb0, 0x00, 0x00, 0x00,
+ 0xb8, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00,
+ 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x4f, 0x66, 0x66, 0x73,
+ 0x65, 0x74, 0x00, 0xab, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x02, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x53, 0x63, 0x61, 0x6c, 0x65, 0x00, 0xab, 0xab,
+ 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0x3f, 0x4d, 0x69, 0x63, 0x72,
+ 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c,
+ 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f,
+ 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x36, 0x2e, 0x33, 0x2e, 0x39,
+ 0x36, 0x30, 0x30, 0x2e, 0x31, 0x36, 0x33, 0x38, 0x34, 0x00, 0xab, 0xab,
+ 0x49, 0x53, 0x47, 0x4e, 0x2c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+ 0x08, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x07, 0x03, 0x00, 0x00, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e,
+ 0x00, 0xab, 0xab, 0xab, 0x4f, 0x53, 0x47, 0x4e, 0x2c, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x50,
+ 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x00, 0x53, 0x48, 0x44, 0x52,
+ 0x84, 0x00, 0x00, 0x00, 0x40, 0x00, 0x01, 0x00, 0x21, 0x00, 0x00, 0x00,
+ 0x59, 0x00, 0x00, 0x04, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x03, 0x32, 0x10, 0x10, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x04, 0xf2, 0x20, 0x10, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0b,
+ 0x32, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x10, 0x10, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xe6, 0x8a, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x46, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x08, 0xc2, 0x20, 0x10, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x80, 0x3f,
+ 0x3e, 0x00, 0x00, 0x01, 0x53, 0x54, 0x41, 0x54, 0x74, 0x00, 0x00, 0x00,
+ 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+#endif
diff --git a/LibOVR/Src/CAPI/Shaders/SimpleQuad_vs_refl.h b/LibOVR/Src/CAPI/Shaders/SimpleQuad_vs_refl.h
new file mode 100644
index 0000000..2e1fe09
--- /dev/null
+++ b/LibOVR/Src/CAPI/Shaders/SimpleQuad_vs_refl.h
@@ -0,0 +1,9 @@
+#ifndef SimpleQuad_vs_refl
+
+const OVR::CAPI::D3D_NS::ShaderBase::Uniform SimpleQuad_vs_refl[] =
+{
+ { "PositionOffset", OVR::CAPI::D3D_NS::ShaderBase::VARTYPE_FLOAT, 0, 8 },
+ { "Scale", OVR::CAPI::D3D_NS::ShaderBase::VARTYPE_FLOAT, 8, 8 },
+};
+
+#endif