OLD-8171: a failed ResizeBuffers leaves the swap chain without buffers until the next one succeeds, as on the host #389

Manually merged
github merged 3 commits from gh-pr/389/head into gh-pr/389/base 2026-11-26 08:57:13 +00:00
Owner

@⁠lines9686-rgb on GitHub · 2026-11-24 04:24 UTC · original
lines9686-rgb:dxgi-resizebuffers-lost → main · +287 −18 · 3 files · 3 commits · merged 2026-11-24 05:09 UTC

Claimed in the coordination issue as: OLD-8171 (carried over from the original repository, same author)

What and why

On the host, once ResizeBuffers accepts its arguments the old buffers are gone. When the new ones cannot be made the call fails and the swap chain stays without buffers: its description already reports the new size, count and format, GetBuffer and Present are DXGI_ERROR_INVALID_CALL, and the next successful ResizeBuffers brings it back. A side above 16384 is E_INVALIDARG on a hardware device. The layer kept the old buffers instead, so a title that recovers by resizing again saw different answers than on Windows.

dxgi_com.cpp now models that state (lost_): GetDesc/GetDesc1 report the requested description, Present and GetBuffer refuse, SetSourceSize checks against the requested size, a side above 16384 is E_INVALIDARG, and a Vulkan failure is E_OUTOFMEMORY.

Rebased on this main: on main every chain is the offscreen ring, so the two fake-table cases that expected the direct path now expect the ring with matching counts.

Tested

Windows 11, RTX 3060 Ti, NVIDIA 621.24, MSVC:

  • dxgi_swapchain_test: PASS. Its new step compares 17 steps of a failed resize and the recovery with the host runtime: 0 mismatches (Present answering DXGI_STATUS_OCCLUDED for a window off screen counts as S_OK).
  • dxgi_swapchain_count_test: PASS, with 4 failed-resize cases: vkCreateSwapchainKHR fails or the new ring fails, with and without extra native images. Each case checks that the next resize builds a working swap chain.

GPUs tested: NVIDIA GeForce RTX 3060 Ti, driver 621.24, Windows 11

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly.
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (scripts/check_no_game_data.py over every changed file: clean).
  • A new translator rule is in the contract table of docs/design.md: n/a

🤖 Generated with Claude Code

**@⁠lines9686-rgb** on GitHub · 2026-11-24 04:24 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/389) `lines9686-rgb:dxgi-resizebuffers-lost` → `main` · +287 −18 · 3 files · 3 commits · merged 2026-11-24 05:09 UTC Claimed in the coordination issue as: `OLD-8171` (carried over from the original repository, same author) ### What and why On the host, once `ResizeBuffers` accepts its arguments the old buffers are gone. When the new ones cannot be made the call fails and the swap chain stays without buffers: its description already reports the new size, count and format, `GetBuffer` and `Present` are `DXGI_ERROR_INVALID_CALL`, and the next successful `ResizeBuffers` brings it back. A side above 16384 is `E_INVALIDARG` on a hardware device. The layer kept the old buffers instead, so a title that recovers by resizing again saw different answers than on Windows. `dxgi_com.cpp` now models that state (`lost_`): `GetDesc`/`GetDesc1` report the requested description, `Present` and `GetBuffer` refuse, `SetSourceSize` checks against the requested size, a side above 16384 is `E_INVALIDARG`, and a Vulkan failure is `E_OUTOFMEMORY`. Rebased on this `main`: on `main` every chain is the offscreen ring, so the two fake-table cases that expected the direct path now expect the ring with matching counts. ### Tested Windows 11, RTX 3060 Ti, NVIDIA 621.24, MSVC: - `dxgi_swapchain_test`: PASS. Its new step compares 17 steps of a failed resize and the recovery with the host runtime: 0 mismatches (`Present` answering `DXGI_STATUS_OCCLUDED` for a window off screen counts as `S_OK`). - `dxgi_swapchain_count_test`: PASS, with 4 failed-resize cases: `vkCreateSwapchainKHR` fails or the new ring fails, with and without extra native images. Each case checks that the next resize builds a working swap chain. GPUs tested: NVIDIA GeForce RTX 3060 Ti, driver 621.24, Windows 11 AI-assisted: yes (Claude Code) ### Checklist - [x] Based on current `main` and merges cleanly. - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (`scripts/check_no_game_data.py` over every changed file: clean). - [x] A new translator rule is in the contract table of `docs/design.md`: n/a 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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 <[email protected]>
Review by @KarolKurzyna in the original repository:
- 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 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:57:12 +00:00
github manually merged commit eeeda84c90 into gh-pr/389/base 2026-11-26 08:57:13 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.