rev |
line source |
nuclear@0
|
1 /************************************************************************************
|
nuclear@0
|
2
|
nuclear@0
|
3 Filename : OVR_CAPI_HMDRenderState.cpp
|
nuclear@0
|
4 Content : Combines all of the rendering state associated with the HMD
|
nuclear@0
|
5 Created : February 2, 2014
|
nuclear@0
|
6 Authors : Michael Antonov
|
nuclear@0
|
7
|
nuclear@0
|
8 Copyright : Copyright 2014 Oculus VR, LLC All Rights reserved.
|
nuclear@0
|
9
|
nuclear@0
|
10 Licensed under the Oculus VR Rift SDK License Version 3.2 (the "License");
|
nuclear@0
|
11 you may not use the Oculus VR Rift SDK except in compliance with the License,
|
nuclear@0
|
12 which is provided at the time of installation or download, or which
|
nuclear@0
|
13 otherwise accompanies this software in either electronic or hard copy form.
|
nuclear@0
|
14
|
nuclear@0
|
15 You may obtain a copy of the License at
|
nuclear@0
|
16
|
nuclear@0
|
17 http://www.oculusvr.com/licenses/LICENSE-3.2
|
nuclear@0
|
18
|
nuclear@0
|
19 Unless required by applicable law or agreed to in writing, the Oculus VR SDK
|
nuclear@0
|
20 distributed under the License is distributed on an "AS IS" BASIS,
|
nuclear@0
|
21 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
nuclear@0
|
22 See the License for the specific language governing permissions and
|
nuclear@0
|
23 limitations under the License.
|
nuclear@0
|
24
|
nuclear@0
|
25 ************************************************************************************/
|
nuclear@0
|
26
|
nuclear@0
|
27 #include "CAPI_HMDRenderState.h"
|
nuclear@0
|
28
|
nuclear@0
|
29 namespace OVR { namespace CAPI {
|
nuclear@0
|
30
|
nuclear@0
|
31
|
nuclear@0
|
32 //-------------------------------------------------------------------------------------
|
nuclear@0
|
33 // ***** HMDRenderState
|
nuclear@0
|
34
|
nuclear@0
|
35 ovrHmdDesc HMDRenderState::GetDesc() const
|
nuclear@0
|
36 {
|
nuclear@0
|
37 ovrHmdDesc d;
|
nuclear@0
|
38 memset(&d, 0, sizeof(d));
|
nuclear@0
|
39
|
nuclear@0
|
40 d.Type = ovrHmd_Other;
|
nuclear@0
|
41
|
nuclear@0
|
42 d.ProductName = OurHMDInfo.ProductName;
|
nuclear@0
|
43 d.Manufacturer = OurHMDInfo.Manufacturer;
|
nuclear@0
|
44 d.Resolution.w = OurHMDInfo.ResolutionInPixels.w;
|
nuclear@0
|
45 d.Resolution.h = OurHMDInfo.ResolutionInPixels.h;
|
nuclear@0
|
46 d.WindowsPos.x = OurHMDInfo.DesktopX;
|
nuclear@0
|
47 d.WindowsPos.y = OurHMDInfo.DesktopY;
|
nuclear@0
|
48 d.DisplayDeviceName = OurHMDInfo.DisplayDeviceName;
|
nuclear@0
|
49 d.DisplayId = OurHMDInfo.DisplayId;
|
nuclear@0
|
50 d.VendorId = (short)OurHMDInfo.VendorId;
|
nuclear@0
|
51 d.ProductId = (short)OurHMDInfo.ProductId;
|
nuclear@0
|
52 d.FirmwareMajor = (short)OurHMDInfo.FirmwareMajor;
|
nuclear@0
|
53 d.FirmwareMinor = (short)OurHMDInfo.FirmwareMinor;
|
nuclear@0
|
54 d.CameraFrustumFarZInMeters = OurHMDInfo.CameraFrustumFarZInMeters;
|
nuclear@0
|
55 d.CameraFrustumHFovInRadians = OurHMDInfo.CameraFrustumHFovInRadians;
|
nuclear@0
|
56 d.CameraFrustumNearZInMeters = OurHMDInfo.CameraFrustumNearZInMeters;
|
nuclear@0
|
57 d.CameraFrustumVFovInRadians = OurHMDInfo.CameraFrustumVFovInRadians;
|
nuclear@0
|
58
|
nuclear@0
|
59 OVR_strcpy(d.SerialNumber, sizeof(d.SerialNumber), OurHMDInfo.PrintedSerial.ToCStr());
|
nuclear@0
|
60
|
nuclear@0
|
61 d.HmdCaps = ovrHmdCap_Present | ovrHmdCap_NoVSync;
|
nuclear@0
|
62 d.TrackingCaps = ovrTrackingCap_MagYawCorrection | ovrTrackingCap_Orientation;
|
nuclear@0
|
63 d.DistortionCaps = ovrDistortionCap_Chromatic | ovrDistortionCap_TimeWarp |
|
nuclear@0
|
64 ovrDistortionCap_Vignette | ovrDistortionCap_SRGB |
|
nuclear@0
|
65 ovrDistortionCap_FlipInput | ovrDistortionCap_ProfileNoTimewarpSpinWaits |
|
nuclear@0
|
66 ovrDistortionCap_HqDistortion | ovrDistortionCap_LinuxDevFullscreen;
|
nuclear@0
|
67
|
nuclear@0
|
68 #if defined(OVR_OS_WIN32) || defined(OVR_OS_WIN64)
|
nuclear@0
|
69 // TODO: this gets enabled for everything, but is only applicable for DX11+
|
nuclear@0
|
70 d.DistortionCaps |= ovrDistortionCap_ComputeShader;
|
nuclear@0
|
71 #endif
|
nuclear@0
|
72
|
nuclear@0
|
73 if( OurHMDInfo.InCompatibilityMode )
|
nuclear@0
|
74 d.HmdCaps |= ovrHmdCap_ExtendDesktop;
|
nuclear@0
|
75
|
nuclear@0
|
76 if (strstr(OurHMDInfo.ProductName, "DK1"))
|
nuclear@0
|
77 {
|
nuclear@0
|
78 d.Type = ovrHmd_DK1;
|
nuclear@0
|
79 }
|
nuclear@0
|
80 else if (strstr(OurHMDInfo.ProductName, "DK2"))
|
nuclear@0
|
81 {
|
nuclear@0
|
82 d.Type = ovrHmd_DK2;
|
nuclear@0
|
83 d.HmdCaps |= ovrHmdCap_LowPersistence | ovrHmdCap_DynamicPrediction;
|
nuclear@0
|
84 d.TrackingCaps |= ovrTrackingCap_Position;
|
nuclear@0
|
85 d.DistortionCaps |= ovrDistortionCap_Overdrive;
|
nuclear@0
|
86 }
|
nuclear@0
|
87
|
nuclear@0
|
88 const DistortionRenderDesc& leftDistortion = Distortion[0];
|
nuclear@0
|
89 const DistortionRenderDesc& rightDistortion = Distortion[1];
|
nuclear@0
|
90
|
nuclear@0
|
91 // The suggested FOV (assuming eye rotation)
|
nuclear@0
|
92 d.DefaultEyeFov[0] = CalculateFovFromHmdInfo(StereoEye_Left, leftDistortion, RenderInfo, OVR_DEFAULT_EXTRA_EYE_ROTATION);
|
nuclear@0
|
93 d.DefaultEyeFov[1] = CalculateFovFromHmdInfo(StereoEye_Right, rightDistortion, RenderInfo, OVR_DEFAULT_EXTRA_EYE_ROTATION);
|
nuclear@0
|
94
|
nuclear@0
|
95 // FOV extended across the entire screen
|
nuclear@0
|
96 d.MaxEyeFov[0] = GetPhysicalScreenFov(StereoEye_Left, leftDistortion);
|
nuclear@0
|
97 d.MaxEyeFov[1] = GetPhysicalScreenFov(StereoEye_Right, rightDistortion);
|
nuclear@0
|
98
|
nuclear@0
|
99 if (OurHMDInfo.Shutter.Type == HmdShutter_RollingRightToLeft)
|
nuclear@0
|
100 {
|
nuclear@0
|
101 d.EyeRenderOrder[0] = ovrEye_Right;
|
nuclear@0
|
102 d.EyeRenderOrder[1] = ovrEye_Left;
|
nuclear@0
|
103 }
|
nuclear@0
|
104 else
|
nuclear@0
|
105 {
|
nuclear@0
|
106 d.EyeRenderOrder[0] = ovrEye_Left;
|
nuclear@0
|
107 d.EyeRenderOrder[1] = ovrEye_Right;
|
nuclear@0
|
108 }
|
nuclear@0
|
109
|
nuclear@0
|
110 // MA: Taking this out on purpose.
|
nuclear@0
|
111 // Important information for those that are required to do their own timing,
|
nuclear@0
|
112 // because of shortfalls in timing code.
|
nuclear@0
|
113 //d.VsyncToNextVsync = OurHMDInfo.Shutter.VsyncToNextVsync;
|
nuclear@0
|
114 //d.PixelPersistence = OurHMDInfo.Shutter.PixelPersistence;
|
nuclear@0
|
115
|
nuclear@0
|
116 return d;
|
nuclear@0
|
117 }
|
nuclear@0
|
118
|
nuclear@0
|
119
|
nuclear@0
|
120 ovrSizei HMDRenderState::GetFOVTextureSize(int eye, ovrFovPort fov, float pixelsPerDisplayPixel) const
|
nuclear@0
|
121 {
|
nuclear@0
|
122 OVR_ASSERT((unsigned)eye < 2);
|
nuclear@0
|
123 StereoEye seye = (eye == ovrEye_Left) ? StereoEye_Left : StereoEye_Right;
|
nuclear@0
|
124 return CalculateIdealPixelSize(seye, Distortion[eye], fov, pixelsPerDisplayPixel);
|
nuclear@0
|
125 }
|
nuclear@0
|
126
|
nuclear@0
|
127 ovrEyeRenderDesc HMDRenderState::CalcRenderDesc(ovrEyeType eyeType, const ovrFovPort& fov) const
|
nuclear@0
|
128 {
|
nuclear@0
|
129 const HmdRenderInfo& hmdri = RenderInfo;
|
nuclear@0
|
130 StereoEye eye = (eyeType == ovrEye_Left) ? StereoEye_Left : StereoEye_Right;
|
nuclear@0
|
131 ovrEyeRenderDesc e0;
|
nuclear@0
|
132
|
nuclear@0
|
133 e0.Eye = eyeType;
|
nuclear@0
|
134 e0.Fov = fov;
|
nuclear@0
|
135 e0.HmdToEyeViewOffset = CalculateEyeVirtualCameraOffset(hmdri, eye, false);
|
nuclear@0
|
136 e0.DistortedViewport = GetFramebufferViewport(eye, hmdri);
|
nuclear@0
|
137 e0.PixelsPerTanAngleAtCenter = Distortion[0].PixelsPerTanAngleAtCenter;
|
nuclear@0
|
138
|
nuclear@0
|
139 return e0;
|
nuclear@0
|
140 }
|
nuclear@0
|
141
|
nuclear@0
|
142 }} // namespace OVR::CAPI
|
nuclear@0
|
143
|