d3d12: select only the needed deferred Vulkan draw pipeline #681

Open
github-bot wants to merge 2 commits from github-bot/gh-681 into main AGit
Owner

@⁠QemmHD on GitHub · 2026-11-24 11:49 UTC · original
ubiquitarianism:qemmhd/rt-lazy-attachment-variant → main · +250 −41 · 5 files · 2 commits · draft

Claimed in #14 as RT-LAZY-ATTACHMENT-VARIANT.

Depends on: #511. This branch keeps the original #511 commit intact. The last commit is the change for review.

What and why

The deferred Vulkan draw path tries the full-attachment pipeline before it knows which attachments are bound. When a target is absent, this can compile two pipelines for one draw. If the full-attachment compile fails, replay rejects the draw before trying its usable variant.

Select the pipeline once after draw validation, using the final attachment mask. Fully bound eager draws still use the pipeline they already have. The CPU replay self-test covers eager draws, fully bound and partial lazy draws, a refused unused base, and an invalid mesh draw.

Tested

  • On #511 with the new fixture, three cases failed: duplicate compilation, premature rejection, and compilation for an invalid draw.
  • With the fix, all seven selection cases passed in replay_cpu_bench_selftest on Windows 11 with MSVC 2022 x64 and Vulkan SDK headers.
  • git diff --check, the repository game-data scan on both changed files, and the merge check against main at 21625bca8 passed.

GPU coverage for this follow-up: CPU replay fixture only.

AI-assisted: yes (Codex).

**@⁠QemmHD** on GitHub · 2026-11-24 11:49 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/681) `ubiquitarianism:qemmhd/rt-lazy-attachment-variant` → `main` · +250 −41 · 5 files · 2 commits · draft Claimed in #14 as [RT-LAZY-ATTACHMENT-VARIANT](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14). Depends on: #511. This branch keeps the original #511 commit intact. The last commit is the change for review. ### What and why The deferred Vulkan draw path tries the full-attachment pipeline before it knows which attachments are bound. When a target is absent, this can compile two pipelines for one draw. If the full-attachment compile fails, replay rejects the draw before trying its usable variant. Select the pipeline once after draw validation, using the final attachment mask. Fully bound eager draws still use the pipeline they already have. The CPU replay self-test covers eager draws, fully bound and partial lazy draws, a refused unused base, and an invalid mesh draw. ### Tested - On #511 with the new fixture, three cases failed: duplicate compilation, premature rejection, and compilation for an invalid draw. - With the fix, all seven selection cases passed in `replay_cpu_bench_selftest` on Windows 11 with MSVC 2022 x64 and Vulkan SDK headers. - `git diff --check`, the repository game-data scan on both changed files, and the merge check against `main` at `21625bca8` passed. GPU coverage for this follow-up: CPU replay fixture only. AI-assisted: yes (Codex).
Graphics PSOs build their driver pipeline as variant(0) at the first draw; compute PSOs compile through
ComputePipeline::build at the first dispatch. A stage the runtime does not edit (no f16 link, no D24 depth patch)
keeps no VkShaderModule: build() makes one from the library's words per pipeline and destroys it after. The compute
subgroup request is still decided and recorded at creation in both modes. Off by default.

Tests: d3d12_compute_lazy_pso, d3d12_draw_lazy_pso, d3d12_mesh_lazy_pso (the existing tests with the switch on).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:15:57 +00:00
Author
Owner

@⁠SweatierKey on GitHub · 2026-11-24 16:00 UTC · original · approved these changes

Independent verification on Windows 11 against origin/main@1504c1af6:

  • Cross-compiled replay_cpu_bench.exe (clang-cl + xwin SDK 10.0.26100) and ran natively on Windows 11:
    • Passed check_draw_pipeline_selection() and all replay CPU benchmarks (rc=0).
  • Audited d3d12_vulkan_device.cpp and vulkan_replay.h: clean deferred pipeline creation under LEONIDA_LAZY_PSO=1 (preserving edited modules for f16-link and depth24 fragments, building unedited stages on demand and destroying transient VkShaderModules immediately after vkCreate*Pipelines).
  • python3 -I scripts/check_no_game_data.py: clean.

AI-assisted: yes

**@⁠SweatierKey** on GitHub · 2026-11-24 16:00 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/681#pullrequestreview-6042795565) · **approved these changes** Independent verification on Windows 11 against `origin/main@1504c1af6`: - Cross-compiled `replay_cpu_bench.exe` (`clang-cl` + xwin SDK 10.0.26100) and ran natively on Windows 11: - Passed `check_draw_pipeline_selection()` and all replay CPU benchmarks (`rc=0`). - Audited `d3d12_vulkan_device.cpp` and `vulkan_replay.h`: clean deferred pipeline creation under `LEONIDA_LAZY_PSO=1` (preserving edited modules for f16-link and depth24 fragments, building unedited stages on demand and destroying transient `VkShaderModule`s immediately after `vkCreate*Pipelines`). - `python3 -I scripts/check_no_game_data.py`: clean. AI-assisted: yes
This pull request has changes conflicting with the target branch.
  • runtime/CMakeLists.txt
  • runtime/shims/d3d12_vulkan_device.cpp
  • 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/681/head:github-bot/gh-681'
git switch 'github-bot/gh-681'

Merge

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