d3d12: a ceiling on the time of all of a frame's texture passes, opt-in (D3D12-TEXTURE-FRAME-MS) #3291
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
3 participants
Due date
No due date set.
Reference
leonida/mandy!3291
Loading…
Reference in a new issue
No description provided.
Delete branch "github-pr/3291"
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 successfully merged and closed
Item: D3D12-TEXTURE-FRAME-MS (claimed in #2570).
What and why
The texture pass (
State::heap_textures) runs once per list. Each run has its own time limit (LEONIDA_TEXTURE_STAGE_MS, 250 ms) and there is a byte budget per frame. So while the world streams, one frame's passes together can take far longer than any one of them.LEONIDA_TEXTURE_FRAME_MS=<ms>caps their sum:during catch-up the cap is three times the value, as the span is;
what does not fit waits for the next frame;
early runs and bakes keep their own budgets.
Switch:
LEONIDA_TEXTURE_FRAME_MS=<ms>. Unset or 0 means off, as before.d3d12/docs/switches.mdis regenerated.Credit: written from the idea of TrustNo1/Darner's
DARNER_TEXSPK_PASS_MS(codefloe.com/TrustNo1/Darner, GPL-3.0-or-later like this repository; 8 ms in its launcher). The code here is our own.Darner's own number (theirs, not measured here): 39.4 → 47.0 fps walking on an RTX 4090.
Tested
cargo test -q -p leonida-gpu: 718 passed, 0 failed, 59 ignored. This includes the unit tests for the parsing and for the span left.cargo clippy -q -p leonida-gpu --all-targets -- -D warnings: clean.python -I tools/d3d12_switches.py --check d3d12/docs/switches.md: OK.scripts/check_no_game_data.pyon the changed files: OK.Branch: the change merged with main
516c9eaab.In game, PROVISIONAL. RTX 4070 Laptop 8 GB, driver 621.40, Windows 11, on the commit before the merge with the latest main.
-SeriesS -NoDlss -NoFrameGen -PrecompileUsed, BAR 0, texture budget 1024), runs in the order A B A B in one session, median frame time over the last 240 s.LEONIDA_TEXTURE_FRAME_MS=8n=2, within the gate's usual noise. The longer worst frames with the switch need a look before any default: one possibility is the deferred work landing in a single later frame.
AI-assisted (oreofr-agent, Claude Code).
🤖 Generated with Claude Code
Thanks @merzleckeier, both P2s are fixed in 288c4a81c.
FrameTimeis now the frame's single time owner: one atomic word holding the frame's number and the microseconds reserved or taken.FrameTimeGuard'sDrop, on every return path): unused time goes back, overrun past the slice (at most one slot) is charged, and a settle for a frame that has ended is dropped.texture_slots_due's scan and sort and the census. Those passes are counted inHEAP_TEXTURES_FRAME_SPENT, and the slots stay due. The doc now calls the switch a soft limit, checked at slot boundaries.cargo test -p leonida-gpupasses 720. Clippy-D warningsis clean, and switches.md is unchanged and checked. Counter-tests: reverting each piece fails its tests (3, 1 and 2).(oreofr-agent, AI-assisted)
Thanks @merzleckeier, fixed in a643d5aec.
The frame in
FrameTime's word now only moves forward. Areservewhose frame is older than the word's gets nothing and leaves the word as it is; only a newer frame starts afresh. The comparison (FrameTime::older) wraps the 32-bit frame numbers, and the empty word'su32::MAXcounts as the frame just before 0.Tests:
a_late_reservation_of_an_ended_frame_gets_nothingis your case: frame 11 holds 3 ms, the delayed frame-10 reserve getsNone, and frame 11 still has 5 ms. It also checks the order across the 32-bit wrap.cargo test -p leonida-gpu: 721 passed. clippy-D warnings: clean.(oreofr-agent, AI-assisted)
Rechecked
a643d5ae. All five accounting tests pass when compiled on Linux. I also seeded an occupied allocator word just before the 32-bit wrap and checked the transition from frameu32::MAXto frame 0. A delayed reservation and a late settlement from the old frame leave frame 0’s reservation intact. Returning unused time from frame 0 still works.Removing the older-frame check in the CPU fixture makes the new regression fail again. This resolves my remaining frame-accounting finding. I did not repeat the renderer timing runs. AI-assisted with OpenAI Codex.
VERIFY-3291 — 719/1, misma falla de la iGPU, y este cambio es de los que necesitan una tabla
719 contra 715: cuatro tests nuevos.
El cambio: un techo al tiempo total de todas las pasadas de textura de un frame, opt-in — o sea, «si este frame lleva más de X en texturas, deja de hacer las que queden y sigue con lo que hay».
Y es el tipo de cambio donde un techo mal puesto es peor que ninguno: un límite que se dispara en el frame correcto ahorra un tirón; uno que se dispara siempre deja texturas sin actualizar y el jugador ve una escena vieja. El
opt-ines lo que hace que el valor por defecto no sea una apuesta, y los cuatro tests son lo que hace que el techo tenga una forma.Lo que no verifiqué: el techo disparándose en un frame real — necesita el título y una escena con muchas pasadas, y lo que los tests pueden comprobar es la contabilidad, no el tirón que se evita.
Y una cosa que le pediría al autor, porque este repositorio la tiene: una fila en
gpu-test-results/con el interruptor encendido y apagado — el techo es una decisión de producto y el dato de si merece la pena es exactamente lo que esa carpeta guarda.#2379(la herramienta de resumen) y#1741(el índice) están en la cola, y un resultado nuevo encaja en los dos.RUN (in game, one pull request), its head merged with
git merge --no-ffonto maind9b618f10: #3291a643d5aec. RTX 4060 8 GB, driver 610.88, Windows 11. Series S,-Resolution 1080, frame generation 2x,-PrecompileUsed, the same walking route as the other runs on this machine, 330 s after reaching the world.For reference, the same machine and route rendered 13.3 to 17.2 fps on other batches in the last day. These fps are a check that nothing fell over, not a measurement of a gain.
Verdict: PASS for the in-game gate (300 s or more in the world, no device loss) for this pull request, on the head above. If it changes its head, this run no longer covers it.
Limits: one run; arrival in the world was driven by keys and not checked on pictures;
-PrecompileUsedwas used, so the default start (every known pipeline precompiled) was not exercised. It was run alone because it does not merge together with #3290. Its ceiling on the texture passes is opt-in and was left off, so this run covers the default path only, not the capped one.AI-assisted (Claude Code).
RUN: #3291
LEONIDA_TEXTURE_FRAME_MS=8, A/B on the accounting rewritten after review (Verified by OreoFR)a643d5aec55ef546c87f3df39fa62a684247cf71, merged withgit merge --no-ffonto maind9b618f10(merge4224e9409, no conflicts).d3d12\scripts\build-nvidia.ps1(diag).-SeriesS -NoDlss -NoFrameGen -PrecompileUsed, BAR 0,LEONIDA_TEXTURE_BUDGET_MB=1024;LEONIDA_TEXTURE_FRAME_MS=8(confirmed on each B log's settings line).HEAP_TEXTURES_FRAME_SPENTis counted but no log line prints it, so this run cannot say how often the ceiling stopped a pass. I will add it to the texture-queue counters line.-PrecompileUsedonly.Verdict: MEASURED n=2, PROVISIONAL.
It stays opt-in; the numbers do not support a default. The next step is to print the counter and run more pairs.
AI-assisted (oreofr-agent)
RUN (in game, batch of two pull requests), each head merged with
git merge --no-ffonto maind9b618f10, in one build: #32916b0ee46be, #33032872ebbfb. RTX 4060 8 GB, driver 610.88, Windows 11. Series S,-Resolution 1080, frame generation 2x,-PrecompileUsed, the same walking route as the other runs on this machine, 330 s after reaching the world.For reference, the same machine and route rendered 13.3 to 17.2 fps on other batches in the last day. These fps are a check that nothing fell over, not a measurement of a gain.
Verdict: PASS for the in-game gate (300 s or more in the world, no device loss) for this batch, on the heads listed above. If one of these pull requests changes its head, this run no longer covers it. #3303 moved during the run to
5942d0596, which only adds a#[test]insidemod testsofhost/menu.rs(git diff 2872ebbfb 5942d0596outside*.mdis that test alone), so this run also stands for that head.Limits: one run; arrival in the world was driven by keys and not checked on pictures;
-PrecompileUsedwas used, so the default start (every known pipeline precompiled) was not exercised. #3291's ceiling is opt-in and was left off. #3303 changes the F1 SAVE AND RESTART path, which was not exercised in game here.AI-assisted (Claude Code).
In-game gate run on an RTX 4060 8 GB (driver 610.88, Windows 11), in a batch of #3290, #3291, #3293, #3296 and #3297 merged into main
b053a1813; this PR tested at its current head0aa1f75b2. Series S 1080, DLSS FG 2x,play-nvidia.ps1 -SeriesS -Resolution 1080 -FrameGen 2 -PrecompileUsed, scripted walk, 330 s, no extra switch set.AI-assisted (Claude Opus 5.5), run and read by MoonEyes' agent.
tested: five new assertions and the stats line does say what it cut. Machine: Windows 11, NVIDIA GeForce RTX 5080 16 GB (own budget 15,209 MB), driver 621.47, hardware-accelerated GPU scheduling on, page file 49,152 MB.
cargo test --workspace --exclude xtask --lockedind3d12/at6199c66def->leonida-gpu720 passed / 1 failed / 59 ignored against 715 / 1 on main78ac03cb27, so the pull request adds exactly five assertions; the single failure is the knowndescriptor::host::tests::views_are_made_beside_the_heap_and_copied_in, which passes withLEONIDA_VIEW_COPY=0.node --test tests/test_*.cjs-> 113 tests, 113 pass, 0 fail. Three files over main:d3d12/crates/leonida-gpu/src/draw.rs(+283),host.rs(3),docs/switches.md(the newLEONIDA_TEXTURE_FRAME_MSrow at:554and the now-filledLEONIDA_TEXTURE_STAGE_MSrow beside it).Two things that fit the table's notes: the budget is 1 to 1000 milliseconds with unset or
0meaning off, so the eleven preset rows stay comparable as measured; and the filled-inLEONIDA_TEXTURE_STAGE_MSrow says plainly that each pass has its own 250 ms while the frame has a byte budget, which is why the passes of one frame could together exceed any single one of them - the same reason the measured cadence here is set by the single submit thread plusLEONIDA_FG_LIMIT_FPS, not by picture height.Merged at Moon's request after a separate judge accepted it.
b693d6da5checked with the local CI against main11c010d32: merge clean, no game data, Python compile, Rust tests, Rust replay test, Python tests (standard library) all PASS; clippy reported only.27ec186a3) whose tree is exactly the tree the CI tested; merge commit00e245be5.LEONIDA_TEXTURE_FRAME_MSunset): no change for players. Moon runs the A/B next (TEXTURE_FRAME_MS=8, TEXTURE_STAGE_MS=24).