mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-10-26 02:35:27 +00:00
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:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user