Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
3b32c52
Add external texture array render test and fix numLayers bug
bghgary Mar 25, 2026
117f588
Fix Update signature on Metal, D3D12, and OpenGL backends
bghgary Mar 25, 2026
e616594
Update all callers to use new sync ExternalTexture API
bghgary Mar 25, 2026
2628906
Fix D3D12/Linux builds: guard RenderDoc for D3D11 only, update all ca…
bghgary Mar 25, 2026
0c45a8c
Fix OpenGL build: use portable cast for TextureT to uintptr_t
bghgary Mar 25, 2026
271adaa
Make RenderDoc support API-agnostic (D3D11, D3D12, Vulkan, OpenGL)
bghgary Mar 25, 2026
e103f3e
Remove accidentally committed test artifact
bghgary Mar 25, 2026
bb4ec86
Fix test ordering: finish frame before destroying native texture
bghgary Mar 25, 2026
a1e534c
Add shaderCache.bin to .gitignore
bghgary Mar 25, 2026
38590d9
Fix startup ordering: wait for JS before ending frame
bghgary Mar 25, 2026
92a533c
Fix CI crashes: simplify D3D11 test, revert to single-call texture cr…
bghgary Mar 25, 2026
752cfb8
Fix duplicate test name: rename to CreateForJavaScriptD3D11
bghgary Mar 25, 2026
dfb4018
Remove D3D11-specific ExternalTexture test (covered by cross-platform…
bghgary Mar 25, 2026
1114f20
Log bgfx fatal errors to stderr before crashing
bghgary Mar 25, 2026
0e3f97b
Enable D3D debug layer on CI and revert to _external texture path
bghgary Mar 25, 2026
ba78cdf
Skip render test on CI (WARP SRV issue), keep _external path
bghgary Mar 25, 2026
0d96409
Use overrideInternal for CreateForJavaScript (fixes WARP)
bghgary Mar 25, 2026
3e3abfc
Add extra frame pump in PrecompiledShaderTest for overrideInternal
bghgary Mar 25, 2026
0b309bc
Fix Install CMake, add frame pump to all ExternalTexture callers
bghgary Mar 25, 2026
ca85709
Reworked threading model.
bkaradzic Mar 25, 2026
9daf790
Added first frame started check.
bkaradzic Apr 6, 2026
9fa86ff
Fixed ordering.
bkaradzic Apr 8, 2026
55712c8
Capture just POD values.
bkaradzic Apr 8, 2026
b80caa4
Removed unused captures.
bkaradzic Apr 8, 2026
a2b1679
Fix null encoder crash in Canvas::Flush by adding defensive check aft…
bkaradzic Apr 8, 2026
05e682b
Fix LoadCubeTexture*.
bkaradzic Mar 12, 2026
212eb4a
Fix null encoder crash in SubmitCommands by using stack-scoped FrameC…
bkaradzic Apr 8, 2026
ed656eb
Always acquire FrameCompletionScope in SubmitCommands to prevent enco…
bkaradzic Apr 8, 2026
8cb30d5
Revert "Fix LoadCubeTexture*."
bkaradzic Apr 8, 2026
3d491d8
Pump frames in JavaScript unit test to prevent deadlock from always-a…
bkaradzic Apr 8, 2026
bf32f2d
Fix unit test shutdown race by using 16ms frame interval instead of s…
bkaradzic Apr 8, 2026
eb86445
Keep frame open during unit test shutdown to prevent JS thread deadlo…
bkaradzic Apr 9, 2026
d5560b6
Fix PrecompiledShaderTest deadlock by keeping frame open during start…
bkaradzic Apr 9, 2026
c73534c
Revert ReadTexture to inline blit with FrameCompletionScope — BeforeR…
bkaradzic Apr 9, 2026
935bf4a
Discard encoder state before Canvas Flush to prevent NativeEngine sta…
bkaradzic Apr 9, 2026
e97bfdc
Add FrameCompletionScope to ReadTexture — called during init and from…
bkaradzic Apr 9, 2026
16a3324
Merge remote-tracking branch 'origin/master' into external-texture-re…
bghgary Apr 22, 2026
0c1f999
Revert WARP workaround: bgfx update (#1669) fixed CreateShaderResourc…
bghgary Apr 22, 2026
a92a2f5
Cleanup: drop stale overrideInternal references
bghgary Apr 22, 2026
804a5f0
Revert shaderCache.bin .gitignore (out of scope; fixed in separate PR)
bghgary Apr 22, 2026
d78c3e1
Run render tests on Win32 CI
bghgary Apr 22, 2026
a641589
Merge remote-tracking branch 'origin/master' into external-texture-re…
bghgary Apr 22, 2026
80676a5
Address review feedback
bghgary Apr 22, 2026
f667490
Address reviewer feedback
bghgary Apr 23, 2026
ac6ba6e
Address reviewer feedback round 2
bghgary Apr 23, 2026
8a519b7
Merge remote-tracking branch 'origin/rework-thread-model' into partne…
bghgary Apr 23, 2026
4c79b1d
Merge branch 'external-texture-render-test' into partner-test-1652-1646
bghgary Apr 23, 2026
e453e9d
Wait for JS Dispatch before finishing frame in ExternalTexture tests.
bghgary Apr 23, 2026
996c1ad
Merge branch 'external-texture-render-test' into partner-test-1652-1646
bghgary Apr 23, 2026
dd75619
Add regression test for ExternalTexture::CreateForJavaScript recursiv…
bghgary Apr 27, 2026
415f193
Resolve DeviceContext before locking impl in CreateForJavaScript
bghgary Apr 27, 2026
2d3e549
Skip ExternalTexture lock-probe test on JSI build
bghgary Apr 27, 2026
148df39
Remove ExternalTexture lock-probe regression test
bghgary Apr 27, 2026
04bfb6b
Encapsulate ExternalTexture::Impl mutex inside the impl
bghgary Apr 27, 2026
bac5c8e
Inline static_cast in CreateTexture
bghgary Apr 27, 2026
f2c0c95
Merge branch 'external-texture-render-test' into partner-test-1652-1646
bghgary Apr 27, 2026
bb6b0a8
Merge remote-tracking branch 'origin/master' into partner-test-1652-1646
bghgary Apr 27, 2026
1528700
Merge remote-tracking branch 'origin/master' into partner-test-1652-1646
bghgary Apr 27, 2026
282a9a6
Apps/UnitTests: hold the frame open across the JS test pump
bghgary Apr 29, 2026
55f1461
Apps/UnitTests: hold the frame open across the JS test pump
bghgary Apr 29, 2026
68e3506
Apps: fix dispatch ordering merge artifact between #1652 and #1646
bghgary Apr 29, 2026
ede3565
Merge origin/master into rework-thread-model-pump-fix
bghgary Apr 29, 2026
1804e4a
Merge rework-thread-model-pump-fix: master integration + pump fix
bghgary Apr 29, 2026
7f98c7c
NativeEngine: hold FrameCompletionScope across the JS-thread frame
bghgary May 4, 2026
0ba1c1a
Merge rework-thread-model-pump-fix: SubmitCommands scope fix
bghgary May 4, 2026
bb16582
NativeEngine: fix Linux gcc build of SubmitCommands scope capture, re…
bghgary May 4, 2026
19353eb
Merge rework-thread-model-pump-fix: gcc fix + doc refresh
bghgary May 4, 2026
606369a
NativeEngine: dispatch the SubmitCommands frame scope at the top
bghgary May 4, 2026
a8006e9
Merge rework-thread-model-pump-fix: dispatch scope at top of SubmitCo…
bghgary May 4, 2026
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
46 changes: 21 additions & 25 deletions Apps/HeadlessScreenshotApp/Win32/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,41 +127,37 @@ int main()
// Create a render target texture for the output.
winrt::com_ptr<ID3D11Texture2D> outputTexture = CreateD3DRenderTargetTexture(d3dDevice.get());

std::promise<void> addToContext{};
// 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{};

// Create an external texture for the render target texture and pass it to
// the `startup` JavaScript function.
loader.Dispatch([externalTexture = Babylon::Plugins::ExternalTexture{outputTexture.get()}, &addToContext, &startup](Napi::Env env) {
auto jsPromise = externalTexture.AddToContextAsync(env);
addToContext.set_value();

auto jsOnFulfilled = Napi::Function::New(env, [&startup](const Napi::CallbackInfo& info) {
auto nativeTexture = info[0];
info.Env().Global().Get("startup").As<Napi::Function>().Call(
{
nativeTexture,
Napi::Value::From(info.Env(), WIDTH),
Napi::Value::From(info.Env(), HEIGHT),
});
startup.set_value();
});

jsPromise = jsPromise.Get("then").As<Napi::Function>().Call(jsPromise, {jsOnFulfilled}).As<Napi::Promise>();

CatchAndLogError(jsPromise);
loader.Dispatch([externalTexture = Babylon::Plugins::ExternalTexture{outputTexture.get()}, &startup](Napi::Env env) {
auto nativeTexture = externalTexture.CreateForJavaScript(env);
env.Global().Get("startup").As<Napi::Function>().Call(
{
nativeTexture,
Napi::Value::From(env, WIDTH),
Napi::Value::From(env, HEIGHT),
});
startup.set_value();
});

// Wait for `AddToContextAsync` to be called.
addToContext.get_future().wait();
// Wait for `startup` to finish.
startup.get_future().wait();

// Render a frame so that `AddToContextAsync` will complete.
// Close the startup frame.
deviceUpdate.Finish();
device.FinishRenderingCurrentFrame();

// Wait for `startup` to finish.
startup.get_future().wait();

struct Asset
{
const char* Name;
Expand Down
45 changes: 21 additions & 24 deletions Apps/PrecompiledShaderTest/Source/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,40 +135,37 @@ int RunApp(
Babylon::ScriptLoader loader{runtime};
loader.LoadScript("app:///index.js");

std::promise<void> addToContext{};
// 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{};

// Create an external texture for the render target texture and pass it to
// the `startup` JavaScript function.
loader.Dispatch([externalTexture = std::move(externalTexture), &addToContext, &startup](Napi::Env env) {
auto jsPromise = externalTexture.AddToContextAsync(env);
addToContext.set_value();

auto jsOnFulfilled = Napi::Function::New(env, [&startup](const Napi::CallbackInfo& info) {
auto nativeTexture = info[0];
info.Env().Global().Get("startup").As<Napi::Function>().Call(
{
nativeTexture,
Napi::Value::From(info.Env(), WIDTH),
Napi::Value::From(info.Env(), HEIGHT),
});
startup.set_value();
});

jsPromise = jsPromise.Get("then").As<Napi::Function>().Call(jsPromise, {jsOnFulfilled}).As<Napi::Promise>();
CatchAndLogError(jsPromise);
loader.Dispatch([externalTexture = std::move(externalTexture), &startup](Napi::Env env) {
auto nativeTexture = externalTexture.CreateForJavaScript(env);
env.Global().Get("startup").As<Napi::Function>().Call(
{
nativeTexture,
Napi::Value::From(env, WIDTH),
Napi::Value::From(env, HEIGHT),
});
startup.set_value();
});

// Wait for `AddToContextAsync` to be called.
addToContext.get_future().wait();
// Wait for `startup` to finish.
startup.get_future().wait();

// Render a frame so that `AddToContextAsync` will complete.
// Close the startup frame.
deviceUpdate.Finish();
device.FinishRenderingCurrentFrame();

// Wait for `startup` to finish.
startup.get_future().wait();

// Start a new frame for rendering the scene.
device.StartRenderingCurrentFrame();
deviceUpdate.Start();
Expand Down
42 changes: 21 additions & 21 deletions Apps/StyleTransferApp/Win32/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,37 +334,37 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
loader.LoadScript("app:///Scripts/babylonjs.loaders.js");
loader.LoadScript("app:///Scripts/index.js");

std::promise<void> addToContext{};
// 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{};

// Create an external texture for the render target texture and pass it to
// the `startup` JavaScript function.
loader.Dispatch([externalTexture = Babylon::Plugins::ExternalTexture{g_BabylonRenderTexture.get()}, &addToContext, &startup](Napi::Env env) {
auto jsPromise = externalTexture.AddToContextAsync(env);
addToContext.set_value();

jsPromise.Get("then").As<Napi::Function>().Call(jsPromise, {Napi::Function::New(env, [&startup](const Napi::CallbackInfo& info) {
auto nativeTexture = info[0];
info.Env().Global().Get("startup").As<Napi::Function>().Call(
{
nativeTexture,
Napi::Value::From(info.Env(), WIDTH),
Napi::Value::From(info.Env(), HEIGHT),
});
startup.set_value();
})});
loader.Dispatch([externalTexture = Babylon::Plugins::ExternalTexture{g_BabylonRenderTexture.get()}, &startup](Napi::Env env) {
auto nativeTexture = externalTexture.CreateForJavaScript(env);
env.Global().Get("startup").As<Napi::Function>().Call(
{
nativeTexture,
Napi::Value::From(env, WIDTH),
Napi::Value::From(env, HEIGHT),
});
startup.set_value();
});

// Wait for `AddToContextAsync` to be called.
addToContext.get_future().wait();
// Wait for `startup` to finish.
startup.get_future().wait();

// Render a frame so that `AddToContextAsync` will complete.
// Close the startup frame.
g_update->Finish();
g_device->FinishRenderingCurrentFrame();

// Wait for `startup` to finish.
startup.get_future().wait();

// --------------------------- Rendering loop -------------------------

HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_PLAYGROUNDWIN32));
Expand Down
15 changes: 12 additions & 3 deletions Apps/UnitTests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ set(BABYLONJS_MATERIALS_ASSETS
"../node_modules/babylonjs-materials/babylonjs.materials.js")

set(TEST_ASSETS
"JavaScript/dist/tests.externalTexture.render.js"
"JavaScript/dist/tests.javaScript.all.js"
"JavaScript/dist/tests.shaderCache.basicScene.js")

set(SOURCES
"Source/App.h"
"Source/App.cpp"
"Source/Tests.ExternalTexture.cpp"
"Source/Tests.ExternalTexture.Render.cpp"
"Source/Tests.JavaScript.cpp"
"Source/Tests.ShaderCache.cpp"
"Source/Tests.UniformPadding.cpp"
Expand All @@ -26,8 +28,7 @@ set(SOURCES

if(GRAPHICS_API STREQUAL "D3D11")
set(SOURCES ${SOURCES}
"Source/Tests.Device.${GRAPHICS_API}.cpp"
"Source/Tests.ExternalTexture.${GRAPHICS_API}.cpp")
"Source/Tests.Device.${GRAPHICS_API}.cpp")
endif()

if(APPLE)
Expand All @@ -43,7 +44,11 @@ elseif(UNIX AND NOT ANDROID)
set(SOURCES ${SOURCES} "Source/App.X11.cpp")
set(ADDITIONAL_COMPILE_DEFINITIONS PRIVATE SKIP_EXTERNAL_TEXTURE_TESTS)
elseif(WIN32)
set(SOURCES ${SOURCES} "Source/App.Win32.cpp")
set(SOURCES ${SOURCES}
"Source/App.Win32.cpp"
"Source/RenderDoc.h"
"Source/RenderDoc.cpp")
set(ADDITIONAL_COMPILE_DEFINITIONS ${ADDITIONAL_COMPILE_DEFINITIONS} PRIVATE HAS_RENDERDOC)
endif()

add_executable(UnitTests ${BABYLONJS_ASSETS} ${BABYLONJS_MATERIALS_ASSETS} ${TEST_ASSETS} ${SOURCES})
Expand All @@ -65,6 +70,10 @@ target_link_libraries(UnitTests

target_compile_definitions(UnitTests PRIVATE ${ADDITIONAL_COMPILE_DEFINITIONS})

if(GRAPHICS_API STREQUAL "D3D12")
target_compile_definitions(UnitTests PRIVATE SKIP_RENDER_TESTS)
endif()

add_test(NAME UnitTests COMMAND UnitTests)

# See https://gitlab.kitware.com/cmake/cmake/-/issues/23543
Expand Down
Loading