d3d12: LEONIDA_EXP_NO_PIXELS empties the scissors at each draw; what the pixels cost (D3D12-NO-PIXELS-PER-DRAW) #3164
Open
github-bot
wants to merge 6 commits from
github-bot/gh-3164 into main
AGit
pull from: github-bot/gh-3164
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!3164
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3164"
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?
@Lanworm on GitHub · 2026-12-02 15:48 UTC · original
Lanworm:nopixels-diagnostics→main· +378 −17 · 6 files · 6 commits · openClaimed in the coordination issue as: D3D12-NO-PIXELS-PER-DRAW (#2570)
What and why
LEONIDA_EXP_NO_PIXELSis a diagnostics-only timing switch forLEONIDA_AB: it should leave the title's draws without pixels, so a phase's card time against the next one's is what the pixels cost. Until now it emptied the scissors insidedraw::scissors, i.e. only where a scissor was set. In the game it changed neither the picture nor the card's time, although new counters showed every scissor set in its phases being emptied, and a GPU test shows the driver honours an empty scissor.This PR:
draw.rs:State::no_pixelsempties the scissors right before each of the title's graphics draws (DrawInstanced, DrawIndexedInstanced, direct and amplified DispatchMesh, non-dispatch ExecuteIndirect), andState::pixels_backputs the title's back right after it, the wayLEONIDA_EXP_MESH_ONE_PIXELalready does for mesh draws. A draw before the title set any scissor in the list is left alone (it has none to take back).set_scissorsnow stores the rects and calls the newapply_scissors, whichmesh_scissoralso uses to restore; somesh_scissornow restores the widened rects underLEONIDA_SCISSOR_TEST=fulltoo (only when both experiments are set). With the switch off, and in non-diagnostics builds, every path sets the same scissors as before.ab.rs: the A/B counters line getsgraphics_drawsanddraws_without_pixels.tests/scissor.rs: a GPU test of the driver, not of the port: a full-target triangle under an empty, one-pixel and whole-target scissor, on the default adapter and WARP (0, 1 and 64 of 64 pixels). It shows the earlier no-effect result was not the driver.docs/findings.md: the measurement below.docs/switches.md: the two changed rows.The measurement (RTX 5060 Ti, i5-12400F, Series X as the F1 menu had saved it (the title's own upscaler from a render scale of 0.6667, no DLSS), no generated frames, standing,
LEONIDA_GPU_TIMING=1,LEONIDA_AB=4,LEONIDA_EXP_NO_PIXELS, 42 adjacent pairs of phases):draws_without_pixelsequalsgraphics_draws(about 4,900 a frame).The 14 ms is a difference rather than an exact share: it includes depth and blending, and anything the title derives from depth saw other input. Cheaper pixel shading can therefore take at most about a fifth off the card.
Tested
cargo test -p leonida-gpu --features diagnostics --locked: lib 777 passed,--test scissorpassed.cargo test -p leonida-gpu --locked --lib: 696 passed.cargo check -p leonida-gpu --locked, with and withoutdiagnostics.cargo clippy --all-targetsshows no new warnings in the changed code.python -I tests/test_d3d12_switches.pyandpython -m unittest discover -s tests -p "test_docs_*.py"pass.python -I scripts/check_no_game_data.pyon every changed file passes.python -I scripts/red_green.py nopixels-diagnosticsgivesverdict: no red(697 pass on both sides). This is expected: the only new test checks the driver, which is the same without the change. The change itself was confirmed in the game, by the counters above and by the card time and picture changing in ON phases, which they did not before.GPUs tested: NVIDIA GeForce RTX 5060 Ti, Windows 11 Pro 26200, plus WARP (the GPU test).
AI-assisted: yes. Claude Code with Claude Opus 5.5 wrote the code and the texts. The reviewer was also Claude Opus 5.5. The measurements were run in the game by the submitter.
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code
Edited 2026-12-03: the run's profile corrected. The F1 menu had saved Series X before the run (the title's own upscaler from a render scale of 0.6667, no DLSS), not Series S with DLSS as first written; the numbers are unchanged.
@fiestorra on GitHub · 2026-12-02 16:34 UTC · original
Verified here: it applies on the current
mainand its integration test passes.The test is the right shape for the switch:
LEONIDA_EXP_NO_PIXELSempties each draw's scissor, and the test checks that a scissor leaves only its own pixels - which is what has to be true before the timing it produces means anything.What that does not say: the timings. The whole point of the switch is to measure what the pixels cost, and the number it produces has to come from a run of the title with and without it - this machine can measure neither, so I am not vouching for the finding it is meant to produce, only that the mechanism it rests on is tested.
For the merge: the checks show
BLOCKEDand the documentation files are in the change, sod3d12_switches.py --checkis worth a run before the review - it is the one check that catches a switch table that no longer matches the code.AI-assisted: yes - DeepSeek v4.1 (flash).
Written with an AI assistant.
@MoonEyes on GitHub · 2026-12-02 18:18 UTC · original
Verification of #3164 (third party, code review on Linux; not built: Windows-only
leonida-gpu)1065952da5fb0f12c354d8782568132c22c836ed(5 files:ab.rs,draw.rs, newtests/scissor.rs,findings.md,switches.md; +326/-17).3c106eb2f.git merge-tree --write-tree origin/main pr/3164againstmain45dc41f95is clean(21 commits behind).
python -I scripts/check_no_game_data.pyon the 5 files (on the merge): exit 0.Review
mainemptied scissors only insidedraw::scissors, that is, only when the title set one. Draws thatran under scissors set earlier kept their pixels, so the A/B phase measured nothing. The fix empties the title's
scissors right before each graphics draw and puts them back right after (
State::no_pixels/pixels_back,draw.rs:5344-5372). It is applied at every title draw site: direct, mesh, indirect (kind != DISPATCH) andthe three other draw paths. This fixes the cause rather than adding another special case to
scissors().draw.rs:5391-5403) and the indirect site (:6905-6930). There is no?orreturnbetween the two calls, so a list never keeps empty scissors. The ordering withmesh_scissor(LEONIDA_EXP_MESH_ONE_PIXEL) is right: one-pixel scissor, emptied, title's scissors back,then
mesh_scissor(false).#[cfg(feature = "diagnostics")]. Release builds compileno_pixelstofalse, andpixels_back(.., false)is a branch. In diagnostics builds each draw does one relaxed atomic addand one
ab::pick.self.scissors.is_empty()). The newgraphics_draws/draws_without_pixelscounters in the A/B line show how much is missed. That is the rightinstrument, per AGENTS.md "check the instrument".
tests/scissor.rstests the driver, not the port. Its own header says it "cannot fail on the port's side", sothere is no red/green for the
draw.rschange. The counters and thefindings.mdrun are the evidence. Thatis acceptable for a diagnostics-only timing switch, and the body is honest about it.
Process
Windows at this head.
Verdict: ready (not built here). It only needs the fork CI approved.
AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.
Generated by Claude Code
@Kal0s-design on GitHub · 2026-12-02 20:43 UTC · original
Ran natively on Windows 11, head
1065952damerged into currentmain(b41763227, clean merge).MoonEyes read the code and fiestorra ran the scissor test, so here I only add what the thread doesn't have yet. That means the suite on the merge, a driver probe of what an empty scissor leaves besides pixels, the debug layer and the switches check.
Suite (measured)
cargo test -p leonida-gpu --features diagnostics, libtests/replay.rstests/scissor.rscargo test -p leonida-gpu --libwithout diagnosticscargo clippy -p leonida-gpu --all-targets, with / without diagnosticstests/scissor.rscopied ontomainpasses there too. That's expected because it tests the driver and not the port, so there's no red/green to get.python -I tools/d3d12_switches.py --check d3d12/docs/switches.mdpasses on the merge, which answers fiestorra's point.test_d3d12_switches.pypasses andcheck_no_game_data.pyon the 5 files exits 0.test_docs_python_depserrors here (f-string SyntaxError) onmainas well, so it isn't from this PR.What an empty scissor leaves (measured with a throwaway test, not pushed)
The test draws a full-target triangle into an 8x8 target through VS, GS, stream-out and PS, with depth and stencil writes on. VS, GS and PS each add to a root UAV, and occlusion, pipeline statistics and SO statistics queries wrap the draw.
DrawInstancedandExecuteIndirectwith a DRAW signature gave the same numbers. The card and WARP matched too, apart from the two cells marked WARP.I also ran a plain pipeline with no UAV, GS or stream-out, in case the driver skips vertex work once nothing can reach the rasterizer. It doesn't. VSInvocations is still 3 under the empty scissor on both adapters. So for VS/GS pipelines the PR's claim holds. Shading, depth, stencil, colour writes, PS UAV writes and occlusion counts all drop to zero, and everything before the rasterizer still runs. Mesh pipelines aren't covered because the probe only had FXC.
Debug layer (measured once, ID3D12InfoQueue present on both devices)
There are no errors. Each draw under an empty scissor gives one warning, ID 695, saying viewport 0 is non-empty while its scissor is empty.
Host::log_messagesdrains the queue at every submit and turns each message into atracing::warn. So withLEONIDA_D3D12_DEBUG=1and this switch on, the log would get up to one line per emptied draw, unless the info queue's own message limit caps it first. I didn't run the port under the debug layer, so that part is read. Muting ID 695 while the switch is inLEONIDA_ABwould be cheap, or one line in switches.md would do.Code (read)
On the title's runtime path, every host
DrawInstanced,DrawIndexedInstanced,DispatchMeshandExecuteIndirectis one of the five wrapped sites indraw.rs. The other hits are the port's own passes (compose, trainer overlay,record_plane_pass), the startup dispatch probeask_wide, tests and benches, and the capture player inreplay/play.rs. The title's list has noExecuteBundlehandler, so there's no bundle path to cover. All title scissors go throughset_scissors. Clears with rects ignore scissors in D3D12, so clears keep their cost in ON phases and aren't part of the 14 ms.MoonEyes checked the mesh and indirect sites for early exits. The other three (
DrawInstanced,DrawIndexedInstanced, amplified mesh) have nothing betweenno_pixelsandpixels_backeither. After a list cutreplay()sets the title's scissors again, and the next draw empties them again, so I don't see a way for the original scissors to leak back into an ON draw.With the switch off it reads the same as
main, except for the case the body already names.mesh_scissornow restores widened rects whenLEONIDA_SCISSOR_TEST=fulland mesh mode 2 are both set.LEONIDA_MESH_TEST=scissorworks withoutdiagnostics, so that one combination changes in normal builds too.The A/B counters fit the claim.
graphics_drawscounts calls, so anExecuteIndirectof N records counts once and the 4,900 a frame are calls, not records. ON phases also add twoRSSetScissorRectsper draw that OFF phases don't have, so the card-busy delta is if anything slightly low, and the frame median carries some extra submit-thread work.Conflicts (measured with
git merge-tree)Out of the 36 open PRs touching
draw.rs,ab.rs,findings.mdorswitches.md, only #2958 gets a new conflict from this one. It's indraw.rsat theDrawIndexedInstancedsite, on adjacent lines, and keeping both sides fixes it. The others that conflict already conflict withmainin the same files.Not checked: the in-game timings, mesh-shader pipelines under an empty scissor, a port-level test that each title draw really gets emptied or that switch-off is identical (both only read), the port itself under WARP or the debug layer (the probe made its own devices), a release build.
GPUs tested: an NVIDIA card (default adapter, hardware) and WARP (software adapter). The debug layer was confirmed on both for one probe run.
AI-assisted: yes (Claude Code).
@EdenBendheim on GitHub · 2026-12-02 21:01 UTC · original
RUN (in-game RTX 3090 300 s stress gate, 14-PR combined batch) — PASS covering exact head
1065952da5fb0f12c354d8782568132c22c836ed.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,LEONIDA_EXP_NO_PIXELSoff/default) 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 default-off in-game stability gate on
1065952da. (We also plan a dedicatedLEONIDA_AB=10,LEONIDA_EXP_NO_PIXELSRTX 3090 measurement next.)(AI-assisted verification:
gemini-4-neon+gpt-6.2-astra.)@fiestorra on GitHub · 2026-12-02 23:54 UTC · original
VERIFY-3164 — Windows nativo: la suite pasa, y el arreglo no tiene test porque el camino está tras un interruptor apagado
1065952da—draw.rs(two code lines + doc),tests/scissor.rs(comments)Ran at the head
The change, and it is a real bug:
pixels_offusedself.scissors.len().clamp(1, EMPTY.len())— so an empty scissor list became one empty scissor, i.e. it emptied a scissor that does not exist — and now it is.min(...)with a!self.scissors.is_empty()guard, so a draw before the title set any scissor is left alone.My control, which did not bite, and why: I put both lines back (
clamp(1, ...), no guard) and the suite stayed green. Because the whole path is insideif crate::ab::pick("LEONIDA_EXP_NO_PIXELS") == Some(true)— an experiment switch that is off unless someone sets it, and no test in the crate sets it.So, honestly:
red not constructiblefrom here. The fix is right by reading —clamp(1, ..)on an empty slice is exactly the "take back what was never set" bug — but the suite cannot fail on it, and a change that no test can reach is a change that a later edit can undo silently.And the second half of the commit is a test whose comments say more than most:
tests/scissor.rsis "a check of the driver, not of the port" — "a test of it cannot fail on the port's side". Writing that down is what keeps the test from being trusted for the wrong thing, which is a bigger service than the code line.What I could not test
LEONIDA_EXP_NO_PIXELSpath: it needs a D3D12 device and a title's scissor list.pixels_offwith the switch forced on (anab::pickseam), which would make this fix reachable by the suite.Written with an AI assistant.
@Lanworm on GitHub · 2026-12-03 07:47 UTC · original
Thanks to everyone who verified this.
e4dfc90answers the three points raised:State::no_pixelssets are now chosen by a small pure function,no_pixel_scissors(title, on)indraw.rs, covered byno_pixel_tests::no_pixels_empties_the_titles_scissors_only. It checks: as many empty scissors as the title set, at most 16; none when the title set none; none when the switch is off. I put the old choice back (on.then(|| &EMPTY[..title.clamp(1, 16)]), no guard) and the test fails:left: Some([RECT { 0, 0, 0, 0 }]),right: None. It passes with the change. This was done by reverting that one line by hand:red_green.pycannot build the new test againstmain, where the function does not exist.LEONIDA_EXP_NO_PIXELSis named inLEONIDA_AB, the host's info queue now gets a storage deny filter forD3D12_MESSAGE_ID_DRAW_EMPTY_SCISSOR_RECTANGLE(695). This is diagnostics builds only. It compiles and the suite passes; I have not run the port underLEONIDA_D3D12_DEBUG=1to see the log stay quiet.graphics_drawsdoc andfindings.mdnow say these are calls: an indirect execution of several records counts once.Tests on the head (RTX 5060 Ti, Windows 11):
cargo test -p leonida-gpu --features diagnostics --locked --lib: 778 passed.--test scissor: passed.test_d3d12_switches.pyandcheck_no_game_data.pyon the changed files: pass.@EdenBendheim, thanks for the gate run; an
LEONIDA_AB=10,LEONIDA_EXP_NO_PIXELSnumber from a 3090 would be a useful second point next to the 5060 Ti one.AI-assisted: yes (Claude Code, Claude Opus 5.5; reviewed by a separate Claude Opus 5.5 agent).
@MoonEyes on GitHub · 2026-12-03 08:00 UTC · original
RUN (in game, one pull request), its head merged with
git merge --no-ffonto maind9b618f10: #3164e4dfc9012. 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.LEONIDA_EXP_NO_PIXELSis an experiment switch that is off by default and was left off, so this run covers the default path only. This run is at the low end of tonight's range on this machine (13.3 to 17.4 fps); one run cannot say whether that is the change or the scene.AI-assisted (Claude Code).
@merzleckeier on GitHub · 2026-12-03 08:04 UTC · original
Rechecked
e4dfc901merged ontomaind9b618f1. The Windows MSVC diagnostics build under Wine 11.22 ran the draw suite with 28 passes and three existing ignores, includingno_pixels_empties_the_titles_scissors_only. A scratch control restored the original lower clamp insideno_pixel_scissorsand kept the new test. It failed on the zero-scissor case:Some([RECT { 0, 0, 0, 0 }])instead ofNone. The debug-layer filter compiled in the diagnostics build. The execution check here covered the scissor regression.I also paired this head with #3291
6b0ee46band the stricter catalog check from #3270. The combination merges cleanly and the tracked page passes all 21 catalog tests with 685 names and 646 descriptions. AI-assisted with OpenAI Codex.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.