NativeEngine: accept R8 and RG32F in raw texture upload path.#1694
Merged
bkaradzic-microsoft merged 1 commit intoMay 11, 2026
Merged
Conversation
`NativeEngine::LoadRawTexture` (called from `engine.createRawTexture` on the Babylon.js side) passes the JS-supplied format to `PrepareImage`, which asserts a small whitelist. Babylon emits `R8` for a few raw-data textures and `RG32F` for GPU particle state textures - neither was on the list, causing SIGABRT in the assert at startup of those tests. Add `R8` and `RG32F` to the whitelist. `RG16F` was already accepted; the 32-bit twin had been overlooked. For these specific JS callers, `mips=false` and `srgb=false`, so the mipmap-generation and sRGB-conversion branches of `PrepareImage` are not exercised and need no further changes. `FlipImage` (the only other in-place operation in the function) is format-agnostic. The `bimg` container and bgfx both already support both formats; this was purely an adapter-side gap. Verified locally on Win32 V8 D3D11 Debug for the 8 currently-excluded Playground tests that hit this assert (idx 336, 652, 682, 684, 685, 686, 687, 688): all 8 no longer SIGABRT. They remain pixel-diff failures (or hit unrelated downstream issues), tracked separately. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the NativeEngine raw texture upload preparation path to accept two additional bimg texture formats (R8 and RG32F) that are already supported downstream (bimg/bgfx), preventing debug-time aborts when Babylon.js requests these formats via engine.createRawTexture(...).
Changes:
- Extend
PrepareImage’s debug-format whitelist to includebimg::TextureFormat::R8. - Extend
PrepareImage’s debug-format whitelist to includebimg::TextureFormat::RG32F.
bghgary
approved these changes
May 11, 2026
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.
What
Adds
R8andRG32Fto the small format whitelist asserted byPrepareImageinPlugins/NativeEngine/Source/NativeEngine.cpp. Both formats are already supported bybimgandbgfx; the gap was only in BN's adapter assert.Why
NativeEngine::LoadRawTexture(the binding for Babylon.jsengine.createRawTexture(...)) forwards the JS-supplied texture format toPrepareImage, which had a hard-coded whitelist of 8 formats. Two formats that Babylon.js requests in normal usage fall outside that list and cause SIGABRT on the assert:R8createRawTexturefor single-channel byte data (texture updates)RG32FRG16Fwas already on the list - the 32-bit twin had simply been overlooked.How verified
Local Win32 V8 D3D11 Debug build, headless Playground runner, 8 currently-excluded tests known to hit this assert:
Each failing call was confirmed by a temporary
fprintfplaced inLoadRawTexture(build, capture, revert).Scope
mips=falseandsrgb=false, so the mipmap-generation and SRGB-conversion branches inPrepareImagedon't need format-aware extensions for this fix. If a future caller requests mips onR8/RG32F, the existing mip branch will need analogous handling.FlipImageis format-agnostic (it computes rowPitch from total-size / height), soinvertYis safe for the new formats.Risk
Very low. Two enum values added to a disjunction. No code path that previously rejected these formats now accepts data that bgfx would refuse to ingest - the underlying renderer already advertises both formats.