[Native] Report engine.name "Native" and implement updateTextureData#18566
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/18566/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/18566/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/18566/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)
|
|
WebGL2 visualization test reporter: |
|
Visualization tests for WebGPU |
⚡ Performance Test Results🟢 All performance tests passed — no regressions detected. |
0333ba6 to
373db14
Compare
373db14 to
d01c82c
Compare
|
WebGL2 visualization test reporter: |
🟢 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 |
⚡ Performance Test Results🟢 All performance tests passed — no regressions detected. |
🟢 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: |
3bc4613 to
aab7a48
Compare
🟢 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 |
There was a problem hiding this comment.
Pull request overview
This PR updates the Babylon Native (ThinNativeEngine) implementation to (1) report a distinct engine.name value ("Native") instead of inheriting "WebGL" from ThinEngine, and (2) implement updateTextureData by forwarding sub-rectangle texture updates to the native engine bridge.
Changes:
- Set the native engine name to
"Native"to prevent WebGL-only code paths from running on Native (which has no_gl). - Implement
ThinNativeEngine.updateTextureDatato call into a new optional native bridge method. - Extend the native engine interface with an
updateTextureDatasignature.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/dev/core/src/Engines/thinNativeEngine.pure.ts | Sets _name = "Native" and forwards updateTextureData calls to the native bridge. |
| packages/dev/core/src/Engines/Native/nativeInterfaces.ts | Adds the optional INativeEngine.updateTextureData method signature. |
🟢 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: |
⚡ Performance Test Results🟢 All performance tests passed — no regressions detected. |
|
Visualization tests for WebGPU |
aab7a48 to
3f8fe1c
Compare
🟢 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 |
⚡ Performance Test Results🟢 All performance tests passed — no regressions detected. |
The native engine inherited engine.name === "WebGL" from ThinEngine, so code
that guards WebGL-only _gl access with �ngine.name === "WebGL" ran on the
native engine and dereferenced the null _gl context (e.g. TEXTURE_2D undefined).
updateTextureData also threw "not implemented".
- Report a distinct engine name ("Native"), mirroring how the WebGPU engine
reports "WebGPU", so name-gated WebGL-only code paths skip the native engine.
- Implement updateTextureData: forward the sub-rectangle (plus invertY, so the
native side can match the base texture's vertical orientation) to the native
engine. generateMipMaps is ignored (mip regeneration after a partial update is
not supported on Native).
Pairs with the BabylonNative change adding NativeEngine::UpdateTextureData.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Addresses review: existence-check before calling this._engine.updateTextureData so older native binaries (PROTOCOL_VERSION not bumped) restore the explicit 'updateTextureData not implemented.' error instead of a raw 'is not a function'.
3f8fe1c to
56b98ff
Compare
🟢 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 |
⚡ Performance Test ResultsBaseline: Latest · Candidate: Dev
🔘 Not Significant — p ≥ 0.05 (1)
|
Paired native PR: BabylonJS/BabylonNative#1751
What
engine.name→"Native". The native engine inherited"WebGL"fromThinEngine, so external code gating WebGL-only_glaccess onengine.name === "WebGL"ran on native and dereferenced the null_gl(e.g.TypeError: ... 'TEXTURE_2D' of null). It now reports"Native"(as WebGPU reports"WebGPU"). No internal=== "WebGL"checks exist (selection uses_shaderPlatformName/isWebGPU), so only external name-branching code is affected — exactly the code already broken on native.updateTextureDataimplemented (was throwing "not implemented"). Forwards the sub-rectangle withinvertY; ignoresgenerateMipMaps(no partial-update mip regen on Native). The native binding is optional + existence-checked, so old native binaries get the explicit"updateTextureData not implemented."instead of... is not a function.Changes (
packages/dev/core/src/Engines)thinNativeEngine.pure.ts: set_name = "Native"; implementupdateTextureData(early-return without_hardwareTexture, existence-check before forwarding).Native/nativeInterfaces.ts: add optionalupdateTextureData?signature (matchingsetRenderResetCallback?/sortSplats?).Testing
Built
babylon.max.js+ ran the BabylonNative Playground validation suite (D3D11): the "Test updateTextureData" scene (previously crashed on_gl.TEXTURE_2D) renders and passes pixel comparison, stable across runs.Landing order
Co-dependent with
NativeEngine::UpdateTextureDatain BabylonJS/BabylonNative#1751:babylonjsnpm release ships them.babylonjs+ re-enables the validation test (passes only with the paired JS).