Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update BN submodule #589

Merged
merged 11 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/bn_master_commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Setup CMake
uses: jwlawson/[email protected]
with:
cmake-version: '3.19.6' # See https://gitlab.kitware.com/cmake/cmake/-/issues/22021
cmake-version: '3.26.3'
- name: Setup Ninja
run: brew install ninja
- name: NPM Install (Playground)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ios_android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Setup CMake
uses: jwlawson/[email protected]
with:
cmake-version: '3.19.6' # See https://gitlab.kitware.com/cmake/cmake/-/issues/22021
cmake-version: '3.26.3'
- name: Setup Ninja
run: brew install ninja
- name: 'Select XCode ${{ inputs.xcode-version }}'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- name: Setup CMake
uses: jwlawson/[email protected]
with:
cmake-version: '3.19.6' # See https://gitlab.kitware.com/cmake/cmake/-/issues/22021
cmake-version: '3.26.3'
- name: Setup Ninja
run: brew install ninja
- name: NPM Install (Playground)
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
- name: Setup CMake
uses: jwlawson/[email protected]
with:
cmake-version: '3.19.6' # See https://gitlab.kitware.com/cmake/cmake/-/issues/22021
cmake-version: '3.26.3'
- name: Setup Ninja
run: brew install ninja
- name: NPM Install (Playground)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ if (EXISTS "${TURBOMODULE_DIR}/CMakeLists.txt")
turbomodulejsijni # prefab ready
yoga # prefab ready
AndroidExtensions
Graphics
GraphicsDevice
JsRuntime
NativeCamera
NativeCapture
Expand Down Expand Up @@ -196,7 +196,7 @@ else()
jsi
turbomodulejsijni
AndroidExtensions
Graphics
GraphicsDevice
JsRuntime
NativeCamera
NativeCapture
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ android {
}
externalNativeBuild {
cmake {
version '3.19.6'
version '3.19.6+'
path 'CMakeLists.txt'
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ target_include_directories(BabylonNative PUBLIC ${CMAKE_CURRENT_LIST_DIR})
target_link_libraries(BabylonNative
z
arcana
Graphics
GraphicsDevice
jsi
reactnative
JsRuntime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ target_include_directories(BabylonNative PRIVATE ${SHARED_INCLUDES})

target_link_libraries(BabylonNative
arcana
Graphics
GraphicsDevice
jsi
JsRuntime
NativeCamera
Expand Down
48 changes: 24 additions & 24 deletions Modules/@babylonjs/react-native/shared/BabylonNative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ namespace BabylonNative
namespace
{
Dispatcher g_inlineDispatcher{ [](const std::function<void()>& func) { func(); } };
std::unique_ptr<Babylon::Graphics::Device> g_graphics{};
std::unique_ptr<Babylon::Graphics::DeviceUpdate> g_update{};
std::optional<Babylon::Graphics::Device> g_graphicsDevice{};
std::optional<Babylon::Graphics::DeviceUpdate> g_update{};
std::unique_ptr<Babylon::Polyfills::Canvas> g_nativeCanvas{};
}

Expand Down Expand Up @@ -75,34 +75,34 @@ namespace BabylonNative

void UpdateView(WindowType window, size_t width, size_t height)
{
m_windowConfig.Window = window;
m_windowConfig.Width = width;
m_windowConfig.Height = height;
m_graphicsConfig.Window = window;
m_graphicsConfig.Width = width;
m_graphicsConfig.Height = height;
UpdateGraphicsConfiguration();
}

void UpdateGraphicsConfiguration()
{
if (!g_graphics)
if (!g_graphicsDevice)
{
g_graphics = Babylon::Graphics::Device::Create(m_windowConfig);
g_update = std::make_unique<Babylon::Graphics::DeviceUpdate>(g_graphics->GetUpdate("update"));
g_graphicsDevice.emplace(m_graphicsConfig);
g_update.emplace(g_graphicsDevice->GetUpdate("update"));
}
else
{
g_graphics->UpdateWindow(m_windowConfig);
g_graphics->UpdateSize(m_windowConfig.Width, m_windowConfig.Height);
g_graphicsDevice->UpdateWindow(m_graphicsConfig.Window);
g_graphicsDevice->UpdateSize(m_graphicsConfig.Width, m_graphicsConfig.Height);
}
g_graphics->UpdateMSAA(mMSAAValue);
g_graphics->UpdateAlphaPremultiplied(mAlphaPremultiplied);
g_graphicsDevice->UpdateMSAA(mMSAAValue);
g_graphicsDevice->UpdateAlphaPremultiplied(mAlphaPremultiplied);

g_graphics->EnableRendering();
g_graphicsDevice->EnableRendering();

std::call_once(m_isGraphicsInitialized, [this]()
{
m_jsDispatcher([this]()
{
g_graphics->AddToJavaScript(m_env);
g_graphicsDevice->AddToJavaScript(m_env);
Babylon::Plugins::NativeEngine::Initialize(m_env);
});
});
Expand All @@ -121,18 +121,18 @@ namespace BabylonNative
void UpdateMSAA(uint8_t value)
{
mMSAAValue = value;
if (g_graphics)
if (g_graphicsDevice)
{
g_graphics->UpdateMSAA(value);
g_graphicsDevice->UpdateMSAA(value);
}
}

void UpdateAlphaPremultiplied(bool enabled)
{
mAlphaPremultiplied = enabled;
if (g_graphics)
if (g_graphicsDevice)
{
g_graphics->UpdateAlphaPremultiplied(enabled);
g_graphicsDevice->UpdateAlphaPremultiplied(enabled);
}
}

Expand All @@ -144,12 +144,12 @@ namespace BabylonNative
}
// If rendering has not been explicitly enabled, or has been explicitly disabled, then don't try to render.
// Otherwise rendering can be implicitly enabled, which may not be desirable (e.g. after the engine is disposed).
if (g_graphics && m_isRenderingEnabled)
if (g_graphicsDevice && m_isRenderingEnabled)
{
g_graphics->StartRenderingCurrentFrame();
g_graphicsDevice->StartRenderingCurrentFrame();
g_update->Start();
g_update->Finish();
g_graphics->FinishRenderingCurrentFrame();
g_graphicsDevice->FinishRenderingCurrentFrame();
}
}

Expand All @@ -160,10 +160,10 @@ namespace BabylonNative

void ResetView()
{
if (g_graphics)
if (g_graphicsDevice)
{
g_nativeCanvas->FlushGraphicResources();
g_graphics->DisableRendering();
g_graphicsDevice->DisableRendering();
}

m_isRenderingEnabled = false;
Expand Down Expand Up @@ -264,7 +264,7 @@ namespace BabylonNative
Babylon::Plugins::NativeInput* m_nativeInput{};
std::optional<Babylon::Plugins::NativeXr> m_nativeXr{};

Babylon::Graphics::WindowConfiguration m_windowConfig{};
Babylon::Graphics::Configuration m_graphicsConfig{};

std::shared_ptr<bool> m_isXRActive{};
uint8_t mMSAAValue{};
Expand Down