Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/build-win32-shader.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ jobs:
-A ${{ inputs.platform }} ^
-D BX_CONFIG_DEBUG=ON ^
-D GRAPHICS_API=D3D11 ^
-D BGFX_CONFIG_MAX_FRAME_BUFFERS=256 ^
-D BABYLON_DEBUG_TRACE=ON ^
-D BABYLON_NATIVE_PLUGIN_NATIVEENGINE_COMPILESHADERS=OFF

Expand Down
1 change: 0 additions & 1 deletion .github/workflows/build-win32.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ jobs:
${{ steps.vars.outputs.js_define }} ^
-D BX_CONFIG_DEBUG=ON ^
-D GRAPHICS_API=${{ inputs.graphics-api }} ^
-D BGFX_CONFIG_MAX_FRAME_BUFFERS=256 ^
-D BABYLON_DEBUG_TRACE=ON ^
-D BABYLON_NATIVE_PLUGIN_NATIVEDRACO=ON ^
-D BABYLON_NATIVE_PLUGIN_NATIVEMESHOPT=ON ^
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 5c98749de48e8609a62e5c1fd2cfffbbd970588e
GIT_TAG f7333d92a0ca19ad9a6bd2efb34548e8a8d8a792
EXCLUDE_FROM_ALL)
FetchContent_Declare(CMakeExtensions
GIT_REPOSITORY https://github.com/BabylonJS/CMakeExtensions.git
Expand Down
59 changes: 33 additions & 26 deletions Dependencies/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,46 +38,53 @@ set(BGFX_INSTALL OFF)
set(BGFX_OPENGL_USE_EGL ON)
set(BGFX_USE_DEBUG_SUFFIX OFF)

# Babylon Native's bgfx settings are defaults. A value already supplied, on the command
# line or by a project embedding Babylon Native, is left alone. bgfx.cmake forwards
# whichever value survives, so each setting reaches the compiler exactly once.
macro(babylon_native_bgfx_config NAME DEFAULT)
if("${BGFX_CONFIG_${NAME}}" STREQUAL "")
set(BGFX_CONFIG_${NAME} "${DEFAULT}")
endif()
endmacro()

babylon_native_bgfx_config(DEFAULT_MAX_ENCODERS 2)
babylon_native_bgfx_config(MAX_VERTEX_STREAMS 18)
babylon_native_bgfx_config(MIN_RESOURCE_COMMAND_BUFFER_SIZE 16)
babylon_native_bgfx_config(MIN_UNIFORM_BUFFER_SIZE 4096)
babylon_native_bgfx_config(UNIFORM_BUFFER_RESIZE_THRESHOLD_SIZE 256)
babylon_native_bgfx_config(UNIFORM_BUFFER_RESIZE_INCREMENT_SIZE 1024)

# Temporary disable uniform debug.
babylon_native_bgfx_config(DEBUG_UNIFORM 0)

# Disable video decoding support (not used by Babylon Native).
babylon_native_bgfx_config(VIDEO 0)

# Disable the C99 API (Babylon Native uses the C++ API only); saves binary size.
babylon_native_bgfx_config(C99_API 0)

# The Canvas polyfill allocates one bgfx framebuffer per JS Canvas object and per
# text-rendering operation; combined with V8 GC pacing this can exceed the bgfx default
# of 128 during long playground sweeps. An embedder that disables the polyfill draws
# into a handful of framebuffers and has no reason to pay for the larger pool.
if(BABYLON_NATIVE_POLYFILL_CANVAS)
babylon_native_bgfx_config(MAX_FRAME_BUFFERS 512)
endif()

FetchContent_MakeAvailable_With_Message(bgfx.cmake)

# Turn off debug annotations as it causes an access violation in D3D12.
# This flag is set using compile definitions because the bgfx.cmake option is ignored in debug configuration.
# See https://github.com/BabylonJS/bgfx.cmake/blob/0af3c9865a66aff1748a51bb466b24f05a123043/cmake/bgfx/bgfx.cmake#L126.
target_compile_definitions(bgfx PRIVATE BGFX_CONFIG_DEBUG_ANNOTATION=0)

target_compile_definitions(bgfx PRIVATE BGFX_CONFIG_DEFAULT_MAX_ENCODERS=2)
target_compile_definitions(bgfx PRIVATE BGFX_CONFIG_MAX_VERTEX_STREAMS=18)
target_compile_definitions(bgfx PRIVATE BGFX_CONFIG_MIN_RESOURCE_COMMAND_BUFFER_SIZE=16)
target_compile_definitions(bgfx PRIVATE BGFX_CONFIG_MIN_UNIFORM_BUFFER_SIZE=4096)
target_compile_definitions(bgfx PRIVATE BGFX_CONFIG_UNIFORM_BUFFER_RESIZE_THRESHOLD_SIZE=256)
target_compile_definitions(bgfx PRIVATE BGFX_CONFIG_UNIFORM_BUFFER_RESIZE_INCREMENT_SIZE=1024)
target_compile_definitions(bgfx PUBLIC BGFX_PLATFORM_SUPPORTS_WGSL=0)

# bgfx bundles the Khronos GLES headers but adds them as a PRIVATE include
# directory, and Windows has no system copy the way Linux and Android do.
# Expose the path so the OpenGL backends of our own targets can use it.
set(BGFX_KHRONOS_INCLUDE_DIR "${bgfx.cmake_SOURCE_DIR}/bgfx/3rdparty/khronos" CACHE INTERNAL "")

# Canvas plugin allocates one bgfx framebuffer per JS Canvas object and per
# text-rendering operation; combined with V8 GC pacing this can exceed the
# default 128 limit during long playground sweeps. We enforce a floor of 512:
# CI workflows pass -DBGFX_CONFIG_MAX_FRAME_BUFFERS, and any value below 512
# (including a smaller CI override) is clamped up so the pool never regresses
# below the size the Canvas sweeps need.
if(NOT BGFX_CONFIG_MAX_FRAME_BUFFERS OR BGFX_CONFIG_MAX_FRAME_BUFFERS LESS 512)
set(BGFX_CONFIG_MAX_FRAME_BUFFERS 512)
endif()
target_compile_definitions(bgfx PRIVATE BGFX_CONFIG_MAX_FRAME_BUFFERS=${BGFX_CONFIG_MAX_FRAME_BUFFERS})

# Temporary disable uniform debug.
target_compile_definitions(bgfx PRIVATE BGFX_CONFIG_DEBUG_UNIFORM=0)

# Disable video decoding support (not used by Babylon Native).
target_compile_definitions(bgfx PRIVATE BGFX_CONFIG_VIDEO=0)

# Disable the C99 API (Babylon Native uses the C++ API only); saves binary size.
target_compile_definitions(bgfx PRIVATE BGFX_CONFIG_C99_API=0)

if(GRAPHICS_API STREQUAL "D3D11")
target_compile_definitions(bgfx PRIVATE BGFX_CONFIG_RENDERER_DIRECT3D11=1)
elseif(GRAPHICS_API STREQUAL "D3D12")
Expand Down
2 changes: 1 addition & 1 deletion nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- checkout: self

- script: |
cmake -G "Visual Studio 17 2022" -B build -A x64 -D BX_CONFIG_DEBUG=ON -D BGFX_CONFIG_MAX_FRAME_BUFFERS=256 -D BABYLON_DEBUG_TRACE=ON
cmake -G "Visual Studio 17 2022" -B build -A x64 -D BX_CONFIG_DEBUG=ON -D BABYLON_DEBUG_TRACE=ON
displayName: 'Generate solution'

- script: |
Expand Down