Skip to content

Support standalone sampleable native depth textures - #1886

Merged
bkaradzic-microsoft merged 2 commits into
BabylonJS:masterfrom
bkaradzic-microsoft:pr/native-sampleable-depth
Sep 18, 2026
Merged

bkaradzic-microsoft merged 2 commits into
BabylonJS:masterfrom
bkaradzic-microsoft:pr/native-sampleable-depth

Conversation

@bkaradzic-microsoft

@bkaradzic-microsoft bkaradzic-microsoft commented Sep 17, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Recognize the standalone depth-texture request already issued by Babylon.js: createFrameBuffer receives a freshly created, uninitialized native texture.
  • Do not attach that invalid handle as a color target. Allocate readable depth storage and alias it into the caller's texture, leaving ownership with the framebuffer.
  • Keep ordinary generated depth attachments write-only. Select readable multisample flags without combining mutually exclusive sample-count values.
  • Report HasDepth() for stencil-only requests, since the allocated D24S8 attachment really contains depth.
  • Reject an uninitialized texture when neither depth nor stencil was requested.

Independence

Based on current master (bb01e283). Published Babylon.js 9.21.2 already issues this request. No JavaScript engine changes, protocol changes, dependency updates, reference changes, or tolerance changes. This does not include newer FrameGraph shared-depth APIs.

Validation

Windows x64 / D3D11 / Chakra / RelWithDebInfo, using stock dependencies and Babylon.js 9.21.2:

  • Native regression covers depth-only, combined depth/stencil, stencil-only depth bookkeeping, readable flags, attachment aliasing, alias disposal followed by framebuffer clears, invalid requests, and legacy null-texture depth framebuffers.
  • Existing JavaScript suite: 65 passing, 27 optional codec tests pending (plugins disabled).

Multisample review follow-up

a7bc0938 extends the native ownership regression to 1x/2x/4x depth-only and depth/stencil allocations, asserting the exact RT-MSAA mask and the MSAA sampling bit. Unsupported multisample format combinations are reported explicitly before allocation. All combinations ran without skips and passed on Windows D3D11/Chakra and Linux Vulkan/JavaScriptCore/lavapipe; both existing D3D11 clear controls also pass. No production changes, renderer exclusions, or dependency on the separate MSAA PR were added.

Copilot AI lite review requested due to automatic review settings September 17, 2026 20:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Pull request overview

Adds support for Babylon.js standalone depth-texture requests by creating readable native depth attachments and aliasing them into the requested texture while retaining framebuffer ownership.

Changes:

  • Detects uninitialized textures passed to createFrameBuffer and rejects requests without depth or stencil.
  • Creates readable depth textures for standalone requests, preserves write-only behavior for generated attachments, and reports depth for stencil-only framebuffers.
  • Adds native regression coverage for attachment aliasing, disposal, flags, invalid requests, and legacy depth framebuffers.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
Plugins/NativeEngine/Source/NativeEngine.h Extends the framebuffer implementation signature to accept a standalone depth/stencil texture.
Plugins/NativeEngine/Source/NativeEngine.cpp Implements standalone depth-texture detection, readable attachment creation, aliasing, and depth bookkeeping.
Apps/UnitTests/Source/Tests.NativeEngine.DepthTextures.cpp Adds regression tests for standalone and legacy depth framebuffer behavior.
Apps/UnitTests/CMakeLists.txt Includes the new depth-texture test source in the unit-test target.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new multisample depth-texture flag path is not exercised by the regression test.

Get a fresh assessment by requesting another Copilot review.

Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread Apps/UnitTests/Source/Tests.NativeEngine.DepthTextures.cpp Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation matches the stated ownership and multisampling requirements with focused regression coverage.

Review details
  • Files reviewed: 4/4 changed files
  • Comments generated: 0 new
  • Review effort level: Balanced

bkaradzic-microsoft and others added 2 commits September 18, 2026 07:27
Recognize the existing uninitialized-texture request, omit the invalid
color attachment, and expose a non-owning alias of the readable depth
attachment. Keep ordinary generated depth storage write-only.

Report depth for stencil-only requests backed by combined depth/stencil.
Cover attachment metadata, alias disposal, clears, and legacy null-texture
depth framebuffers without changing protocol or dependencies.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 60c2ec68-6de1-445d-9fc9-b699db737eae
Exercise one, two, and four samples for depth-only and depth/stencil
attachments. Assert the MSAA sampling bit and exact exclusive RT-MSAA
mask, while retaining the alias lifetime and attachment metadata checks.

Check backend format capabilities before optional multisample allocations
and report unsupported combinations explicitly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 60c2ec68-6de1-445d-9fc9-b699db737eae
@bkaradzic-microsoft
bkaradzic-microsoft enabled auto-merge (squash) September 18, 2026 15:47
@bkaradzic-microsoft
bkaradzic-microsoft merged commit 32a0e2d into BabylonJS:master Sep 18, 2026
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants