[Native] MultiRenderTarget, reverse-Z clear, applyStates, OIT alpha modes#18568
[Native] MultiRenderTarget, reverse-Z clear, applyStates, OIT alpha modes#18568bkaradzic-microsoft wants to merge 1 commit into
Conversation
|
Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s). |
|
Snapshot stored with reference name: Test environment: To test a playground add it to the URL, for example: https://snapshots-cvgtc2eugrd3cgfd.z01.azurefd.net/refs/pull/18568/merge/index.html#WGZLGJ#4600 Links to test your changes to core in the published versions of the Babylon tools (does not contain changes you made to the tools themselves): https://playground.babylonjs.com/?snapshot=refs/pull/18568/merge To test the snapshot in the playground with a playground ID add it after the snapshot query string: https://playground.babylonjs.com/?snapshot=refs/pull/18568/merge#BCU1XR#0 If you made changes to the sandbox or playground in this PR, additional comments will be generated soon containing links to the dev versions of those tools. |
🟢 Memory Leak Test Results13 passed, 0 leaked out of 13 scenarios 🟢 All memory leak tests passed — no leaks detected. Passed Scenarios (13)
|
|
Visualization tests for WebGPU |
|
WebGL2 visualization test reporter: |
⚡ Performance Test Results🟢 All performance tests passed — no regressions detected. |
…odes Foundational native-engine surface so MultiRenderTarget, the reverse depth buffer, and the order-independent-transparency renderer stop dereferencing the null _gl context. Removes several crash classes; does not by itself land the dependent validation tests. - createMultipleRenderTarget + the MRT helper overrides (bindAttachments, buildTextureLayout, restoreSingleAttachment[ForRenderTarget], generateMipMapsMultiFramebuffer, resolveMultiFramebuffer, unBindMultiColorAttachmentFramebuffer, updateMultipleRenderTargetTextureSampleCount). bgfx writes every color attachment of the bound framebuffer, so the WebGL drawBuffers / MSAA-resolve plumbing becomes no-ops on Native. Reports drawBuffersExtension = true. - clear(): implement the reverse depth buffer (clear depth to 0 + GEQUAL) instead of throwing. - applyStates(): override so it flushes the depth-culling state through the native command path (the base implementation drives the null _gl directly), fixing callers that mutate engine.depthCullingState then call applyStates() (e.g. the OIT depth-peeling renderer). - Map alpha modes ALPHA_ONEONE_ONEONE and ALPHA_LAYER_ACCUMULATE to the native engine. Pairs with the BabylonNative change (createMultiFrameBuffer + native alpha modes). Known follow-ups: OIT depth-peeling still faults in the D3D11 driver on submit; the blend equation (MAX) is not yet applied natively. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
5e7e85e to
c5da3b6
Compare
Paired native PR: BabylonJS/BabylonNative#1754
What
Foundational native-engine surface so
MultiRenderTarget, the reverse depth buffer, and theorder-independent-transparency (depth-peeling) renderer stop dereferencing the null
_glcontext.This removes several distinct crash classes. It does not by itself turn the MRT/OIT/FrameGraph
validation tests green — those need further work (see Follow-ups).
Changes (
packages/dev/core/src/Engines)thinNativeEngine.pure.tscreateMultipleRenderTarget+ the MRT helper overrides:bindAttachments,buildTextureLayout,restoreSingleAttachment/restoreSingleAttachmentForRenderTarget,generateMipMapsMultiFramebuffer,resolveMultiFramebuffer,unBindMultiColorAttachmentFramebuffer,updateMultipleRenderTargetTextureSampleCount. bgfx writes every color attachment of the boundframebuffer, so the WebGL
drawBuffers/ MSAA-resolve plumbing becomes no-ops on Native. ReportsdrawBuffersExtension = true.clear(): implement the reverse depth buffer (clear depth to 0 +GEQUAL) instead of throwing.applyStates(): override so it flushes the depth-culling state through the native command path —the base implementation drives the null
_gldirectly, which crashed callers that mutateengine.depthCullingStatethen callapplyStates()(e.g. the OIT depth-peeling renderer).Native/nativeHelpers.ts/nativeInterfaces.ts: map alpha modesALPHA_ONEONE_ONEONEandALPHA_LAYER_ACCUMULATEto the native engine; declarecreateMultiFrameBuffer.Paired native PR
Requires the matching BabylonNative C++ change (
NativeEngine::CreateMultiFrameBuffer+ the two alphablend modes).
Follow-ups (not in this PR)
thinDepthPeelingRenderer) still faults inside the D3D11 driver onsubmit(a multi-output / SRV↔RTV ping-pong state the driver rejects); needs interactive GPU debugging.
MAX) is not yet applied on Native (setAlphaEquationis a no-op),so OIT blending would still be incorrect once the crash is resolved.
Testing
Built
babylon.max.jsand ran the BabylonNative Playground suite (D3D11). MRT, reverse-Z, and thedepth-peeling setup no longer crash with
COLOR_ATTACHMENT0/reverse depth buffer/depthMask of undefined/Unsupported alpha mode. No regressions in existing 2D render-target tests.Related PRs & landing order
These two are co-dependent and land in this order:
babylonjsnpm release ships that TS change.babylonjsto that release. (This foundational pair does not yet turn the MRT/OIT/FrameGraph tests green — that is separate follow-up work.)