Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 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
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
f20f5d9
Enable Unit Tests on Win32 D3D12 CI
bghgary Apr 22, 2026
f667490
Address reviewer feedback
bghgary Apr 23, 2026
6818785
Merge external-texture-render-test for reviewer-feedback fixes
bghgary Apr 23, 2026
ac6ba6e
Address reviewer feedback round 2
bghgary Apr 23, 2026
4359aa0
Merge branch 'external-texture-render-test' into enable-d3d12-unit-tests
bghgary Apr 23, 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
1 change: 0 additions & 1 deletion .github/workflows/build-win32.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ jobs:
Copy-Item -Path "build\${{ steps.vars.outputs.solution_name }}\Apps\Playground\RelWithDebInfo\Playground.*" -Destination "$env:RUNNER_TEMP\Dumps\" -ErrorAction SilentlyContinue

- name: Unit Tests
if: ${{ inputs.graphics-api != 'D3D12' }}
shell: cmd
run: |
cd build\${{ steps.vars.outputs.solution_name }}\Apps\UnitTests\RelWithDebInfo
Expand Down
33 changes: 9 additions & 24 deletions Apps/HeadlessScreenshotApp/Win32/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,39 +127,24 @@ int main()
// Create a render target texture for the output.
winrt::com_ptr<ID3D11Texture2D> outputTexture = CreateD3DRenderTargetTexture(d3dDevice.get());

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

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

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

struct Asset
Expand Down
32 changes: 9 additions & 23 deletions Apps/PrecompiledShaderTest/Source/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,38 +135,24 @@ int RunApp(
Babylon::ScriptLoader loader{runtime};
loader.LoadScript("app:///index.js");

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

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

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

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

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

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

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

// --------------------------- Rendering loop -------------------------
Expand Down
27 changes: 24 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 All @@ -80,6 +89,18 @@ if(ANGLE_LIBEGL)
)
endif()

if(WIN32 AND GRAPHICS_API STREQUAL "D3D12")
# bgfx's D3D12 renderer uses DXC for runtime shader compilation.
# dxcompiler.dll + dxil.dll aren't part of Windows, so deploy the copies shipped with bgfx.
FetchContent_GetProperties(bgfx.cmake SOURCE_DIR BGFX_CMAKE_SOURCE_DIR)
set(BGFX_DXC_DLL_DIR "${BGFX_CMAKE_SOURCE_DIR}/bgfx/tools/bin/windows")
add_custom_command(TARGET UnitTests POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${BGFX_DXC_DLL_DIR}/dxcompiler.dll" "$<TARGET_FILE_DIR:UnitTests>"
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${BGFX_DXC_DLL_DIR}/dxil.dll" "$<TARGET_FILE_DIR:UnitTests>"
COMMENT "Copying DXC runtime DLLs for D3D12"
)
endif()

foreach(ASSET ${BABYLONJS_ASSETS} ${BABYLONJS_MATERIALS_ASSETS} ${TEST_ASSETS})
get_filename_component(ASSET_NAME "${ASSET}" NAME)
add_custom_command(
Expand Down
Loading