Skip to content
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
7 changes: 0 additions & 7 deletions Apps/HeadlessScreenshotApp/Win32/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,10 @@ int main()

// Create the Babylon Native graphics device and update.
auto device = CreateGraphicsDevice(d3dDevice.get());
auto deviceUpdate = device.GetUpdate("update");

// Start rendering a frame to unblock the JavaScript from queuing graphics
// commands.
device.StartRenderingCurrentFrame();
deviceUpdate.Start();

// Create a Babylon Native application runtime which hosts a JavaScript
// engine on a new thread.
Expand Down Expand Up @@ -128,13 +126,11 @@ int main()
winrt::com_ptr<ID3D11Texture2D> outputTexture = CreateD3DRenderTargetTexture(d3dDevice.get());

// Close the script-load frame.
deviceUpdate.Finish();
device.FinishRenderingCurrentFrame();

// Open a new frame for `startup` so the JS-side resource creation and
// startup() call run in the same frame as the wait that observes them.
device.StartRenderingCurrentFrame();
deviceUpdate.Start();

std::promise<void> startup{};

Expand All @@ -155,7 +151,6 @@ int main()
startup.get_future().wait();

// Close the startup frame.
deviceUpdate.Finish();
device.FinishRenderingCurrentFrame();

struct Asset
Expand All @@ -177,7 +172,6 @@ int main()

// Start rendering a frame to unblock the JavaScript again.
device.StartRenderingCurrentFrame();
deviceUpdate.Start();

std::promise<void> loadAndRenderAsset{};

Expand All @@ -200,7 +194,6 @@ int main()
loadAndRenderAsset.get_future().wait();

// Finish rendering the frame.
deviceUpdate.Finish();
device.FinishRenderingCurrentFrame();

// Tell RenderDoc to stop capturing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,8 @@ extern "C"
{
if (appContext)
{
appContext->DeviceUpdate().Finish();
appContext->Device().FinishRenderingCurrentFrame();
appContext->Device().StartRenderingCurrentFrame();
appContext->DeviceUpdate().Start();
}
}

