Skip to content

Configure bgfx through CMake and restore uniform checks - #1807

Merged
bghgary merged 3 commits into
BabylonJS:masterfrom
bghgary:bgfx-config-overridable
Oct 16, 2026
Merged

bghgary merged 3 commits into
BabylonJS:masterfrom
bghgary:bgfx-config-overridable

Conversation

@bghgary

@bghgary bghgary commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

[Created by Copilot on behalf of @bghgary]

The bgfx integration settings remain controlled by Babylon Native, not exposed as consumer tuning options.

Remove the temporary uniform-debug override so bgfx’s normal Debug checks apply. This requires fixing duplicate uniform assignments in NativeEngine texture binding and Canvas clipping/filtering.

Copilot AI review requested due to automatic review settings July 30, 2026 23:16

This comment was marked as outdated.

bghgary added a commit that referenced this pull request Aug 14, 2026
…amping the pool (#1837)

[Created by Copilot on behalf of @bghgary]

## Context

The pool floor added in #1715 (512) and raised in #1830 (2048) clamps
any smaller value upward, so the three CI workflows passing `-D
BGFX_CONFIG_MAX_FRAME_BUFFERS=256` have had no effect since June while
reading as deliberate coverage of a 256-slot pool.

The clamp is also wrong on its own terms: an embedder that deliberately
picks a smaller pool is overridden with no diagnostic.

## Worth a look

- Both changes are in one commit because the ordering is a constraint,
not a preference. Relaxing the clamp on its own would make CI's `=256`
take effect and reintroduce the pool exhaustion #1830 fixed, since
`build-win32.yml` and `nightly.yml` run the validation sweep the larger
pool exists for.
- `build-win32-shader.yml` builds only `PrecompiledShaderTest`, where
the value never mattered.
- #1807 replaces this block with a general default-if-unset macro across
every `BGFX_CONFIG_` setting. It predates #1830 and still carries 512,
so its merge from master needs to keep 2048.

## Verification

Configured Win32 x64 D3D11 both ways: with no flag bgfx still compiles
with `BGFX_CONFIG_MAX_FRAME_BUFFERS=2048`, so CI is unchanged, and `-D
BGFX_CONFIG_MAX_FRAME_BUFFERS=256` now reaches the compile line instead
of being clamped up.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: e327caab-46c0-4c04-a3c0-1577ad67f08c
@bghgary bghgary changed the title Let embedders override Babylon Native's bgfx configuration Allow bgfx overrides and restore uniform debugging Oct 16, 2026
@bghgary
bghgary force-pushed the bgfx-config-overridable branch 2 times, most recently from fb3a4f8 to 0d96ebf Compare October 16, 2026 17:52
@bghgary bghgary changed the title Allow bgfx overrides and restore uniform debugging Configure bgfx through CMake and restore uniform checks Oct 16, 2026
Keep Babylon Native's fixed bgfx integration settings in the sorted CMake
configuration block without changing their values.

Remove the temporary uniform-debug override. Apply cached textures once
per submission and select Canvas clipping and composite uniforms without
overwriting values within a draw.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 082c63a9-7e4b-426f-9b1e-fe59305417cb
@bghgary
bghgary force-pushed the bgfx-config-overridable branch from ca8cc0f to 2972a31 Compare October 16, 2026 18:04
@bghgary
bghgary requested a balanced review from Copilot October 16, 2026 18:08
@bghgary
bghgary enabled auto-merge (squash) October 16, 2026 18:10

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.

Comment thread Plugins/NativeEngine/Source/NativeEngine.cpp
Comment thread Plugins/NativeEngine/Source/NativeEngine.cpp
Comment thread Polyfills/Canvas/Source/nanovg/nanovg_babylon.cpp
bghgary and others added 2 commits October 16, 2026 11:19
bgfx shares uniform handles by name, but shader programs can assign the
same sampler to different texture stages. Replaying every cached stage
therefore writes the same sampler uniform more than once.

Ignore cached bindings absent from the current program or left at a
stage used by a previous program.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 082c63a9-7e4b-426f-9b1e-fe59305417cb
Derive sampler handles and stages from the current program while keeping texture bindings by stage. Bind missing textures explicitly so unsetting a sampler still assigns its texture unit, including for transform-feedback dispatches.

Upload Canvas stencil uniforms only when submitting stencil geometry. Empty and two-point fills otherwise upload the same uniforms again for the paint pass without an intervening draw.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 082c63a9-7e4b-426f-9b1e-fe59305417cb
@bghgary
bghgary merged commit af8d8aa into BabylonJS:master Oct 16, 2026
27 checks passed
@bghgary
bghgary deleted the bgfx-config-overridable branch October 16, 2026 18:58
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