[Native] Add cube render target support to the native engine#18561
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/18561/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/18561/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/18561/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. |
|
WebGL2 visualization test reporter: |
|
Visualization tests for WebGPU |
🟢 Memory Leak Test Results13 passed, 0 leaked out of 13 scenarios 🟢 All memory leak tests passed — no leaks detected. Passed Scenarios (13)
|
⚡ Performance Test Results🟢 All performance tests passed — no regressions detected. |
3309ed2 to
cfa76cd
Compare
NativeEngine had no createRenderTargetCubeTexture / per-face bindFramebuffer override, so ReflectionProbe and point-light cube shadows fell through to the WebGL path and dereferenced the null _gl context (TEXTURE_CUBE_MAP undefined). - createRenderTargetCubeTexture: native cube color texture + one framebuffer per face (the native side binds the matching cube layer). - bindFramebuffer: bind the per-face framebuffer for cube render targets. - generateMipMapsForCubemap: no-op on Native (bgfx auto-generates the mip chain on render-target resolve, like 2D RTTs). - NativeRenderTargetWrapper: track per-face framebuffers, release on dispose. - nativeInterfaces: thread cube/layer params through initializeTexture and createFrameBuffer. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
cfa76cd to
3381c85
Compare
🟢 Memory Leak Test Results13 passed, 0 leaked out of 13 scenarios 🟢 All memory leak tests passed — no leaks detected. Passed Scenarios (13)
|
⚡ Performance Test Results🟢 All performance tests passed — no regressions detected. |
|
WebGL2 visualization test reporter: |
|
Visualization tests for WebGPU |
There was a problem hiding this comment.
Pull request overview
Adds Babylon Native support for rendering into cube-map render targets by implementing a Native-specific createRenderTargetCubeTexture path and updating framebuffer binding to select per-face framebuffers. This closes the gap where cube-map RTT features (eg ReflectionProbe, point-light cube shadows) previously fell back to WebGL code paths and crashed on Native due to the missing GL context.
Changes:
- Implement
ThinNativeEngine.createRenderTargetCubeTexturewith native cube texture initialization and one framebuffer per cube face. - Update Native RTT wrapper lifecycle to track/release per-face framebuffers.
- Extend the native engine TypeScript interface to thread
isCube/layerparameters into texture/framebuffer initialization.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| packages/dev/core/src/Engines/thinNativeEngine.pure.ts | Adds cube RTT creation + per-face framebuffer binding, plus a Native no-op override for cubemap mipgen. |
| packages/dev/core/src/Engines/Native/nativeRenderTargetWrapper.ts | Tracks per-face framebuffer arrays for cube RTTs and releases them on reassignment/dispose. |
| packages/dev/core/src/Engines/Native/nativeInterfaces.ts | Updates native interface signatures to support cube texture init and per-layer/per-face framebuffer creation. |
Addresses review: cube RT adds isCube/layer params that old native silently ignores (2D RT with aliased faces, no error). Bumping the protocol version makes any JS<->Native version skew fail loudly at engine init via the existing strict-equality check, instead of rendering incorrectly. Pairs with the native-side bump in BabylonJS/BabylonNative#1750 (landed together with the babylonjs pin bump).
|
Please make sure to label your PR with "bug", "new feature" or "breaking change" label(s). |
…are MSAA update Address Copilot reviewer feedback on createRenderTargetCubeTexture: - apply float/half-float linear-filtering samplingMode fallback (NEAREST) - propagate options.label to the InternalTexture - push the hand-built texture to _internalTexturesCache for lifecycle tracking - make updateRenderTargetTextureSampleCount cube-aware (reinit with isCube + recreate all six per-face framebuffers) so changing samples after creation no longer breaks bindFramebuffer(faceIndex)
|
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/18561/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/18561/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/18561/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)
|
⚡ Performance Test Results🟢 All performance tests passed — no regressions detected. |
|
WebGL2 visualization test reporter: |
|
Visualization tests for WebGPU |
The required Native tests check runs the PR JS against the BabylonNative Nightly artifact (native PROTOCOL_VERSION = 9 from BN master), so bumping the JS side to 10 made new NativeEngine() throw a protocol-version mismatch and crash every native test. The version gate will land later as a coordinated atomic bump (BJS JS + BabylonNative native + babylonjs pin together).
🟢 Memory Leak Test Results13 passed, 0 leaked out of 13 scenarios 🟢 All memory leak tests passed — no leaks detected. Passed Scenarios (13)
|
|
WebGL2 visualization test reporter: |
|
Visualization tests for WebGPU |
Paired native PR: BabylonJS/BabylonNative#1750
What
Adds cube render target support to the Babylon Native engine. Previously the
native engine had no
createRenderTargetCubeTextureoverride andbindFramebuffer(faceIndex)threw, so any feature that renders into a cube map—
ReflectionProbe, point-light cube shadow maps — fell through to the WebGLcode path and dereferenced the null
_glcontext (TEXTURE_CUBE_MAP undefined).Changes (
packages/dev/core/src/Engines)thinNativeEngine.pure.tscreateRenderTargetCubeTexture: creates a native cube color texture and oneframebuffer per face (the native side binds the matching cube layer).
bindFramebuffer: binds the per-face framebuffer for cube render targets.generateMipMapsForCubemap: no-op on Native — bgfx auto-generates the mipchain on render-target resolve, the same way 2D RTTs get their mips.
Native/nativeRenderTargetWrapper.ts: tracks per-face framebuffers andreleases them on dispose.
Native/nativeInterfaces.ts: threads the cube/layer params throughinitializeTextureandcreateFrameBuffer.Paired native change
Requires the matching BabylonNative C++ change (cube color texture + per-face
attachment). Draft until both land.
Testing
Built
babylon.max.jsand ran the BabylonNative Playground validation suite(D3D11). The "Shadows with instances" tests (left/right handed), which
previously crashed, now pass; the ReflectionProbe and point-light-shadow scenes
render with correct geometry and orientation.
Related PRs & landing order
Co-dependent; land in this order:
babylonjsnpm release ships that TS change.babylonjsand re-enables the 2Shadows with instances(left/right handed) validation tests, which only pass once the paired JS is present in the bundled engine.