From 3a350f5051d5d353f84d13a05ab29b2406d1e7e6 Mon Sep 17 00:00:00 2001 From: Gary Hsu Date: Tue, 29 Sep 2026 12:44:17 -0700 Subject: [PATCH 01/28] Use JsRuntimeHost switches for Embedding polyfills AbortController, Scheduling, URL, and WebSocket were controlled by separate Babylon Native options even though JsRuntimeHost owns their targets. Removing a target in JsRuntimeHost left Embedding and Window referencing unavailable headers and libraries. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- CMakeLists.txt | 4 ---- Documentation/Polyfills.md | 10 ++++++++++ Embedding/CMakeLists.txt | 21 ++++++++++----------- Embedding/Source/Runtime.cpp | 16 ++++++++-------- Polyfills/Window/CMakeLists.txt | 6 +++++- Polyfills/Window/Source/Window.cpp | 4 ++++ 6 files changed, 37 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f976128bff..88ec2a968b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -146,11 +146,7 @@ option(BABYLON_NATIVE_PLUGIN_SHADERTOOL "Include Babylon Native Plugin ShaderToo option(BABYLON_NATIVE_PLUGIN_TESTUTILS "Include Babylon Native Plugin TestUtils." ON) # Polyfills -option(BABYLON_NATIVE_POLYFILL_ABORTCONTROLLER "Include Babylon Native Polyfill AbortController." ON) option(BABYLON_NATIVE_POLYFILL_CANVAS "Include Babylon Native Polyfill Canvas." ON) -option(BABYLON_NATIVE_POLYFILL_SCHEDULING "Include Babylon Native Polyfill Scheduling." ON) -option(BABYLON_NATIVE_POLYFILL_URL "Include Babylon Native Polyfill URL." ON) -option(BABYLON_NATIVE_POLYFILL_WEBSOCKET "Include Babylon Native Polyfill WebSocket." ON) option(BABYLON_NATIVE_POLYFILL_WINDOW "Include Babylon Native Polyfill Window." ON) # Embedding diff --git a/Documentation/Polyfills.md b/Documentation/Polyfills.md index 2c687dc198..10c9b015d9 100644 --- a/Documentation/Polyfills.md +++ b/Documentation/Polyfills.md @@ -3,6 +3,16 @@ Babylon Native Polyfills add support for certain JavaScript browser APIs, such a The polyfills are still in an early stage and are subject to change. +When building Embedding, JsRuntimeHost enables AbortController, Scheduling, +URL, and WebSocket by default. Set the corresponding +`JSRUNTIMEHOST_POLYFILL_ABORT_CONTROLLER`, `JSRUNTIMEHOST_POLYFILL_SCHEDULING`, +`JSRUNTIMEHOST_POLYFILL_URL`, or `JSRUNTIMEHOST_POLYFILL_WEBSOCKET` CMake +option to `OFF` to omit that library and its Embedding initialization. The +former `BABYLON_NATIVE_POLYFILL_ABORTCONTROLLER`, +`BABYLON_NATIVE_POLYFILL_SCHEDULING`, `BABYLON_NATIVE_POLYFILL_URL`, and +`BABYLON_NATIVE_POLYFILL_WEBSOCKET` options no longer control these polyfills. +Window remains available when Scheduling is disabled, without its scheduling APIs. + At the moment, we are using the following polyfills: * [Canvas](../Polyfills/Canvas/readme.md) * [Console](../Polyfills/Console/readme.md) diff --git a/Embedding/CMakeLists.txt b/Embedding/CMakeLists.txt index b2f7047263..9b8667315f 100644 --- a/Embedding/CMakeLists.txt +++ b/Embedding/CMakeLists.txt @@ -46,9 +46,8 @@ target_link_libraries(Embedding # ----- Conditionally-included polyfills ----- # -# Each flag is exposed as a PUBLIC compile definition so the public -# headers (Runtime.h / View.h) and the impl source files can both gate -# on the same value via `#if BABYLON_NATIVE_*`. +# Public compile definitions are used for options exposed by public +# headers; JsRuntimeHost polyfills only need private definitions. if(BABYLON_NATIVE_POLYFILL_WINDOW) target_compile_definitions(Embedding PUBLIC BABYLON_NATIVE_POLYFILL_WINDOW=1) @@ -60,23 +59,23 @@ if(BABYLON_NATIVE_POLYFILL_CANVAS) target_link_libraries(Embedding PRIVATE Canvas) endif() -if(BABYLON_NATIVE_POLYFILL_ABORTCONTROLLER) - target_compile_definitions(Embedding PUBLIC BABYLON_NATIVE_POLYFILL_ABORTCONTROLLER=1) +if(TARGET AbortController) + target_compile_definitions(Embedding PRIVATE JSRUNTIMEHOST_POLYFILL_ABORT_CONTROLLER=1) target_link_libraries(Embedding PRIVATE AbortController) endif() -if(BABYLON_NATIVE_POLYFILL_SCHEDULING) - target_compile_definitions(Embedding PUBLIC BABYLON_NATIVE_POLYFILL_SCHEDULING=1) +if(TARGET Scheduling) + target_compile_definitions(Embedding PRIVATE JSRUNTIMEHOST_POLYFILL_SCHEDULING=1) target_link_libraries(Embedding PRIVATE Scheduling) endif() -if(BABYLON_NATIVE_POLYFILL_URL) - target_compile_definitions(Embedding PUBLIC BABYLON_NATIVE_POLYFILL_URL=1) +if(TARGET URL) + target_compile_definitions(Embedding PRIVATE JSRUNTIMEHOST_POLYFILL_URL=1) target_link_libraries(Embedding PRIVATE URL) endif() -if(BABYLON_NATIVE_POLYFILL_WEBSOCKET) - target_compile_definitions(Embedding PUBLIC BABYLON_NATIVE_POLYFILL_WEBSOCKET=1) +if(TARGET WebSocket) + target_compile_definitions(Embedding PRIVATE JSRUNTIMEHOST_POLYFILL_WEBSOCKET=1) target_link_libraries(Embedding PRIVATE WebSocket) endif() diff --git a/Embedding/Source/Runtime.cpp b/Embedding/Source/Runtime.cpp index c279458182..a301c9e3b0 100644 --- a/Embedding/Source/Runtime.cpp +++ b/Embedding/Source/Runtime.cpp @@ -42,19 +42,19 @@ #include #include -#if BABYLON_NATIVE_POLYFILL_ABORTCONTROLLER +#if JSRUNTIMEHOST_POLYFILL_ABORT_CONTROLLER #include #endif -#if BABYLON_NATIVE_POLYFILL_SCHEDULING +#if JSRUNTIMEHOST_POLYFILL_SCHEDULING #include #endif -#if BABYLON_NATIVE_POLYFILL_URL +#if JSRUNTIMEHOST_POLYFILL_URL #include #endif -#if BABYLON_NATIVE_POLYFILL_WEBSOCKET +#if JSRUNTIMEHOST_POLYFILL_WEBSOCKET #include #endif @@ -249,16 +249,16 @@ namespace Babylon::Embedding Babylon::Polyfills::XMLHttpRequest::Initialize(env); Babylon::Polyfills::Fetch::Initialize(env); -#if BABYLON_NATIVE_POLYFILL_ABORTCONTROLLER +#if JSRUNTIMEHOST_POLYFILL_ABORT_CONTROLLER Babylon::Polyfills::AbortController::Initialize(env); #endif -#if BABYLON_NATIVE_POLYFILL_SCHEDULING +#if JSRUNTIMEHOST_POLYFILL_SCHEDULING Babylon::Polyfills::Scheduling::Initialize(env); #endif -#if BABYLON_NATIVE_POLYFILL_URL +#if JSRUNTIMEHOST_POLYFILL_URL Babylon::Polyfills::URL::Initialize(env); #endif -#if BABYLON_NATIVE_POLYFILL_WEBSOCKET +#if JSRUNTIMEHOST_POLYFILL_WEBSOCKET Babylon::Polyfills::WebSocket::Initialize(env); #endif diff --git a/Polyfills/Window/CMakeLists.txt b/Polyfills/Window/CMakeLists.txt index 42afacaddd..3dbe74ad08 100644 --- a/Polyfills/Window/CMakeLists.txt +++ b/Polyfills/Window/CMakeLists.txt @@ -12,9 +12,13 @@ target_include_directories(Window target_link_libraries(Window PUBLIC napi PRIVATE base-n - PRIVATE Scheduling PRIVATE JsRuntimeInternal PRIVATE GraphicsDeviceContext) +if(TARGET Scheduling) + target_compile_definitions(Window PRIVATE JSRUNTIMEHOST_POLYFILL_SCHEDULING=1) + target_link_libraries(Window PRIVATE Scheduling) +endif() + set_property(TARGET Window PROPERTY FOLDER Polyfills) source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCES}) \ No newline at end of file diff --git a/Polyfills/Window/Source/Window.cpp b/Polyfills/Window/Source/Window.cpp index faa99a7642..7883a12e7c 100644 --- a/Polyfills/Window/Source/Window.cpp +++ b/Polyfills/Window/Source/Window.cpp @@ -1,7 +1,9 @@ #include "Window.h" #include +#if JSRUNTIMEHOST_POLYFILL_SCHEDULING #include +#endif #include @@ -31,7 +33,9 @@ namespace Babylon::Polyfills::Internal jsNative.Set(JS_WINDOW_NAME, jsWindow); +#if JSRUNTIMEHOST_POLYFILL_SCHEDULING Scheduling::Initialize(env); +#endif if (global.Get(JS_A_TO_B_NAME).IsUndefined()) { From 341cba55d5f9faf5489d68b6fef512db6a93a0a1 Mon Sep 17 00:00:00 2001 From: Gary Hsu Date: Tue, 29 Sep 2026 15:11:59 -0700 Subject: [PATCH 02/28] Adopt renamed JsRuntimeHost AbortController option Pin the revision that exposes the new spelling and use it to guard Embedding compilation and initialization. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- CMakeLists.txt | 2 +- Documentation/Polyfills.md | 2 +- Embedding/CMakeLists.txt | 2 +- Embedding/Source/Runtime.cpp | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 88ec2a968b..1045be02fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,7 +62,7 @@ FetchContent_Declare(ios-cmake EXCLUDE_FROM_ALL) FetchContent_Declare(JsRuntimeHost GIT_REPOSITORY https://github.com/BabylonJS/JsRuntimeHost.git - GIT_TAG b2b51ca86737cf8145235226b7591c191a94355a) + GIT_TAG 33e4a233dea178712352ec90a647683084bfbf1d) FetchContent_Declare(metal-cpp GIT_REPOSITORY https://github.com/bkaradzic/metal-cpp.git GIT_TAG metal-cpp_26 diff --git a/Documentation/Polyfills.md b/Documentation/Polyfills.md index 10c9b015d9..3712590100 100644 --- a/Documentation/Polyfills.md +++ b/Documentation/Polyfills.md @@ -5,7 +5,7 @@ The polyfills are still in an early stage and are subject to change. When building Embedding, JsRuntimeHost enables AbortController, Scheduling, URL, and WebSocket by default. Set the corresponding -`JSRUNTIMEHOST_POLYFILL_ABORT_CONTROLLER`, `JSRUNTIMEHOST_POLYFILL_SCHEDULING`, +`JSRUNTIMEHOST_POLYFILL_ABORTCONTROLLER`, `JSRUNTIMEHOST_POLYFILL_SCHEDULING`, `JSRUNTIMEHOST_POLYFILL_URL`, or `JSRUNTIMEHOST_POLYFILL_WEBSOCKET` CMake option to `OFF` to omit that library and its Embedding initialization. The former `BABYLON_NATIVE_POLYFILL_ABORTCONTROLLER`, diff --git a/Embedding/CMakeLists.txt b/Embedding/CMakeLists.txt index 9b8667315f..5df8bcb33d 100644 --- a/Embedding/CMakeLists.txt +++ b/Embedding/CMakeLists.txt @@ -60,7 +60,7 @@ if(BABYLON_NATIVE_POLYFILL_CANVAS) endif() if(TARGET AbortController) - target_compile_definitions(Embedding PRIVATE JSRUNTIMEHOST_POLYFILL_ABORT_CONTROLLER=1) + target_compile_definitions(Embedding PRIVATE JSRUNTIMEHOST_POLYFILL_ABORTCONTROLLER=1) target_link_libraries(Embedding PRIVATE AbortController) endif() diff --git a/Embedding/Source/Runtime.cpp b/Embedding/Source/Runtime.cpp index a301c9e3b0..cc70ba2139 100644 --- a/Embedding/Source/Runtime.cpp +++ b/Embedding/Source/Runtime.cpp @@ -42,7 +42,7 @@ #include #include -#if JSRUNTIMEHOST_POLYFILL_ABORT_CONTROLLER +#if JSRUNTIMEHOST_POLYFILL_ABORTCONTROLLER #include #endif @@ -249,7 +249,7 @@ namespace Babylon::Embedding Babylon::Polyfills::XMLHttpRequest::Initialize(env); Babylon::Polyfills::Fetch::Initialize(env); -#if JSRUNTIMEHOST_POLYFILL_ABORT_CONTROLLER +#if JSRUNTIMEHOST_POLYFILL_ABORTCONTROLLER Babylon::Polyfills::AbortController::Initialize(env); #endif #if JSRUNTIMEHOST_POLYFILL_SCHEDULING From 2de330059489a032c354de04da5597359717cc4c Mon Sep 17 00:00:00 2001 From: Gary Hsu Date: Tue, 29 Sep 2026 12:41:29 -0700 Subject: [PATCH 03/28] Install required Embedding polyfills Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- Install/Install.cmake | 15 +++++++++++++++ Install/Test/CMakeLists.txt | 10 ++++++++++ 2 files changed, 25 insertions(+) diff --git a/Install/Install.cmake b/Install/Install.cmake index 16efea0eab..c7c431ddca 100644 --- a/Install/Install.cmake +++ b/Install/Install.cmake @@ -216,6 +216,16 @@ if(TARGET Console) install_include(Console) endif() +if(TARGET Fetch) + install_lib(Fetch) + install_include(Fetch) +endif() + +if(TARGET File) + install_lib(File) + install_include(File) +endif() + if(TARGET Performance) install_lib(Performance) install_include(Performance) @@ -226,6 +236,11 @@ if(TARGET TextDecoder) install_include(TextDecoder) endif() +if(TARGET TextEncoder) + install_lib(TextEncoder) + install_include(TextEncoder) +endif() + if(TARGET URL) install_lib(URL) install_include(URL) diff --git a/Install/Test/CMakeLists.txt b/Install/Test/CMakeLists.txt index c77d6a009b..82ebc0a31c 100644 --- a/Install/Test/CMakeLists.txt +++ b/Install/Test/CMakeLists.txt @@ -71,6 +71,16 @@ target_include_directories(TestInstall PRIVATE "${INSTALL_DIR}/include") message(STATUS "Install lib directory: ${INSTALL_DIR}/lib") set(INSTALL_LIBS_DIR "${INSTALL_DIR}/lib") +if(EXISTS "${INSTALL_LIBS_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}Embedding${CMAKE_STATIC_LIBRARY_SUFFIX}") + foreach(POLYFILL Fetch File TextEncoder) + if(NOT EXISTS "${INSTALL_LIBS_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}${POLYFILL}${CMAKE_STATIC_LIBRARY_SUFFIX}") + message(FATAL_ERROR "Missing installed ${POLYFILL} library") + endif() + if(NOT EXISTS "${INSTALL_DIR}/include/Babylon/Polyfills/${POLYFILL}.h") + message(FATAL_ERROR "Missing installed ${POLYFILL} header") + endif() + endforeach() +endif() target_link_directories(TestInstall PRIVATE ${INSTALL_LIBS_DIR}) if(WIN32) file(GLOB INSTALL_LIBS "${INSTALL_LIBS_DIR}/*.lib") From befb2ca4073a6019c8c10f6e3fb5963c8e9cd337 Mon Sep 17 00:00:00 2001 From: Gary Hsu Date: Tue, 29 Sep 2026 12:41:28 -0700 Subject: [PATCH 04/28] Honor NativeEngine WebP parsing when generic bimg parsers are disabled Set bimg's WebP macro explicitly for active NativeEngine image loading, while keeping the existing off and disabled-engine behavior. Add a focused compile-definition regression fixture and document the option interaction. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- Dependencies/CMakeLists.txt | 14 ++++-- .../Tests/WebPParserOption/CMakeLists.txt | 47 +++++++++++++++++++ .../Tests/WebPParserOption/decoder.cpp | 5 ++ Documentation/BuildSystem.md | 7 +++ 4 files changed, 68 insertions(+), 5 deletions(-) create mode 100644 Dependencies/Tests/WebPParserOption/CMakeLists.txt create mode 100644 Dependencies/Tests/WebPParserOption/decoder.cpp diff --git a/Dependencies/CMakeLists.txt b/Dependencies/CMakeLists.txt index a6cdae9531..e2eb2b7b5d 100644 --- a/Dependencies/CMakeLists.txt +++ b/Dependencies/CMakeLists.txt @@ -106,11 +106,15 @@ foreach(_bimg_target IN ITEMS bimg_decode bimg_encode tinyexr) endif() endforeach() -# WebP parsing is provided by bimg's bundled simplewebp decoder. Toggle it -# through bimg's own config macro so disabling the option compiles the parser -# out of bimg_decode instead of pulling in a separate libwebp dependency. -if(NOT BABYLON_NATIVE_PLUGIN_NATIVEENGINE_WEBP AND TARGET bimg_decode) - target_compile_definitions(bimg_decode PRIVATE BIMG_CONFIG_PARSE_WEBP=0) +# WebP parsing is provided by bimg's bundled simplewebp decoder. Set its +# parser macro explicitly when NativeEngine needs it, even if a parent project +# disables the other bimg parsers with BIMG_CONFIG_PARSE_ENABLE=0. +if(TARGET bimg_decode) + if(NOT BABYLON_NATIVE_PLUGIN_NATIVEENGINE_WEBP) + target_compile_definitions(bimg_decode PRIVATE BIMG_CONFIG_PARSE_WEBP=0) + elseif(BABYLON_NATIVE_PLUGIN_NATIVEENGINE AND BABYLON_NATIVE_PLUGIN_NATIVEENGINE_LOAD_IMAGES) + target_compile_definitions(bimg_decode PRIVATE BIMG_CONFIG_PARSE_WEBP=1) + endif() endif() if(NOT APPLE AND NOT ANDROID AND CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64|amd64|AMD64)" AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") diff --git a/Dependencies/Tests/WebPParserOption/CMakeLists.txt b/Dependencies/Tests/WebPParserOption/CMakeLists.txt new file mode 100644 index 0000000000..1cc8a15449 --- /dev/null +++ b/Dependencies/Tests/WebPParserOption/CMakeLists.txt @@ -0,0 +1,47 @@ +cmake_minimum_required(VERSION 3.21) +project(WebPParserOption LANGUAGES CXX) + +if(NOT DEFINED EXPECTED_WEBP OR NOT DEFINED EXPECTED_WEBP_DEFINITION) + message(FATAL_ERROR "Set EXPECTED_WEBP and EXPECTED_WEBP_DEFINITION (0, 1, or inherit)") +endif() + +# Provide the bimg targets without fetching unrelated Babylon Native dependencies. +# Stop including Dependencies/CMakeLists.txt after its bimg configuration. +macro(FetchContent_MakeAvailable_With_Message dependency) + if("${dependency}" STREQUAL "bgfx.cmake") + foreach(target IN ITEMS bx bgfx bimg bimg_encode) + add_library(${target} STATIC decoder.cpp) + endforeach() + add_library(bimg_decode STATIC decoder.cpp) + target_compile_definitions(bimg_decode PRIVATE BIMG_CONFIG_PARSE_ENABLE=$) + elseif("${dependency}" STREQUAL "glslang") + return() + endif() +endmacro() + +if(NOT DEFINED BN_DEPENDENCIES_FILE) + set(BN_DEPENDENCIES_FILE "${CMAKE_CURRENT_LIST_DIR}/../../CMakeLists.txt") +endif() +include("${BN_DEPENDENCIES_FILE}") + +if(LATE_GENERIC_DISABLE) + target_compile_definitions(bimg_decode PRIVATE BIMG_CONFIG_PARSE_ENABLE=0) +endif() + +get_target_property(definitions bimg_decode COMPILE_DEFINITIONS) +set(webp_definitions) +foreach(definition IN LISTS definitions) + if(definition MATCHES "^BIMG_CONFIG_PARSE_WEBP=") + list(APPEND webp_definitions "${definition}") + endif() +endforeach() + +if(EXPECTED_WEBP_DEFINITION STREQUAL "inherit") + if(webp_definitions) + message(FATAL_ERROR "Expected WebP to inherit the generic setting, got ${webp_definitions}") + endif() +elseif(NOT webp_definitions STREQUAL "BIMG_CONFIG_PARSE_WEBP=${EXPECTED_WEBP_DEFINITION}") + message(FATAL_ERROR "Expected one BIMG_CONFIG_PARSE_WEBP=${EXPECTED_WEBP_DEFINITION}, got ${webp_definitions}") +endif() + +target_compile_definitions(bimg_decode PRIVATE EXPECTED_WEBP=${EXPECTED_WEBP}) diff --git a/Dependencies/Tests/WebPParserOption/decoder.cpp b/Dependencies/Tests/WebPParserOption/decoder.cpp new file mode 100644 index 0000000000..c1aa1c9c1b --- /dev/null +++ b/Dependencies/Tests/WebPParserOption/decoder.cpp @@ -0,0 +1,5 @@ +#ifndef BIMG_CONFIG_PARSE_WEBP +#define BIMG_CONFIG_PARSE_WEBP BIMG_CONFIG_PARSE_ENABLE +#endif + +static_assert(BIMG_CONFIG_PARSE_WEBP == EXPECTED_WEBP); diff --git a/Documentation/BuildSystem.md b/Documentation/BuildSystem.md index 55ec769c9e..c961ed64de 100644 --- a/Documentation/BuildSystem.md +++ b/Documentation/BuildSystem.md @@ -17,6 +17,13 @@ An explicit setting from a parent CMake project is also respected. Unset or empt values use Babylon Native's disabled default, including empty cache entries left by earlier configurations. +NativeEngine WebP decoding is enabled by default when image loading is enabled. +`BABYLON_NATIVE_PLUGIN_NATIVEENGINE_WEBP=ON` enables bimg's WebP parser even +if a parent project disables generic bimg parsers with `BIMG_CONFIG_PARSE_ENABLE=0`. +Setting the WebP option to `OFF` disables its parser; disabling NativeEngine +leaves bimg's generic parser setting in control unless the WebP option is `OFF`. +Disabling NativeEngine image loading also forces the WebP option off. + ## Lateral Dependency Management Scalable dependency management can be a challenge when making heavy use of Git Submodules. From 0ea8682227b4c9374e8d97daa4eb02bcb4bf9492 Mon Sep 17 00:00:00 2001 From: Gary Hsu Date: Tue, 29 Sep 2026 15:47:40 -0700 Subject: [PATCH 05/28] Remove synthetic WebP parser test fixture The production decoder was verified with real WebP input under generic parser-off settings, both with WebP enabled and disabled. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../Tests/WebPParserOption/CMakeLists.txt | 47 ------------------- .../Tests/WebPParserOption/decoder.cpp | 5 -- 2 files changed, 52 deletions(-) delete mode 100644 Dependencies/Tests/WebPParserOption/CMakeLists.txt delete mode 100644 Dependencies/Tests/WebPParserOption/decoder.cpp diff --git a/Dependencies/Tests/WebPParserOption/CMakeLists.txt b/Dependencies/Tests/WebPParserOption/CMakeLists.txt deleted file mode 100644 index 1cc8a15449..0000000000 --- a/Dependencies/Tests/WebPParserOption/CMakeLists.txt +++ /dev/null @@ -1,47 +0,0 @@ -cmake_minimum_required(VERSION 3.21) -project(WebPParserOption LANGUAGES CXX) - -if(NOT DEFINED EXPECTED_WEBP OR NOT DEFINED EXPECTED_WEBP_DEFINITION) - message(FATAL_ERROR "Set EXPECTED_WEBP and EXPECTED_WEBP_DEFINITION (0, 1, or inherit)") -endif() - -# Provide the bimg targets without fetching unrelated Babylon Native dependencies. -# Stop including Dependencies/CMakeLists.txt after its bimg configuration. -macro(FetchContent_MakeAvailable_With_Message dependency) - if("${dependency}" STREQUAL "bgfx.cmake") - foreach(target IN ITEMS bx bgfx bimg bimg_encode) - add_library(${target} STATIC decoder.cpp) - endforeach() - add_library(bimg_decode STATIC decoder.cpp) - target_compile_definitions(bimg_decode PRIVATE BIMG_CONFIG_PARSE_ENABLE=$) - elseif("${dependency}" STREQUAL "glslang") - return() - endif() -endmacro() - -if(NOT DEFINED BN_DEPENDENCIES_FILE) - set(BN_DEPENDENCIES_FILE "${CMAKE_CURRENT_LIST_DIR}/../../CMakeLists.txt") -endif() -include("${BN_DEPENDENCIES_FILE}") - -if(LATE_GENERIC_DISABLE) - target_compile_definitions(bimg_decode PRIVATE BIMG_CONFIG_PARSE_ENABLE=0) -endif() - -get_target_property(definitions bimg_decode COMPILE_DEFINITIONS) -set(webp_definitions) -foreach(definition IN LISTS definitions) - if(definition MATCHES "^BIMG_CONFIG_PARSE_WEBP=") - list(APPEND webp_definitions "${definition}") - endif() -endforeach() - -if(EXPECTED_WEBP_DEFINITION STREQUAL "inherit") - if(webp_definitions) - message(FATAL_ERROR "Expected WebP to inherit the generic setting, got ${webp_definitions}") - endif() -elseif(NOT webp_definitions STREQUAL "BIMG_CONFIG_PARSE_WEBP=${EXPECTED_WEBP_DEFINITION}") - message(FATAL_ERROR "Expected one BIMG_CONFIG_PARSE_WEBP=${EXPECTED_WEBP_DEFINITION}, got ${webp_definitions}") -endif() - -target_compile_definitions(bimg_decode PRIVATE EXPECTED_WEBP=${EXPECTED_WEBP}) diff --git a/Dependencies/Tests/WebPParserOption/decoder.cpp b/Dependencies/Tests/WebPParserOption/decoder.cpp deleted file mode 100644 index c1aa1c9c1b..0000000000 --- a/Dependencies/Tests/WebPParserOption/decoder.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#ifndef BIMG_CONFIG_PARSE_WEBP -#define BIMG_CONFIG_PARSE_WEBP BIMG_CONFIG_PARSE_ENABLE -#endif - -static_assert(BIMG_CONFIG_PARSE_WEBP == EXPECTED_WEBP); From d3101275748dd0e90fb4d82c1770ebcfea5a51c3 Mon Sep 17 00:00:00 2001 From: Gary Hsu Date: Tue, 29 Sep 2026 15:51:29 -0700 Subject: [PATCH 06/28] Keep polyfill documentation focused on current options Remove the WebP option explanation and historical polyfill-switch notes after review. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- Documentation/BuildSystem.md | 7 ------- Documentation/Polyfills.md | 6 +----- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/Documentation/BuildSystem.md b/Documentation/BuildSystem.md index c961ed64de..55ec769c9e 100644 --- a/Documentation/BuildSystem.md +++ b/Documentation/BuildSystem.md @@ -17,13 +17,6 @@ An explicit setting from a parent CMake project is also respected. Unset or empt values use Babylon Native's disabled default, including empty cache entries left by earlier configurations. -NativeEngine WebP decoding is enabled by default when image loading is enabled. -`BABYLON_NATIVE_PLUGIN_NATIVEENGINE_WEBP=ON` enables bimg's WebP parser even -if a parent project disables generic bimg parsers with `BIMG_CONFIG_PARSE_ENABLE=0`. -Setting the WebP option to `OFF` disables its parser; disabling NativeEngine -leaves bimg's generic parser setting in control unless the WebP option is `OFF`. -Disabling NativeEngine image loading also forces the WebP option off. - ## Lateral Dependency Management Scalable dependency management can be a challenge when making heavy use of Git Submodules. diff --git a/Documentation/Polyfills.md b/Documentation/Polyfills.md index 3712590100..350038345e 100644 --- a/Documentation/Polyfills.md +++ b/Documentation/Polyfills.md @@ -7,11 +7,7 @@ When building Embedding, JsRuntimeHost enables AbortController, Scheduling, URL, and WebSocket by default. Set the corresponding `JSRUNTIMEHOST_POLYFILL_ABORTCONTROLLER`, `JSRUNTIMEHOST_POLYFILL_SCHEDULING`, `JSRUNTIMEHOST_POLYFILL_URL`, or `JSRUNTIMEHOST_POLYFILL_WEBSOCKET` CMake -option to `OFF` to omit that library and its Embedding initialization. The -former `BABYLON_NATIVE_POLYFILL_ABORTCONTROLLER`, -`BABYLON_NATIVE_POLYFILL_SCHEDULING`, `BABYLON_NATIVE_POLYFILL_URL`, and -`BABYLON_NATIVE_POLYFILL_WEBSOCKET` options no longer control these polyfills. -Window remains available when Scheduling is disabled, without its scheduling APIs. +option to `OFF` to omit that library and its Embedding initialization. At the moment, we are using the following polyfills: * [Canvas](../Polyfills/Canvas/readme.md) From 8f266096983de409e88db103b481844776398656 Mon Sep 17 00:00:00 2001 From: Gary Hsu Date: Tue, 29 Sep 2026 15:51:57 -0700 Subject: [PATCH 07/28] Remove Embedding switch notes from polyfills guide Embedding build settings belong with Embedding documentation; avoid adding a new document before its location is agreed. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- Documentation/Polyfills.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Documentation/Polyfills.md b/Documentation/Polyfills.md index 350038345e..2c687dc198 100644 --- a/Documentation/Polyfills.md +++ b/Documentation/Polyfills.md @@ -3,12 +3,6 @@ Babylon Native Polyfills add support for certain JavaScript browser APIs, such a The polyfills are still in an early stage and are subject to change. -When building Embedding, JsRuntimeHost enables AbortController, Scheduling, -URL, and WebSocket by default. Set the corresponding -`JSRUNTIMEHOST_POLYFILL_ABORTCONTROLLER`, `JSRUNTIMEHOST_POLYFILL_SCHEDULING`, -`JSRUNTIMEHOST_POLYFILL_URL`, or `JSRUNTIMEHOST_POLYFILL_WEBSOCKET` CMake -option to `OFF` to omit that library and its Embedding initialization. - At the moment, we are using the following polyfills: * [Canvas](../Polyfills/Canvas/readme.md) * [Console](../Polyfills/Console/readme.md) From 41a231c9be4417623bd769f1cea3b3810c9beb97 Mon Sep 17 00:00:00 2001 From: Gary Hsu Date: Tue, 29 Sep 2026 16:31:54 -0700 Subject: [PATCH 08/28] Make bimg format options the sole parser controls Default generic parsing off and enable the eight image formats used by native image loading. Forward each format option directly to bimg_decode instead of tying WebP parsing to NativeEngine image loading. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- CMakeLists.txt | 10 +++++----- Dependencies/CMakeLists.txt | 11 +++-------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1045be02fd..9c17465f9e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,6 +118,11 @@ option(BABYLON_NATIVE_BUILD_APPS "Build Babylon Native apps." ${PROJECT_IS_TOP_L option(BABYLON_NATIVE_INSTALL "Include the install target." ${PROJECT_IS_TOP_LEVEL}) option(BABYLON_DEBUG_TRACE "Enable debug trace." OFF) +option(BIMG_CONFIG_PARSE_ENABLE "Enable bimg image format parsers by default." OFF) +foreach(_bimg_format IN ITEMS BMP EXR GIF HDR JPEG PNG TGA WEBP) + option(BIMG_CONFIG_PARSE_${_bimg_format} "Enable bimg ${_bimg_format} image parsing." ON) +endforeach() + # WARNING: This is experimental. Only use it if you can ensure that your application will properly handle thread affinity. option(BABYLON_NATIVE_CHECK_THREAD_AFFINITY "Checks thread safety in the graphics device calls. It can be removed if hosting application ensures thread coherence." ON) @@ -128,12 +133,7 @@ option(BABYLON_NATIVE_PLUGIN_NATIVECAPTURE "Include Babylon Native Plugin Native option(BABYLON_NATIVE_PLUGIN_NATIVEDRACO "Include Babylon Native Plugin NativeDraco." OFF) option(BABYLON_NATIVE_PLUGIN_NATIVEENCODING "Include Babylon Native Plugin NativeEncoding." ON) option(BABYLON_NATIVE_PLUGIN_NATIVEENGINE "Include Babylon Native Plugin NativeEngine." ON) -option(BABYLON_NATIVE_PLUGIN_NATIVEENGINE_WEBP "Enable WebP image parsing in NativeEngine (via bimg)." ON) option(BABYLON_NATIVE_PLUGIN_NATIVEENGINE_LOAD_IMAGES "Enable image loading in NativeEngine (LoadTexture, image bitmap, bimg)." ON) -if(NOT BABYLON_NATIVE_PLUGIN_NATIVEENGINE_LOAD_IMAGES) - # WebP support relies on image loading code paths; force it off when image loading is disabled. - set(BABYLON_NATIVE_PLUGIN_NATIVEENGINE_WEBP OFF CACHE BOOL "Enable WebP image parsing in NativeEngine (via bimg)." FORCE) -endif() option(BABYLON_NATIVE_PLUGIN_NATIVEENGINE_COMPILESHADERS "Include Babylon Native Plugin NativeEngine - Compile Shaders." ON) option(BABYLON_NATIVE_PLUGIN_NATIVEINPUT "Include Babylon Native Plugin NativeInput." ON) option(BABYLON_NATIVE_PLUGIN_NATIVEMESHOPT "Include Babylon Native Plugin NativeMeshopt." OFF) diff --git a/Dependencies/CMakeLists.txt b/Dependencies/CMakeLists.txt index e2eb2b7b5d..23866fbfe7 100644 --- a/Dependencies/CMakeLists.txt +++ b/Dependencies/CMakeLists.txt @@ -106,15 +106,10 @@ foreach(_bimg_target IN ITEMS bimg_decode bimg_encode tinyexr) endif() endforeach() -# WebP parsing is provided by bimg's bundled simplewebp decoder. Set its -# parser macro explicitly when NativeEngine needs it, even if a parent project -# disables the other bimg parsers with BIMG_CONFIG_PARSE_ENABLE=0. if(TARGET bimg_decode) - if(NOT BABYLON_NATIVE_PLUGIN_NATIVEENGINE_WEBP) - target_compile_definitions(bimg_decode PRIVATE BIMG_CONFIG_PARSE_WEBP=0) - elseif(BABYLON_NATIVE_PLUGIN_NATIVEENGINE AND BABYLON_NATIVE_PLUGIN_NATIVEENGINE_LOAD_IMAGES) - target_compile_definitions(bimg_decode PRIVATE BIMG_CONFIG_PARSE_WEBP=1) - endif() + foreach(_bimg_format IN ITEMS BMP EXR GIF HDR JPEG PNG TGA WEBP) + target_compile_definitions(bimg_decode PRIVATE BIMG_CONFIG_PARSE_${_bimg_format}=$) + endforeach() endif() if(NOT APPLE AND NOT ANDROID AND CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64|amd64|AMD64)" AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") From aad14cfa142836c1b7a579657ff1f5065fc78104 Mon Sep 17 00:00:00 2001 From: Gary Hsu Date: Wed, 30 Sep 2026 08:11:04 -0700 Subject: [PATCH 09/28] Expose one native image parser format selection Keep bgfx.cmake as owner of the generic parser switch while defaulting it off for Babylon Native. Compile only selected bundled parsers, validate format names, and reject stb combinations unsupported by the pinned bimg decoder. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- CMakeLists.txt | 5 ----- Dependencies/CMakeLists.txt | 36 ++++++++++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c17465f9e..53cacd37a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,11 +118,6 @@ option(BABYLON_NATIVE_BUILD_APPS "Build Babylon Native apps." ${PROJECT_IS_TOP_L option(BABYLON_NATIVE_INSTALL "Include the install target." ${PROJECT_IS_TOP_LEVEL}) option(BABYLON_DEBUG_TRACE "Enable debug trace." OFF) -option(BIMG_CONFIG_PARSE_ENABLE "Enable bimg image format parsers by default." OFF) -foreach(_bimg_format IN ITEMS BMP EXR GIF HDR JPEG PNG TGA WEBP) - option(BIMG_CONFIG_PARSE_${_bimg_format} "Enable bimg ${_bimg_format} image parsing." ON) -endforeach() - # WARNING: This is experimental. Only use it if you can ensure that your application will properly handle thread affinity. option(BABYLON_NATIVE_CHECK_THREAD_AFFINITY "Checks thread safety in the graphics device calls. It can be removed if hosting application ensures thread coherence." ON) diff --git a/Dependencies/CMakeLists.txt b/Dependencies/CMakeLists.txt index 23866fbfe7..0f07fe7693 100644 --- a/Dependencies/CMakeLists.txt +++ b/Dependencies/CMakeLists.txt @@ -39,6 +39,38 @@ set(BGFX_OPENGL_USE_EGL ON) set(BGFX_USE_DEBUG_SUFFIX OFF) set(BGFX_CONFIG_VIDEO OFF) +if(NOT DEFINED BIMG_CONFIG_PARSE_ENABLE) + set(BIMG_CONFIG_PARSE_ENABLE OFF CACHE BOOL "Enable bimg image format parsers.") +endif() + +if(NOT DEFINED BABYLON_NATIVE_IMAGE_PARSER_FORMATS) + set(BABYLON_NATIVE_IMAGE_PARSER_FORMATS "BMP;EXR;GIF;HDR;JPEG;PNG;TGA;WEBP" CACHE STRING "Bundled bimg image parsers to compile.") +endif() + +set(_bimg_supported_formats BMP EXR GIF HDR JPEG PNG TGA WEBP) +set(_bimg_selected_formats) +if(BABYLON_NATIVE_IMAGE_PARSER_FORMATS MATCHES "(^;|;;|;$)") + message(FATAL_ERROR "BABYLON_NATIVE_IMAGE_PARSER_FORMATS contains an empty format name.") +endif() +foreach(_bimg_format IN LISTS BABYLON_NATIVE_IMAGE_PARSER_FORMATS) + if(NOT _bimg_format IN_LIST _bimg_supported_formats) + message(FATAL_ERROR "Unsupported image parser format '${_bimg_format}' in BABYLON_NATIVE_IMAGE_PARSER_FORMATS.") + endif() + if(_bimg_format IN_LIST _bimg_selected_formats) + message(FATAL_ERROR "Duplicate image parser format '${_bimg_format}' in BABYLON_NATIVE_IMAGE_PARSER_FORMATS.") + endif() + list(APPEND _bimg_selected_formats "${_bimg_format}") +endforeach() + +# Pinned bimg's stb parsers use allocators defined only when its PNG parser is enabled. +if(NOT BIMG_CONFIG_PARSE_ENABLE AND NOT "PNG" IN_LIST _bimg_selected_formats) + foreach(_bimg_stb_format IN ITEMS BMP GIF HDR JPEG TGA) + if(_bimg_stb_format IN_LIST _bimg_selected_formats) + message(FATAL_ERROR "The pinned bimg decoder requires PNG when ${_bimg_stb_format} is selected in BABYLON_NATIVE_IMAGE_PARSER_FORMATS.") + endif() + endforeach() +endif() + # Keep AVIF opt-in, including caches with bgfx.cmake's empty (inherit) default. if(NOT DEFINED BIMG_CONFIG_PARSE_AVIF OR "${BIMG_CONFIG_PARSE_AVIF}" STREQUAL "") set(BIMG_CONFIG_PARSE_AVIF OFF) @@ -107,8 +139,8 @@ foreach(_bimg_target IN ITEMS bimg_decode bimg_encode tinyexr) endforeach() if(TARGET bimg_decode) - foreach(_bimg_format IN ITEMS BMP EXR GIF HDR JPEG PNG TGA WEBP) - target_compile_definitions(bimg_decode PRIVATE BIMG_CONFIG_PARSE_${_bimg_format}=$) + foreach(_bimg_format IN LISTS _bimg_selected_formats) + target_compile_definitions(bimg_decode PRIVATE BIMG_CONFIG_PARSE_${_bimg_format}=1) endforeach() endif() From 63d27806e89d7e875c9b95d04165fc8737c2c73f Mon Sep 17 00:00:00 2001 From: Gary Hsu Date: Wed, 30 Sep 2026 13:39:02 -0700 Subject: [PATCH 10/28] Move image parser selection beside NativeEngine options Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- CMakeLists.txt | 3 +++ Dependencies/CMakeLists.txt | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 53cacd37a6..dda05968e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -129,6 +129,9 @@ option(BABYLON_NATIVE_PLUGIN_NATIVEDRACO "Include Babylon Native Plugin NativeDr option(BABYLON_NATIVE_PLUGIN_NATIVEENCODING "Include Babylon Native Plugin NativeEncoding." ON) option(BABYLON_NATIVE_PLUGIN_NATIVEENGINE "Include Babylon Native Plugin NativeEngine." ON) option(BABYLON_NATIVE_PLUGIN_NATIVEENGINE_LOAD_IMAGES "Enable image loading in NativeEngine (LoadTexture, image bitmap, bimg)." ON) +if(NOT DEFINED BABYLON_NATIVE_IMAGE_PARSER_FORMATS) + set(BABYLON_NATIVE_IMAGE_PARSER_FORMATS "BMP;EXR;GIF;HDR;JPEG;PNG;TGA;WEBP" CACHE STRING "Bundled bimg image parsers to compile.") +endif() option(BABYLON_NATIVE_PLUGIN_NATIVEENGINE_COMPILESHADERS "Include Babylon Native Plugin NativeEngine - Compile Shaders." ON) option(BABYLON_NATIVE_PLUGIN_NATIVEINPUT "Include Babylon Native Plugin NativeInput." ON) option(BABYLON_NATIVE_PLUGIN_NATIVEMESHOPT "Include Babylon Native Plugin NativeMeshopt." OFF) diff --git a/Dependencies/CMakeLists.txt b/Dependencies/CMakeLists.txt index 0f07fe7693..175ed51aa7 100644 --- a/Dependencies/CMakeLists.txt +++ b/Dependencies/CMakeLists.txt @@ -43,10 +43,6 @@ if(NOT DEFINED BIMG_CONFIG_PARSE_ENABLE) set(BIMG_CONFIG_PARSE_ENABLE OFF CACHE BOOL "Enable bimg image format parsers.") endif() -if(NOT DEFINED BABYLON_NATIVE_IMAGE_PARSER_FORMATS) - set(BABYLON_NATIVE_IMAGE_PARSER_FORMATS "BMP;EXR;GIF;HDR;JPEG;PNG;TGA;WEBP" CACHE STRING "Bundled bimg image parsers to compile.") -endif() - set(_bimg_supported_formats BMP EXR GIF HDR JPEG PNG TGA WEBP) set(_bimg_selected_formats) if(BABYLON_NATIVE_IMAGE_PARSER_FORMATS MATCHES "(^;|;;|;$)") From d6fd4072d86bb3550c9871b2de7a3de8f51da673 Mon Sep 17 00:00:00 2001 From: Gary Hsu Date: Wed, 30 Sep 2026 14:07:56 -0700 Subject: [PATCH 11/28] Use dependency image parser controls and enable AVIF by default The updated wrapper forwards per-format settings and pins the bimg allocator fix, allowing JPEG without PNG. Preserve explicit overrides while passing selected defaults before dependency configuration. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- CMakeLists.txt | 4 ++-- Dependencies/CMakeLists.txt | 26 ++++++-------------------- 2 files changed, 8 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dda05968e6..fa2ea2dbf3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,7 @@ FetchContent_Declare(base-n EXCLUDE_FROM_ALL) FetchContent_Declare(bgfx.cmake GIT_REPOSITORY https://github.com/BabylonJS/bgfx.cmake.git - GIT_TAG 650e4a7c68e68e65b05da882c0b3d6980f9a96d3 + GIT_TAG 3947195a451f85da9836adcbb6c165927b145b52 EXCLUDE_FROM_ALL) FetchContent_Declare(CMakeExtensions GIT_REPOSITORY https://github.com/BabylonJS/CMakeExtensions.git @@ -130,7 +130,7 @@ option(BABYLON_NATIVE_PLUGIN_NATIVEENCODING "Include Babylon Native Plugin Nativ option(BABYLON_NATIVE_PLUGIN_NATIVEENGINE "Include Babylon Native Plugin NativeEngine." ON) option(BABYLON_NATIVE_PLUGIN_NATIVEENGINE_LOAD_IMAGES "Enable image loading in NativeEngine (LoadTexture, image bitmap, bimg)." ON) if(NOT DEFINED BABYLON_NATIVE_IMAGE_PARSER_FORMATS) - set(BABYLON_NATIVE_IMAGE_PARSER_FORMATS "BMP;EXR;GIF;HDR;JPEG;PNG;TGA;WEBP" CACHE STRING "Bundled bimg image parsers to compile.") + set(BABYLON_NATIVE_IMAGE_PARSER_FORMATS "AVIF;BMP;EXR;GIF;HDR;JPEG;PNG;TGA;WEBP" CACHE STRING "Bundled bimg image parsers to compile.") endif() option(BABYLON_NATIVE_PLUGIN_NATIVEENGINE_COMPILESHADERS "Include Babylon Native Plugin NativeEngine - Compile Shaders." ON) option(BABYLON_NATIVE_PLUGIN_NATIVEINPUT "Include Babylon Native Plugin NativeInput." ON) diff --git a/Dependencies/CMakeLists.txt b/Dependencies/CMakeLists.txt index 175ed51aa7..2b4797b8a5 100644 --- a/Dependencies/CMakeLists.txt +++ b/Dependencies/CMakeLists.txt @@ -43,7 +43,7 @@ if(NOT DEFINED BIMG_CONFIG_PARSE_ENABLE) set(BIMG_CONFIG_PARSE_ENABLE OFF CACHE BOOL "Enable bimg image format parsers.") endif() -set(_bimg_supported_formats BMP EXR GIF HDR JPEG PNG TGA WEBP) +set(_bimg_supported_formats AVIF BMP EXR GIF HDR JPEG PNG TGA WEBP) set(_bimg_selected_formats) if(BABYLON_NATIVE_IMAGE_PARSER_FORMATS MATCHES "(^;|;;|;$)") message(FATAL_ERROR "BABYLON_NATIVE_IMAGE_PARSER_FORMATS contains an empty format name.") @@ -58,19 +58,11 @@ foreach(_bimg_format IN LISTS BABYLON_NATIVE_IMAGE_PARSER_FORMATS) list(APPEND _bimg_selected_formats "${_bimg_format}") endforeach() -# Pinned bimg's stb parsers use allocators defined only when its PNG parser is enabled. -if(NOT BIMG_CONFIG_PARSE_ENABLE AND NOT "PNG" IN_LIST _bimg_selected_formats) - foreach(_bimg_stb_format IN ITEMS BMP GIF HDR JPEG TGA) - if(_bimg_stb_format IN_LIST _bimg_selected_formats) - message(FATAL_ERROR "The pinned bimg decoder requires PNG when ${_bimg_stb_format} is selected in BABYLON_NATIVE_IMAGE_PARSER_FORMATS.") - endif() - endforeach() -endif() - -# Keep AVIF opt-in, including caches with bgfx.cmake's empty (inherit) default. -if(NOT DEFINED BIMG_CONFIG_PARSE_AVIF OR "${BIMG_CONFIG_PARSE_AVIF}" STREQUAL "") - set(BIMG_CONFIG_PARSE_AVIF OFF) -endif() +foreach(_bimg_format IN LISTS _bimg_selected_formats) + if(NOT DEFINED BIMG_CONFIG_PARSE_${_bimg_format} OR "${BIMG_CONFIG_PARSE_${_bimg_format}}" STREQUAL "") + set(BIMG_CONFIG_PARSE_${_bimg_format} ON) + endif() +endforeach() FetchContent_MakeAvailable_With_Message(bgfx.cmake) @@ -134,12 +126,6 @@ foreach(_bimg_target IN ITEMS bimg_decode bimg_encode tinyexr) endif() endforeach() -if(TARGET bimg_decode) - foreach(_bimg_format IN LISTS _bimg_selected_formats) - target_compile_definitions(bimg_decode PRIVATE BIMG_CONFIG_PARSE_${_bimg_format}=1) - endforeach() -endif() - if(NOT APPLE AND NOT ANDROID AND CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64|amd64|AMD64)" AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") foreach(_bx_target IN ITEMS bx bgfx bimg bimg_decode bimg_encode) if(TARGET ${_bx_target}) From dea671ea56a46ecb8d33f5e242d76717a9eb20d6 Mon Sep 17 00:00:00 2001 From: Gary Hsu Date: Wed, 30 Sep 2026 14:40:04 -0700 Subject: [PATCH 12/28] Pin remotely available image parser dependency revisions Use the fork until the dependency changes land upstream. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fa2ea2dbf3..e6ea53262c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,8 +34,8 @@ FetchContent_Declare(base-n GIT_TAG 7573e77c0b9b0e8a5fb63d96dbde212c921993b4 EXCLUDE_FROM_ALL) FetchContent_Declare(bgfx.cmake - GIT_REPOSITORY https://github.com/BabylonJS/bgfx.cmake.git - GIT_TAG 3947195a451f85da9836adcbb6c165927b145b52 + GIT_REPOSITORY https://github.com/bghgary/bgfx.cmake.git + GIT_TAG a61a035875677a86ae0a7e92b4894ddf09796fcf EXCLUDE_FROM_ALL) FetchContent_Declare(CMakeExtensions GIT_REPOSITORY https://github.com/BabylonJS/CMakeExtensions.git From 6314aac07076f0728ab76a1e1a866ccab6f12208 Mon Sep 17 00:00:00 2001 From: Gary Hsu Date: Wed, 30 Sep 2026 14:47:58 -0700 Subject: [PATCH 13/28] Update image parser wrapper to merged upstream bimg fix Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e6ea53262c..48b8f33c9e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,7 @@ FetchContent_Declare(base-n EXCLUDE_FROM_ALL) FetchContent_Declare(bgfx.cmake GIT_REPOSITORY https://github.com/bghgary/bgfx.cmake.git - GIT_TAG a61a035875677a86ae0a7e92b4894ddf09796fcf + GIT_TAG c09d95807217ed8db01186c9502cac6d64e2e6f7 EXCLUDE_FROM_ALL) FetchContent_Declare(CMakeExtensions GIT_REPOSITORY https://github.com/BabylonJS/CMakeExtensions.git From 95b0a2a413224887cf3f544d148fcd291880978c Mon Sep 17 00:00:00 2001 From: Gary Hsu Date: Wed, 30 Sep 2026 15:07:12 -0700 Subject: [PATCH 14/28] Pin explicit parser options and separate WIC backend configuration Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 48b8f33c9e..4d7b787c51 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,7 @@ FetchContent_Declare(base-n EXCLUDE_FROM_ALL) FetchContent_Declare(bgfx.cmake GIT_REPOSITORY https://github.com/bghgary/bgfx.cmake.git - GIT_TAG c09d95807217ed8db01186c9502cac6d64e2e6f7 + GIT_TAG d3f12c41ec8b172acec73c8b10c2198a93f1ac84 EXCLUDE_FROM_ALL) FetchContent_Declare(CMakeExtensions GIT_REPOSITORY https://github.com/BabylonJS/CMakeExtensions.git From c268265ba091ecf9824d19e4590b4764ab193662 Mon Sep 17 00:00:00 2001 From: Gary Hsu Date: Wed, 30 Sep 2026 15:22:05 -0700 Subject: [PATCH 15/28] Keep parser list changes effective with boolean dependency options Supply normal defaults for unselected formats as well as selected formats so dependency options do not cache implicit choices. Explicit consumer overrides remain untouched. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- CMakeLists.txt | 2 +- Dependencies/CMakeLists.txt | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4d7b787c51..1428ff7a01 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,7 @@ FetchContent_Declare(base-n EXCLUDE_FROM_ALL) FetchContent_Declare(bgfx.cmake GIT_REPOSITORY https://github.com/bghgary/bgfx.cmake.git - GIT_TAG d3f12c41ec8b172acec73c8b10c2198a93f1ac84 + GIT_TAG c14308ad9c6059434f3ba905959ae9c5bc6b5aac EXCLUDE_FROM_ALL) FetchContent_Declare(CMakeExtensions GIT_REPOSITORY https://github.com/BabylonJS/CMakeExtensions.git diff --git a/Dependencies/CMakeLists.txt b/Dependencies/CMakeLists.txt index 2b4797b8a5..1cb8de9de5 100644 --- a/Dependencies/CMakeLists.txt +++ b/Dependencies/CMakeLists.txt @@ -58,9 +58,14 @@ foreach(_bimg_format IN LISTS BABYLON_NATIVE_IMAGE_PARSER_FORMATS) list(APPEND _bimg_selected_formats "${_bimg_format}") endforeach() -foreach(_bimg_format IN LISTS _bimg_selected_formats) +# Normal defaults for every format prevent dependency cache entries from freezing later list changes. +foreach(_bimg_format IN LISTS _bimg_supported_formats) if(NOT DEFINED BIMG_CONFIG_PARSE_${_bimg_format} OR "${BIMG_CONFIG_PARSE_${_bimg_format}}" STREQUAL "") - set(BIMG_CONFIG_PARSE_${_bimg_format} ON) + if(_bimg_format IN_LIST _bimg_selected_formats) + set(BIMG_CONFIG_PARSE_${_bimg_format} ON) + else() + set(BIMG_CONFIG_PARSE_${_bimg_format} "${BIMG_CONFIG_PARSE_ENABLE}") + endif() endif() endforeach() From 42211361b746eea19858051ebd0e753f3fed5635 Mon Sep 17 00:00:00 2001 From: Gary Hsu Date: Wed, 30 Sep 2026 17:05:27 -0700 Subject: [PATCH 16/28] Pin wrapper with anticipated WIC backend control The WIC decoder contract remains pending upstream; keep the consumer PR draft until runtime behavior can be verified. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1428ff7a01..c86fd635d8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,7 @@ FetchContent_Declare(base-n EXCLUDE_FROM_ALL) FetchContent_Declare(bgfx.cmake GIT_REPOSITORY https://github.com/bghgary/bgfx.cmake.git - GIT_TAG c14308ad9c6059434f3ba905959ae9c5bc6b5aac + GIT_TAG 2a141f76469781be935355cfcec0ad5662d0b3af EXCLUDE_FROM_ALL) FetchContent_Declare(CMakeExtensions GIT_REPOSITORY https://github.com/BabylonJS/CMakeExtensions.git From 07c75f14c8d1dcb47bc5be3319485c8de32bf5fc Mon Sep 17 00:00:00 2001 From: Gary Hsu Date: Wed, 30 Sep 2026 17:25:37 -0700 Subject: [PATCH 17/28] Pin wrapper with WIC disabled by default Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c86fd635d8..2a806262c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,7 @@ FetchContent_Declare(base-n EXCLUDE_FROM_ALL) FetchContent_Declare(bgfx.cmake GIT_REPOSITORY https://github.com/bghgary/bgfx.cmake.git - GIT_TAG 2a141f76469781be935355cfcec0ad5662d0b3af + GIT_TAG 130dc09b251d876fab33fd5c9c70c94a11d97f20 EXCLUDE_FROM_ALL) FetchContent_Declare(CMakeExtensions GIT_REPOSITORY https://github.com/BabylonJS/CMakeExtensions.git From 090520352d247e84ce05869649c2780d6215a673 Mon Sep 17 00:00:00 2001 From: Gary Hsu Date: Wed, 30 Sep 2026 18:04:27 -0700 Subject: [PATCH 18/28] Pin wrapper with inherited per-format parser defaults Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2a806262c2..279ef5338f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,7 @@ FetchContent_Declare(base-n EXCLUDE_FROM_ALL) FetchContent_Declare(bgfx.cmake GIT_REPOSITORY https://github.com/bghgary/bgfx.cmake.git - GIT_TAG 130dc09b251d876fab33fd5c9c70c94a11d97f20 + GIT_TAG 2dadc1e958caade03d90047417d0ccf9a1d81f63 EXCLUDE_FROM_ALL) FetchContent_Declare(CMakeExtensions GIT_REPOSITORY https://github.com/BabylonJS/CMakeExtensions.git From 71b7ab4f46bbec7e0affddf1dd6b152a9c0136bb Mon Sep 17 00:00:00 2001 From: Gary Hsu Date: Thu, 1 Oct 2026 09:29:21 -0700 Subject: [PATCH 19/28] Pin parser-only wrapper without anticipated WIC control Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 017f0b570f..f06cafe75e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,7 @@ FetchContent_Declare(base-n EXCLUDE_FROM_ALL) FetchContent_Declare(bgfx.cmake GIT_REPOSITORY https://github.com/bghgary/bgfx.cmake.git - GIT_TAG 4c4e1d960356060d945c29096ad8139a2f981c9a + GIT_TAG 8f8c77f9b96301fd45269d9259522384ccc1c021 EXCLUDE_FROM_ALL) FetchContent_Declare(CMakeExtensions GIT_REPOSITORY https://github.com/BabylonJS/CMakeExtensions.git From c087d91d7ca570e33af86e8a636a2a1aa7bbeb6a Mon Sep 17 00:00:00 2001 From: Gary Hsu Date: Thu, 1 Oct 2026 09:39:06 -0700 Subject: [PATCH 20/28] Use merged upstream image parser configuration Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f06cafe75e..84f4131cea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,8 +34,8 @@ FetchContent_Declare(base-n GIT_TAG 7573e77c0b9b0e8a5fb63d96dbde212c921993b4 EXCLUDE_FROM_ALL) FetchContent_Declare(bgfx.cmake - GIT_REPOSITORY https://github.com/bghgary/bgfx.cmake.git - GIT_TAG 8f8c77f9b96301fd45269d9259522384ccc1c021 + GIT_REPOSITORY https://github.com/BabylonJS/bgfx.cmake.git + GIT_TAG bc2b98c9365a8b9849a556b2f3e481b67242b930 EXCLUDE_FROM_ALL) FetchContent_Declare(CMakeExtensions GIT_REPOSITORY https://github.com/BabylonJS/CMakeExtensions.git From ebfc1418ea36a8f0bfd4daae8fae4bf876bc70fa Mon Sep 17 00:00:00 2001 From: Gary Hsu Date: Thu, 1 Oct 2026 09:54:01 -0700 Subject: [PATCH 21/28] Use bgfx.cmake image parser controls directly Remove the redundant Babylon Native format list and adapter defaults so upstream parser settings remain authoritative. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- CMakeLists.txt | 3 --- Dependencies/CMakeLists.txt | 30 ------------------------------ 2 files changed, 33 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 84f4131cea..9aeff5b542 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -129,9 +129,6 @@ option(BABYLON_NATIVE_PLUGIN_NATIVEDRACO "Include Babylon Native Plugin NativeDr option(BABYLON_NATIVE_PLUGIN_NATIVEENCODING "Include Babylon Native Plugin NativeEncoding." ON) option(BABYLON_NATIVE_PLUGIN_NATIVEENGINE "Include Babylon Native Plugin NativeEngine." ON) option(BABYLON_NATIVE_PLUGIN_NATIVEENGINE_LOAD_IMAGES "Enable image loading in NativeEngine (LoadTexture, image bitmap, bimg)." ON) -if(NOT DEFINED BABYLON_NATIVE_IMAGE_PARSER_FORMATS) - set(BABYLON_NATIVE_IMAGE_PARSER_FORMATS "AVIF;BMP;EXR;GIF;HDR;JPEG;PNG;TGA;WEBP" CACHE STRING "Bundled bimg image parsers to compile.") -endif() option(BABYLON_NATIVE_PLUGIN_NATIVEENGINE_COMPILESHADERS "Include Babylon Native Plugin NativeEngine - Compile Shaders." ON) option(BABYLON_NATIVE_PLUGIN_NATIVEINPUT "Include Babylon Native Plugin NativeInput." ON) option(BABYLON_NATIVE_PLUGIN_NATIVEMESHOPT "Include Babylon Native Plugin NativeMeshopt." OFF) diff --git a/Dependencies/CMakeLists.txt b/Dependencies/CMakeLists.txt index 1cb8de9de5..f95d98b0d8 100644 --- a/Dependencies/CMakeLists.txt +++ b/Dependencies/CMakeLists.txt @@ -39,36 +39,6 @@ set(BGFX_OPENGL_USE_EGL ON) set(BGFX_USE_DEBUG_SUFFIX OFF) set(BGFX_CONFIG_VIDEO OFF) -if(NOT DEFINED BIMG_CONFIG_PARSE_ENABLE) - set(BIMG_CONFIG_PARSE_ENABLE OFF CACHE BOOL "Enable bimg image format parsers.") -endif() - -set(_bimg_supported_formats AVIF BMP EXR GIF HDR JPEG PNG TGA WEBP) -set(_bimg_selected_formats) -if(BABYLON_NATIVE_IMAGE_PARSER_FORMATS MATCHES "(^;|;;|;$)") - message(FATAL_ERROR "BABYLON_NATIVE_IMAGE_PARSER_FORMATS contains an empty format name.") -endif() -foreach(_bimg_format IN LISTS BABYLON_NATIVE_IMAGE_PARSER_FORMATS) - if(NOT _bimg_format IN_LIST _bimg_supported_formats) - message(FATAL_ERROR "Unsupported image parser format '${_bimg_format}' in BABYLON_NATIVE_IMAGE_PARSER_FORMATS.") - endif() - if(_bimg_format IN_LIST _bimg_selected_formats) - message(FATAL_ERROR "Duplicate image parser format '${_bimg_format}' in BABYLON_NATIVE_IMAGE_PARSER_FORMATS.") - endif() - list(APPEND _bimg_selected_formats "${_bimg_format}") -endforeach() - -# Normal defaults for every format prevent dependency cache entries from freezing later list changes. -foreach(_bimg_format IN LISTS _bimg_supported_formats) - if(NOT DEFINED BIMG_CONFIG_PARSE_${_bimg_format} OR "${BIMG_CONFIG_PARSE_${_bimg_format}}" STREQUAL "") - if(_bimg_format IN_LIST _bimg_selected_formats) - set(BIMG_CONFIG_PARSE_${_bimg_format} ON) - else() - set(BIMG_CONFIG_PARSE_${_bimg_format} "${BIMG_CONFIG_PARSE_ENABLE}") - endif() - endif() -endforeach() - FetchContent_MakeAvailable_With_Message(bgfx.cmake) # Turn off debug annotations as it causes an access violation in D3D12. From ffcd897a5cda4e10b705f890c2d0ab37ce58a7ad Mon Sep 17 00:00:00 2001 From: Gary Hsu Date: Thu, 1 Oct 2026 10:14:57 -0700 Subject: [PATCH 22/28] Limit default image parsers to Babylon.js formats Default PIC, PNM and PSD parsing to OFF without replacing explicit cache or parent settings. Keep empty values inheriting the generic upstream parser switch. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- Dependencies/CMakeLists.txt | 5 +++++ Documentation/BuildSystem.md | 8 ++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Dependencies/CMakeLists.txt b/Dependencies/CMakeLists.txt index f95d98b0d8..ece3d173cd 100644 --- a/Dependencies/CMakeLists.txt +++ b/Dependencies/CMakeLists.txt @@ -39,6 +39,11 @@ set(BGFX_OPENGL_USE_EGL ON) set(BGFX_USE_DEBUG_SUFFIX OFF) set(BGFX_CONFIG_VIDEO OFF) +# These formats have neither browser image support nor Babylon.js texture loaders. +set(BIMG_CONFIG_PARSE_PIC OFF CACHE STRING "Enable PIC parsing (empty uses bimg's default).") +set(BIMG_CONFIG_PARSE_PNM OFF CACHE STRING "Enable PNM parsing (empty uses bimg's default).") +set(BIMG_CONFIG_PARSE_PSD OFF CACHE STRING "Enable PSD parsing (empty uses bimg's default).") + FetchContent_MakeAvailable_With_Message(bgfx.cmake) # Turn off debug annotations as it causes an access violation in D3D12. diff --git a/Documentation/BuildSystem.md b/Documentation/BuildSystem.md index 55ec769c9e..0ee13e21e6 100644 --- a/Documentation/BuildSystem.md +++ b/Documentation/BuildSystem.md @@ -9,13 +9,9 @@ and outlines some of the reasoning and intent behind them. ## Image Format Parsing -Native AVIF image decoding is disabled by default. This excludes the libavif and -dav1d sources from the bimg decoder build; other image-format defaults are unchanged. +Bundled image parsers default to AVIF, BMP, EXR, GIF, HDR, JPEG, PNG, TGA, and WebP, matching browser image formats and Babylon.js texture loaders. PIC, PNM, and PSD default to OFF; HEIF is OFF upstream. -To enable AVIF support, configure Babylon Native with `-DBIMG_CONFIG_PARSE_AVIF=ON`. -An explicit setting from a parent CMake project is also respected. Unset or empty -values use Babylon Native's disabled default, including empty cache entries left by -earlier configurations. +Configure individual formats with bgfx.cmake's `BIMG_CONFIG_PARSE_` settings (`ON`, `OFF`, or empty), for example `-DBIMG_CONFIG_PARSE_PSD=ON`. Explicit cache entries and parent-project values are preserved. Empty values inherit `BIMG_CONFIG_PARSE_ENABLE`, which defaults to ON. These settings do not control bimg's texture-container parsers. ## Lateral Dependency Management From 4804e7d706dd26b631f3c4dea0becd44a59a80e8 Mon Sep 17 00:00:00 2001 From: Gary Hsu Date: Thu, 1 Oct 2026 10:30:14 -0700 Subject: [PATCH 23/28] Test installed Embedding linkage and require Scheduling for Window Construct Runtime in a separate installed-library consumer instead of checking three dependency files. The link check exposes missing installed dependencies, including the optional TestUtils archive. Keep Scheduling required by Window and reject incompatible configuration before compilation. Embedding remains usable with both Window and Scheduling disabled. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- Install/Install.cmake | 5 +++++ Install/Test/CMakeLists.txt | 24 +++++++++++------------- Install/Test/Embedding.cpp | 7 +++++++ Polyfills/Window/CMakeLists.txt | 10 +++++----- Polyfills/Window/Source/Window.cpp | 4 ---- 5 files changed, 28 insertions(+), 22 deletions(-) create mode 100644 Install/Test/Embedding.cpp diff --git a/Install/Install.cmake b/Install/Install.cmake index c7c431ddca..287fc842be 100644 --- a/Install/Install.cmake +++ b/Install/Install.cmake @@ -188,6 +188,11 @@ if(TARGET ShaderCompiler) install_lib(ShaderCompiler) endif() +if(TARGET TestUtils) + install_lib(TestUtils) + install_include(TestUtils) +endif() + if(TARGET ShaderTool) install_bin(ShaderTool) endif() diff --git a/Install/Test/CMakeLists.txt b/Install/Test/CMakeLists.txt index 82ebc0a31c..c0bd87ee91 100644 --- a/Install/Test/CMakeLists.txt +++ b/Install/Test/CMakeLists.txt @@ -71,16 +71,6 @@ target_include_directories(TestInstall PRIVATE "${INSTALL_DIR}/include") message(STATUS "Install lib directory: ${INSTALL_DIR}/lib") set(INSTALL_LIBS_DIR "${INSTALL_DIR}/lib") -if(EXISTS "${INSTALL_LIBS_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}Embedding${CMAKE_STATIC_LIBRARY_SUFFIX}") - foreach(POLYFILL Fetch File TextEncoder) - if(NOT EXISTS "${INSTALL_LIBS_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}${POLYFILL}${CMAKE_STATIC_LIBRARY_SUFFIX}") - message(FATAL_ERROR "Missing installed ${POLYFILL} library") - endif() - if(NOT EXISTS "${INSTALL_DIR}/include/Babylon/Polyfills/${POLYFILL}.h") - message(FATAL_ERROR "Missing installed ${POLYFILL} header") - endif() - endforeach() -endif() target_link_directories(TestInstall PRIVATE ${INSTALL_LIBS_DIR}) if(WIN32) file(GLOB INSTALL_LIBS "${INSTALL_LIBS_DIR}/*.lib") @@ -98,8 +88,8 @@ foreach(LIB_NAME ${INSTALL_LIB_NAMES}) endforeach() if(WIN32 AND NOT WINDOWS_STORE) - target_link_libraries(TestInstall - ${INSTALL_LIB_NAMES} + set(INSTALL_TEST_LIBS + ${INSTALL_LIBS} gtest_main chakrart d3d11 @@ -115,7 +105,7 @@ else() # The installed tree is plain archives with no CMake targets describing how they depend on # each other, so link them as a group and let the linker resolve the cycles rather than # depending on glob order. - target_link_libraries(TestInstall + set(INSTALL_TEST_LIBS -Wl,--start-group ${INSTALL_LIBS} -Wl,--end-group gtest_main ${JAVASCRIPTCORE_LIBRARY} @@ -128,6 +118,14 @@ else() dl) endif() +target_link_libraries(TestInstall ${INSTALL_TEST_LIBS}) + +if(EXISTS "${INSTALL_LIBS_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}Embedding${CMAKE_STATIC_LIBRARY_SUFFIX}") + add_executable(TestInstallEmbedding Embedding.cpp) + target_include_directories(TestInstallEmbedding PRIVATE "${INSTALL_DIR}/include") + target_link_libraries(TestInstallEmbedding PRIVATE ${INSTALL_TEST_LIBS}) +endif() + # See https://gitlab.kitware.com/cmake/cmake/-/issues/23543 # If we can set minimum required to 3.26+, then we can use the `copy -t` syntax instead. add_custom_command(TARGET TestInstall POST_BUILD diff --git a/Install/Test/Embedding.cpp b/Install/Test/Embedding.cpp new file mode 100644 index 0000000000..c6d06ea082 --- /dev/null +++ b/Install/Test/Embedding.cpp @@ -0,0 +1,7 @@ +#include + +int main() +{ + Babylon::Embedding::Runtime runtime{}; + return runtime.IsSuspended() ? 1 : 0; +} diff --git a/Polyfills/Window/CMakeLists.txt b/Polyfills/Window/CMakeLists.txt index 3dbe74ad08..690713eb04 100644 --- a/Polyfills/Window/CMakeLists.txt +++ b/Polyfills/Window/CMakeLists.txt @@ -1,3 +1,7 @@ +if(NOT TARGET Scheduling) + message(FATAL_ERROR "The Window polyfill requires Scheduling. Enable JSRUNTIMEHOST_POLYFILL_SCHEDULING or disable BABYLON_NATIVE_POLYFILL_WINDOW.") +endif() + set(SOURCES "Include/Babylon/Polyfills/Window.h" "Source/Window.h" @@ -13,12 +17,8 @@ target_link_libraries(Window PUBLIC napi PRIVATE base-n PRIVATE JsRuntimeInternal + PRIVATE Scheduling PRIVATE GraphicsDeviceContext) -if(TARGET Scheduling) - target_compile_definitions(Window PRIVATE JSRUNTIMEHOST_POLYFILL_SCHEDULING=1) - target_link_libraries(Window PRIVATE Scheduling) -endif() - set_property(TARGET Window PROPERTY FOLDER Polyfills) source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SOURCES}) \ No newline at end of file diff --git a/Polyfills/Window/Source/Window.cpp b/Polyfills/Window/Source/Window.cpp index 7883a12e7c..faa99a7642 100644 --- a/Polyfills/Window/Source/Window.cpp +++ b/Polyfills/Window/Source/Window.cpp @@ -1,9 +1,7 @@ #include "Window.h" #include -#if JSRUNTIMEHOST_POLYFILL_SCHEDULING #include -#endif #include @@ -33,9 +31,7 @@ namespace Babylon::Polyfills::Internal jsNative.Set(JS_WINDOW_NAME, jsWindow); -#if JSRUNTIMEHOST_POLYFILL_SCHEDULING Scheduling::Initialize(env); -#endif if (global.Get(JS_A_TO_B_NAME).IsUndefined()) { From caeb1ecaa0e5229e52809fc6e7c07a0811fbc3aa Mon Sep 17 00:00:00 2001 From: Gary Hsu Date: Thu, 1 Oct 2026 10:36:24 -0700 Subject: [PATCH 24/28] Disable unsupported image parsers unconditionally Use normal OFF variables for PIC, PNM and PSD so Babylon Native excludes them even when upstream cache or parent settings request them. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- Dependencies/CMakeLists.txt | 6 +++--- Documentation/BuildSystem.md | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Dependencies/CMakeLists.txt b/Dependencies/CMakeLists.txt index ece3d173cd..c80cec1ff9 100644 --- a/Dependencies/CMakeLists.txt +++ b/Dependencies/CMakeLists.txt @@ -40,9 +40,9 @@ set(BGFX_USE_DEBUG_SUFFIX OFF) set(BGFX_CONFIG_VIDEO OFF) # These formats have neither browser image support nor Babylon.js texture loaders. -set(BIMG_CONFIG_PARSE_PIC OFF CACHE STRING "Enable PIC parsing (empty uses bimg's default).") -set(BIMG_CONFIG_PARSE_PNM OFF CACHE STRING "Enable PNM parsing (empty uses bimg's default).") -set(BIMG_CONFIG_PARSE_PSD OFF CACHE STRING "Enable PSD parsing (empty uses bimg's default).") +set(BIMG_CONFIG_PARSE_PIC OFF) +set(BIMG_CONFIG_PARSE_PNM OFF) +set(BIMG_CONFIG_PARSE_PSD OFF) FetchContent_MakeAvailable_With_Message(bgfx.cmake) diff --git a/Documentation/BuildSystem.md b/Documentation/BuildSystem.md index 0ee13e21e6..eea900358f 100644 --- a/Documentation/BuildSystem.md +++ b/Documentation/BuildSystem.md @@ -9,9 +9,9 @@ and outlines some of the reasoning and intent behind them. ## Image Format Parsing -Bundled image parsers default to AVIF, BMP, EXR, GIF, HDR, JPEG, PNG, TGA, and WebP, matching browser image formats and Babylon.js texture loaders. PIC, PNM, and PSD default to OFF; HEIF is OFF upstream. +Bundled image parsers default to AVIF, BMP, EXR, GIF, HDR, JPEG, PNG, TGA, and WebP, matching browser image formats and Babylon.js texture loaders. PIC, PNM, and PSD are disabled by Babylon Native; HEIF is OFF upstream. -Configure individual formats with bgfx.cmake's `BIMG_CONFIG_PARSE_` settings (`ON`, `OFF`, or empty), for example `-DBIMG_CONFIG_PARSE_PSD=ON`. Explicit cache entries and parent-project values are preserved. Empty values inherit `BIMG_CONFIG_PARSE_ENABLE`, which defaults to ON. These settings do not control bimg's texture-container parsers. +Configure the supported formats with bgfx.cmake's `BIMG_CONFIG_PARSE_` settings (`ON`, `OFF`, or empty), for example `-DBIMG_CONFIG_PARSE_WEBP=OFF`. Empty values inherit `BIMG_CONFIG_PARSE_ENABLE`, which defaults to ON. PIC, PNM, and PSD remain disabled regardless of cache or parent-project settings. These settings do not control bimg's texture-container parsers. ## Lateral Dependency Management From fd00b23eb3d5f1162cba0a58c923518ba7f8a3d1 Mon Sep 17 00:00:00 2001 From: Gary Hsu Date: Thu, 1 Oct 2026 11:57:26 -0700 Subject: [PATCH 25/28] Move image parser configuration to the building guide Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- BUILDING.md | 6 ++++++ Documentation/BuildSystem.md | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/BUILDING.md b/BUILDING.md index 92f72887c9..3c804e2634 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -335,6 +335,12 @@ export CXX=/usr/bin/g++ You will have to run CMake again to take changes into account. +## Image Format Parsing + +Bundled image parsers default to AVIF, BMP, EXR, GIF, HDR, JPEG, PNG, TGA, and WebP, matching browser image formats and Babylon.js texture loaders. PIC, PNM, and PSD are disabled by Babylon Native; HEIF is OFF upstream. + +Configure the supported formats with bgfx.cmake's `BIMG_CONFIG_PARSE_` settings (`ON`, `OFF`, or empty), for example `-DBIMG_CONFIG_PARSE_WEBP=OFF`. Empty values inherit `BIMG_CONFIG_PARSE_ENABLE`, which defaults to ON. PIC, PNM, and PSD remain disabled regardless of cache or parent-project settings. These settings do not control bimg's texture-container parsers. + ## Selecting the Graphics API For Win32, UWP, Android, and Linux, it's possible to build for different graphics API. diff --git a/Documentation/BuildSystem.md b/Documentation/BuildSystem.md index eea900358f..dea046a749 100644 --- a/Documentation/BuildSystem.md +++ b/Documentation/BuildSystem.md @@ -7,12 +7,6 @@ and it should be easy to incorporate Babylon Native into other existing projects document provides an overview of the concepts underpinning the Babylon Native build system and outlines some of the reasoning and intent behind them. -## Image Format Parsing - -Bundled image parsers default to AVIF, BMP, EXR, GIF, HDR, JPEG, PNG, TGA, and WebP, matching browser image formats and Babylon.js texture loaders. PIC, PNM, and PSD are disabled by Babylon Native; HEIF is OFF upstream. - -Configure the supported formats with bgfx.cmake's `BIMG_CONFIG_PARSE_` settings (`ON`, `OFF`, or empty), for example `-DBIMG_CONFIG_PARSE_WEBP=OFF`. Empty values inherit `BIMG_CONFIG_PARSE_ENABLE`, which defaults to ON. PIC, PNM, and PSD remain disabled regardless of cache or parent-project settings. These settings do not control bimg's texture-container parsers. - ## Lateral Dependency Management Scalable dependency management can be a challenge when making heavy use of Git Submodules. From 5f795bdf45fc55922937a9a326cb6e30c93ece1c Mon Sep 17 00:00:00 2001 From: Gary Hsu Date: Thu, 1 Oct 2026 12:22:42 -0700 Subject: [PATCH 26/28] Preserve original Window dependency ordering Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- Polyfills/Window/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Polyfills/Window/CMakeLists.txt b/Polyfills/Window/CMakeLists.txt index 690713eb04..d87b4354b9 100644 --- a/Polyfills/Window/CMakeLists.txt +++ b/Polyfills/Window/CMakeLists.txt @@ -16,8 +16,8 @@ target_include_directories(Window target_link_libraries(Window PUBLIC napi PRIVATE base-n - PRIVATE JsRuntimeInternal PRIVATE Scheduling + PRIVATE JsRuntimeInternal PRIVATE GraphicsDeviceContext) set_property(TARGET Window PROPERTY FOLDER Polyfills) From 7d5d1c5bce9bbe1e6e616a0902fc31c00bcb31e5 Mon Sep 17 00:00:00 2001 From: Gary Hsu Date: Thu, 1 Oct 2026 17:41:58 -0700 Subject: [PATCH 27/28] Adopt upstream WIC decoder configuration Pin the merged bgfx.cmake option that forwards BIMG_CONFIG_USE_WIC with its upstream OFF default. Document direct Windows usage without adding a Babylon Native switch. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- BUILDING.md | 2 ++ CMakeLists.txt | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/BUILDING.md b/BUILDING.md index 3c804e2634..e9cb30e106 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -341,6 +341,8 @@ Bundled image parsers default to AVIF, BMP, EXR, GIF, HDR, JPEG, PNG, TGA, and W Configure the supported formats with bgfx.cmake's `BIMG_CONFIG_PARSE_` settings (`ON`, `OFF`, or empty), for example `-DBIMG_CONFIG_PARSE_WEBP=OFF`. Empty values inherit `BIMG_CONFIG_PARSE_ENABLE`, which defaults to ON. PIC, PNM, and PSD remain disabled regardless of cache or parent-project settings. These settings do not control bimg's texture-container parsers. +On Windows, `-DBIMG_CONFIG_USE_WIC=ON` selects Windows Imaging Component (WIC) decoding for enabled PNG, JPEG, BMP, and GIF formats instead of their bundled decoders. It defaults to OFF and does not enable formats disabled by their `BIMG_CONFIG_PARSE_` settings. + ## Selecting the Graphics API For Win32, UWP, Android, and Linux, it's possible to build for different graphics API. diff --git a/CMakeLists.txt b/CMakeLists.txt index c58f04ac4a..9dc5c51807 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,7 @@ FetchContent_Declare(base-n EXCLUDE_FROM_ALL) FetchContent_Declare(bgfx.cmake GIT_REPOSITORY https://github.com/BabylonJS/bgfx.cmake.git - GIT_TAG 8edfdc308848df5bb86fc1af0228080deda0045b + GIT_TAG 9a7a35ed0d588c64de867c5e5c7f990676da8c21 EXCLUDE_FROM_ALL) FetchContent_Declare(CMakeExtensions GIT_REPOSITORY https://github.com/BabylonJS/CMakeExtensions.git From 7d9f6c098af7d79dae2b1ce6e0058ee82472f339 Mon Sep 17 00:00:00 2001 From: Gary Hsu Date: Thu, 1 Oct 2026 17:53:48 -0700 Subject: [PATCH 28/28] Enable WIC by default on Windows Respect explicit decoder selections. Allow one-level rounding differences when 16-bit PNG samples are converted to 8-bit, retaining exact endpoint and 8-bit comparisons. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../JavaScript/dist/tests.javaScript.all.js | 22 ++++++++++++----- .../JavaScript/src/tests.nativeEngine.png.ts | 24 +++++++++++++------ BUILDING.md | 2 +- Dependencies/CMakeLists.txt | 4 ++++ 4 files changed, 38 insertions(+), 14 deletions(-) diff --git a/Apps/UnitTests/JavaScript/dist/tests.javaScript.all.js b/Apps/UnitTests/JavaScript/dist/tests.javaScript.all.js index 58440130cf..5d5828f1b4 100644 --- a/Apps/UnitTests/JavaScript/dist/tests.javaScript.all.js +++ b/Apps/UnitTests/JavaScript/dist/tests.javaScript.all.js @@ -24,22 +24,22 @@ function _createForOfIteratorHelper(r, e) {var t = "undefined" != typeof Symbol var fixtures = [ { - name: "16-bit RGBA", width: 4, + name: "16-bit RGBA", width: 4, tolerance: 1, png: "iVBORw0KGgoAAAANSUhEUgAAAAQAAAABEAYAAACprNOOAAAAI0lEQVR4nGOo/38v9Ene//8MDP//NzBAeAwMIB4D4/9/90IBNYURsvcM43UAAAAASUVORK5CYII=", pixels: [128, 222, 227, 255, 0, 255, 128, 128, 222, 227, 0, 0, 255, 0, 255, 222] }, { - name: "16-bit RGB", width: 4, + name: "16-bit RGB", width: 4, tolerance: 1, png: "iVBORw0KGgoAAAANSUhEUgAAAAQAAAABEAIAAAAmzkTZAAAAG0lEQVR4nGOo/38v9EkeA8P//w0MMBYD4/9/AKWbDQOAUd17AAAAAElFTkSuQmCC", pixels: [128, 222, 227, 255, 0, 255, 128, 255, 222, 227, 0, 255, 255, 0, 255, 255] }, { - name: "16-bit grayscale", width: 4, + name: "16-bit grayscale", width: 4, tolerance: 1, png: "iVBORw0KGgoAAAANSUhEUgAAAAQAAAABEAAAAACMx4xSAAAAEUlEQVR4nGOo/38v9Ene//8AGa4GAvbhooAAAAAASUVORK5CYII=", pixels: [128, 128, 128, 255, 222, 222, 222, 255, 227, 227, 227, 255, 255, 255, 255, 255] }, { - name: "16-bit grayscale with alpha", width: 4, + name: "16-bit grayscale with alpha", width: 4, tolerance: 1, png: "iVBORw0KGgoAAAANSUhEUgAAAAQAAAABEAQAAAADpRsFAAAAF0lEQVR4nGOo/////73Q+v9P8hgYQCwAYP8KsdIXi8oAAAAASUVORK5CYII=", pixels: [128, 128, 128, 255, 222, 222, 222, 128, 227, 227, 227, 0, 255, 255, 255, 222] }, @@ -55,6 +55,16 @@ var fixtures = [ }]; +function expectPixels(pixels, fixture) { + (0,chai__WEBPACK_IMPORTED_MODULE_2__.expect)(pixels.length).to.equal(fixture.pixels.length); + // WIC and bundled decoders quantize 16-bit channels to 8-bit with different rounding. + for (var index = 0; index < pixels.length; ++index) {var _fixture$tolerance; + var expected = fixture.pixels[index]; + var tolerance = expected === 0 || expected === 255 ? 0 : (_fixture$tolerance = fixture.tolerance) !== null && _fixture$tolerance !== void 0 ? _fixture$tolerance : 0; + (0,chai__WEBPACK_IMPORTED_MODULE_2__.expect)(pixels[index], "channel ".concat(index)).to.be.closeTo(expected, tolerance); + } +} + function registerPngTests( describe, it, @@ -80,7 +90,7 @@ enabled) pixels instanceof Uint8Array) {_context.next = 4;break;}throw ( new Error("Expected unsigned-byte PNG texture readback"));case 4: - (0,chai__WEBPACK_IMPORTED_MODULE_2__.expect)(Array.from(pixels)).to.deep.equal(fixture.pixels); + expectPixels(pixels, fixture); (0,chai__WEBPACK_IMPORTED_MODULE_2__.expect)(texture.getSize().width).to.equal(fixture.width); (0,chai__WEBPACK_IMPORTED_MODULE_2__.expect)(texture.getSize().height).to.equal(1);if (! generateMips) {_context.next = 6;break;} @@ -103,7 +113,7 @@ enabled) (0,chai__WEBPACK_IMPORTED_MODULE_2__.expect)(bitmap.width).to.equal(fixture.width); (0,chai__WEBPACK_IMPORTED_MODULE_2__.expect)(bitmap.height).to.equal(1); pixels = engine.resizeImageBitmap(bitmap, fixture.width, 1); - (0,chai__WEBPACK_IMPORTED_MODULE_2__.expect)(Array.from(pixels)).to.deep.equal(fixture.pixels);case 3:_context2.prev = 3; + expectPixels(pixels, fixture);case 3:_context2.prev = 3; engine.dispose();return _context2.finish(3);case 4:case "end":return _context2.stop();}}, _callee2, null, [[1,, 3, 4]]);})) diff --git a/Apps/UnitTests/JavaScript/src/tests.nativeEngine.png.ts b/Apps/UnitTests/JavaScript/src/tests.nativeEngine.png.ts index 3384851096..7fcdd04f42 100644 --- a/Apps/UnitTests/JavaScript/src/tests.nativeEngine.png.ts +++ b/Apps/UnitTests/JavaScript/src/tests.nativeEngine.png.ts @@ -2,24 +2,24 @@ import * as Mocha from "mocha"; import { expect } from "chai"; import { Constants, NativeEngine, Scene, Texture } from "@babylonjs/core"; -const fixtures: { name: string; png: string; pixels: number[]; width: number }[] = [ +const fixtures: { name: string; png: string; pixels: number[]; width: number; tolerance?: number }[] = [ { - name: "16-bit RGBA", width: 4, + name: "16-bit RGBA", width: 4, tolerance: 1, png: "iVBORw0KGgoAAAANSUhEUgAAAAQAAAABEAYAAACprNOOAAAAI0lEQVR4nGOo/38v9Ene//8MDP//NzBAeAwMIB4D4/9/90IBNYURsvcM43UAAAAASUVORK5CYII=", pixels: [128, 222, 227, 255, 0, 255, 128, 128, 222, 227, 0, 0, 255, 0, 255, 222], }, { - name: "16-bit RGB", width: 4, + name: "16-bit RGB", width: 4, tolerance: 1, png: "iVBORw0KGgoAAAANSUhEUgAAAAQAAAABEAIAAAAmzkTZAAAAG0lEQVR4nGOo/38v9EkeA8P//w0MMBYD4/9/AKWbDQOAUd17AAAAAElFTkSuQmCC", pixels: [128, 222, 227, 255, 0, 255, 128, 255, 222, 227, 0, 255, 255, 0, 255, 255], }, { - name: "16-bit grayscale", width: 4, + name: "16-bit grayscale", width: 4, tolerance: 1, png: "iVBORw0KGgoAAAANSUhEUgAAAAQAAAABEAAAAACMx4xSAAAAEUlEQVR4nGOo/38v9Ene//8AGa4GAvbhooAAAAAASUVORK5CYII=", pixels: [128, 128, 128, 255, 222, 222, 222, 255, 227, 227, 227, 255, 255, 255, 255, 255], }, { - name: "16-bit grayscale with alpha", width: 4, + name: "16-bit grayscale with alpha", width: 4, tolerance: 1, png: "iVBORw0KGgoAAAANSUhEUgAAAAQAAAABEAQAAAADpRsFAAAAF0lEQVR4nGOo/////73Q+v9P8hgYQCwAYP8KsdIXi8oAAAAASUVORK5CYII=", pixels: [128, 128, 128, 255, 222, 222, 222, 128, 227, 227, 227, 0, 255, 255, 255, 222], }, @@ -35,6 +35,16 @@ const fixtures: { name: string; png: string; pixels: number[]; width: number }[] }, ]; +function expectPixels(pixels: Uint8Array, fixture: typeof fixtures[number]): void { + expect(pixels.length).to.equal(fixture.pixels.length); + // WIC and bundled decoders quantize 16-bit channels to 8-bit with different rounding. + for (let index = 0; index < pixels.length; ++index) { + const expected = fixture.pixels[index]; + const tolerance = expected === 0 || expected === 255 ? 0 : fixture.tolerance ?? 0; + expect(pixels[index], `channel ${index}`).to.be.closeTo(expected, tolerance); + } +} + export function registerPngTests( describe: typeof Mocha.describe, it: typeof Mocha.it, @@ -60,7 +70,7 @@ export function registerPngTests( if (!(pixels instanceof Uint8Array)) { throw new Error("Expected unsigned-byte PNG texture readback"); } - expect(Array.from(pixels)).to.deep.equal(fixture.pixels); + expectPixels(pixels, fixture); expect(texture.getSize().width).to.equal(fixture.width); expect(texture.getSize().height).to.equal(1); if (generateMips) { @@ -83,7 +93,7 @@ export function registerPngTests( expect(bitmap.width).to.equal(fixture.width); expect(bitmap.height).to.equal(1); const pixels = engine.resizeImageBitmap(bitmap, fixture.width, 1); - expect(Array.from(pixels)).to.deep.equal(fixture.pixels); + expectPixels(pixels, fixture); } finally { engine.dispose(); } diff --git a/BUILDING.md b/BUILDING.md index e9cb30e106..c185cb7493 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -341,7 +341,7 @@ Bundled image parsers default to AVIF, BMP, EXR, GIF, HDR, JPEG, PNG, TGA, and W Configure the supported formats with bgfx.cmake's `BIMG_CONFIG_PARSE_` settings (`ON`, `OFF`, or empty), for example `-DBIMG_CONFIG_PARSE_WEBP=OFF`. Empty values inherit `BIMG_CONFIG_PARSE_ENABLE`, which defaults to ON. PIC, PNM, and PSD remain disabled regardless of cache or parent-project settings. These settings do not control bimg's texture-container parsers. -On Windows, `-DBIMG_CONFIG_USE_WIC=ON` selects Windows Imaging Component (WIC) decoding for enabled PNG, JPEG, BMP, and GIF formats instead of their bundled decoders. It defaults to OFF and does not enable formats disabled by their `BIMG_CONFIG_PARSE_` settings. +On Windows, Windows Imaging Component (WIC) decoding defaults to ON for enabled PNG, JPEG, BMP, and GIF formats instead of their bundled decoders. Set `-DBIMG_CONFIG_USE_WIC=OFF` to use the bundled decoders. Explicit cache and parent-project settings are respected; WIC does not enable formats disabled by their `BIMG_CONFIG_PARSE_` settings. ## Selecting the Graphics API diff --git a/Dependencies/CMakeLists.txt b/Dependencies/CMakeLists.txt index c80cec1ff9..29dae77122 100644 --- a/Dependencies/CMakeLists.txt +++ b/Dependencies/CMakeLists.txt @@ -44,6 +44,10 @@ set(BIMG_CONFIG_PARSE_PIC OFF) set(BIMG_CONFIG_PARSE_PNM OFF) set(BIMG_CONFIG_PARSE_PSD OFF) +if(WIN32 AND NOT DEFINED BIMG_CONFIG_USE_WIC) + set(BIMG_CONFIG_USE_WIC ON) +endif() + FetchContent_MakeAvailable_With_Message(bgfx.cmake) # Turn off debug annotations as it causes an access violation in D3D12.