From d1b4ef8f0cc3bfc9c9b095241f73beac3d47bae2 Mon Sep 17 00:00:00 2001 From: Branimir Karadzic Date: Mon, 11 May 2026 11:37:03 -0700 Subject: [PATCH] NativeEngine: accept R8 and RG32F in raw texture upload path. `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> --- Plugins/NativeEngine/Source/NativeEngine.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Plugins/NativeEngine/Source/NativeEngine.cpp b/Plugins/NativeEngine/Source/NativeEngine.cpp index 2cab6e696..186c5923e 100644 --- a/Plugins/NativeEngine/Source/NativeEngine.cpp +++ b/Plugins/NativeEngine/Source/NativeEngine.cpp @@ -254,12 +254,14 @@ namespace Babylon bimg::ImageContainer* PrepareImage(bx::AllocatorI& allocator, bimg::ImageContainer* image, bool invertY, bool srgb, bool generateMips) { assert( + image->m_format == bimg::TextureFormat::R8 || image->m_format == bimg::TextureFormat::R16 || image->m_format == bimg::TextureFormat::RGB8 || image->m_format == bimg::TextureFormat::RGBA8 || image->m_format == bimg::TextureFormat::RGBA16 || image->m_format == bimg::TextureFormat::RGBA16F || image->m_format == bimg::TextureFormat::RG16F || + image->m_format == bimg::TextureFormat::RG32F || image->m_format == bimg::TextureFormat::RGBA32F || image->m_format == bimg::TextureFormat::RGBA32U);