From ff35c76dff736e5eab085dae7252128b41b6f183 Mon Sep 17 00:00:00 2001 From: Sergio Ricardo Zerbetto Masson Date: Thu, 23 Jul 2026 09:43:02 -0300 Subject: [PATCH 1/2] ShaderProvider: guard useCache with #ifdef SHADER_CACHE useCache is only referenced inside the #ifdef SHADER_CACHE blocks, so move its declaration into the first such block instead of marking it [[maybe_unused]]. Because #ifdef does not introduce a C++ scope, the variable remains visible to the later SHADER_CACHE block, and when the ShaderCache plugin is disabled it is compiled out entirely (and instancedAttributes.empty() is not computed) rather than merely having an unused-variable diagnostic suppressed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 45aaf3cc-900d-442b-a7e5-0fb6d3fe6658 --- Plugins/NativeEngine/Source/ShaderProvider.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Plugins/NativeEngine/Source/ShaderProvider.cpp b/Plugins/NativeEngine/Source/ShaderProvider.cpp index bef621bea..0278c02c5 100644 --- a/Plugins/NativeEngine/Source/ShaderProvider.cpp +++ b/Plugins/NativeEngine/Source/ShaderProvider.cpp @@ -35,11 +35,11 @@ namespace Babylon { // The shader cache is keyed only by source, so it must be bypassed when routing instanced // attributes (otherwise a variant would collide with the base program's cached shader). - // Only referenced inside the SHADER_CACHE blocks below, so mark it maybe_unused for builds - // that compile with the ShaderCache plugin disabled. - [[maybe_unused]] const bool useCache = instancedAttributes.empty(); - + // Declared and used only inside the SHADER_CACHE blocks, so it is compiled out entirely when + // the ShaderCache plugin is disabled. #ifdef SHADER_CACHE + const bool useCache = instancedAttributes.empty(); + if (useCache && Plugins::ShaderCache::IsEnabled()) { const auto shaderInfo = Plugins::ShaderCache::GetShader(vertexSource, fragmentSource); From db53b049034f8d1e353d4aff4853639fe2e9f3b7 Mon Sep 17 00:00:00 2001 From: Sergio Ricardo Zerbetto Masson Date: Thu, 23 Jul 2026 13:14:45 -0300 Subject: [PATCH 2/2] Bump bgfx.cmake and drop now-redundant Windows/SSE workarounds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Advance the bgfx.cmake pin to 8f7e4455, which carries the x86_64 SSE4.2 minspec on the bx target and bumps bx to include the platform.h fixes (MSVC ARM64 detected as 64-bit; 32-bit Windows _WIN32_WINNT default raised to 0x0601). With those handled upstream, remove the two workarounds this repo carried: * Dependencies/CMakeLists.txt: the manual -msse4.2 flag on bx/bgfx/bimg — the bx target now propagates the minspec itself (including the x86_64 slice of Apple universal builds). * Plugins/NativeEngine/CMakeLists.txt: the _WIN32_WINNT / WINVER = 0x0A00 pin — bx/platform.h now defaults every Windows arch to a >= Vista baseline, so arcana's ETW trace_region.h compiles without it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 45aaf3cc-900d-442b-a7e5-0fb6d3fe6658 --- CMakeLists.txt | 2 +- Dependencies/CMakeLists.txt | 15 --------------- Plugins/NativeEngine/CMakeLists.txt | 11 ----------- 3 files changed, 1 insertion(+), 27 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e519d981..1f19a2d2f 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 3b67f0c0c5505a22f6e88640519b5b473c938ad9 + GIT_TAG 8f7e4455933085fc719913138c78ef61242709e3 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 5a41c1853..95f25ea6e 100644 --- a/Dependencies/CMakeLists.txt +++ b/Dependencies/CMakeLists.txt @@ -115,21 +115,6 @@ if(NOT BABYLON_NATIVE_PLUGIN_NATIVEENGINE_WEBP AND TARGET bimg_decode) target_compile_definitions(bimg_decode PRIVATE BIMG_CONFIG_PARSE_WEBP=0) endif() -if(NOT APPLE AND NOT ANDROID AND CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64|amd64|AMD64)" AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") - # The new bx requires SSE4.2 on x86_64 (see bx scripts/toolchain.lua and - # include/bx/inline/simd128_sse.inl which uses _mm_round_ps / _mm_blendv_ps - # under "SSE4.1 - always available with SSE4.2 minspec"). bgfx.cmake does - # not propagate this flag, so add it explicitly for any GCC/Clang frontend on - # x86_64 (e.g. Linux, or Clang targeting Windows), none of which enable SSE4.x - # by default. MSVC (cl.exe) allows the intrinsics regardless and Apple Silicon - # is unaffected. - foreach(_bx_target IN ITEMS bx bgfx bimg bimg_decode bimg_encode) - if(TARGET ${_bx_target}) - target_compile_options(${_bx_target} PRIVATE -msse4.2) - endif() - endforeach() -endif() - if(UNIX AND NOT APPLE AND NOT ANDROID) # Use GLVND libraries for EGL support in bgfx set(OpenGL_GL_PREFERENCE GLVND) diff --git a/Plugins/NativeEngine/CMakeLists.txt b/Plugins/NativeEngine/CMakeLists.txt index 251fc2d4a..f197c0f84 100644 --- a/Plugins/NativeEngine/CMakeLists.txt +++ b/Plugins/NativeEngine/CMakeLists.txt @@ -67,17 +67,6 @@ endif() if(WIN32) target_compile_definitions(NativeEngine PRIVATE NOMINMAX) - - # arcana's Windows trace_region.h (pulled in by NativeEngine.cpp and Program.cpp) - # emits ETW TraceLogging events. The EventRegister/EventUnregister/EventWriteTransfer - # declarations it relies on (via ) are only visible when - # _WIN32_WINNT >= _WIN32_WINNT_VISTA (0x0600). bx/platform.h only sets _WIN32_WINNT - # when it is still undefined, and then to 0x0601 for 64-bit but 0x0502 (pre-Vista) - # for 32-bit; its 64-bit check also misses MSVC's _M_ARM64, so Windows ARM64 is - # treated as 32-bit. Both cases leave _WIN32_WINNT below Vista and break the compile - # (error C3861). Pin a modern Windows API baseline so it is set before any header. - target_compile_definitions(NativeEngine - PRIVATE _WIN32_WINNT=0x0A00 WINVER=0x0A00) endif() # Required by VertexBuffer::BuildInstanceDataBuffer. Remove once we have a better solution for that method.