Skip to content

Commit 0ded041

Browse files
bghgaryCopilot
andauthored
Add ExternalTexture MSAA render unit tests (#1712)
## Context Coverage for MSAA + ExternalTexture rendering. Both tests pass on master on D3D11 today; this PR characterizes what works so future device-loss / `updateWrappedNativeTexture` MSAA work has a regression baseline. ## Changes Two new gtest cases in `Tests.ExternalTexture.Msaa.cpp` that drive a JS-side `RenderTargetTexture` whose `colorAttachment` is a `wrapNativeTexture` over an MSAA GPU texture, then read back the pixels (resolving MSAA before staging): - `RenderWithMsaaSamples1` -- discriminator, asserts zero blend pixels along the rotated red-plane edges so the samples=4 case is diagnostic. - `RenderWithMsaaSamples4` -- asserts red/white blend pixels along the same edges. Cross-platform per the convention #1646 establishes: file lives in shared `SOURCES`, gated by `SKIP_EXTERNAL_TEXTURE_TESTS` / `SKIP_RENDER_TESTS`. CMake defines `SKIP_RENDER_TESTS` for D3D12 (no impl). Renames `Utils.{h,cpp,mm}` -> `Helpers.{h,cpp,mm}` under `namespace Helpers`. Collapses `CreateTestTexture` and the new MSAA-RT helper into one `Helpers::CreateTexture(d, w, h, arraySize=1, renderTarget=false, samples=1)`. Adds `Helpers::ReadPixels` taking `PlatformInfo` so the Metal path can use bgfx's command queue (avoids cross-queue sync). Implemented on D3D11 and Metal; D3D12 / OpenGL throw (test skipped on those configurations). Will conflict with #1646 on `Helpers.h` / `Helpers.D3D11.cpp` / `CMakeLists.txt` -- whichever lands first picks a winner. [Created by Copilot on behalf of @bghgary] --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent a400a90 commit 0ded041

19 files changed

Lines changed: 1206 additions & 126 deletions

Apps/UnitTests/CMakeLists.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ set(BABYLONJS_MATERIALS_ASSETS
1111
"../node_modules/babylonjs-materials/babylonjs.materials.js")
1212

1313
set(TEST_ASSETS
14+
"JavaScript/dist/tests.externalTexture.msaa.js"
1415
"JavaScript/dist/tests.javaScript.all.js"
1516
"JavaScript/dist/tests.shaderCache.basicScene.js"
1617
"JavaScript/dist/tests.shaders.cross.js")
@@ -22,12 +23,13 @@ set(SOURCES
2223
"Source/App.h"
2324
"Source/App.cpp"
2425
"Source/Tests.ExternalTexture.cpp"
26+
"Source/Tests.ExternalTexture.Msaa.cpp"
2527
"Source/Tests.JavaScript.cpp"
2628
"Source/Tests.ShaderCache.cpp"
2729
"Source/Tests.ShaderCompilation.cpp"
2830
"Source/Tests.UniformPadding.cpp"
29-
"Source/Utils.h"
30-
"Source/Utils.${GRAPHICS_API}.${BABYLON_NATIVE_PLATFORM_IMPL_EXT}")
31+
"Source/Helpers.h"
32+
"Source/Helpers.${GRAPHICS_API}.${BABYLON_NATIVE_PLATFORM_IMPL_EXT}")
3133

3234
if(GRAPHICS_API STREQUAL "D3D11")
3335
set(SOURCES ${SOURCES}
@@ -70,6 +72,10 @@ target_link_libraries(UnitTests
7072

7173
target_compile_definitions(UnitTests PRIVATE ${ADDITIONAL_COMPILE_DEFINITIONS})
7274

75+
if(GRAPHICS_API STREQUAL "D3D12")
76+
target_compile_definitions(UnitTests PRIVATE SKIP_RENDER_TESTS)
77+
endif()
78+
7379
add_test(NAME UnitTests COMMAND UnitTests)
7480

7581
# See https://gitlab.kitware.com/cmake/cmake/-/issues/23543

0 commit comments

Comments
 (0)