d3d12: keep sparse tile mappings in queue order (D3D-SPARSE-TILE-WAIT-ORDER) #1182
Closed
lixonik wants to merge 2 commits from
upstream-pr/1182 into main
pull from: upstream-pr/1182
merge into: ProjectLeonida:main
ProjectLeonida:main
ProjectLeonida:claude/loop-total
ProjectLeonida:claude/pops-collision-seed
ProjectLeonida:claude/dstorage-hold-page-reads
ProjectLeonida:claude/host-image-copy-switch
ProjectLeonida:feat/gdk-lifecycle-window-hook
ProjectLeonida:claude/d16s8-uav-nvidia-fallback
ProjectLeonida:feat/mfplat-offline-shim
ProjectLeonida:claude/gameinput-slow-reader
ProjectLeonida:fix/rt-null-barrier-clear
ProjectLeonida:claude/depth-resolve-sample-positions
ProjectLeonida:integration/palmetto-parity
ProjectLeonida:claude/valu-literal-sext
ProjectLeonida:claude/slot74-pool-handle
ProjectLeonida:claude/rgb9e5-uint-alias-view
ProjectLeonida:claude/fssm-root-layout-tables
ProjectLeonida:feat/gdk-speech-display-lifecycle
ProjectLeonida:asset-audio-skip-current
ProjectLeonida:qemmhd/old-9940-rectangle-quad-lists
ProjectLeonida:feat/ws2-offline-shim
ProjectLeonida:qemmhd/rt-d16-unorm-uav
ProjectLeonida:feat/xs-device-stops-7-9
ProjectLeonida:qemmhd/rt-depth-same-base-shapes
ProjectLeonida:qemmhd/rt-lazy-attachment-variant
ProjectLeonida:feat/acphal-xma2-decoder
ProjectLeonida:asset-audio-skip
ProjectLeonida:codex/coord-claim-check-20261124-7e48
ProjectLeonida:feat/xs-frame-pacing-presentx
ProjectLeonida:feat/xs-device-vm-options
ProjectLeonida:old-pr/9844
ProjectLeonida:old-pr/9978
ProjectLeonida:old-pr/9815
ProjectLeonida:old-pr/10057
ProjectLeonida:old-pr/9874
ProjectLeonida:old-pr/9965
ProjectLeonida:old-pr/9863
ProjectLeonida:old-pr/10068
ProjectLeonida:old-pr/10066
ProjectLeonida:old-pr/10067
ProjectLeonida:old-pr/10007
ProjectLeonida:old-pr/10061
ProjectLeonida:old-pr/10065
ProjectLeonida:old-pr/10059
ProjectLeonida:old-pr/10063
ProjectLeonida:old-pr/10055
ProjectLeonida:old-pr/10062
ProjectLeonida:old-pr/10042
ProjectLeonida:old-pr/10041
ProjectLeonida:old-pr/10049
ProjectLeonida:old-pr/10047
ProjectLeonida:old-pr/10046
ProjectLeonida:old-pr/10045
ProjectLeonida:old-pr/10056
ProjectLeonida:old-pr/10043
ProjectLeonida:old-pr/10036
ProjectLeonida:old-pr/10034
ProjectLeonida:old-pr/9984
ProjectLeonida:old-pr/10052
ProjectLeonida:old-pr/10038
ProjectLeonida:old-pr/10033
ProjectLeonida:old-pr/10028
ProjectLeonida:old-pr/10050
ProjectLeonida:old-pr/9891
ProjectLeonida:old-pr/9889
ProjectLeonida:old-pr/10051
ProjectLeonida:old-pr/10019
ProjectLeonida:old-pr/10027
ProjectLeonida:old-pr/10029
ProjectLeonida:old-pr/10031
ProjectLeonida:old-pr/10026
ProjectLeonida:old-pr/9941
ProjectLeonida:old-pr/10030
ProjectLeonida:old-pr/10040
ProjectLeonida:old-pr/9990
ProjectLeonida:old-pr/10021
ProjectLeonida:old-pr/9962
ProjectLeonida:old-pr/10022
ProjectLeonida:old-pr/10020
ProjectLeonida:old-pr/10015
ProjectLeonida:old-pr/10025
ProjectLeonida:old-pr/9886
ProjectLeonida:old-pr/10048
ProjectLeonida:old-pr/10014
ProjectLeonida:old-pr/10011
ProjectLeonida:old-pr/9861
ProjectLeonida:old-pr/10010
ProjectLeonida:old-pr/10008
ProjectLeonida:old-pr/9860
ProjectLeonida:old-pr/10006
ProjectLeonida:old-pr/9920
ProjectLeonida:old-pr/9995
ProjectLeonida:old-pr/10000
ProjectLeonida:old-pr/10016
ProjectLeonida:old-pr/10004
ProjectLeonida:old-pr/10023
ProjectLeonida:old-pr/9982
ProjectLeonida:old-pr/9981
ProjectLeonida:old-pr/9983
ProjectLeonida:old-pr/9970
ProjectLeonida:old-pr/9969
ProjectLeonida:old-pr/9968
ProjectLeonida:old-pr/9971
ProjectLeonida:old-pr/9972
ProjectLeonida:old-pr/9942
ProjectLeonida:old-pr/9963
ProjectLeonida:old-pr/9960
ProjectLeonida:old-pr/9964
ProjectLeonida:old-pr/9985
ProjectLeonida:old-pr/9973
ProjectLeonida:old-pr/9862
ProjectLeonida:old-pr/9953
ProjectLeonida:old-pr/10017
ProjectLeonida:old-pr/9952
ProjectLeonida:old-pr/9955
ProjectLeonida:old-pr/9946
ProjectLeonida:old-pr/9954
ProjectLeonida:old-pr/9938
ProjectLeonida:old-pr/9956
ProjectLeonida:old-pr/9856
ProjectLeonida:old-pr/9947
ProjectLeonida:old-pr/9924
ProjectLeonida:old-pr/9961
ProjectLeonida:old-pr/9927
ProjectLeonida:old-pr/9979
ProjectLeonida:old-pr/10032
ProjectLeonida:old-pr/9926
ProjectLeonida:old-pr/5237
ProjectLeonida:old-pr/9951
ProjectLeonida:old-pr/9931
ProjectLeonida:old-pr/9902
ProjectLeonida:old-pr/9921
ProjectLeonida:old-pr/9994
ProjectLeonida:old-pr/9775
ProjectLeonida:old-pr/9768
ProjectLeonida:old-pr/9905
ProjectLeonida:old-pr/9936
ProjectLeonida:old-pr/9901
ProjectLeonida:old-pr/9904
ProjectLeonida:old-pr/9906
ProjectLeonida:old-pr/9988
ProjectLeonida:old-pr/9908
ProjectLeonida:old-pr/9909
ProjectLeonida:old-pr/9911
ProjectLeonida:old-pr/9912
ProjectLeonida:old-pr/9913
ProjectLeonida:old-pr/9887
ProjectLeonida:old-pr/9916
ProjectLeonida:old-pr/9919
ProjectLeonida:old-pr/9925
ProjectLeonida:old-pr/9933
ProjectLeonida:old-pr/9935
ProjectLeonida:old-pr/9918
ProjectLeonida:old-pr/9879
ProjectLeonida:old-pr/9880
ProjectLeonida:old-pr/9881
ProjectLeonida:old-pr/9996
ProjectLeonida:old-pr/9876
ProjectLeonida:old-pr/9892
ProjectLeonida:old-pr/9899
ProjectLeonida:old-pr/9915
ProjectLeonida:old-pr/9914
ProjectLeonida:old-pr/9872
ProjectLeonida:old-pr/9869
ProjectLeonida:old-pr/9866
ProjectLeonida:old-pr/9819
ProjectLeonida:old-pr/10012
ProjectLeonida:old-pr/9857
ProjectLeonida:old-pr/9893
ProjectLeonida:old-pr/9897
ProjectLeonida:old-pr/9928
ProjectLeonida:old-pr/9868
ProjectLeonida:old-pr/9917
ProjectLeonida:old-pr/9940
ProjectLeonida:old-pr/9873
ProjectLeonida:old-pr/9816
ProjectLeonida:old-pr/10009
ProjectLeonida:old-pr/9900
ProjectLeonida:old-pr/9966
ProjectLeonida:old-pr/9859
ProjectLeonida:old-pr/9843
ProjectLeonida:old-pr/9991
ProjectLeonida:old-pr/10058
ProjectLeonida:old-pr/9883
ProjectLeonida:old-pr/9838
ProjectLeonida:old-pr/9835
ProjectLeonida:old-pr/9959
ProjectLeonida:old-pr/9895
ProjectLeonida:old-pr/9837
ProjectLeonida:old-pr/9858
ProjectLeonida:old-pr/9865
ProjectLeonida:old-pr/9864
ProjectLeonida:old-pr/9840
ProjectLeonida:old-pr/9820
ProjectLeonida:old-pr/4669
ProjectLeonida:old-pr/9848
ProjectLeonida:old-pr/9850
ProjectLeonida:old-pr/9810
ProjectLeonida:old-pr/9799
ProjectLeonida:old-pr/9853
ProjectLeonida:old-pr/9875
ProjectLeonida:old-pr/9831
ProjectLeonida:old-pr/9796
ProjectLeonida:old-pr/9801
ProjectLeonida:old-pr/9813
ProjectLeonida:old-pr/9794
ProjectLeonida:old-pr/7417
ProjectLeonida:old-pr/9781
ProjectLeonida:old-pr/9806
ProjectLeonida:old-pr/9958
ProjectLeonida:old-pr/9809
ProjectLeonida:old-pr/9791
ProjectLeonida:old-pr/9792
ProjectLeonida:old-pr/10053
ProjectLeonida:old-pr/9784
ProjectLeonida:old-pr/9789
ProjectLeonida:old-pr/9849
ProjectLeonida:old-pr/9846
ProjectLeonida:old-pr/9773
ProjectLeonida:old-pr/9785
ProjectLeonida:old-pr/9803
ProjectLeonida:old-pr/9826
ProjectLeonida:old-pr/9839
ProjectLeonida:old-pr/9922
ProjectLeonida:old-pr/9948
ProjectLeonida:old-pr/7189
ProjectLeonida:old-pr/9957
ProjectLeonida:old-pr/9823
ProjectLeonida:old-pr/9807
ProjectLeonida:old-pr/9851
ProjectLeonida:old-pr/9774
ProjectLeonida:old-pr/9830
ProjectLeonida:old-pr/9836
ProjectLeonida:old-pr/9822
ProjectLeonida:old-pr/9783
ProjectLeonida:old-pr/9833
ProjectLeonida:old-pr/9890
ProjectLeonida:old-pr/9770
ProjectLeonida:old-pr/9769
ProjectLeonida:old-pr/9772
ProjectLeonida:old-pr/9787
ProjectLeonida:old-pr/9852
ProjectLeonida:old-pr/9834
ProjectLeonida:old-pr/9845
ProjectLeonida:old-pr/9871
ProjectLeonida:old-pr/9771
ProjectLeonida:old-pr/9776
ProjectLeonida:old-pr/10005
ProjectLeonida:old-pr/9949
ProjectLeonida:old-pr/9923
ProjectLeonida:old-pr/9805
ProjectLeonida:old-pr/9829
ProjectLeonida:old-pr/9790
ProjectLeonida:old-pr/9827
ProjectLeonida:old-pr/9929
ProjectLeonida:old-pr/9855
ProjectLeonida:old-pr/9934
ProjectLeonida:old-pr/9907
ProjectLeonida:old-pr/9910
ProjectLeonida:old-pr/9779
ProjectLeonida:old-pr/9780
ProjectLeonida:old-pr/9885
ProjectLeonida:old-pr/9882
ProjectLeonida:old-pr/9877
ProjectLeonida:old-pr/9998
ProjectLeonida:old-pr/4251
ProjectLeonida:old-pr/9987
ProjectLeonida:old-pr/9989
ProjectLeonida:old-pr/9950
ProjectLeonida:old-pr/9777
ProjectLeonida:old-pr/10044
ProjectLeonida:old-pr/9884
ProjectLeonida:old-pr/2906
ProjectLeonida:old-pr/5076
ProjectLeonida:old-pr/9937
ProjectLeonida:old-pr/9986
ProjectLeonida:old-pr/3014
ProjectLeonida:old-pr/9943
ProjectLeonida:old-pr/9939
ProjectLeonida:old-pr/4682
ProjectLeonida:old-pr/4765
No reviewers
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Reference
ProjectLeonida/mandy!1182
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1182"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-24T19:44:38Z.
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
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.git diff --checkand the game-data check passed.GPUs tested: n/a (synthetic Vulkan calls).
AI-assisted.
Checklist
main.Imported from ubiquitarianism/leonida. Originally posted by madhyn on 2026-11-24T20:08:07Z.
Tested
07c3e8edaon Arch Linux:ctest --test-dir runtime/build/linux -R "^vk_sparse_queue_order$" --output-on-failure: Passed (0.00 s)AI-assisted: yes
Imported from ubiquitarianism/leonida. Originally posted by Deedlyy on 2026-11-24T20:09:27Z.
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 ofvk_sparse_queue_orderand 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 withmain.Impact level: 6/10
Imported from ubiquitarianism/leonida. Originally posted by PierreEbele on 2026-11-25T09:25:05Z.
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.
42537e7b6,d3d12_buffer_tilesandd3d12_texture_tileshang until the ctest 300 s kill.UpdateTileMappingsis refused with "sparse residency unavailable" although the standalone sparse probe passes on this driver, then teardown deadlocks onWait(gate). Without the valve both hang indefinitely (seen for 15+ minutes).vk_sparse_queue_ordertest passes, and the rest of thed3d12_queue/d3d12_sparse/vk_sparseselection 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
Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T23:57:20Z.
#1182 | head
47420b299f(merged cleanly with mainba8b77b390— no conflicts on currentmain) |ctest --test-dir runtime/build -C RelWithDebInfo -R "^(vk_sparse_queue_order|d3d12_buffer_tiles|d3d12_texture_tiles|d3d12_sparse_queue_family_contract|vk_queue|vk_host_at_aliasing)$" --output-on-failure(LEONIDA_VK_VALIDATION=1) | red on main: buildingvk_sparse_queue_order_testagainstmain'sruntime/src/vulkan_backend.hfailsvk_sparse_queue_orderatline 142: submissions.empty()(vkQueueBindSparsesubmits immediately ahead of fence-held queue operations) | green on PR+main:6/6CTests (vk_sparse_queue_order,d3d12_buffer_tiles—12 full tiles matchedvs native D3D12 Tier 4,d3d12_texture_tiles— all4gated remap/COPY-to-DIRECT handoff cases matched native D3D12,d3d12_sparse_queue_family_contract,vk_queue,vk_host_at_aliasing) pass in6.44 son RTX 3090 with0Khronos validation errors;test_docs_encoding.py&test_docs_repo_paths.py(6/6 OK) andcheck_no_game_data.py(0violations) pass | Windows 11, MSVC 19.44, RTX 3090, Vulkan SDK 1.4.363.1 | AI-assisted: yesImported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-11-30T08:41:03Z.
Independent verification on this machine (Windows 11, MSVC 19.44.35226): the test this pull request registers cannot run -
ctestreports it as "Not Run" - while the executable it points at builds fine.1. It applies.
merge-treeclean; the commit cherry-picks ontomaine236b19c6without a conflict.2. The executable builds:
3. The test does not run:
4. The reason is visible in ctest's own manifest (
ctest --show-only=json-v1):vk_sparse_queue_orderhas an emptycommandwhile its neighbours have the resolved path.add_testresolvesCOMMAND <name>to a target's output only when that target is visible in the same directory scope at that point; an empty command means the resolution failed, so CTest has a test with nothing to run.What this costs: the test is listed and red in any full
ctestrun (Not Runcounts as a failure), and it never exercises anything. So the pull request adds a test that fails the suite without testing the code it adds.What I would check first: whether the
add_test(NAME vk_sparse_queue_order COMMAND vk_sparse_queue_order_test)sits in a different scope from itsadd_executable- theif(BUILD_TESTING)block it is in, or afunction()- or simply uses$<TARGET_FILE:vk_sparse_queue_order_test>instead of the bare target name, which always resolves.How it was found: a sweep of open pull requests that replay onto current
main, building what each test'scommand[0]says to build, and running it. This is the first case of the sweep where the binary is fine and the registration is not.Written with an AI assistant.
Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-30T10:02:33Z.
@fiestorra Thanks for the detailed report. I rebuilt
vk_sparse_queue_order_testwith the unchanged registration at47420b299f6e0cbbc0f22ceeeaae4887e8288d34merged locally withmain4014af7fe9a479caee2946c1814c11935b24bf60. Windows 10 22H2, MSVC 19.44.35230, CMake/CTest 3.31.8. This is a mock Vulkan test and uses no GPU.CMAKE_BUILD_TYPE=Release):ctest --show-only=json-v1 -R '^vk_sparse_queue_order$'resolves the built.exe;ctest -V -R '^vk_sparse_queue_order$'passes 1/1.--config Release: omitting-CproducesNot RunwithTest not available without configuration. Adding-C Releaseresolves the Release executable in the manifest and passes 1/1.The
add_executableandadd_testlines are also identical when the head is merged onto youre236b19c6baseline. WhichCMAKE_GENERATORvalue and CTest configuration did your original build directory use? If it was single-config Ninja, the generatedadd_testline for this entry would help compare the two setups.AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-11-30T11:14:02Z.
Correction: this pull request does not have the empty-command problem I reported earlier. On current
mainthe test resolves and passes.Measured just now, with a fresh configure and a fresh manifest:
What I reported at the time and now withdraw: that
vk_sparse_queue_orderwas registered with an emptycommandand came upNot Run. That is not what the tree does today, and I could not reproduce it onmaind367675c7in three attempts.Why I got it wrong, as best I can reconstruct: the reading came from a
ctest.jsonproduced in a batch that reused one build directory across a series of pull requests. A manifest generated for one tree, read against another, reports whichever tests the previous configure knew about - and a name it does not know looks exactly like "registered with no command". It is the same class of error as the stale binary, one level up: a stale manifest.What this does not change: #2344 does have the defect - I reproduced it there with a freshly built binary at 12:09:30 and a freshly configured manifest, and both proposed fixes resolve it. #1242 and #1419 I have not re-checked with the same rigour, and given this, I would treat my reports on those two as unconfirmed until someone re-runs them cleanly.
The rule I should have applied and did not: a manifest is a build artefact like any other - delete it or regenerate it in a fresh directory before reading it as evidence about a tree.
Written with an AI assistant.
Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-30T12:24:23Z.
@fiestorra Thanks for rerunning it from a fresh manifest. The CTest registration stayed unchanged. After #2566 changed the queue execution path, I merged main
d367675c705c758f731ae9eb603839a4ebb2283cin103b1f9e9cf36ce9a05aee9454533771de969d44and wired deferred tile updates and copies into the new held queue.Fresh Ninja Release build on Windows 10 22H2, MSVC 19.44.35230:
vk_sparse_queue_order,vk_queue, andsubmit_framepassed. Sparse ordering uses mock Vulkan submissions.submit_frameran on an RTX 5070 with NVIDIA 610.88.AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-11-30T12:59:11Z.
Independent two-fence queue-order check. CachyOS, Clang 23.1.5, native Release. I tested
103b1f9emerged onto497bdd039(tree2323eff6), with the same runtime sources as GitHub merge2efa4385.MEASURED, synthetic Vulkan callbacks. A consumer queues Wait A → tile update → Wait B → tile copy → completion signal. A separate producer signals A and B in both orders. I ran three trials per order and revision.
mainforwarded the three consumer operations to the Vulkan callbacks before the first producer signal in all six trials.MEASURED, checked-in tests.
vk_sparse_queue_order,vk_queueandsubmit_framepassed on each native run. The latter two exercised the RTX 4070 SUPER (620.73.04) and Radeon 610M (RADV 26.3.1) with Vulkan validation enabled. The sparse-order checks used mocked binds and submits.AI-assisted with OpenAI Codex. Results independently checked against the raw logs.
Imported from ubiquitarianism/leonida. Originally posted by ammonium231 on 2026-11-30T13:43:44Z.
RTX 3090 / 621.40, validation on,
103b1f9e9merged onto mainf9f3ec4c6: vk_sparse_queue_order_test OK; vk_queue_test and submit_frame_test OK as on main. No validation errors.Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-02T00:43:40Z.
Thank you for the careful work and thorough verification here. The legacy C++/Vulkan runtime/ directory is now frozen and deprecated as active development focuses on the d3d12/ and clean-room Rust vulkan/ tracks, so we are closing open legacy runtime/ PRs. We really appreciate the effort that went into this.
Pull request closed