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
14 changes: 14 additions & 0 deletions Core/Graphics/Source/DeviceImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,20 @@ namespace Babylon::Graphics
auto& init = m_state.Bgfx.InitState;
init.callback = &m_bgfxCallback;

// bgfx reserves limits.numDrawCalls render-item slots (sort keys, RenderItem,
// RenderBind) up front for every Frame, and defaults to
// BGFX_CONFIG_MAX_DRAW_CALLS (65535) -- tens of megabytes.
//
// 0 asks for a single BGFX_CONFIG_DRAW_CALL_BLOCK instead (4096, set in
// Dependencies/CMakeLists.txt), and bgfx resizes in block steps up to that same
// ceiling. Growth is reactive -- the frame that overflows drops the draws past
// capacity -- so the block should sit above the expected peak.
//
// numDrawCallPeakFrames is the shrink delay in frames, ~1s at 60fps. Resizing
// is disabled entirely at 0.
init.limits.numDrawCalls = 0;
init.limits.numDrawCallPeakFrames = 60;

// Use the noop renderer if the configuration has no window and no size.
if (config.Window == WindowT{} && config.Width == 0 && config.Height == 0)
{
Expand Down
1 change: 1 addition & 0 deletions Dependencies/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ FetchContent_MakeAvailable_With_Message(bgfx.cmake)
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_DRAW_CALL_BLOCK=4096)
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)
Expand Down