Expand Down
4 changes: 0 additions & 4 deletions Apps/Playground/Shared/AppContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ AppContext::AppContext(
graphicsConfig.MSAASamples = 4;

m_device.emplace(graphicsConfig);
m_deviceUpdate.emplace(m_device->GetUpdate("update"));

// Mirror bgfx trace output (BgfxCallback::traceVargs) to debugLog so it
// reaches stdout in headless mode, not just OutputDebugString.
Expand All @@ -89,7 +88,6 @@ AppContext::AppContext(
Babylon::Plugins::ShaderCache::Enable();

m_device->StartRenderingCurrentFrame();
m_deviceUpdate->Start();

Babylon::AppRuntime::Options options{};

Expand Down Expand Up @@ -228,7 +226,6 @@ AppContext::~AppContext()
{
if (m_device)
{
m_deviceUpdate->Finish();
m_device->FinishRenderingCurrentFrame();
}

Expand All @@ -238,6 +235,5 @@ AppContext::~AppContext()
m_canvas.reset();
m_input = {};
m_runtime.reset();
m_deviceUpdate.reset();
m_device.reset();
}
2 changes: 0 additions & 2 deletions Apps/Playground/Shared/AppContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,13 @@ class AppContext
AppContext& operator=(AppContext&&) noexcept = delete;

Babylon::Graphics::Device& Device() { return *m_device; }
Babylon::Graphics::DeviceUpdate& DeviceUpdate() { return *m_deviceUpdate; }
Babylon::AppRuntime& Runtime() { return *m_runtime; }
Babylon::Polyfills::Canvas& Canvas() { return *m_canvas; }
Babylon::Plugins::NativeInput* Input() { return m_input; }
Babylon::ScriptLoader& ScriptLoader() { return *m_scriptLoader; }

private:
std::optional<Babylon::Graphics::Device> m_device;
std::optional<Babylon::Graphics::DeviceUpdate> m_deviceUpdate;
std::optional<Babylon::AppRuntime> m_runtime;
std::optional<Babylon::Polyfills::Canvas> m_canvas;
Babylon::Plugins::NativeInput* m_input{};
Expand Down
4 changes: 0 additions & 4 deletions Apps/Playground/UWP/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,8 @@ void App::Run()
{
if (m_appContext)
{
m_appContext->DeviceUpdate().Finish();
m_appContext->Device().FinishRenderingCurrentFrame();
m_appContext->Device().StartRenderingCurrentFrame();
m_appContext->DeviceUpdate().Start();
}

CoreWindow::GetForCurrentThread().Dispatcher().ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);
Expand Down Expand Up @@ -156,7 +154,6 @@ void App::OnSuspending(IInspectable const& /*sender*/, SuspendingEventArgs const

if (m_appContext)
{
m_appContext->DeviceUpdate().Finish();
m_appContext->Device().FinishRenderingCurrentFrame();

m_appContext->Runtime().Suspend();
Expand All @@ -175,7 +172,6 @@ void App::OnResuming(IInspectable const& /*sender*/, IInspectable const& /*args*
m_appContext->Runtime().Resume();

m_appContext->Device().StartRenderingCurrentFrame();
m_appContext->DeviceUpdate().Start();
}
}

Expand Down
4 changes: 0 additions & 4 deletions Apps/Playground/Win32/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,8 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
{
if (appContext)
{
appContext->DeviceUpdate().Finish();
appContext->Device().FinishRenderingCurrentFrame();
appContext->Device().StartRenderingCurrentFrame();
appContext->DeviceUpdate().Start();
}

result = PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE) && msg.message != WM_QUIT;
Expand Down Expand Up @@ -340,7 +338,6 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if (appContext)
{
appContext->DeviceUpdate().Finish();
appContext->Device().FinishRenderingCurrentFrame();

appContext->Runtime().Suspend();
Expand All @@ -359,7 +356,6 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
appContext->Runtime().Resume();

appContext->Device().StartRenderingCurrentFrame();
appContext->DeviceUpdate().Start();
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions Apps/Playground/X11/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,8 @@ int main(int _argc, const char* const* _argv)
{
if (!XPending(display) && g_appContext)
{
g_appContext->DeviceUpdate().Finish();
g_appContext->Device().FinishRenderingCurrentFrame();
g_appContext->Device().StartRenderingCurrentFrame();
g_appContext->DeviceUpdate().Start();
}
else
{
Expand Down
4 changes: 0 additions & 4 deletions Apps/Playground/iOS/LibNativeBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,20 @@ - (void)resize:(int)inWidth height:(int)inHeight
{
if (appContext)
{
appContext->DeviceUpdate().Finish();
appContext->Device().FinishRenderingCurrentFrame();

appContext->Device().UpdateSize(static_cast<size_t>(inWidth), static_cast<size_t>(inHeight));

appContext->Device().StartRenderingCurrentFrame();
appContext->DeviceUpdate().Start();
}
}

- (void)render
{
if (appContext)
{
appContext->DeviceUpdate().Finish();
appContext->Device().FinishRenderingCurrentFrame();
appContext->Device().StartRenderingCurrentFrame();
appContext->DeviceUpdate().Start();
}
}

Expand Down
4 changes: 0 additions & 4 deletions Apps/Playground/macOS/ViewController.mm
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,19 @@ @implementation EngineView
- (void)mtkView:(MTKView *)__unused view drawableSizeWillChange:(CGSize) size
{
if (appContext) {
appContext->DeviceUpdate().Finish();
appContext->Device().FinishRenderingCurrentFrame();

appContext->Device().UpdateSize(static_cast<size_t>(size.width), static_cast<size_t>(size.height));

appContext->Device().StartRenderingCurrentFrame();
appContext->DeviceUpdate().Start();
}
}

- (void)drawInMTKView:(MTKView *)__unused view
{
if (appContext) {
appContext->DeviceUpdate().Finish();
appContext->Device().FinishRenderingCurrentFrame();
appContext->Device().StartRenderingCurrentFrame();
appContext->DeviceUpdate().Start();
}
}

Expand Down
4 changes: 0 additions & 4 deletions Apps/Playground/visionOS/LibNativeBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,11 @@ - (bool)initializeWithWidth:(NSInteger)width height:(NSInteger)height {

- (void)drawableWillChangeSizeWithWidth:(NSInteger)width height:(NSInteger)height {
if (_appContext) {
_appContext->DeviceUpdate().Finish();
_appContext->Device().FinishRenderingCurrentFrame();

_appContext->Device().UpdateSize(static_cast<size_t>(width), static_cast<size_t>(height));

_appContext->Device().StartRenderingCurrentFrame();
_appContext->DeviceUpdate().Start();
}
}

Expand All @@ -67,10 +65,8 @@ - (void)setTouchUp:(int)pointerId x:(int)inX y:(int)inY {

- (void)render {
if (_appContext && self.initialized) {
_appContext->DeviceUpdate().Finish();
_appContext->Device().FinishRenderingCurrentFrame();
_appContext->Device().StartRenderingCurrentFrame();
_appContext->DeviceUpdate().Start();
}
}

Expand Down
7 changes: 0 additions & 7 deletions Apps/PrecompiledShaderTest/Source/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,10 @@ int RunApp(

// Create the Babylon Native graphics device and update.
auto device = Babylon::Graphics::Device(config);
auto deviceUpdate = device.GetUpdate("update");

// Start rendering a frame to unblock the JavaScript from queuing graphics
// commands.
device.StartRenderingCurrentFrame();
deviceUpdate.Start();

// Create a Babylon Native application runtime which hosts a JavaScript
// engine on a new thread.
Expand Down Expand Up @@ -136,13 +134,11 @@ int RunApp(
loader.LoadScript("app:///index.js");

// Close the script-load frame.
deviceUpdate.Finish();
device.FinishRenderingCurrentFrame();

// Open a new frame for `startup` so the JS-side resource creation and
// startup() call run in the same frame as the wait that observes them.
device.StartRenderingCurrentFrame();
deviceUpdate.Start();

std::promise<void> startup{};

Expand All @@ -163,12 +159,10 @@ int RunApp(
startup.get_future().wait();

// Close the startup frame.
deviceUpdate.Finish();
device.FinishRenderingCurrentFrame();

// Start a new frame for rendering the scene.
device.StartRenderingCurrentFrame();
deviceUpdate.Start();

std::promise<void> renderScene{};

Expand All @@ -190,7 +184,6 @@ int RunApp(
renderScene.get_future().wait();

// Finish the frame.
deviceUpdate.Finish();
device.FinishRenderingCurrentFrame();

// Save the rendered output as a PNG.
Expand Down
15 changes: 1 addition & 14 deletions Apps/StyleTransferApp/Win32/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ namespace
WCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name

std::optional<Babylon::Graphics::Device> g_device{};
std::optional<Babylon::Graphics::DeviceUpdate> g_update{};
Babylon::Plugins::NativeInput* g_nativeInput{};
std::optional<Babylon::AppRuntime> g_runtime{};
bool g_minimized{false};
Expand Down Expand Up @@ -219,13 +218,11 @@ namespace
{
if (g_device)
{
g_update->Finish();
g_device->FinishRenderingCurrentFrame();
}

g_nativeInput = {};
g_runtime.reset();
g_update.reset();
g_device.reset();
}

Expand Down Expand Up @@ -300,12 +297,10 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
// --------------------- Babylon Native initialization --------------------------

g_device = CreateBabylonGraphicsDevice(d3d11Device.get());
g_update.emplace(g_device->GetUpdate("update"));

// Start rendering a frame to unblock the JavaScript from queuing graphics
// commands.
g_device->StartRenderingCurrentFrame();
g_update->Start();

// Create a Babylon Native application runtime which hosts a JavaScript
// engine on a new thread.
Expand Down Expand Up @@ -335,13 +330,11 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
loader.LoadScript("app:///Scripts/index.js");

// Close the script-load frame.
g_update->Finish();
g_device->FinishRenderingCurrentFrame();

// Open a new frame for `startup` so the JS-side resource creation and
// startup() call run in the same frame as the wait that observes them.
g_device->StartRenderingCurrentFrame();
g_update->Start();

std::promise<void> startup{};

Expand All @@ -362,7 +355,6 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
startup.get_future().wait();

// Close the startup frame.
g_update->Finish();
g_device->FinishRenderingCurrentFrame();

// --------------------------- Rendering loop -------------------------
Expand All @@ -372,7 +364,6 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
MSG msg{};

g_device->StartRenderingCurrentFrame();
g_update->Start();

// Main message loop:
while (msg.message != WM_QUIT)
Expand All @@ -388,7 +379,6 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
if (g_device)
{
// Finish Babylon Native rendering.
g_update->Finish();
g_device->FinishRenderingCurrentFrame();

if (g_selectedModel >= 0)
Expand All @@ -406,7 +396,6 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
// Present and start rendering next frame.
swapChain->Present(1, 0);
g_device->StartRenderingCurrentFrame();
g_update->Start();
}

result = PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE) && msg.message != WM_QUIT;
Expand Down Expand Up @@ -460,7 +449,6 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if (g_device)
{
g_update->Finish();
g_device->FinishRenderingCurrentFrame();
}

Expand All @@ -479,7 +467,6 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
if (g_device)
{
g_device->StartRenderingCurrentFrame();
g_update->Start();
}
}
}
Expand Down Expand Up @@ -601,4 +588,4 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
}
}
return 0;
}
}
Loading