From 3cd471457ab254a15d6dd945ac1276270817c998 Mon Sep 17 00:00:00 2001 From: Ryan Tremblay Date: Thu, 7 Dec 2023 17:12:24 -0800 Subject: [PATCH 1/3] Swap finish/start order --- .../react-native/shared/BabylonNative.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Modules/@babylonjs/react-native/shared/BabylonNative.cpp b/Modules/@babylonjs/react-native/shared/BabylonNative.cpp index ac06316a9..b190530cd 100644 --- a/Modules/@babylonjs/react-native/shared/BabylonNative.cpp +++ b/Modules/@babylonjs/react-native/shared/BabylonNative.cpp @@ -73,6 +73,12 @@ namespace BabylonNative ~ReactNativeModule() override { + if (g_graphicsDevice) + { + g_update->Finish(); + g_graphicsDevice->FinishRenderingCurrentFrame(); + } + *m_isRunning = false; Napi::Detach(m_env); } @@ -91,11 +97,20 @@ namespace BabylonNative { g_graphicsDevice.emplace(m_graphicsConfig); g_update.emplace(g_graphicsDevice->GetUpdate("update")); + + g_graphicsDevice->StartRenderingCurrentFrame(); + g_update->Start(); } else { + g_update->Finish(); + g_graphicsDevice->FinishRenderingCurrentFrame(); + g_graphicsDevice->UpdateWindow(m_graphicsConfig.Window); g_graphicsDevice->UpdateSize(m_graphicsConfig.Width, m_graphicsConfig.Height); + + g_graphicsDevice->StartRenderingCurrentFrame(); + g_update->Start(); } g_graphicsDevice->UpdateMSAA(mMSAAValue); g_graphicsDevice->UpdateAlphaPremultiplied(mAlphaPremultiplied); @@ -150,10 +165,10 @@ namespace BabylonNative // Otherwise rendering can be implicitly enabled, which may not be desirable (e.g. after the engine is disposed). if (g_graphicsDevice && m_isRenderingEnabled) { - g_graphicsDevice->StartRenderingCurrentFrame(); - g_update->Start(); g_update->Finish(); g_graphicsDevice->FinishRenderingCurrentFrame(); + g_graphicsDevice->StartRenderingCurrentFrame(); + g_update->Start(); } } From 12da3ebef517b1d7fc14a0fb12756ff4048ab244 Mon Sep 17 00:00:00 2001 From: Ryan Tremblay Date: Tue, 12 Dec 2023 15:49:11 -0800 Subject: [PATCH 2/3] More ordering issues --- Modules/@babylonjs/react-native/shared/BabylonNative.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Modules/@babylonjs/react-native/shared/BabylonNative.cpp b/Modules/@babylonjs/react-native/shared/BabylonNative.cpp index b190530cd..ce34955e3 100644 --- a/Modules/@babylonjs/react-native/shared/BabylonNative.cpp +++ b/Modules/@babylonjs/react-native/shared/BabylonNative.cpp @@ -103,8 +103,11 @@ namespace BabylonNative } else { - g_update->Finish(); - g_graphicsDevice->FinishRenderingCurrentFrame(); + if (m_isRenderingEnabled) + { + g_update->Finish(); + g_graphicsDevice->FinishRenderingCurrentFrame(); + } g_graphicsDevice->UpdateWindow(m_graphicsConfig.Window); g_graphicsDevice->UpdateSize(m_graphicsConfig.Width, m_graphicsConfig.Height); @@ -181,6 +184,8 @@ namespace BabylonNative { if (g_graphicsDevice) { + g_update->Finish(); + g_graphicsDevice->FinishRenderingCurrentFrame(); g_nativeCanvas->FlushGraphicResources(); g_graphicsDevice->DisableRendering(); } From d6612e2d3025755c165a9ee72bf7126d46987722 Mon Sep 17 00:00:00 2001 From: Ryan Tremblay Date: Thu, 14 Dec 2023 16:56:08 -0800 Subject: [PATCH 3/3] More ordering issues --- Modules/@babylonjs/react-native/shared/BabylonNative.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/Modules/@babylonjs/react-native/shared/BabylonNative.cpp b/Modules/@babylonjs/react-native/shared/BabylonNative.cpp index ce34955e3..d9a572b4a 100644 --- a/Modules/@babylonjs/react-native/shared/BabylonNative.cpp +++ b/Modules/@babylonjs/react-native/shared/BabylonNative.cpp @@ -97,9 +97,6 @@ namespace BabylonNative { g_graphicsDevice.emplace(m_graphicsConfig); g_update.emplace(g_graphicsDevice->GetUpdate("update")); - - g_graphicsDevice->StartRenderingCurrentFrame(); - g_update->Start(); } else { @@ -111,14 +108,12 @@ namespace BabylonNative g_graphicsDevice->UpdateWindow(m_graphicsConfig.Window); g_graphicsDevice->UpdateSize(m_graphicsConfig.Width, m_graphicsConfig.Height); - - g_graphicsDevice->StartRenderingCurrentFrame(); - g_update->Start(); } g_graphicsDevice->UpdateMSAA(mMSAAValue); g_graphicsDevice->UpdateAlphaPremultiplied(mAlphaPremultiplied); - g_graphicsDevice->EnableRendering(); + g_graphicsDevice->StartRenderingCurrentFrame(); + g_update->Start(); std::call_once(m_isGraphicsInitialized, [this]() {