| 367 | } |
| 368 | |
| 369 | vr::VRCompositorError CompositorBase::SubmitLayer(ovrSession session, const ovrLayerHeader* baseLayer, const ovrViewScaleDesc* viewScaleDesc) |
| 370 | { |
| 371 | MICROPROFILE_SCOPE(SubmitLayer); |
| 372 | |
| 373 | const ovrLayer_Union& layer = ToUnion(baseLayer); |
| 374 | |
| 375 | // Submit the scene layer. |
| 376 | vr::VRCompositorError err; |
| 377 | vr::Texture_t depthTexture; |
| 378 | vr::Texture_t colorTexture; |
| 379 | ovrTextureSwapChain colorChain = nullptr; |
| 380 | ovrTextureSwapChain depthChain = nullptr; |
| 381 | for (int i = 0; i < ovrEye_Count; i++) |
| 382 | { |
| 383 | if (layer.EyeFov.ColorTexture[i] && layer.EyeFov.ColorTexture[i] != colorChain) |
| 384 | { |
| 385 | colorChain = layer.EyeFov.ColorTexture[i]; |
| 386 | colorChain->Submit()->ToVRTexture(colorTexture); |
| 387 | } |
| 388 | |
| 389 | ovrFovPort fov = baseLayer->Type == ovrLayerType_EyeMatrix ? |
| 390 | REV::Matrix4f(layer.EyeMatrix.Matrix[i]).ToFovPort() : layer.EyeFov.Fov[i]; |
| 391 | |
| 392 | vr::VRTextureBounds_t bounds = ViewportToTextureBounds(layer.EyeFov.Viewport[i], colorChain, baseLayer->Flags); |
| 393 | |
| 394 | // Get the descriptor for this eye |
| 395 | const ovrEyeRenderDesc& desc = session->RenderDesc[i]; |
| 396 | |
| 397 | // Shrink the bounds to account for the overlapping fov |
| 398 | vr::VRTextureBounds_t fovBounds = FovPortToTextureBounds(desc.Fov, fov); |
| 399 | |
| 400 | // Combine the fov bounds with the viewport bounds |
| 401 | bounds.uMin += fovBounds.uMin * (bounds.uMax - bounds.uMin); |
| 402 | bounds.uMax = bounds.uMin + fovBounds.uMax * (bounds.uMax - bounds.uMin); |
| 403 | bounds.vMin += fovBounds.vMin * (bounds.vMax - bounds.vMin); |
| 404 | bounds.vMax = bounds.vMin + fovBounds.vMax * (bounds.vMax - bounds.vMin); |
| 405 | |
| 406 | unsigned int submitFlags = vr::Submit_Default; |
| 407 | union |
| 408 | { |
| 409 | vr::Texture_t Color; |
| 410 | vr::VRTextureWithPose_t Pose; |
| 411 | vr::VRTextureWithDepth_t Depth; |
| 412 | vr::VRTextureWithPoseAndDepth_t PoseDepth; |
| 413 | } texture; |
| 414 | texture.Color = colorTexture; |
| 415 | |
| 416 | // Add the pose data to the eye texture |
| 417 | OVR::Matrix4f hmdToEye(viewScaleDesc ? viewScaleDesc->HmdToEyePose[i] : desc.HmdToEyePose); |
| 418 | OVR::Matrix4f pose(baseLayer->Type == ovrLayerType_EyeMatrix ? |
| 419 | layer.EyeMatrix.RenderPose[i] : layer.EyeFov.RenderPose[i]); |
| 420 | texture.Pose.mDeviceToAbsoluteTracking = REV::Matrix4f(pose * hmdToEye.Inverted()); |
| 421 | submitFlags |= vr::Submit_TextureWithPose; |
| 422 | |
| 423 | // Add the depth data if present in the layer |
| 424 | if (baseLayer->Type == ovrLayerType_EyeFovDepth) |
| 425 | { |
| 426 | if (layer.EyeFovDepth.DepthTexture[i] && layer.EyeFovDepth.DepthTexture[i] != depthChain) |
nothing calls this directly
no test coverage detected