@@ -696,47 +696,47 @@ namespace Babylon
696
696
bgfx::overrideInternal (colorTexture, reinterpret_cast <uintptr_t >(viewConfig.ColorTexturePointer ));
697
697
bgfx::overrideInternal (depthTexture, reinterpret_cast <uintptr_t >(viewConfig.DepthTexturePointer ));
698
698
}).then (m_runtimeScheduler.Get (), m_sessionState->CancellationSource , [this , thisRef{shared_from_this ()}, colorTexture, depthTexture, requiresAppClear, &viewConfig]() {
699
- const auto eyeCount = std::max (static_cast <uint16_t >(1 ), static_cast <uint16_t >(viewConfig.ViewTextureSize .Depth ));
700
- // TODO (rgerd): Remove old framebuffers from resource table?
701
- viewConfig.FrameBuffers .resize (eyeCount);
702
- for (uint16_t eyeIdx = 0 ; eyeIdx < eyeCount; eyeIdx++)
703
- {
704
- std::array<bgfx::Attachment, 2 > attachments{};
705
- attachments[0 ].init (colorTexture, bgfx::Access::Write, eyeIdx);
706
- attachments[1 ].init (depthTexture, bgfx::Access::Write, eyeIdx);
707
-
708
- auto frameBufferHandle = bgfx::createFrameBuffer (static_cast <uint8_t >(attachments.size ()), attachments.data (), false );
709
-
710
- const auto frameBufferPtr = new Graphics::FrameBuffer (
711
- m_sessionState->GraphicsContext ,
712
- frameBufferHandle,
713
- static_cast <uint16_t >(viewConfig.ViewTextureSize .Width ),
714
- static_cast <uint16_t >(viewConfig.ViewTextureSize .Height ),
715
- true ,
716
- true ,
717
- true );
718
-
719
- auto & frameBuffer = *frameBufferPtr;
720
-
721
- // WebXR, at least in its current implementation, specifies an implicit default clear to black.
722
- // https://immersive-web.github.io/webxr/#xrwebgllayer-interface
723
- frameBuffer.Clear (*m_sessionState->Update .GetUpdateToken ().GetEncoder (), BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH | BGFX_CLEAR_STENCIL, 0 , 1 .0f , 0 );
724
-
725
- viewConfig.FrameBuffers [eyeIdx] = frameBufferPtr;
726
-
727
- auto jsWidth{Napi::Value::From (m_env, viewConfig.ViewTextureSize .Width )};
728
- auto jsHeight{Napi::Value::From (m_env, viewConfig.ViewTextureSize .Height )};
729
- auto jsFrameBuffer{Napi::Pointer<Graphics::FrameBuffer>::Create (m_env, frameBufferPtr, Napi::NapiPointerDeleter (frameBufferPtr))};
730
- viewConfig.JsTextures [frameBufferPtr] = Napi::Persistent (m_sessionState->CreateRenderTexture .Call ({jsWidth, jsHeight, jsFrameBuffer}).As <Napi::Object>());
731
- // OpenXR doesn't pre-clear textures, and so we need to make sure the render target gets cleared before rendering the scene.
732
- // ARCore and ARKit effectively pre-clear by pre-compositing the camera feed.
733
- if (requiresAppClear)
734
- {
735
- viewConfig.JsTextures [frameBufferPtr].Set (" skipInitialClear" , false );
736
- }
737
- }
738
- viewConfig.Initialized = true ;
739
- }).then (arcana::inline_scheduler, m_sessionState->CancellationSource , [env{m_env}](const arcana::expected<void , std::exception_ptr>& result) {
699
+ const auto eyeCount = std::max (static_cast <uint16_t >(1 ), static_cast <uint16_t >(viewConfig.ViewTextureSize .Depth ));
700
+ // TODO (rgerd): Remove old framebuffers from resource table?
701
+ viewConfig.FrameBuffers .resize (eyeCount);
702
+ for (uint16_t eyeIdx = 0 ; eyeIdx < eyeCount; eyeIdx++)
703
+ {
704
+ std::array<bgfx::Attachment, 2 > attachments{};
705
+ attachments[0 ].init (colorTexture, bgfx::Access::Write, eyeIdx);
706
+ attachments[1 ].init (depthTexture, bgfx::Access::Write, eyeIdx);
707
+
708
+ auto frameBufferHandle = bgfx::createFrameBuffer (static_cast <uint8_t >(attachments.size ()), attachments.data (), false );
709
+
710
+ const auto frameBufferPtr = new Graphics::FrameBuffer (
711
+ m_sessionState->GraphicsContext ,
712
+ frameBufferHandle,
713
+ static_cast <uint16_t >(viewConfig.ViewTextureSize .Width ),
714
+ static_cast <uint16_t >(viewConfig.ViewTextureSize .Height ),
715
+ true ,
716
+ true ,
717
+ true );
718
+
719
+ auto & frameBuffer = *frameBufferPtr;
720
+
721
+ // WebXR, at least in its current implementation, specifies an implicit default clear to black.
722
+ // https://immersive-web.github.io/webxr/#xrwebgllayer-interface
723
+ frameBuffer.Clear (*m_sessionState->Update .GetUpdateToken ().GetEncoder (), BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH | BGFX_CLEAR_STENCIL, 0 , 1 .0f , 0 );
724
+
725
+ viewConfig.FrameBuffers [eyeIdx] = frameBufferPtr;
726
+
727
+ auto jsWidth{Napi::Value::From (m_env, viewConfig.ViewTextureSize .Width )};
728
+ auto jsHeight{Napi::Value::From (m_env, viewConfig.ViewTextureSize .Height )};
729
+ auto jsFrameBuffer{Napi::Pointer<Graphics::FrameBuffer>::Create (m_env, frameBufferPtr, Napi::NapiPointerDeleter (frameBufferPtr))};
730
+ viewConfig.JsTextures [frameBufferPtr] = Napi::Persistent (m_sessionState->CreateRenderTexture .Call ({jsWidth, jsHeight, jsFrameBuffer}).As <Napi::Object>());
731
+ // OpenXR doesn't pre-clear textures, and so we need to make sure the render target gets cleared before rendering the scene.
732
+ // ARCore and ARKit effectively pre-clear by pre-compositing the camera feed.
733
+ if (requiresAppClear)
734
+ {
735
+ viewConfig.JsTextures [frameBufferPtr].Set (" skipInitialClear" , false );
736
+ }
737
+ }
738
+ viewConfig.Initialized = true ;
739
+ }).then (arcana::inline_scheduler, m_sessionState->CancellationSource , [env{m_env}](const arcana::expected<void , std::exception_ptr>& result) {
740
740
if (result.has_error ())
741
741
{
742
742
Napi::Error::New (env, result.error ()).ThrowAsJavaScriptException ();
@@ -3427,10 +3427,9 @@ namespace Babylon
3427
3427
3428
3428
// Fire off the IsSessionSupported task.
3429
3429
xr::System::IsSessionSupportedAsync (sessionType)
3430
- .then (m_runtimeScheduler.Get (), arcana::cancellation::none (), [deferred, thisRef = Napi::Persistent (info.This ())](bool result)
3431
- {
3432
- deferred.Resolve (Napi::Boolean::New (thisRef.Env (), result));
3433
- });
3430
+ .then (m_runtimeScheduler.Get (), arcana::cancellation::none (), [deferred, thisRef = Napi::Persistent (info.This ())](bool result) {
3431
+ deferred.Resolve (Napi::Boolean::New (thisRef.Env (), result));
3432
+ });
3434
3433
3435
3434
return deferred.Promise ();
3436
3435
}
0 commit comments