dxgi: let shaders sample swap-chain back buffers #60

Open
github-bot wants to merge 1 commit from github-bot/gh-60 into main AGit
Owner

@⁠Andretuta on GitHub · 2026-11-24 02:10 UTC · original
ubiquitarianism:old-pr/9783 → main · +481 −83 · 8 files · 1 commits · draft

Carried over from old PR 9783 by Michael-M51 in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9783, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
Michael-M51: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

Claimed in the coordination issue as: DXGI shader-input back buffers

Depends on: #4317, #5248

These PRs have overlapping refcount and Vulkan image-lifetime edits. This patch builds directly on a60e5eab5, which includes the round-robin buffer change from #9602.

What and why

A swap chain can request DXGI_USAGE_SHADER_INPUT so a later pass can sample a rendered frame. Leonida returned a valid resource from GetBuffer, but CreateShaderResourceView left its descriptor empty. A compute shader read zero after a successful colour clear. DXGI usage flags

Register shader-input back buffers with the existing texture descriptor path. A default view or an explicit view matching the buffer format can now be sampled. An application reference to the buffer keeps its swap chain alive. Resize and teardown retire the cached views before destroying the Vulkan images. Cross-format sRGB views still need mutable images, which #5248 supplies for render-target views.

Tested

Windows 11, MSVC 19.44 Release, NVIDIA RTX 4070 SUPER, driver 621.24, Vulkan validation enabled. The new test uses a hand-written shader and synthetic colours.

  • The ordinary texture control matched 64/64 texels on both builds. The unpatched shim matched 0/64 before Present, after Present, and after ResizeBuffers. The patched shim matched 64/64 in all three and after release of the application's final swap-chain reference. The new test reported zero Vulkan validation errors.
  • A separate native D3D12 WARP run matched 64/64 for both default and explicit views before and after Present, including through a retained buffer, with zero D3D12 debug errors.
  • 14 of 16 graphics CTests passed. The two failures reproduced on the comparison build with the same command-list assertion and depth-clear validation messages. Both were previously reported on #9569. The two DXGI host-parity tests also passed with PROBE_WARP=1.
  • The full translator suite ran 6,015 tests across 456 files. The 48 failing subtests in test_image_atomics_guard and test_image_store_d16 matched the unmodified base.

Draft while the upstream Windows runtime build is broken. Stock a60e5eab5 and this commit both hit the compiler errors reported on #9576. For the GPU comparison only, I locally reversed 3630610ca on both sides. The workaround is absent from the submitted diff.

AI-assisted: yes

Checklist

  • Ran scripts/check_no_game_data.py on all eight changed files and git diff --check. No game data, keys or decryption.
  • Translator contract table: N/A for a runtime change.
**@⁠Andretuta** on GitHub · 2026-11-24 02:10 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/60) `ubiquitarianism:old-pr/9783` → `main` · +481 −83 · 8 files · 1 commits · draft > Carried over from **old PR 9783** by `Michael-M51` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/9783`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > `Michael-M51`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): Claimed in the coordination issue as: [DXGI shader-input back buffers](https://github.com/ProjectLeonida/Leonida/issues/9522#issuecomment-7114996659) Depends on: `#4317`, `#5248` These PRs have overlapping refcount and Vulkan image-lifetime edits. This patch builds directly on `a60e5eab5`, which includes the round-robin buffer change from `#9602`. ### What and why A swap chain can request `DXGI_USAGE_SHADER_INPUT` so a later pass can sample a rendered frame. Leonida returned a valid resource from `GetBuffer`, but `CreateShaderResourceView` left its descriptor empty. A compute shader read zero after a successful colour clear. [DXGI usage flags](https://learn.microsoft.com/windows/win32/direct3ddxgi/dxgi-usage) Register shader-input back buffers with the existing texture descriptor path. A default view or an explicit view matching the buffer format can now be sampled. An application reference to the buffer keeps its swap chain alive. Resize and teardown retire the cached views before destroying the Vulkan images. Cross-format sRGB views still need mutable images, which `#5248` supplies for render-target views. ### Tested Windows 11, MSVC 19.44 Release, NVIDIA RTX 4070 SUPER, driver 621.24, Vulkan validation enabled. The new test uses a hand-written shader and synthetic colours. - The ordinary texture control matched 64/64 texels on both builds. The unpatched shim matched 0/64 before Present, after Present, and after ResizeBuffers. The patched shim matched 64/64 in all three and after release of the application's final swap-chain reference. The new test reported zero Vulkan validation errors. - A separate native D3D12 WARP run matched 64/64 for both default and explicit views before and after Present, including through a retained buffer, with zero D3D12 debug errors. - 14 of 16 graphics CTests passed. The two failures reproduced on the comparison build with the same command-list assertion and depth-clear validation messages. Both were previously reported on `#9569`. The two DXGI host-parity tests also passed with `PROBE_WARP=1`. - The full translator suite ran 6,015 tests across 456 files. The 48 failing subtests in `test_image_atomics_guard` and `test_image_store_d16` matched the unmodified base. Draft while the upstream Windows runtime build is broken. Stock `a60e5eab5` and this commit both hit the [compiler errors reported on `#9576`](https://github.com/ProjectLeonida/Leonida/pull/9576#issuecomment-7114788903). For the GPU comparison only, I locally reversed `3630610ca` on both sides. The workaround is absent from the submitted diff. AI-assisted: yes ### Checklist - [x] Ran `scripts/check_no_game_data.py` on all eight changed files and `git diff --check`. No game data, keys or decryption. - Translator contract table: N/A for a runtime change.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:42:43 +00:00
This pull request has changes conflicting with the target branch.
  • runtime/CMakeLists.txt
  • runtime/shims/d3d12_vulkan_device.cpp
  • runtime/shims/dxgi_com.cpp
  • runtime/shims/dxgi_swapchain.h
  • runtime/src/vulkan_backend.h
  • runtime/src/vulkan_replay.h
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/60/head:github-bot/gh-60'
git switch 'github-bot/gh-60'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-60'
git switch 'github-bot/gh-60'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-60'
git switch 'github-bot/gh-60'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-60'
git switch 'main'
git merge --squash 'github-bot/gh-60'
git switch 'main'
git merge --ff-only 'github-bot/gh-60'
git switch 'main'
git merge 'github-bot/gh-60'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.