Skip to content

Resolve #1786 review follow-ups: drop BN workarounds, bump bgfx.cmake, guard useCache - #1788

Open
SergioRZMasson wants to merge 2 commits into
BabylonJS:masterfrom
SergioRZMasson:cleanup-shaderprovider-usecache
Open

Resolve #1786 review follow-ups: drop BN workarounds, bump bgfx.cmake, guard useCache#1788
SergioRZMasson wants to merge 2 commits into
BabylonJS:masterfrom
SergioRZMasson:cleanup-shaderprovider-usecache

Conversation

@SergioRZMasson

@SergioRZMasson SergioRZMasson commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Addresses the three review follow-ups from #1786 (bghgary's notes), moving each fix to its proper home so BN no longer carries the workarounds.

1. Drop the manual -msse4.2 flag (Dependencies/CMakeLists.txt)

The SSE4.2 minspec that bx's x86_64 SIMD path requires now lives in bgfx.cmake (BabylonJS/bgfx.cmake#130), applied PUBLIC on the bx target — including the -Xarch_x86_64 scoping needed for Apple universal (arm64;x86_64) builds. BN no longer needs to re-add it.

2. Drop the per-plugin _WIN32_WINNT / WINVER pin (Plugins/NativeEngine/CMakeLists.txt)

The root cause was fixed in bx (bkaradzic/bx#409): platform.h now detects MSVC ARM64 as 64-bit and defaults every 32-bit Windows target to 0x0601 instead of the pre-Vista 0x0502. With that, arcana's ETW trace_region.h compiles on Windows x86/ARM64 without pinning an API baseline on the NativeEngine target.

3. Guard useCache with #ifdef SHADER_CACHE (Plugins/NativeEngine/Source/ShaderProvider.cpp)

useCache is referenced only inside the #ifdef SHADER_CACHE blocks, so its declaration moves into that guard (rather than [[maybe_unused]]): the variable — and instancedAttributes.empty() — is compiled out entirely when the ShaderCache plugin is disabled.

To consume 1 and 2, this bumps the bgfx.cmake pin to 8f7e4455 (which carries the SSE minspec on the bx target and advances bx to cd6720ce with the platform.h fixes).

Testing

  • Built NativeEngine for Win32 against the bumped pin with the _WIN32_WINNT workaround removed — NativeEngine.cpp / Program.cpp / ShaderProvider.cpp compile and NativeEngine.lib links (previously this arch failed with error C3861 in TraceLoggingProvider.h).
  • The SSE minspec on the bx target was verified in bgfx.cmake#130 (compiles the _mm_round_ps SSE4.1 intrinsic on Clang/x86_64, -Xarch_x86_64-scoped on Apple).
  • ShaderProvider compiles clean under Clang -Werror -Wunused-variable with ShaderCache enabled and disabled.

Copilot AI review requested due to automatic review settings July 23, 2026 12:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refines ShaderProvider::Get to avoid declaring useCache when the ShaderCache plugin is disabled, aligning the variable’s lifetime and evaluation with the existing #ifdef SHADER_CACHE usage blocks.

Changes:

  • Replaced [[maybe_unused]] on useCache with an #ifdef SHADER_CACHE-guarded declaration.
  • Ensures instancedAttributes.empty() is only evaluated when ShaderCache support is compiled in.

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
@SergioRZMasson
SergioRZMasson force-pushed the cleanup-shaderprovider-usecache branch from 45481f9 to ff35c76 Compare July 23, 2026 13:06
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
@SergioRZMasson SergioRZMasson changed the title ShaderProvider: guard useCache with #ifdef SHADER_CACHE Resolve #1786 review follow-ups: drop BN workarounds, bump bgfx.cmake, guard useCache Jul 23, 2026

@bghgary bghgary left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants