d3d12/pipeline: offload sample-mask twin builds to pipeline workers with bounded wait (D3D12-MASKED-TWIN-WORKER-WAIT) #3200
Code
Clone this repository
Checkout
From your project repository, check out a new branch and test the changes.
git fetch -u origin "github-pr/3200:github-pr/3200" git switch "github-pr/3200"
Open
leonida/mandy
zmasi wants to merge 7 commits from
github-pr/3200 into main
pull from: github-pr/3200
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/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
3 participants
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!3200
Loading…
Reference in a new issue
No description provided.
Delete branch "github-pr/3200"
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?
This branch is out-of-date with the base branch
Reviewers 0 approvals
Details
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Claimed in the coordination issue as:
D3D12-MASKED-TWIN-WORKER-WAIT(https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7353810942)Depends on: #3132 (stacked on
#3132head8eedef9b4merged withorigin/mainat5d2dddbfe; this PR's own commitd1a91afd1touchesd3d12/crates/leonida-gpu/src/pipeline/make.rsonly)Addresses #3105 (does not close it: targets the open-world
> 0.6–2.3 slist-thread freezes on cold sample-mask twin PSO compiles confirmed by@TripyFoxin #3105; in-game validation on the reporter's RTX 3090 save remains to be run).What and why
Routes
pipeline::make::masked_forthroughreadyinstead of invokingPending::makesynchronously onleonida-list-*recording threads:#3105:65f372c08("gpu: honor coverage on the first masked draw") changedmasked_forfrommade_or_start(0 mswait) to a synchronousp.make()on the calling command-list thread so fast/cached masked twins would be ready on their first LOD-fade draw.p.make()directly onleonida-list-Nbypassedleonida-pipelines-*workers, ignoredLEONIDA_PIPELINE_WAIT_MSandLEONIDA_PIPELINE_WAIT_ONCE, left all pipeline worker threads idle when multiple list threads hit cold masked twins in the same frame, blocked second list threads hitting the same twin insideOnceLock'sWaitOnAddress, skippedWAITING/C::PipelineWaitUs(waiting for pipelines) accounting, and skipped worker-sidelibrary::save(false).#3105,@TripyFoxconfirmed that 10 of 14 open-world log silences>= 600 msand all 4 silences> 1 s(1.0–2.3 s) ended within30 msonhost mesh pipeline shaders=[..., pixel ... masked], andLEONIDA_SAMPLE_MASK=0reduced>= 1 sfreezes from5to1(1,436 ms -> 716 mslongest silence).d3d12/crates/leonida-gpu/src/pipeline/make.rs):masked_forresolves any render-target format variant (variant) as before and delegates toready(p)(start(p, REQUESTED)+wait(p, crate::frame::current())).leonida-pipelines-*withinLEONIDA_PIPELINE_WAIT_MS(withAWAITEDpromotion and#3132's live-waiterTHREAD_PRIORITY_NORMALdonation), preserving first-draw sample-mask coverage without LOD-fade flicker.Nonewhen the budget expires, leavingp.madeunset (Gone::Making, never poisoned asGone::Refused) and demoting the worker back to background priority whiledraw::State::graphics_pipeline(draw.rs:2537) falls back cleanly to the already-built unmasked pipeline until the worker publishesSome(HostPipeline).Tested
d1a91afd1onto--base 5d2dddbfe,#3132head8eedef9b4merged withorigin/main):python -I scripts/red_green.py HEAD --base 5d2dddbfe --no-fetch --no-python --mutate(pipeline::make::runner):verdict: red then green(2/2new testsred -> green,36/36existingpipeline::make::tests pass on both, code hunkmake.rs:393mutation caught).x86_64-pc-windows-msvc):cargo test --locked --target x86_64-pc-windows-msvc -p leonida-gpu --lib pipeline::—67 passed, 0 failed, 8 ignored.cargo test --locked --target x86_64-pc-windows-msvc -p leonida-gpu --features diagnostics --lib pipeline::—68 passed, 0 failed, 8 ignored.cargo clippy --locked --target x86_64-pc-windows-msvc -p leonida-gpu [--features diagnostics] --all-targets --no-deps— exit0(0warnings inpipeline/make.rs).python -I tools/d3d12_switches.py --check d3d12/docs/switches.md,python -I tests/test_d3d12_switches.py,python -I scripts/check_no_game_data.py, andpython -I tests/test_text_write_line_endings.py— all exit0.git apply --cached --3way,rc=0) against open PRs#2957(pipeline.rs,pipeline/known.rs) and#3185(pipeline/library.rs).GPUs tested: NVIDIA GeForce RTX 3090 24 GB, driver 610.88, Windows 11 Pro
10.0.26200(synthetic D3D12 compute PSO + pipeline worker scheduling and priority-donation tests; no retail title run).AI-assisted: yes — authored with Gemini Carbon and independently audited in read-only mode by Gemini 4 Neon XHigh (
opus-systems-critic).Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed (n/a: no translator rule added).Ran natively on Windows 11, head
d1a91afd1merged into currentmain(f1a559851, clean merge).The branch still carries #3132 (completion.rs, completion_tests.rs, library.rs, switches.md, most of make.rs), so the merge needs #3132 first. This PR's own change is the one
masked_forhunk (nowready(p)) plus its tests. To keep the two apart I also ran "merge with that hunk reverted" (= main + #3132 + the new tests).Suites (
leonida-gpu --lib,--test-threads=4)--features diagnosticsThe +8 are 2 from this PR and 6 from #3132.
Red check (masked_for hunk reverted, tests kept): both new tests fail,
masked_twin_dispatches_to_pipeline_worker_with_priority_donation(built on the caller thread) andmasked_twin_exceeding_wait_budget_returns_promptly_and_resolves_once_built(caller stalled 813 ms against a 40 ms budget). The otherpipeline::tests pass: 65 passed, 2 failed, 8 ignored.Clippy
--all-targets --no-deps: 0 warnings on the merge, 12 with--features diagnosticson both main and the merge, none inpipeline/. So no new warnings.Switch (read). There's no new switch and nothing that brings back the old inline build. The switches.md line is #3132's rewording of
LEONIDA_PIPELINE_LOWEST. The bound on a twin is the normal pipeline wait budget (LEONIDA_PIPELINE_WAIT_MS, per-pipeline withWAIT_ONCE, shared per frame). When it runs out,masked_forreturnsNoneandgraphics_pipelinedraws with the unmasked pipeline. It is not dropped, not built inline and not blocked. The twin stays queued and is picked up on a later draw. Twin builds have no queue limit of their own.Concurrency, measured. Throwaway tests, not part of the PR. They use empty-shader
Pendings, which are refused before any D3D12 call, so they test scheduling and not the driver. Card vs WARP doesn't change anything for them. 50 iterations on the card, 50 on WARP and 5 with the debug layer, all on the merge, all passed. The PR's own three masked tests also passed 50/50 on the card and 50/50 on WARP.Refused, no hangs, one variant per format set,waiting()back to 0, longest pair of calls 270 ms at 500 ms budget, under 10 ms at 0/1 msRefused, caller unaffected, next twin fineLEONIDA_PIPELINE_PANIC_CATCH=0, 1 workerMakingfor good, later twins never made, caller doesn't panic (before this PR the recording thread panicked). That is the same as any other pipeline under that switchThe trade-off, measured. One case changes in a way you can see. If a frame has already used up its wait budget on another pipeline (a cold plain pipeline, say), a twin asked for later in that same frame gets no wait at all, even when it would build in microseconds and workers are idle:
masked_forreturnsSo in frames that are already waiting on cold pipelines, the first masked draws go out unmasked, which is the LOD-fade case 65f372c08 fixed. It lasts one frame per twin when the twin is fast. That seems a fair price for the 0.6–2.3 s stalls in #3105, but it would be good to say so in the PR. Along the same lines, the PR rewrote
first_masked_draw_observes_the_finished_build. With the old body (twin already markedMAKING), the merge now waits the full 500 ms and returns with the twin unmade, where main returned the finished refusal at once. So the old invariant is gone, not just moved to a new test.Races (read). Build twice: no, the worker, the no-worker fallback in
startandnow()all go through the sameOnceLock(I couldn't count builds in the stress test because the refusal is logged once per process). A draw seeing the twin missing is the intended fallback. Stale twin after a library reset: n/a, I found no path that clearsmadeormasked, and the twin belongs to the title pipeline. Small thing: when a twin uses up its own budget,wait_withlogs "its draws are dropped until it is", but a masked draw isn't dropped, it uses the unmasked pipeline.Other open PRs (
git merge-treeagainst the merge, all clean): #2588, #2654, #2774, #2789, #2919, #2957, #3071, #3150, #3185.Not checked: in-game run or any retail title, a real masked draw on the GPU (the only sample-mask test in
draw.rschecks the mask word and builds no pipeline), timing under a real cold driver compile, release build, Wine.GPUs tested: one NVIDIA desktop card + WARP
AI-assisted: yes (Claude Code).
Correction to my comment above. In
leonida-gpu,LEONIDA_D3D12_WARPandLEONIDA_D3D12_DEBUGonly take effect in a build with--features diagnostics(host.rs,cfg!(feature = "diagnostics") && switch::on(..)). My WARP and debug-layer runs were built without it, so they were repeats on the card.What that changes:
The rest is unaffected: the merge, the red check, clippy, the merge-tree results and the same-frame budget finding were all measured on the card.
AI-assisted: yes (Claude Code).
RUN (in game) -- unit tests + 300 s render-path verification for PR #3200:
d1a91afd1mainSHA:f1a559851(git merge --no-ff, clean merge; includes stacked #3132 commits)python -I scripts/check_no_game_data.pyPASSpython -I tools/d3d12_switches.py --check d3d12/docs/switches.mdPASScargo test -p leonida-gpu --features diagnostics --lib --locked pipeline:: -- --skip depth_bounds_pipeline_loads_and_filters_draws-- 67 passed, 0 failed, 8 ignored (pre-existing Win10 test tracked in #2855 skipped)diagprofile (diagnostics,dlss,mimalloc), Series S profile, DLSS on, Frame Gen off, same restored save snapshotd1a91afd1onf1a559851)mainalone (f1a559851)Loaded cleanly into the world, stayed up past 300 s in-world with 0 device lost / 0 crashes / 0
ERRORlines, and closed cleanly. Steady-state FPS matchesmainwithin single-run variance.Verdict: PASS.
AI-assisted: yes (Antigravity).
Third-party Windows verification of #3200 (
D3D12-MASKED-TWIN-WORKER-WAIT) on headd1a91afd1(--features diagnostics, HW + WARP + D3D12 Debug Layer)Adds the
--features diagnosticsWARP + D3D12 Debug Layer run noted as missing above.d1a91afd1merged cleanly (git merge --no-ff) ontoorigin/mainb41763227(still carries stacked #3132 commits, so #3132 remains a prerequisite).621.24(32.0.16.2124), AMD Ryzen 7 H 260 w/ Radeon 780M, 32 GB RAM, Windows 1110.0.26300.9974,rustc 1.98.1.--features diagnostics(no retail title run).Results (MEASURED)
python -I scripts/check_no_game_data.py(all 5 touched files)0python -I tools/d3d12_switches.py --check d3d12/docs/switches.md0LEONIDA_ADAPTER=5060+LEONIDA_D3D12_DEBUG=1cargo test -p leonida-gpu --features diagnostics --locked --lib -- pipeline:: --skip depth_bounds_pipeline_loads_and_filters_draws67 passed, 0 failed, 8 ignored(includingfirst_masked_draw_observes_the_finished_build,masked_twin_dispatches_to_pipeline_worker_with_priority_donation, andmasked_twin_exceeding_wait_budget_returns_promptly_and_resolves_once_built)LEONIDA_D3D12_WARP=1+LEONIDA_D3D12_DEBUG=1(samepipeline::command,--features diagnostics)67 passed, 0 failed, 8 ignoredAI-assisted: Gemini 4 Neon (High) via Antigravity (test execution, diff review, and write-up).
RUN (in-game RTX 3090 300 s stress gate, 14-PR combined batch) — PASS covering exact head
d1a91afd1f011eb8b14f98b1fadfe72a5dd20904.git merge --no-ffontomainb41763227(diagnostics,dlss,mimalloc,exe_sha16 = c47eeb717f761d9d; changed-file clean-room scan exit0; workspace test targets compiled).14PRs):#3200d1a91afd1,#319880a627bb1,#319193b47ac9d,#3189c182fc392,#3176ae0075d9a,#3168337388052,#31641065952da,#3146ebc0253ff,#312464600ef0c,#3069311d33a40,#30318df1bfce7,#3029e49404808,#3054ff53fd8b9,#3010d645712a3.610.88, Series X profile,2560x1440,-NoFrameGen,scripts/game-gate.ps1(301.3 sin world) with downtown street-level teleport + 8-leg dynamic sprint/turn/strafe stress mod (GATE CONTROL moved=2.51 m,max_from_ctrl=5,053.9 m).c47eeb717f761d9d)mainb41763227baseline (cf499737bf684f6a)clean,0reasons,0warnings)clean,0reasons,0warnings)301.3 s(4,504frames)305.6 s0/0/00/0/020.10 FPS/69.76 ms19.13 FPS/74.01 ms8,048/5.222 s7,983/2.358 s35,619 MB/15,251 MB37,803 MB/16,220 MBVerdict: PASS for the 300 s in-game stability gate on
d1a91afd1. (Single combined-batch stability check, not an isolated single-PR FPS gain measurement; if the head changes, this run no longer covers it.)(AI-assisted verification:
gemini-4-neon+gpt-6.2-astra.)VERIFY-3200 — Windows nativo: los tests pasan, el control muerde, y el PR trae #3132 dentro
(this PR)45dc41f95(behindmainb41763227)main—merge-treeclean,git merge --no-ffclean (switches.mdauto-merged)Ran
The one failure is this machine's, unchanged all day:
descriptor::host::tests::views_are_made_beside_the_heap_and_copied_in(the iGPU artefact ofD3D12CreateDevice(None, ..)that #2995 addresses).Negative control (synthetic — the tests ship with the change): I made
Worker::boosta no-op under a test variable, rebuilt and ran →FAILED: priority_tracks_live_waiters_during_an_early_build,assertion left == right failed. The priority tests bite.The thing a merger should know: this branch carries #3132
git log 45dc41f95..refs/pull/3200is:#3132("per-pipeline waiter wakeups and live-waiter priority") is still OPEN, and its two commits are inside this branch. Merging #3200 as it stands lands #3132's work as well — so either merge #3132 first (and this becomes a clean diff against it), or a maintainer should knowingly approve both in one go. The body does say "Depends on: #3132", but the merge button does not.Correspondingly, my run above exercised both PRs together — that is the state the branch is in, and it is the state a merge would produce.
What I read and what I could not test
a_worker_with_a_waiter_restores_its_priority_even_on_unwind) — that last one is the test I would have written: a panicking build must not leave worker threads at normal priority for the rest of the run.> 0.6–2.3 slist-thread silences): needs a game run with a cold sample-mask twin; no run here, and the thresholds are timing-dependent.Written with an AI assistant.
Game run on an RTX 5090 with hardware RT: a device loss about 6 minutes in, with masked twins loading from the workers just before. The same build without this PR ran clean right after.
Setup: RTX 5090 32 GB, driver 621.40, i9-14900KS, 64 GB DDR5, Windows 11 (26300). Base: upstream main
0d7a451abplus #3113, #3182 and #3204, plus two local hardware-RT CPU changes (index-buffer arena, BLAS bufferpool), diag build. Candidate: the same plus this PR at
d1a91afd1. Series X profile, 3840x2160 output, renderscale 0.6667,
-HardwareRT -SmoothMotion -PrecompileAll -Log,LEONIDA_PIPELINE_WAIT_MS=0, fullscreen.Tests:
cargo test -p leonida-gpu --lib pipelinegives 67 passed, 0 failed and 8 ignored.Run with this PR: I loaded the save at the player's house, then drove.
relay: fence 18446744073709551615 did not reach 290299; device removed ... (0x887A0006)(DXGI_ERROR_DEVICE_HUNG),and
device-removed data; none(DRED was not on).library on separate threads. For example:
were gone while it ran.
Same build without this PR, launched right after: 4+ minutes of driving, no device loss, 0 frames over 1 s,
20.8 fps median.
Context: I ran this hardware-RT setup about eight times today on this card and never lost the device until
this run. One run is not proof, and DRED was off. A repro with
LEONIDA_D3D12_DRED=1would name the command.The timing points at the worker-made masked twins being used while still in flight, or a twin and its base
pipeline disagreeing in state.
The cold masked-twin stalls themselves are real here: an earlier run without this PR had frames of 1015 ms and
1946 ms, each right after masked twins were made synchronously in
masked_for(pipeline/make.rs), withLEONIDA_PIPELINE_WAIT_MS=0not applying to them. So the PR's aim is right; it is the stability that needs a look.AI-assisted: the builds, the runs, the log reading and the write-up were done with Claude Opus 5.5 (Claude Code),
with a log analysis by GPT-6.2 Sol (Codex); the numbers are the runtime's own log lines, and the glass observation
is the player's.
One more trace of the case this PR targets, from a run where the noted masked twins had already been made ahead by the precompile (the setup is in my comment on #2957). It shows that precompiling noted twins is not enough on its own: a pipeline drawn for the first time still builds its twin on the list thread.
Rig: Ryzen 7 5700G, 32 GB, RTX 5060 8 GB, driver 621.40, Windows 11 Pro 26300,
mainat45dc41f95plus a local change that precompiles the noted twins (not this PR), diag build, Series X,LEONIDA_PIPELINE_WAIT_MS=0.The only frame over 1 s in that 9.5-minute run (UTC times from the log):
first bindof a pipeline never drawn before (mesh0d9099a35c000feb, pixel818a9a0ec6a53abb)shader translated stage="pixel" hash=818a9a0ec6a53abb masked=truehost mesh pipeline shaders=[mesh 0d9099a35c000feb, pixel 818a9a0ec6a53abb masked]9924c82dbd9d9c7e, pixel1b76b94a7050f184,masked=true)The frame-time line for that window:
40 frames: median 61.1 ms, ... longest 2127.7; 3 over 100 ms, 2 over 1 s; host pipelines 0 queued or being made, 0.6 made a second. So the cold twin build took about 2.0 s on the list thread, and the "queued or being made" count stays 0 becausemasked_fordoes not go through the queue, which fits the accounting gap described above.Neither twin had been noted by the earlier run (the scripted route varies a little), so no precompile could have made them. With this PR the draw would wait at most the frame's budget and the twin would finish on a worker. With a precompile of noted twins alone it cannot be avoided.
No device removal in any of my runs today (
mainand this local build, about two hours in the world in all).AI-assisted: summary prepared with help from Claude Code (Claude Opus 5.5). Numbers and lines taken from my own run's log; no logs or game data attached.
Thanks @x2Tweek for the detailed RTX 5090 +
-HardwareRTreport! Cross-referencing your setup (LEONIDA_PIPELINE_WAIT_MS=0 -HardwareRT -SmoothMotion -PrecompileAllon driver621.40) againstpipeline.rs,make.rs,library.rs,warm.rs:167-170, and #3068 / #2821 explains both observations:1. Why
LEONIDA_PIPELINE_WAIT_MS=0showed stippled glass doors (while defaultWAIT_MSstays clean)Pipeline::masked(pipeline.rs:816-834) capturesPixelMask { position_row }on the list thread beforemasked_forruns, andPending::make_withcompletesCreateRootSignature+LoadPipeline/CreatePipelineStatebeforeOnceLockpublication (draw.rs:3178-3204rebinds bothmasked.rootandmasked.pso).mainignoredLEONIDA_PIPELINE_WAIT_MS=0while#3200honors it:host-pipelines.binand listed their"masked"keys inearly-pipelines.txt,hand_out(pipeline.rs:1052-1073) only callsmake::earlyon the unmaskedPipeline.hostatCreatePipelineState—Pipeline.maskedstays an emptyOnceLockuntil the first in-world masked draw, so zero masked twins are loaded during the loading screen.LEONIDA_PIPELINE_WAIT_MS=0,wait_withreturns immediately (if budget.is_zero() { return; }), which skips bothAWAITEDqueue promotion and#3132's live-waiterTHREAD_PRIORITY_NORMALdonation (waiters == 0). Allleonida-pipelines-*workers therefore stay pinned atTHREAD_PRIORITY_LOWESTbehind un-skipped-HardwareRTRayQueryjobs inQueue::requestedwhile uncapped recording (#3204 +WAIT_MS=0) and DXR BLAS/TLAS builds saturate the CPU.2x2sample-mask pair (0b0101/0b1010) has finished loading (7 ms) and discards half its quad pixels, any paired draw still queued falls back to unmasked (0xf), producing2x2stippling across those frames (and inside any stationary reflection/probe captured during opening frames).2. Why
0x887A0006(DXGI_ERROR_DEVICE_HUNG) hit right after the workerLoadPipelineburstpipeline library: loaded [mesh ..., pixel ... masked] in 7.0..236.5 msacross separate worker threads (25768,33456,35780) — those wereID3D12PipelineLibrary1::LoadPipelinecache hits, ending1,844.1 msbefore removal (~156 msbefore Windows's2,000 msTdrDelaytimer expired!).d3d12/apps/leonida/src/warm.rs:167-170specifically notes driver621.40removing the device "during a burst of their first loads in a new place, twice" (same family as #3068 and #2821'sLEONIDA_D3D12_BACKGROUND=0finding).early()startup prewarm, they stayed cold until 6 minutes into driving; onmain,masked_forstalledleonida-list-*for1–2 s(pausingExecuteCommandListsso the GPU went idle duringLoadPipeline), whereas with#3200+LEONIDA_PIPELINE_WAIT_MS=0, list threads waited0 msand kept submitting heavy DXR + mesh work on the GPU while fanning out ~10 concurrentLoadPipelinecalls across worker threads.Two quick isolation checks (no rebuild needed)
To keep
d1a91afd1intact while #3132 / #3200 hold @EdenBendheim's 300 s RTX 3090 gate PASS, we will prepare a follow-up PR to pre-loadearly-pipelines.txtmasked twins during loading (early()) so cached twins don't wait until mid-drive or Frame 1. If you get a chance on that same RTX 5090-HardwareRTsetup, two quick env checks ond1a91afd1would confirm both halves directly:LEONIDA_PIPELINE_WAIT_MS=50instead of0): lets7–50 mshost-pipelines.binhits finish withAWAITED+THREAD_PRIORITY_NORMALdonation before Frame 1 draws (eliminating the glass stipple while still capping multi-second cold compiles at50 ms), and did the glass stipple with=0clear after a few seconds or stay baked into a probe?LEONIDA_D3D12_DRED=light+LEONIDA_LIBRARY_LOCK=1(orLEONIDA_D3D12_BACKGROUND=0): serializes workerLoadPipelinebursts on621.40(and records the exact faulting GPU op if it still hangs).AI-assisted: Gemini 4 Carbon (High).
Merged updated base
#3132(3e36b182d0, incorporatingorigin/main128579e9ef/#3333) into7681ede4e5(needs rebase);#3200's delta over#3132ind3d12/crates/leonida-gpu/src/pipeline/make.rs(+383/-16) is 100% identical tod1a91afd1f(74/74pipeline::tests pass).AI-assisted: Gemini 4 Neon (XHigh) and Gemini 4 Carbon (High).
In-game gate run on an RTX 4060 8 GB (driver 610.88, Windows 11), in a batch of #3132, #3200 and #3226 merged into main
d227aa73e; this PR tested at its current head7681ede4e. Series S 1080, DLSS FG 2x,play-nvidia.ps1 -SeriesS -Resolution 1080 -FrameGen 2 -PrecompileUsed, scripted walk, 330 s.AI-assisted (Claude Opus 5.5), run and read by MoonEyes' agent.
Read-only review against the #3105 audit (no game run, no build). The refactor is right, but as written this PR bounds the freeze rather than removing it.
What is right:
masked_fornow goes throughready(start+wait) instead ofp.make()on the list thread, so the build runs onleonida-pipelines-*, honoursWAIT_ONCE/the frame budget, is counted inC::PipelineWaitUs, and times out into the existing unmasked fallback (draw.rs). The worker/priority/accounting symptoms are fixed, and the two new make tests are genuine red onmain(caller builds; 800 ms block).Why it does not remove the 300–800 ms stall:
readyuses the generalLEONIDA_PIPELINE_WAIT_MS(1000 in the reporter's runs; 10000 by launcher default), so a cold 782 ms masked twin is still waited for in full on the list thread. The code path check:make.rs:472-480->ready->start+wait(p, frame);waituseswait_budget()(env, default 500) or the screen budget, not a masked-specific value;wait_withwaitsleft = budget - billed, so with an empty frameleftis ~1000 ms;A 2.3 s compile is capped at ~1 s (better), but a 0.6–2.3 s compile under the launcher's 10 s budget is unchanged. The test sets
PIPELINE_WAIT_MS=40and only asserts <500 ms, so it does not cover the reporter's setting: with 1000 ms and an 800 ms build this branch would still block ~800 ms.Minimal addition that removes the 300–800 ms without changing ordinary pipelines: a masked-only budget, e.g.
LEONIDA_MASKED_WAIT_MSdefault 50, passed through the samewait_inmachinery (moveWAITSto module scope), withmasked_forcallingstart+wait_masked;0gives the no-wait variant. A 50 ms cap keeps cached/fast twins inside the first draw and falls back for a cold 300–800 ms one, while the worker keeps building and the next draw uses it (noGone::Refusedpoisoning). The ordinaryreadypath stays untouched.Smaller notes:
wait_withlogs 'its draws are dropped until it is' — masked draws are not dropped, they use the unmasked pipeline; andpipeline.rs:888-894still says the first use completes the build.If you would rather keep this PR focused, say so and I will send the dedicated-budget change as a stacked follow-up (
Depends on: #3200). Otherwise this comment is the exact edit I would make.For the masked-pipeline follow-up, I would add a generated draw/readback check around the timeout. Hold the masked twin's build behind a test gate. Verify coverage on the first draw with the fallback, release and observe the worker, then verify masked coverage on the next draw. Check that the release publishes one usable PSO and that a request crossing the timeout keeps its recorded result.
A second generated case would begin with a cold masked twin requested during command-list recording. Record whether the request starts a worker or performs the build on that list thread. That would give the worker handoff and the masked wait budget separate acceptance criteria while the first case checks visible coverage. Worker handoff #3200 · Masked wait #3464 · First-use instrumentation #3490