Fix BGFX_RESET_VSYNC not affecting secondary swap chains on D3D11, Vulkan, OpenGL (#3675)

Toggling BGFX_RESET_VSYNC via bgfx::reset() only updated the main/init swap
chain. Secondary swap chains created through createFrameBuffer(nwh, ...) kept
their initial vsync state, leaving framerate capped at refresh rate. D3D12
already handled this correctly.

D3D11: forward present flags to FrameBufferD3D11::present so it can pass
DXGI_PRESENT_ALLOW_TEARING alongside syncInterval=0. Compute presentFlags once
in flip() and reuse for both secondary framebuffers and the main swap chain.

Vulkan: in updateResolution, iterate m_windows and call FrameBufferVK::update
on each valid secondary framebuffer so SwapChainVK::update sees the new
BGFX_RESET_VSYNC and recreates the swapchain with the correct present mode.

OpenGL (WGL/EGL): wglSwapIntervalEXT is per-context, eglSwapInterval is
per-surface. Cache the desired interval in GlContext::m_swapInterval and
re-apply it in makeCurrent() whenever a different context/surface becomes
current, so secondary SwapChainGL instances pick up the current value. Also
honor the initial BGFX_RESET_VSYNC flag in create() instead of hard-coding 0.
This commit is contained in:
unravel-dev
2026-04-19 22:35:57 +00:00
committed by GitHub
parent 4481b9b46b
commit 4212c8ed27
7 changed files with 67 additions and 17 deletions
+16
View File
@@ -3005,6 +3005,22 @@ VK_IMPORT_DEVICE
m_resolution.width = m_backBuffer.m_width;
m_resolution.height = m_backBuffer.m_height;
// Propagate reset flags (e.g. BGFX_RESET_VSYNC) to secondary window swapchains,
// otherwise they'd keep their original present mode and ignore the reset.
for (uint16_t ii = 0; ii < m_numWindows; ++ii)
{
if (!isValid(m_windows[ii]) )
{
continue;
}
FrameBufferVK& fb = m_frameBuffers[m_windows[ii].idx];
Resolution fbResolution = m_resolution;
fbResolution.width = fb.m_width;
fbResolution.height = fb.m_height;
fb.update(m_commandBuffer, fbResolution);
}
postReset();
}