Repository navigation
dxgi: a failed ResizeBuffers leaves the swap chain without buffers until the next one succeeds, as on the host - #8171
lines9686-rgb wants to merge 2 commits into
Conversation
…til the next one succeeds, as on the host Measured against the host runtime (RTX 3060 Ti, NVIDIA 610.88, and WARP): once ResizeBuffers accepts its arguments the old buffers are gone. If the new ones can't be made it fails, and the swap chain stays without buffers. GetDesc1 already reports the requested size and count, GetBuffer and Present are DXGI_ERROR_INVALID_CALL, and the next successful ResizeBuffers restores everything. A side above 16384 is E_INVALIDARG on the hardware device. A call refused for its arguments (a back buffer still held) changes nothing. The layer answered E_FAIL and kept describing the old buffers. It now answers E_INVALIDARG for a side above 16384 before calling Vulkan (it used to pass the extent to vkCreateImage, past the device's limits) and E_OUTOFMEMORY when Vulkan fails. It reports the requested description, refuses Present, and recovers on the next ResizeBuffers. dxgi_swapchain_test compares 15 steps of that with the host's default adapter. dxgi_swapchain_count_test gets failure injection on its fake Vulkan table: whether the offscreen ring or vkCreateSwapchainKHR fails (the latter retires the old swapchain anyway), on the offscreen and on the direct path, the next resize builds a working swapchain. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent Windows 11 MSVC + dual-GPU review of Environment
Build & Results
Finding (test bug on hidden/occluded Windows 11 desktop)
Minor code-audit note (non-blocking)
Core runtime fix and Vulkan validation look solid across both NVIDIA and Intel — happy to re-verify once the |
…ffers; the comparison treats DXGI_STATUS_OCCLUDED as S_OK Review of ItsNotRexed#8171 (@KarolKurzyna): - The host answers DXGI_STATUS_OCCLUDED from Present for a window that isn't on screen, which depends on the desktop, so compare_failed_resize now counts it as S_OK. The failures stay strict. - After a failed ResizeBuffers the host checks SetSourceSize against the size that was asked for (RTX 3060 Ti: after 16x16385, 100x10 is DXGI_ERROR_INVALID_CALL; after 16385x16 it is S_OK), so the layer does too. The comparison gains those two steps (17 now). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Xiiano
left a comment
There was a problem hiding this comment.
Copilot SDK:
I found two actionable concerns: the new boolean failure mapping conflates allocation failures with unrelated Vulkan/device/surface failures, and the fake test assumes oldSwapchain is retired on a failed vkCreateSwapchainKHR without proving the spec/lifecycle behavior. I’m posting the review against the changed resize call now.
addComment "Blocking: VulkanSwapchain::resize() re…"
Reviewed and posted a comment on PR #8171 covering:
Incorrectly mapping all Vulkan resize failures to E_OUTOFMEMORY.
Ambiguous oldSwapchain retirement and recovery semantics.
Missing cleanup/error distinction after partial swapchain creation.
AI used: GitHub Copilot SDK in VS Code; model information is not exposed in this session.
|
Thanks @KarolKurzyna, both were right. Fixed in 4131eb7:
Re-run here: |
|
@Xiiano, thanks. Point by point (the inline comment your review mentions didn't get posted, so I'm going by the summary):
AI-assisted (Claude Code). |
|
Re-verified
Thanks for the fast fix and the hardware measurement of |
|
Heads tested: ae6810f, then your force-pushed 4131eb7 (delta reviewed on its own; head re-confirmed at check end); main dde82f2; recheck clean vs d612f65/867d922f0 (tree 473803aa3). C++ — review-only; CI (pending at check time) is the gate. The lost-buffers state machine matches the host table line for line — GetDesc/GetDesc1 report the requested size/count/format, GetBuffer and Present give DXGI_ERROR_INVALID_CALL until the next successful ResizeBuffers, >16384 E_INVALIDARG lands before anything reaches vkCreateImage, Vulkan failure maps to E_OUTOFMEMORY, and unregister_buffers() before the failure paths is the right ordering. The force-push delta is coherent: SetSourceSize bounds-checks against the lost extent, and the host comparison normalizes only Present's DXGI_STATUS_OCCLUDED while failures stay strict. The RTX 3060 Ti + WARP per-call host table is hardware-tier evidence; the WARP 16385 divergence is acknowledged in code. Overlap: conflicts with #8176 in dxgi_swapchain_count_test.cpp — later merger rebases. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run). |
Claimed in the coordination issue: #7694 (comment). This is the
ResizeBuffersfailure item @tedin7 released, with their partial branchc2-resizebuffers-fail.What the host does
The item assumed DXGI keeps the old buffers when
ResizeBuffersfails. A probe on the host runtime says it doesn't. The probe is standalone, with no Leonida code. I ran it on an RTX 3060 Ti (NVIDIA 610.88) and on WARP:ResizeBuffers(2, 16384, 16384)ResizeBuffers(2, 16385, 16)/(16, 16385)ResizeBuffers(2, 32768, 32768),(2^20, 2^20)GetDesc1GetBuffer(0),PresentResizeBuffers(2, 128, 128)ResizeBufferswith a back buffer still heldSo once the arguments are accepted, the old buffers are gone. A failure leaves the swap chain without buffers until the next successful
ResizeBuffers. Keeping the old swapchain alive, as the partial branch did, would make the layer differ from the host. This PR implements the host's behaviour instead, so tedin7's commit is not in it. Their oversized-resize test case is the starting point of the comparison below.What the layer did
E_FAILfor every failure and kept describing the old buffers.vkCreateImage. With validation on, that is several errors (extent pastmaxImageDimension2DandmaxFramebufferWidth, a 4 TiB allocation) before the driver fails it.Change (
runtime/shims/dxgi_com.cpp)D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSIONisE_INVALIDARG, before anything reaches Vulkan. A Vulkan failure isE_OUTOFMEMORY.GetDesc/GetDesc1report the requested size, count and format;GetBufferandPresentareDXGI_ERROR_INVALID_CALL;ResizeBuffers(count 0 and format UNKNOWN take the requested ones) rebuilds and clears the state.Tests
dxgi_swapchain_testgetscompare_failed_resize. It runs the same 17 steps on our swap chain and on the host's default adapter, and requires every HRESULT and description field to match. The steps are: 16385×16, its description, GetBuffer and Present; 16×16385; recovery with count 0; GetBuffer and Present after recovering; a resize with a held back buffer and what follows. WARP answers differently, so this compares with the default adapter, as the existingCreateSwapChainForHwndcomparison does.dxgi_swapchain_count_test(fake Vulkan table, no GPU) gets failure injection for the Vulkan side.vkCreateSwapchainKHRfails. The fake follows the rule that the old swapchain is retired even then.Tested (Windows 11, MSVC, RTX 3060 Ti / NVIDIA 610.88)
Branch on main
dde82f27e, MSVC RelWithDebInfo, Ninja.dxgi_swapchain_testwithLEONIDA_VK_VALIDATION=1: PASS.CreateSwapChainForHwndcases and the 17 failed-resize steps both match the host, with 0 mismatches.maxFramebufferWidth/Height, two pastmaxImageDimension2D, and a 4 TiB allocation.dxgi_swapchain_count_test: PASS, the 3 existing cases and the 4 failed-resize cases.ctest -j 1: 268 of 272 pass. This diff touches only the three DXGI files above, and none of the 4 failures uses a DXGI swap chain:d3d12_indirect_rtis fixed by d3d12: an ARRAY_OF_POINTERS entry below the arena is not an overflow (d3d12_indirect_rt on NVIDIA) #6010;d3d12_indirect_dispatch_countis fixed by d3d12_indirect_dispatch_count_test: its compute fixture reads the root UAV at s4:s5 (D3D-448 layout) #5792;d3d12_vulkan_deviceis thetiles == 1row in TEST-1698 / d3d12_vulkan_device: check PC CreateReservedResource2 behind the Xbox proxy, not through slot 78 #7125;d3d12_depth_resolveis NVIDIA host-quirk rows on this main, unrelated to this change.AI-assisted: yes (Claude Code)
Checklist
docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code