MCPcopy Create free account
hub / github.com/LibreVR/Revive / BlitLayers

Method BlitLayers

Revive/CompositorBase.cpp:317–367  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

315}
316
317void CompositorBase::BlitLayers(const ovrLayerHeader* dstLayer, const ovrLayerHeader* srcLayer)
318{
319 MICROPROFILE_SCOPE(BlitLayers);
320
321 const ovrLayer_Union& dst = ToUnion(dstLayer);
322 const ovrLayer_Union& src = ToUnion(srcLayer);
323
324 // Render the scene layer
325 TextureBase* srcTex = nullptr;
326 TextureBase* dstTex = nullptr;
327 ovrTextureSwapChain srcChain = nullptr;
328 ovrTextureSwapChain dstChain = nullptr;
329 for (int i = 0; i < ovrEye_Count; i++)
330 {
331 if (src.EyeFov.ColorTexture[i] && src.EyeFov.ColorTexture[i] != srcChain)
332 {
333 srcChain = src.EyeFov.ColorTexture[i];
334 srcTex = srcChain->Submit();
335 }
336
337 if (dst.EyeFov.ColorTexture[i])
338 {
339 dstChain = dst.EyeFov.ColorTexture[i];
340 dstTex = dstChain->Textures[dstChain->SubmitIndex].get();
341 }
342
343 // Get the scene fov
344 ovrFovPort srcFov = srcLayer->Type == ovrLayerType_EyeMatrix ?
345 REV::Matrix4f(src.EyeMatrix.Matrix[i]).ToFovPort() : src.EyeFov.Fov[i];
346 ovrFovPort dstFov = dstLayer->Type == ovrLayerType_EyeMatrix ?
347 REV::Matrix4f(dst.EyeMatrix.Matrix[i]).ToFovPort() : dst.EyeFov.Fov[i];
348
349 // Calculate the fov quad
350 vr::HmdVector4_t quad;
351 quad.v[0] = srcFov.LeftTan / -dstFov.LeftTan;
352 quad.v[1] = srcFov.RightTan / dstFov.RightTan;
353 quad.v[2] = srcFov.UpTan / dstFov.UpTan;
354 quad.v[3] = srcFov.DownTan / -dstFov.DownTan;
355
356 // Calculate the texture bounds
357 vr::VRTextureBounds_t bounds = ViewportToTextureBounds(src.EyeFov.Viewport[i], srcChain, srcLayer->Flags);
358
359 // Composit the layer
360 RenderTextureSwapChain((vr::EVREye)i, srcTex, dstTex, dst.EyeFov.Viewport[i], bounds, quad);
361 }
362
363 MICROPROFILE_META_CPU("SwapChain Left", src.EyeFov.ColorTexture[0]->Identifier);
364 MICROPROFILE_META_CPU("Submit Left", src.EyeFov.ColorTexture[0]->SubmitIndex);
365 MICROPROFILE_META_CPU("SwapChain Right", srcChain->Identifier);
366 MICROPROFILE_META_CPU("Submit Right", srcChain->SubmitIndex);
367}
368
369vr::VRCompositorError CompositorBase::SubmitLayer(ovrSession session, const ovrLayerHeader* baseLayer, const ovrViewScaleDesc* viewScaleDesc)
370{

Callers

nothing calls this directly

Calls 3

SubmitMethod · 0.80
ToFovPortMethod · 0.80
Matrix4fClass · 0.70

Tested by

no test coverage detected