NativeEngine: implement updateTextureData (re-enables Test updateTextureData)#1751
Draft
bkaradzic-microsoft wants to merge 1 commit into
Draft
Conversation
This was referenced Jun 11, 2026
Open
…ureData) updateTextureData previously threw "not implemented" on Native. Implement it so sub-rectangle texture updates work. - Add NativeEngine::UpdateTextureData: upload the requested sub-rectangle via bgfx::updateTexture2D (Texture::Update2D). Validates the JS-controlled rect against the mip extents, sizes the copy with bgfx::calcTextureSize (no bimg dependency, so it also works in no-image-loading builds), and mirrors the vertical flip the base texture upload applies so the sub-rect lines up on top-left-origin backends (e.g. D3D11). - Re-enable the "Test updateTextureData" validation test. Pairs with the Babylon.js change (engine.name = "Native" so name-gated WebGL _gl access skips Native, plus the updateTextureData override). CI stays red until a babylonjs npm with that change is published and the dependency bumped. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
db312d3 to
027dcd1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Paired engine PR: BabylonJS/Babylon.js#18566
What
Implements
updateTextureDataon the native engine so partial (sub-rectangle) texture updates work;previously it threw "not implemented". Pairs with the Babylon.js change that also stops the native
engine reporting
engine.name === "WebGL"(that masquerade madeengine.name-gated WebGL_glaccess run on native and crash with
TEXTURE_2D undefined).Changes
Plugins/NativeEngine/Source/NativeEngine.cpp/.h: addNativeEngine::UpdateTextureData, whichuploads the requested sub-rectangle via
bgfx::updateTexture2D(Texture::Update2D). It validatesthe JS-controlled rectangle against the mip-level extents, sizes the copy with
bgfx::calcTextureSize(bgfx is always linked, unlike bimg, so this also works in builds withoutimage loading), and mirrors the vertical flip the base texture upload applies so the sub-rectangle
lines up on top-left-origin backends (e.g. D3D11).
Apps/Playground/Scripts/config.json: re-enable "Test updateTextureData".CI
The validation suite uses the published
babylonjsnpm, which does not yet contain the paired JSoverrides, so the re-enabled test stays red until a
babylonjsrelease with the Babylon.js changeships and the dependency is bumped here. Draft until then.
Verified locally
Built against a local
babylon.max.jswith the paired change: the re-enabled test passes (stableacross repeated runs); no regressions in other texture / raw-texture tests.
Related PRs & landing order
Co-dependent; land in this order:
engine.name = "Native"+updateTextureDataTS overrides; no WebGL behavior change.babylonjsnpm release ships that TS change.babylonjsand re-enables theTest updateTextureDatavalidation test, which only passes once the paired JS is present in the bundled engine.