Skip to content

NativeEngine: MultiRenderTarget framebuffers + OIT alpha blend modes#1754

Draft
bkaradzic-microsoft wants to merge 1 commit into
BabylonJS:masterfrom
bkaradzic-microsoft:native-multi-render-target
Draft

NativeEngine: MultiRenderTarget framebuffers + OIT alpha blend modes#1754
bkaradzic-microsoft wants to merge 1 commit into
BabylonJS:masterfrom
bkaradzic-microsoft:native-multi-render-target

Conversation

@bkaradzic-microsoft

@bkaradzic-microsoft bkaradzic-microsoft commented Jun 11, 2026

Copy link
Copy Markdown
Member

Paired engine PR: BabylonJS/Babylon.js#18568

What

Foundational native support for MultiRenderTarget (MRT) and the order-independent-transparency blend
modes, removing several "engine._gl is null" crash classes. It does not by itself turn the
MRT/OIT/FrameGraph validation tests green — those need further work (see Follow-ups).

Changes

  • Plugins/NativeEngine/Source/NativeEngine.cpp / .h
    • NativeEngine::CreateMultiFrameBuffer: build one bgfx framebuffer with N color attachments
      (+ optional depth) so a MultiRenderTarget renders to all targets at once (bgfx writes every
      attachment of the bound framebuffer — no drawBuffers needed). The JS-controlled attachment count
      is validated against caps->limits.maxFBAttachments.
    • Add alpha blend modes ALPHA_ONEONE_ONEONE (11) and ALPHA_LAYER_ACCUMULATE (17) used by the
      depth-peeling OIT renderer.

Paired engine PR

Pairs with the Babylon.js change (createMultipleRenderTarget + MRT helper overrides, applyStates
override, reverse-Z clear, alpha-mode mapping).

CI

The validation suite uses the published babylonjs npm, which doesn't yet contain the paired JS, so
no new tests are enabled here and CI stays in the usual "pending dep bump" state. Verified locally
against a babylon.max.js built from the paired branch.

Follow-ups (separate work)

  • OIT depth-peeling still faults inside the D3D11 driver on submit (multi-output / SRV↔RTV
    ping-pong); needs interactive GPU debugging (PIX / VS Graphics Debugger).
  • Native does not yet apply the blend equation (MAX) — setAlphaEquation is a no-op — so OIT
    blending would still be incorrect after the crash is fixed.
  • 2D-array / cube color attachments for MRT are approximated as 2D (test "MRT with different texture
    types").

Related PRs & landing order

These two are co-dependent and land in this order:

  1. Babylon.js #18568 first — it only adds native-engine TS overrides, changes no WebGL behavior, and re-enables no validation tests on its own, so it can merge independently.
  2. A babylonjs npm release ships that TS change.
  3. BabylonNative NativeEngine: MultiRenderTarget framebuffers + OIT alpha blend modes #1754 last — after bumping the bundled babylonjs to that release. (This foundational pair does not yet turn the MRT/OIT/FrameGraph tests green — that is separate follow-up work.)

Foundational native-engine support for MultiRenderTarget (MRT) and the order-
independent-transparency blend modes, removing several "engine._gl is null"
crash classes. It does not by itself land the MRT/OIT/FrameGraph validation
tests, which need further work (see follow-ups below).

- Add NativeEngine::CreateMultiFrameBuffer: build one bgfx framebuffer with N
  color attachments (+ optional depth) so a MultiRenderTarget renders to all
  targets at once (bgfx writes every attachment of the bound framebuffer, so
  no drawBuffers is needed). JS-controlled attachment count is validated
  against caps->limits.maxFBAttachments.
- Add alpha blend modes ALPHA_ONEONE_ONEONE (11) and ALPHA_LAYER_ACCUMULATE
  (17) used by the depth-peeling OIT renderer.

Pairs with the Babylon.js change (createMultipleRenderTarget + MRT helper
overrides, applyStates, reverse-Z clear). Known follow-ups: the OIT depth-
peeling path still faults inside the D3D11 driver on submit (needs interactive
GPU debugging), and the blend equation (MAX) is not yet applied natively.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@bkaradzic-microsoft bkaradzic-microsoft force-pushed the native-multi-render-target branch from c773272 to db75d2e Compare June 18, 2026 15:22
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.

2 participants