d3d12: keep sparse tile mappings in queue order (D3D-SPARSE-TILE-WAIT-ORDER) #1182
Closed
leonida/mandy
lixonik wants to merge 0 commits from
d3d-sparse-tile-wait-order into main
pull from: d3d-sparse-tile-wait-order
merge into: leonida:main
leonida:main
leonida:github-pr/3295
leonida:beta
leonida:docs/changelog-3483-3500
leonida:github-pr/3294
leonida:github-pr/2975
leonida:github-pr/2815
leonida:feat/gate-driver-start
leonida:feat/skip-pipelines-release
leonida:perf/lazy-compare
leonida:perf/mwaitx-wait
leonida:test/prio-ceiling-main
leonida:fix/ab-cpu-stdout
leonida:fix/gate-old-crashes
leonida:diag/ab-cpu
leonida:test/main-0312
leonida:github-pr/3291
leonida:diag/indirect-clamp-census
leonida:feat/barrier-enhanced
leonida:perf/texture-frame-ceiling
leonida:perf/dstorage-threads
leonida:fix/console-queue-dma-tables
leonida:fix/port-descriptors-record-parts
leonida:fix/frame-waits-fence
leonida:fix/console-sampler-words
leonida:fix/graphics-userdata-spill
leonida:fix/xg-reserved-layout-rotation
leonida:fix/barrier-console-flags
leonida:fix/switches-wait-test-child
leonida:test/list-value-waits
leonida:test/lot-gxdk-0412
leonida:fix/bvh-compacted-size
leonida:docs/i18n-quickstarts
leonida:feat/native-pipeline-slots
leonida:fix/clippy-leonida-gpu
leonida:fix/list-value-producers
leonida:fix/descriptor-page-straddle
leonida:fix/xmem-low-window
leonida:fix/ffx-jitter-never-zero
leonida:fix/run-stdout-closed
leonida:github-pr/2892
leonida:github-pr/2896
leonida:feat/warm-save-every
leonida:github-pr/2980
leonida:github-pr/2994
leonida:github-pr/3005
leonida:github-pr/3010
leonida:github-pr/3136
leonida:github-pr/3303
leonida:github-pr/3220
leonida:github-pr/3143
leonida:github-pr/3330
leonida:github-pr/3226
leonida:github-pr/3187
leonida:carry/3395
leonida:github-pr/2946
leonida:github-pr/2947
leonida:github-pr/2945
leonida:github-pr/2983
leonida:github-pr/3001
leonida:github-pr/3372
leonida:github-pr/3128
leonida:github-pr/3296
leonida:github-pr/2588
leonida:github-pr/3119
leonida:github-pr/3378
leonida:fix/crash-diagnostics
leonida:feat/dlss-mip-bias
leonida:fix/retired-out-of-order
leonida:fix/dxr-postbuild-barrier
leonida:fix/amd-relay-default
leonida:fix/removed-report-wait
leonida:feat/heap-twin
leonida:feat/vram-margin
leonida:github-pr/2472
leonida:github-pr/3123
leonida:github-pr/3088
leonida:assets/annonce-v1
leonida:github-pr/2794
leonida:github-pr/3300
leonida:github-pr/3304
leonida:github-pr/3308
leonida:github-pr/3367
leonida:github-pr/3369
leonida:fix/launcher-dlss-diagnostics
leonida:github-pr/3269
leonida:github-pr/2957
leonida:github-pr/3205
leonida:fix/crash-zero-guard
leonida:github-pr/3185
leonida:github-pr/3099
leonida:github-pr/3104
leonida:github-pr/3348
leonida:github-pr/3379
leonida:github-pr/3377
leonida:perf/darner-title-priority-ceiling
leonida:github-pr/3376
leonida:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
leonida:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
leonida:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
leonida:github-pr/3373
leonida:github-pr/3368
leonida:github-pr/3198
leonida:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
leonida:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
leonida:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
leonida:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
leonida:github-pr/3346
leonida:github-pr/3375
leonida:github-pr/2958
leonida:github-pr/3151
leonida:github-pr/3307
leonida:github-pr/3278
leonida:github-pr/3374
leonida:fix/runtime-test-conservative-fixtures
leonida:github-pr/3366
leonida:ci/shard-semantic-linux
leonida:github-pr/3354
leonida:docs/fg-limit-fps-switch
leonida:github-pr/3365
leonida:fix/read-file-hard-link
leonida:github-pr/3364
leonida:fix/book-slot-heap-never-read
leonida:github-pr/3361
leonida:github-pr/3263
leonida:github-pr/3360
leonida:github-pr/3353
leonida:github-pr/3331
leonida:fix/alias-later-queued-submissions
leonida:github-pr/3352
leonida:github-pr/3228
leonida:github-pr/3349
leonida:claude/gallant-sagan-aamatr
leonida:github-pr/3200
leonida:github-pr/3132
leonida:github-pr/3323
leonida:github-pr/3332
leonida:github-pr/3340
leonida:github-pr/3311
leonida:github-pr/3334
leonida:github-pr/3297
leonida:github-pr/3256
leonida:github-pr/2567
leonida:github-pr/2851
leonida:d3d12/agility-sdk-621
leonida:github-pr/3164
leonida:github-pr/3114
leonida:github-pr/3050
leonida:github-pr/3113
leonida:github-pr/3326
leonida:github-pr/3144
leonida:github-pr/2642
leonida:github-pr/3072
leonida:github-pr/2789
leonida:github-pr/2643
leonida:github-pr/3009
leonida:github-pr/3035
leonida:github-pr/3031
leonida:github-pr/2686
leonida:github-pr/2834
leonida:github-pr/3321
leonida:github-pr/3325
leonida:github-pr/3290
leonida:github-pr/3324
leonida:github-pr/3130
leonida:claude/fervent-curie-m19lnr
leonida:github-pr/3309
leonida:github-pr/3305
leonida:github-pr/3306
leonida:github-pr/3302
leonida:github-pr/3301
leonida:github-pr/3345
leonida:github-pr/3211
leonida:github-pr/3027
leonida:github-pr/3286
leonida:github-pr/3235
leonida:github-pr/3265
leonida:github-pr/3275
leonida:codex/skip-no-hit-ray-passes
leonida:github-pr/2823
leonida:github-pr/2911
leonida:github-pr/3262
leonida:github-pr/3125
leonida:github-pr/3206
leonida:github-pr/3250
leonida:github-pr/3238
leonida:github-pr/3188
leonida:github-pr/2952
leonida:github-pr/3217
leonida:github-pr/3168
leonida:t3/preserve-fsr-sdk-restart-path
leonida:t3/propagate-host-failure-hresult
leonida:github-pr/3209
leonida:t3/launcher-custom-parameters
leonida:github-pr/3207
leonida:github-pr/3183
leonida:github-pr/3160
leonida:github-pr/3201
leonida:ci/less-to-run
leonida:github-pr/2930
leonida:github-pr/2797
leonida:github-pr/2999
leonida:perf/native-compute-shader-forms
leonida:github-pr/3191
leonida:github-pr/3011
leonida:github-pr/3019
leonida:github-pr/2996
leonida:gh-readonly-queue/main/pr-2789-45dc41f95c1cd0dcc29c2c50582e0e9af8a77259
leonida:claude/blissful-franklin-ukp7ag
leonida:github-pr/3141
leonida:github-pr/3156
leonida:github-pr/3150
leonida:github-pr/3153
leonida:github-pr/3163
leonida:github-pr/3142
leonida:github-pr/3139
leonida:github-pr/2841
leonida:github-pr/3069
leonida:github-pr/3098
leonida:github-pr/3107
leonida:github-pr/3071
leonida:github-pr/2774
leonida:github-pr/2889
leonida:github-pr/3075
leonida:github-pr/2661
leonida:github-pr/3064
leonida:github-pr/3054
leonida:github-pr/3049
leonida:github-pr/2855
leonida:github-pr/2943
leonida:github-pr/3016
leonida:github-pr/2887
leonida:github-pr/3006
leonida:github-pr/3003
leonida:github-pr/2993
leonida:notes/card-time-and-plant-flicker
leonida:github-pr/2989
leonida:feat/vulkan-rs
leonida:github-pr/2985
leonida:github-pr/2951
leonida:github-pr/2982
leonida:github-pr/752
leonida:github-pr/792
leonida:github-pr/2877
leonida:github-pr/2654
leonida:github-pr/2893
leonida:github-pr/2948
leonida:github-pr/2944
leonida:github-pr/2919
leonida:github-pr/2915
leonida:archive/ci/less-to-run/20261202T1121Z
leonida:github-pr/2800
leonida:github-pr/2822
leonida:github-pr/2833
leonida:github-pr/2840
leonida:github-pr/2831
leonida:github-pr/2832
leonida:github-pr/2801
leonida:github-pr/2890
leonida:github-pr/2891
leonida:github-pr/2664
leonida:github-pr/2807
leonida:rt-call-trace
leonida:github-pr/2755
leonida:perf/ahead-split
leonida:github-pr/2587
leonida:github-pr/2698
leonida:github-pr/2609
leonida:github-pr/3219
leonida:docs/readme-runtime-proposal
leonida:github-pr/2017
leonida:github-pr/1741
leonida:github-pr/1667
leonida:codex/coord-claim-check-20261124-7e48
No reviewers
Assignees
Clear assignees
No assignees
Labels
Clear labels
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
enhancement
New feature or request
missing claim
Needs a claim in #14
needs rebase
Conflicts with the base branch: rebase it on main
needs-triage
Needs maintainer evaluation before the next triage state
question
Further information is requested
ready-for-agent
Fully specified and ready for an AFK agent
submodules
Pull requests that update submodules code
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
Projects
Clear projects
No items
No project
Milestone
Clear milestone
No items
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Reference
leonida/mandy!1182
Loading…
Reference in a new issue
No description provided.
Delete branch "d3d-sparse-tile-wait-order"
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?
Pull request closed
This pull request cannot be reopened because the branch was deleted.
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.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
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
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.
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
#1182 | head 47420b299f6e0cbbc0f22ceeeaae4887e8288d34 (merged cleanly with main ba8b77b390b278cfb05510a4fc2922fb0fb9a11c — no conflicts on current
main) |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: yesIndependent 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.
@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.
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.
@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.
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.
RTX 3090 / 621.40, validation on, 103b1f9e9 merged onto main f9f3ec4c6: vk_sparse_queue_order_test OK; vk_queue_test and submit_frame_test OK as on main. No validation errors.
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.