D3D12-AHEAD-OF-FRAME-CUT: skip the texture pass the previous list already did #3029
Closed
github-bot
wants to merge 1 commit from
github-bot/gh-3029 into main
AGit
pull from: github-bot/gh-3029
merge into: github:main
github:main
github:perf/darner-title-priority-ceiling
github:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
github:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
github:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
github:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
github:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
github:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
github:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
github:fix/runtime-test-conservative-fixtures
github:ci/shard-semantic-linux
github:docs/fg-limit-fps-switch
github:fix/runtime-test-fixture-paths
github:fix/runtime-test-fixture-readers
github:fix/read-file-hard-link
github:fix/book-slot-heap-never-read
github:fix/depth-resolve-spv-path
github:fix/indirect-unused-batched
github:gh-pr/3358/base
github:fix/xmem-refusal-diagnostics
github:gh-pr/3357/base
github:ci/shorten-ci-time
github:fix/alias-later-queued-submissions
github:claude/gallant-sagan-aamatr
github:gh-pr/3342/base
github:gh-pr/3341/base
github:d3d12/agility-sdk-621
github:gh-pr/3293/base
github:gh-pr/3319/base
github:gh-pr/3318/base
github:gh-pr/3315/base
github:gh-pr/3313/base
github:gh-pr/3314/base
github:claude/fervent-curie-m19lnr
github:gh-pr/3216/base
github:gh-pr/3272/base
github:gh-pr/3276/base
github:gh-pr/3279/base
github:gh-pr/3257/base
github:gh-pr/3258/base
github:gh-pr/3271/base
github:codex/skip-no-hit-ray-passes
github:gh-pr/3230/base
github:gh-pr/3266/base
github:gh-pr/3247/base
github:gh-pr/3246/base
github:gh-pr/3244/base
github:claude/sharp-sagan-1jqnp3
github:t3/preserve-fsr-sdk-restart-path
github:t3/propagate-host-failure-hresult
github:t3/launcher-custom-parameters
github:t3/series-x-2160-startup
github:codex/d3d12-uncapped-simulation
github:ci/less-to-run
github:perf/native-compute-shader-forms
github:claude/blissful-franklin-ukp7ag
github:codex/full-precompile-default
github:gh-pr/3166/base
github:gh-pr/3148/base
github:gh-pr/3138/base
github:gh-pr/3106/base
github:gh-pr/3057/base
github:gh-pr/2756/base
github:gh-pr/2812/base
github:gh-pr/3032/base
github:gh-pr/2992/base
github:notes/card-time-and-plant-flicker
github:gh-pr/2986/base
github:gh-pr/3000/base
github:gh-pr/2966/base
github:gh-pr/2924/base
github:gh-pr/726/base
github:gh-pr/2761/base
github:gh-pr/2663/base
github:gh-pr/2861/base
github:gh-pr/2862/base
github:gh-pr/2820/base
github:gh-pr/2811/base
github:gh-pr/2803/base
github:rt-call-trace
github:gh-pr/2802/base
github:gh-pr/2766/base
github:perf/ahead-split
github:gh-pr/2589/base
github:gh-pr/2699/base
github:gh-pr/2696/base
github:docs/readme-runtime-proposal
github:gh-pr/1346/base
github:codex/coord-claim-check-20261124-7e48
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
area: ci
.github/ workflows and settings
area: d3d12
The D3D12 runtime in d3d12/ (Rust: leonida.exe and its crates)
area: docs
Documentation
area: launcher
The launcher (launcher/)
area: runtime (legacy)
The earlier Vulkan runtime in runtime/
area: shader translator
The shader translator (leonida-shader, tools/rdna2spirv) and its tests
area: tools
tools/ and scripts/
area: viewer
The map viewer (viewer/)
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
missing claim
Needs a claim in #14
needs in-game run
Changes the code a frame runs through: needs the 300 s in-game gate (docs/game_gate.md)
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
wontfix
This will not be worked on
No labels
accessibility
area: ci
area: d3d12
area: docs
area: launcher
area: runtime (legacy)
area: shader translator
area: tools
area: viewer
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs in-game run
needs rebase
needs-triage
question
ready-for-agent
submodules
wontfix
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.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!3029
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3029"
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?
@bobcatchris on GitHub · 2026-12-02 02:13 UTC · original
bobcatchris:fix/d3d12-ahead-of-frame-cut→main· +95 −7 · 2 files · 1 commits · closed without mergingClaimed in the coordination issue as: D3D12-AHEAD-OF-FRAME-CUT
What and why
docs/findings.mdmeasures the submitting thread waiting ~12 ms of an ~80 ms frame inqueue::ahead_of_frame, while the helper pools that record the list ahead of the frame stand 95–99% idle. Most of that recording isState::heap_textures, which walks due texture slots and uploads them every frame even when the previous ahead-of-frame pass already covered the next frame.This change records the texture queue's write counter before each textures pass. If the heap is unchanged, no pages were written, remapped or baked, no view was made again or cast flipped, and no slot is held back or due by the next frame, the following list-ahead recording skips
heap_texturesand returns no list when there is nothing else to record.AHEAD_DIDstill advances, so asking lists keep skipping the pass that was already done. All invalidation signals come from the heap's existing bookkeeping; a write arriving during a pass is stamped as unserved by sampling the counter before it.The heap lock is held while the served state is stored, in the same order as
done_ahead, so a concurrent heap switch cannot leave stale state.Tested
draw::tests::ahead_textures_skip_only_when_nothing_is_pendingcovers every invalidation signal and theframe + 1boundary. Red/green: dropping the dirty-page signal makes the test fail; restoring it passes.cargo test -p leonida-gpu --locked(659 passed, 59 ignored) and the fullcargo test --workspace --exclude xtask --lockedwith the documented skip — green.python -I scripts/check_no_game_data.pyon both changed files andgit diff --check— clean.No in-game FPS measurement was made for this pull request. The 12 ms wait is from the existing profile in
docs/findings.md; this change removes work on quiet frames by construction.GPUs tested: n/a (offline Rust unit tests)
AI-assisted: yes — Gemini 4 Neon (architecture direction and independent review).
Checklist
mainand merges cleanly.@ecox982745 on GitHub · 2026-12-02 02:44 UTC · original
CPU-only source review at
e49404808:texture_ahead_cleancan skip the routine path that publishes completed deferred descriptor flips.texture_slot_show_aheadpushes a ready entry intoFLIPSfrom its upload completion callback (descriptor/host.rs:3461) without bumpingTextureQueue::writes. Once that slot is retired or its next recheck is later thanframe + 1, the heap can look clean even thoughtexture_slots_flip(:3636, called byheap_texturesatdraw.rs:4242) still needs to replace the neutral descriptor. Each subsequent skip refreshesAHEAD_DID, so ordinary draws can keep deferring their own pass.I’d make a ready flip for this heap veto the skip and add a regression with unchanged writes and a completed flip. The immediate
RESHOWNqueue filled bylevels_changed(descriptor/host.rs:417) is also consumed by that pass and is separate fromRESHOWN_AFTER, which the predicate already checks.AI-assisted source review. No game data or GPU used.
@OreoFR on GitHub · 2026-12-02 06:09 UTC · original
RUN by OreoFR (oreofr-agent, AI-assisted): two in-game ABBAs, main against main + this PR (head
e49404808784af77c5804c848174aa7c04ac19d6, merged into main8422def759cda12c89f918438eeb8d53dd5972a6with no conflicts).Setup: RTX 4070 Laptop 8 GB, driver 621.40, Core Ultra 7 155H. Series S, no DLSS, no frame generation, the same warm data. Each run is 450 s walking (lift at 340 s). Frame rate comes from the 5-second
recording per frame (N frames)windows.Numbers are fps.
Verdict: no gain measured on this card, possibly a loss. I am not putting it in the merge queue. This is PROVISIONAL (one card, two ABBAs). A paired in-run A/B behind a switch (
LEONIDA_AB) would settle it with much less noise, if the change can be turned off at run time.@lixonik on GitHub · 2026-12-02 07:14 UTC · original
RUN
Independent verification of
#3029(e49404808) merged cleanly ontomain(f37c4a87d) on Windows 10 Pro 22H2 (build 19045), AMD Ryzen 9 5950X, 64 GiB RAM, NVIDIA GeForce RTX 5070 12 GB (driver621.40), MSVC toolchain (1.98.1).Offline checks & code review
python -I scripts/check_no_game_data.pyon both changed files: PASS.cargo test -p leonida-gpu --locked --lib -- --skip depth_bounds_pipeline_loads_and_filters_draws(includingdraw::tests::ahead_textures_skip_only_when_nothing_is_pending): PASS.@ecox982745's finding:HostHeap::texture_ahead_clean(descriptor/host.rs:2898) checksRESHOWN_AFTER(host.rs:428), but does not checkRESHOWN(host.rs:413) or pending ready flips inFLIPS(host.rs:863) /PENDING_LIST_FLIPS(host.rs:889).In-game 4-leg ABBA (
mainf37c4a87dvsmain + e49404808)Setup: Series S, DLSS Quality,
-NoFrameGen, warm cache (0pipeline waits across all 4 legs), same save snapshot restored before every leg, 75 s in world per leg (17world samples each,0errors /0device removals).main 1PR 1PR 2main 2mainavgPRavgObservations
@OreoFR's RTX 4070 Laptop ABBA, no frame-rate gain was measured on RTX 5070 (20.10vs20.35fps,-1.2%, within run-to-run noise), and ahead-of-frame recording/wait time changed by only~0.25-0.55 msmedian (1.00ahead lists/frame sent in every leg).~220-240guard faults/frame,~0.1 MBwatched & changed,~0.8-1.7 MBhashed per frame) appear to keeptexture_ahead_cleanfalse almost every frame; noteHEAP_TEXTURES_SKIPPED(draw.rs:508,1529) is currently never printed in any stats line, so exposing it (alongside aLEONIDA_ABswitch and theFLIPS/RESHOWNfix) would directly show the actual skip rate in the world.Verdict: No measurable FPS improvement on RTX 5070 (flat vs
main, matching@OreoFR's result);@ecox982745'sFLIPS/RESHOWNskip hazard is confirmed in source.AI-assisted: yes (Antigravity).
@Kal0s-design on GitHub · 2026-12-02 13:54 UTC · original
Ran natively on Windows 11, head
e49404808merged into currentmain(128648cfe, no conflicts),leonida-gpuwith--features diagnostics,--locked, toolchain 1.98.1. I ran the tests on the hardware card and again on WARP, with the same results.The source review above already names
FLIPSandRESHOWN. Two more queues are missing fromtexture_ahead_clean, and I ran a probe that shows the skipped pass leaving them waiting whilemainclears them.Suite
cargo test -p leonida-gpu --lib(merge)draw::tests::ahead_textures_skip_only_when_nothing_is_pendingcargo clippy -p leonida-gpu --all-targetstoo_many_arguments(8/7) onahead_textures_clean(draw.rs:566)The predicate against queued work (throwaway test in
descriptor/host.rs, not committed). The setup is aHostHeapof 8 slots with placed spans noted for slots 2 to 4. I settled the remap cursor and cast, emptied the queue, tookserved = texture_news().0and queued one item at a time.texture_ahead_clean(served, frame)read_short(start)(SHORT)texture_slots_shortmade 1 slot dueWAITINGentry for the start, back-dated 2 frames and waited 1.2 s (whatlevels_waitingleaves)texture_slots_waitingmade 1 slot duelevels_changed(start)(RESHOWN)texture_views_remadedrained itFlipfor this heap pushed intoFLIPStexture_slots_fliptakes itNeither
read_shortnorlevels_waitingincrementsTextureQueue::writesor sets any flag thattexture_newsreads. Only the pass itself turns them into queue entries.End to end through
test_record_passes_ahead(same heap made withcreate_heap,frame::test_advance()before each list,SHORTandWAITINGfilled as above after list 2, queue otherwise empty):SHORTpending /WAITINGpending / duemain: recorded /SHORT/WAITING/ dueOn
mainthe next list's pass turns both into due slots. On the PR they stay queued until something else makes the heap not clean. Each skip also storesAHEAD_DID[1] = frame + 1(read in code), sodone_ahead(1)stays true and draws that are not baking also leave out their own textures' pass.This probe's queue is empty, so it shows the worst case. In a live heap, the slot whose filling queued the item was just uploaded, and by default it keeps a look on the queue (
frame + 1when uploaded in part, otherwiseRECHECK_FRAMES4, 12, 40, 120, 400). That look makesnext_due <= frame + 1and forces a pass, which drains both queues. So in a live heap, I expect a delay until the next due look in the heap, not a permanent stall. The delay grows as a slot's looks spread out, and has no bound withLEONIDA_HEAP_RECHECK=0. I did not measure it.A possible fix: count a non-empty
SHORT, an eligibleWAITINGentry, a non-emptyRESHOWN, or a readyFLIPS/pending flip for this heap as "not clean". Each needs a regression test like the one in the second table.Not checked: how often these queues are non-empty on a quiet heap in game. An earlier in-game run in this thread found
texture_ahead_cleanfalse almost every world frame anyway, so menus and still scenes are where this would show. I made no in-game run. Themaincolumn of the end-to-end probe ran on WARP only.GPUs tested: one NVIDIA desktop card + WARP.
AI-assisted: yes (Claude Code).
@MoonEyes on GitHub · 2026-12-02 18:18 UTC · original
Verification of #3029 (third party, code review on Linux; not built: Windows-only
leonida-gpu)e49404808784af77c5804c848174aa7c04ac19d6(2 files:draw.rs+72/-7,descriptor/host.rs+23).393901a5b.git merge-tree --write-tree origin/main pr/3029againstmain45dc41f95is clean(210 commits behind). CI on the head: 6/6 success.
python -I scripts/check_no_game_data.pyon both files: exit 0.Review
The skip (
draw.rs:503-509) is gated bytexture_ahead_clean(descriptor/host.rs:2890-2911). It treats theheap as clean when
TextureQueue::writesis unchanged and nothing intexture_news,by_due,held,RESHOWN_AFTERor the cast has moved. Theheap_texturespass it skips does more than that predicate looks at:FLIPS(descriptor/host.rs:863, pushed at:3469from anupload completion callback without bumping
writes) are only published bytexture_slots_flipinside thepass. ecox982745 raised this.
RESHOWN(filled bylevels_changed),SHORT(read_short) andWAITING(
levels_waiting) are also consumed only by the pass, and none of them bumpswrites. Kal0s-design's probeshows
SHORTandWAITINGstaying pending for lists 3 to 7 on the PR, wheremainmakes those slots due atthe next list.
AHEAD_DIDfor the frame (the comment atdraw.rs:506-507), so the frame's owndraws keep deferring to a pass that did not run. Items 1 and 2 can then wait indefinitely while the heap is
otherwise quiet. That is a texture that never flips from its neutral descriptor, not just one late frame.
Root-cause fix, not a workaround: the predicate should be derived from the same queues the pass drains. One
option is a single "pass has work" query on
HostHeapthat includesFLIPSfor this heap,RESHOWN,SHORTand
WAITING. Another is to bumpTextureQueue::writeswherever those queues are pushed. A regression testshould keep
writesunchanged and leave one item in each queue.Smaller points:
ahead_textures_cleantakes 8 arguments, so clippy reportstoo_many_arguments(draw.rs:566, perKal0s-design). A struct, or the query above, would remove it.
record_passes_ahead_partnow returnsrecordedinstead oftrue(draw.rs:545), soAHEAD_STATS[0..2]stop counting skipped lists. That is fine, but
findings.mdfigures based on those counters change meaning.Process
Verdict: defects. The skip can leave queued flips and slot work undone (items 1-3). Fix the predicate and add
the regression test before merge. The OreoFR and lixonik in-game ABBAs on this head do not cover these queues.
AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.
Generated by Claude Code
@EdenBendheim on GitHub · 2026-12-02 21:02 UTC · original
RUN (in-game RTX 3090 300 s stress gate, 14-PR combined batch) — PASS covering exact head
e49404808784af77c5804c848174aa7c04ac19d6.git merge --no-ffontomainb41763227(diagnostics,dlss,mimalloc,exe_sha16 = c47eeb717f761d9d; changed-file clean-room scan exit0; standalone Windows unit checks also passed default & diagnostics with compile-time red onahead_textures_clean).14PRs):#3200d1a91afd1,#319880a627bb1,#319193b47ac9d,#3189c182fc392,#3176ae0075d9a,#3168337388052,#31641065952da,#3146ebc0253ff,#312464600ef0c,#3069311d33a40,#30318df1bfce7,#3029e49404808,#3054ff53fd8b9,#3010d645712a3.610.88, Series X profile,2560x1440,-NoFrameGen,LEONIDA_UPLOAD_AHEAD=1,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 sVerdict: PASS for the 300 s in-game stability gate on
e49404808. (Single combined-batch stability check, not an isolated single-PR FPS gain claim.)(AI-assisted verification:
gemini-4-neon+gpt-6.2-astra.)@bobcatchris on GitHub · 2026-12-02 21:02 UTC · original
Closing this optimization attempt as net-negative.
Thank you
@ecox982745,@Kal0s-design,@OreoFR,@lixonik, and@MoonEyesfor the thorough source reviews and in-game ABBA measurements:@OreoFRon RTX 4070 Laptop and@lixonikon RTX 5070) measured zero gain / slight regression (-1.2%to-15%) because active frames mark nearly every frame (1.00ahead lists/frame).@ecox982745and@Kal0s-designshowed,texture_ahead_cleanwould also need to checkFLIPS/PENDING_LIST_FLIPS,RESHOWN,SHORT, andWAITING(reducing skips even further) and avoid refreshingAHEAD_DIDon skip.AI-assisted: Gemini 4 Neon
Pull request closed