| 142 | } |
| 143 | |
| 144 | ovrResult ovrHmdStruct::StartSession(void* graphicsBinding) |
| 145 | { |
| 146 | if (Session) |
| 147 | return ovrError_InvalidOperation; |
| 148 | |
| 149 | XrSessionCreateInfo createInfo = XR_TYPE(SESSION_CREATE_INFO); |
| 150 | createInfo.next = graphicsBinding; |
| 151 | createInfo.systemId = System; |
| 152 | CHK_XR(xrCreateSession(Instance, &createInfo, &Session)); |
| 153 | memset(&SessionStatus, 0, sizeof(SessionStatus)); |
| 154 | |
| 155 | // Attach it to the InputManager |
| 156 | if (Input) |
| 157 | Input->AttachSession(Session); |
| 158 | |
| 159 | // Create reference spaces |
| 160 | XrReferenceSpaceCreateInfo spaceInfo = XR_TYPE(REFERENCE_SPACE_CREATE_INFO); |
| 161 | spaceInfo.poseInReferenceSpace = XR::Posef::Identity(); |
| 162 | spaceInfo.referenceSpaceType = XR_REFERENCE_SPACE_TYPE_VIEW; |
| 163 | CHK_XR(xrCreateReferenceSpace(Session, &spaceInfo, &ViewSpace)); |
| 164 | spaceInfo.referenceSpaceType = XR_REFERENCE_SPACE_TYPE_LOCAL; |
| 165 | CHK_XR(xrCreateReferenceSpace(Session, &spaceInfo, &OriginSpaces[ovrTrackingOrigin_EyeLevel])); |
| 166 | CHK_XR(xrCreateReferenceSpace(Session, &spaceInfo, &TrackingSpaces[ovrTrackingOrigin_EyeLevel])); |
| 167 | spaceInfo.referenceSpaceType = XR_REFERENCE_SPACE_TYPE_STAGE; |
| 168 | CHK_XR(xrCreateReferenceSpace(Session, &spaceInfo, &OriginSpaces[ovrTrackingOrigin_FloorLevel])); |
| 169 | CHK_XR(xrCreateReferenceSpace(Session, &spaceInfo, &TrackingSpaces[ovrTrackingOrigin_FloorLevel])); |
| 170 | |
| 171 | // Update the visibility mask for both eyes |
| 172 | if (Runtime::Get().VisibilityMask) |
| 173 | { |
| 174 | for (uint32_t i = 0; i < ovrEye_Count; i++) |
| 175 | { |
| 176 | UpdateStencil((ovrEyeType)i, XR_VISIBILITY_MASK_TYPE_HIDDEN_TRIANGLE_MESH_KHR); |
| 177 | UpdateStencil((ovrEyeType)i, XR_VISIBILITY_MASK_TYPE_VISIBLE_TRIANGLE_MESH_KHR); |
| 178 | UpdateStencil((ovrEyeType)i, XR_VISIBILITY_MASK_TYPE_LINE_LOOP_KHR); |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | // Enumerate formats |
| 183 | uint32_t formatCount = 0; |
| 184 | CHK_XR(xrEnumerateSwapchainFormats(Session, 0, &formatCount, nullptr)); |
| 185 | SupportedFormats.resize(formatCount); |
| 186 | CHK_XR(xrEnumerateSwapchainFormats(Session, (uint32_t)SupportedFormats.size(), &formatCount, SupportedFormats.data())); |
| 187 | assert(formatCount == SupportedFormats.size()); |
| 188 | |
| 189 | Running.second.notify_all(); |
| 190 | |
| 191 | return ovrSuccess; |
| 192 | } |
| 193 | |
| 194 | ovrResult ovrHmdStruct::BeginSession() |
| 195 | { |
no test coverage detected