d3d12: keep sparse tile mappings in queue order (D3D-SPARSE-TILE-WAIT-ORDER) #1182

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

@⁠lixonik on GitHub · 2026-11-24 19:44 UTC · original
lixonik:d3d-sparse-tile-wait-order → main · +315 −46 · 4 files · 1 commits · open

Claimed in the coordination issue as D3D-SPARSE-TILE-WAIT-ORDER.

What and why

D3D12 tile updates and copies submitted Vulkan sparse binds immediately, even when an earlier operation on the same queue was held waiting for a fence. A remap could therefore reach the GPU ahead of that operation, and a mapping copy could read stale source mappings.

Stage both mapping operations in the same queue FIFO as held batches and signals. Resolve the current mappings when the operation is released. Keep the heap backing alive across the hold and verify that the registered resources are still the ones named when the operation was queued. A held mapping that generates no sparse work still submits its pending waits in order.

Tested

  • Mock Vulkan regression on Ubuntu with GCC. On main it sees sparse submissions before the fence signal. With the fix it checks FIFO ordering, the wait timeline between submissions, mapping and unmapping before a copy, a no-op copy with a pending wait, and removal and reuse of a resource ID.
  • Windows x64, MSVC 19.29, static CRT. All four selected CTest tests passed (vk_sparse_queue_order, vk_queue_constructor_oom, vk_buffer_registration_oom, vk_host_at_aliasing). Also compiled the Windows D3D12 command queue and device translation units with MSVC.
  • Full translator semantic suite passed (470 files, 6,141 tests). git diff --check and the game-data check passed.

GPUs tested: n/a (synthetic Vulkan calls).

AI-assisted.

Checklist

  • Based on current main.
  • One topic.
  • No game data, keys or decryption.
  • No translator rule change.
**@⁠lixonik** on GitHub · 2026-11-24 19:44 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1182) `lixonik:d3d-sparse-tile-wait-order` → `main` · +315 −46 · 4 files · 1 commits · open Claimed in the coordination issue as [D3D-SPARSE-TILE-WAIT-ORDER](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14). ### What and why D3D12 tile updates and copies submitted Vulkan sparse binds immediately, even when an earlier operation on the same queue was held waiting for a fence. A remap could therefore reach the GPU ahead of that operation, and a mapping copy could read stale source mappings. Stage both mapping operations in the same queue FIFO as held batches and signals. Resolve the current mappings when the operation is released. Keep the heap backing alive across the hold and verify that the registered resources are still the ones named when the operation was queued. A held mapping that generates no sparse work still submits its pending waits in order. ### Tested - Mock Vulkan regression on Ubuntu with GCC. On main it sees sparse submissions before the fence signal. With the fix it checks FIFO ordering, the wait timeline between submissions, mapping and unmapping before a copy, a no-op copy with a pending wait, and removal and reuse of a resource ID. - Windows x64, MSVC 19.29, static CRT. All four selected CTest tests passed (`vk_sparse_queue_order`, `vk_queue_constructor_oom`, `vk_buffer_registration_oom`, `vk_host_at_aliasing`). Also compiled the Windows D3D12 command queue and device translation units with MSVC. - Full translator semantic suite passed (470 files, 6,141 tests). `git diff --check` and the game-data check passed. GPUs tested: n/a (synthetic Vulkan calls). AI-assisted. ### Checklist - [x] Based on current `main`. - [x] One topic. - [x] No game data, keys or decryption. - [x] No translator rule change.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:41:49 +00:00
Author
Owner

@⁠madhyn on GitHub · 2026-11-24 20:08 UTC · original

Tested 07c3e8eda on Arch Linux:

  • ctest --test-dir runtime/build/linux -R "^vk_sparse_queue_order$" --output-on-failure: Passed (0.00 s)

AI-assisted: yes

**@⁠madhyn** on GitHub · 2026-11-24 20:08 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1182#issuecomment-7143089396) Tested `07c3e8eda` on Arch Linux: - `ctest --test-dir runtime/build/linux -R "^vk_sparse_queue_order$" --output-on-failure`: **Passed** (0.00 s) AI-assisted: yes
Author
Owner

@⁠Deedlyy on GitHub · 2026-11-24 20:09 UTC · original

Recommendation: [WAIT]

Reasoning: Sparse tile mappings and mapping copies are now staged in the queue FIFO with held batches and signals, so a remap can't overtake an earlier fence-held operation. This rewrites a chunk of vulkan_backend.h (+109/-43) and adds a 195-line test. The fix is plausible and important, but it is concurrency-sensitive and has no review or independent run yet. Get a second-person run of vk_sparse_queue_order and the sparse tile tests (#1156 adds timeouts for those), ideally on two vendors. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with main.

Impact level: 6/10

**@⁠Deedlyy** on GitHub · 2026-11-24 20:09 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1182#issuecomment-7143120934) **Recommendation:** [WAIT] **Reasoning:** Sparse tile mappings and mapping copies are now staged in the queue FIFO with held batches and signals, so a remap can't overtake an earlier fence-held operation. This rewrites a chunk of `vulkan_backend.h` (+109/-43) and adds a 195-line test. The fix is plausible and important, but it is concurrency-sensitive and has no review or independent run yet. Get a second-person run of `vk_sparse_queue_order` and the sparse tile tests (#1156 adds timeouts for those), ideally on two vendors. CI (label, change-scope, no-game-data and the Runtime jobs) is still queued awaiting maintainer workflow approval, so nothing has run in CI yet; GitHub reports no merge conflict with `main`. **Impact level:** 6/10
Author
Owner

@⁠PierreEbele on GitHub · 2026-11-25 09:25 UTC · original

Tested 07c3e8eda under Wine 10.0 on Linux, GTX 1050 Ti (NVIDIA 555.58), Windows runtime cross-built with clang-cl + xwin: the teardown wedge this targets is gone.

  • On main 42537e7b6, d3d12_buffer_tiles and d3d12_texture_tiles hang until the ctest 300 s kill. UpdateTileMappings is refused with "sparse residency unavailable" although the standalone sparse probe passes on this driver, then teardown deadlocks on Wait(gate). Without the valve both hang indefinitely (seen for 15+ minutes).
  • With this PR, both pass in about 3 s, 4/4 attempts each. The new vk_sparse_queue_order test passes, and the rest of the d3d12_queue / d3d12_sparse / vk_sparse selection stays green (16 tests on main, 17 with the new one).

The PR head is based on 6293c1c4f, so a rebase onto current main may be needed before merging. AI-assisted.

Recommendation: Merge

**@⁠PierreEbele** on GitHub · 2026-11-25 09:25 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1182#issuecomment-7158301727) Tested 07c3e8eda under Wine 10.0 on Linux, GTX 1050 Ti (NVIDIA 555.58), Windows runtime cross-built with clang-cl + xwin: the teardown wedge this targets is gone. - On main 42537e7b6, `d3d12_buffer_tiles` and `d3d12_texture_tiles` hang until the ctest 300 s kill. `UpdateTileMappings` is refused with "sparse residency unavailable" although the standalone sparse probe passes on this driver, then teardown deadlocks on `Wait(gate)`. Without the valve both hang indefinitely (seen for 15+ minutes). - With this PR, both pass in about 3 s, 4/4 attempts each. The new `vk_sparse_queue_order` test passes, and the rest of the `d3d12_queue` / `d3d12_sparse` / `vk_sparse` selection stays green (16 tests on main, 17 with the new one). The PR head is based on 6293c1c4f, so a rebase onto current main may be needed before merging. AI-assisted. **Recommendation:** Merge
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

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