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.
The fragment shader CBV address was computed as gpuAddress + vsh->m_size,
but D3D12 requires constant buffer view addresses to be 256-byte aligned
(D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT). When the vertex shader
constant buffer exceeds 256 bytes without being a multiple of 256, the
fragment shader reads from a misaligned address, producing corrupt uniform
values.
This causes rendering artifacts or completely black output for any shader
program where the VS constant buffer size is not a multiple of 256 bytes,
since the fragment shader receives incorrect uniform data (e.g. a non-zero
alpha reference threshold that discards all pixels).
The fix aligns the VS constant buffer size to 256 bytes before placing the
FS constants, and uses the aligned offset when computing the FS CBV address
in both the main render loop and the blitter path.
* DX12: fix invalid state when creating a BLIT_DST texture without mem block
* Only set state when it's not external texture.
---------
Co-authored-by: Branimir Karadžić <branimirkaradzic@gmail.com>
The _external parameter is written to the command buffer as uint64_t (8 bytes)
but read back as uintptr_t (4 bytes on 32-bit). This causes a 4-byte
deserialization misalignment on x86, corrupting all subsequent command
buffer reads and leading to EXCEPTION_ACCESS_VIOLATION (0xC0000005) during
D3D11 initialization.
Co-authored-by: Matteo Valdina <mavaldin@microsoft.com>