d3d12: LEONIDA_EXP_NO_PIXELS empties the scissors at each draw; what the pixels cost (D3D12-NO-PIXELS-PER-DRAW) #3164

Open
Lanworm wants to merge 6 commits from upstream-pr/3164 into main
Lanworm commented 2026-12-02 15:48:29 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Lanworm on 2026-12-02T15:48:29Z.


Claimed in the coordination issue as: D3D12-NO-PIXELS-PER-DRAW (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7350934809)

What and why

LEONIDA_EXP_NO_PIXELS is a diagnostics-only timing switch for LEONIDA_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 inside draw::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_pixels empties the scissors right before each of the title's graphics draws (DrawInstanced, DrawIndexedInstanced, direct and amplified DispatchMesh, non-dispatch ExecuteIndirect), and State::pixels_back puts the title's back right after it, the way LEONIDA_EXP_MESH_ONE_PIXEL already 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_scissors now stores the rects and calls the new apply_scissors, which mesh_scissor also uses to restore; so mesh_scissor now restores the widened rects under LEONIDA_SCISSOR_TEST=full too (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 gets graphics_draws and draws_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):

  • Card busy: −14.4 ± 1.7 ms a frame (75.0 → 60.9).
  • Frame median: −2.7 ± 2.6 ms. Not a clear difference: that run was not card-bound (about 140 ms a frame, the card idle 62 ms of it).
  • Counters: in ON phases draws_without_pixels equals graphics_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 scissor passed. cargo test -p leonida-gpu --locked --lib: 696 passed.
  • cargo check -p leonida-gpu --locked, with and without diagnostics. cargo clippy --all-targets shows no new warnings in the changed code.
  • python -I tests/test_d3d12_switches.py and python -m unittest discover -s tests -p "test_docs_*.py" pass.
  • python -I scripts/check_no_game_data.py on every changed file passes.
  • Red/green: python -I scripts/red_green.py nopixels-diagnostics gives verdict: 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.
  • A separate read-only reviewer agent (Claude Opus 5.5) audited the full diff; its findings were addressed and it was re-run on the fixes.

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

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of 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.

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5609904744 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3164). Originally posted by [Lanworm](https://github.com/Lanworm) on 2026-12-02T15:48:29Z. --- Claimed in the coordination issue as: D3D12-NO-PIXELS-PER-DRAW (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7350934809) ### What and why `LEONIDA_EXP_NO_PIXELS` is a diagnostics-only timing switch for `LEONIDA_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 inside `draw::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_pixels` empties the scissors right before each of the title's graphics draws (DrawInstanced, DrawIndexedInstanced, direct and amplified DispatchMesh, non-dispatch ExecuteIndirect), and `State::pixels_back` puts the title's back right after it, the way `LEONIDA_EXP_MESH_ONE_PIXEL` already 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_scissors` now stores the rects and calls the new `apply_scissors`, which `mesh_scissor` also uses to restore; so `mesh_scissor` now restores the widened rects under `LEONIDA_SCISSOR_TEST=full` too (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 gets `graphics_draws` and `draws_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): - **Card busy:** −14.4 ± 1.7 ms a frame (75.0 → 60.9). - **Frame median:** −2.7 ± 2.6 ms. Not a clear difference: that run was not card-bound (about 140 ms a frame, the card idle 62 ms of it). - **Counters:** in ON phases `draws_without_pixels` equals `graphics_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 scissor` passed. `cargo test -p leonida-gpu --locked --lib`: 696 passed. - `cargo check -p leonida-gpu --locked`, with and without `diagnostics`. `cargo clippy --all-targets` shows no new warnings in the changed code. - `python -I tests/test_d3d12_switches.py` and `python -m unittest discover -s tests -p "test_docs_*.py"` pass. - `python -I scripts/check_no_game_data.py` on every changed file passes. - **Red/green:** `python -I scripts/red_green.py nopixels-diagnostics` gives `verdict: 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. - A separate read-only reviewer agent (Claude Opus 5.5) audited the full diff; its findings were addressed and it was re-run on the fixes. 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 - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) 🤖 Generated with [Claude Code](https://claude.com/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 commented 2026-12-02 16:34:42 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-02T16:34:42Z.


Verified here: it applies on the current main and its integration test passes.

merge base 3c106eb2f (current main), head 1065952da
git apply on main   (5 files: ab.rs, draw.rs, tests/scissor.rs, findings.md, switches.md)

cargo test -p leonida-gpu --test scissor
  a_scissor_leaves_only_its_own_pixels ... ok
  test result: ok. 1 passed; 0 failed

The test is the right shape for the switch: LEONIDA_EXP_NO_PIXELS empties 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 BLOCKED and the documentation files are in the change, so d3d12_switches.py --check is 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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7352149515 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3164#issuecomment-7352149515). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-02T16:34:42Z. --- **Verified here: it applies on the current `main` and its integration test passes.** ``` merge base 3c106eb2f (current main), head 1065952da git apply on main (5 files: ab.rs, draw.rs, tests/scissor.rs, findings.md, switches.md) cargo test -p leonida-gpu --test scissor a_scissor_leaves_only_its_own_pixels ... ok test result: ok. 1 passed; 0 failed ``` **The test is the right shape for the switch**: **`LEONIDA_EXP_NO_PIXELS` empties 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 **`BLOCKED`** and the documentation files are in the change, **so `d3d12_switches.py --check` is 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 commented 2026-12-02 18:18:11 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T18:18:11Z.


Verification of #3164 (third party, code review on Linux; not built: Windows-only leonida-gpu)

  • Head verified: 1065952da5fb0f12c354d8782568132c22c836ed (5 files: ab.rs, draw.rs, new tests/scissor.rs,
    findings.md, switches.md; +326/-17).
  • Merge base 3c106eb2f. git merge-tree --write-tree origin/main pr/3164 against main 45dc41f95 is clean
    (21 commits behind).
  • CI: no check runs on this head (fork workflows waiting for approval).
  • python -I scripts/check_no_game_data.py on the 5 files (on the merge): exit 0.

Review

  • Cause: main emptied scissors only inside draw::scissors, that is, only when the title set one. Draws that
    ran 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) and
    the three other draw paths. This fixes the cause rather than adding another special case to scissors().
  • Early exits: I checked the mesh site (draw.rs:5391-5403) and the indirect site (:6905-6930). There is no
    ? or return between the two calls, so a list never keeps empty scissors. The ordering with
    mesh_scissor (LEONIDA_EXP_MESH_ONE_PIXEL) is right: one-pixel scissor, emptied, title's scissors back,
    then mesh_scissor(false).
  • Hot path: everything new is under #[cfg(feature = "diagnostics")]. Release builds compile no_pixels to
    false, and pixels_back(.., false) is a branch. In diagnostics builds each draw does one relaxed atomic add
    and one ab::pick.
  • Reach: a draw before the title set any scissor in the list is left alone (self.scissors.is_empty()). The new
    graphics_draws / draws_without_pixels counters in the A/B line show how much is missed. That is the right
    instrument, per AGENTS.md "check the instrument".
  • tests/scissor.rs tests the driver, not the port. Its own header says it "cannot fail on the port's side", so
    there is no red/green for the draw.rs change. The counters and the findings.md run are the evidence. That
    is acceptable for a diagnostics-only timing switch, and the body is honest about it.

Process

  • Claim and AI disclosure (Claude Opus 5.5 and a reviewer) are present. fiestorra ran the scissor test on native
    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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7354327593 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3164#issuecomment-7354327593). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T18:18:11Z. --- **Verification of #3164 (third party, code review on Linux; not built: Windows-only `leonida-gpu`)** - Head verified: `1065952da5fb0f12c354d8782568132c22c836ed` (5 files: `ab.rs`, `draw.rs`, new `tests/scissor.rs`, `findings.md`, `switches.md`; +326/-17). - Merge base `3c106eb2f`. `git merge-tree --write-tree origin/main pr/3164` against `main` `45dc41f95` is clean (21 commits behind). - CI: no check runs on this head (fork workflows waiting for approval). - `python -I scripts/check_no_game_data.py` on the 5 files (on the merge): exit 0. **Review** - Cause: `main` emptied scissors only inside `draw::scissors`, that is, only when the title set one. Draws that ran 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`) and the three other draw paths. This fixes the cause rather than adding another special case to `scissors()`. - Early exits: I checked the mesh site (`draw.rs:5391-5403`) and the indirect site (`:6905-6930`). There is no `?` or `return` between the two calls, so a list never keeps empty scissors. The ordering with `mesh_scissor` (`LEONIDA_EXP_MESH_ONE_PIXEL`) is right: one-pixel scissor, emptied, title's scissors back, then `mesh_scissor(false)`. - Hot path: everything new is under `#[cfg(feature = "diagnostics")]`. Release builds compile `no_pixels` to `false`, and `pixels_back(.., false)` is a branch. In diagnostics builds each draw does one relaxed atomic add and one `ab::pick`. - Reach: a draw before the title set any scissor in the list is left alone (`self.scissors.is_empty()`). The new `graphics_draws` / `draws_without_pixels` counters in the A/B line show how much is missed. That is the right instrument, per AGENTS.md "check the instrument". - `tests/scissor.rs` tests the driver, not the port. Its own header says it "cannot fail on the port's side", so there is no red/green for the `draw.rs` change. The counters and the `findings.md` run are the evidence. That is acceptable for a diagnostics-only timing switch, and the body is honest about it. **Process** - Claim and AI disclosure (Claude Opus 5.5 and a reviewer) are present. fiestorra ran the scissor test on native 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](https://claude.ai/code)_
Kal0s-design commented 2026-12-02 20:43:58 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Kal0s-design on 2026-12-02T20:43:58Z.


Ran natively on Windows 11, head 1065952da merged into current main (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)

main merge
cargo test -p leonida-gpu --features diagnostics, lib 784 pass, 59 ignored 784 pass, 59 ignored
same, tests/replay.rs 1 1
same, tests/scissor.rs not there 1 pass
cargo test -p leonida-gpu --lib without diagnostics 703 pass, 59 ignored 703 pass, 59 ignored
cargo clippy -p leonida-gpu --all-targets, with / without diagnostics 10 / 0 warnings same, none in the changed files

tests/scissor.rs copied onto main passes 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.md passes on the merge, which answers fiestorra's point. test_d3d12_switches.py passes and check_no_game_data.py on the 5 files exits 0. test_docs_python_deps errors here (f-string SyntaxError) on main as 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. DrawInstanced and ExecuteIndirect with a DRAW signature gave the same numbers. The card and WARP matched too, apart from the two cells marked WARP.

full scissor empty scissor
render target texels written 64 0
depth / stencil texels changed 64 / 64 0 / 0
occlusion query 64 0
PS UAV writes / PSInvocations 64 / 64 (WARP 80) 0 / 0
VS UAV writes / VSInvocations 3 / 3 3 / 3
GS UAV writes / GSInvocations 1 / 1 1 / 1
clipper invocations / primitives 1 / 1 (WARP 1 / 3) same
stream-out primitives written, filled size 1, 48 bytes 1, 48 bytes

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_messages drains the queue at every submit and turns each message into a tracing::warn. So with LEONIDA_D3D12_DEBUG=1 and 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 in LEONIDA_AB would be cheap, or one line in switches.md would do.

Code (read)

On the title's runtime path, every host DrawInstanced, DrawIndexedInstanced, DispatchMesh and ExecuteIndirect is one of the five wrapped sites in draw.rs. The other hits are the port's own passes (compose, trainer overlay, record_plane_pass), the startup dispatch probe ask_wide, tests and benches, and the capture player in replay/play.rs. The title's list has no ExecuteBundle handler, so there's no bundle path to cover. All title scissors go through set_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 between no_pixels and pixels_back either. After a list cut replay() 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_scissor now restores widened rects when LEONIDA_SCISSOR_TEST=full and mesh mode 2 are both set. LEONIDA_MESH_TEST=scissor works without diagnostics, so that one combination changes in normal builds too.

The A/B counters fit the claim. graphics_draws counts calls, so an ExecuteIndirect of N records counts once and the 4,900 a frame are calls, not records. ON phases also add two RSSetScissorRects per 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.md or switches.md, only #2958 gets a new conflict from this one. It's in draw.rs at the DrawIndexedInstanced site, on adjacent lines, and keeping both sides fixes it. The others that conflict already conflict with main in 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).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7358224992 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3164#issuecomment-7358224992). Originally posted by [Kal0s-design](https://github.com/Kal0s-design) on 2026-12-02T20:43:58Z. --- Ran natively on Windows 11, head `1065952da` merged into current `main` (`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) | | main | merge | |---|---|---| | `cargo test -p leonida-gpu --features diagnostics`, lib | 784 pass, 59 ignored | 784 pass, 59 ignored | | same, `tests/replay.rs` | 1 | 1 | | same, `tests/scissor.rs` | not there | 1 pass | | `cargo test -p leonida-gpu --lib` without diagnostics | 703 pass, 59 ignored | 703 pass, 59 ignored | | `cargo clippy -p leonida-gpu --all-targets`, with / without diagnostics | 10 / 0 warnings | same, none in the changed files | `tests/scissor.rs` copied onto `main` passes 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.md` passes on the merge, which answers fiestorra's point. `test_d3d12_switches.py` passes and `check_no_game_data.py` on the 5 files exits 0. `test_docs_python_deps` errors here (f-string SyntaxError) on `main` as 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. `DrawInstanced` and `ExecuteIndirect` with a DRAW signature gave the same numbers. The card and WARP matched too, apart from the two cells marked WARP. | | full scissor | empty scissor | |---|---|---| | render target texels written | 64 | 0 | | depth / stencil texels changed | 64 / 64 | 0 / 0 | | occlusion query | 64 | 0 | | PS UAV writes / PSInvocations | 64 / 64 (WARP 80) | 0 / 0 | | VS UAV writes / VSInvocations | 3 / 3 | 3 / 3 | | GS UAV writes / GSInvocations | 1 / 1 | 1 / 1 | | clipper invocations / primitives | 1 / 1 (WARP 1 / 3) | same | | stream-out primitives written, filled size | 1, 48 bytes | 1, 48 bytes | 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_messages` drains the queue at every submit and turns each message into a `tracing::warn`. So with `LEONIDA_D3D12_DEBUG=1` and 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 in `LEONIDA_AB` would be cheap, or one line in switches.md would do. Code (read) On the title's runtime path, every host `DrawInstanced`, `DrawIndexedInstanced`, `DispatchMesh` and `ExecuteIndirect` is one of the five wrapped sites in `draw.rs`. The other hits are the port's own passes (compose, trainer overlay, `record_plane_pass`), the startup dispatch probe `ask_wide`, tests and benches, and the capture player in `replay/play.rs`. The title's list has no `ExecuteBundle` handler, so there's no bundle path to cover. All title scissors go through `set_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 between `no_pixels` and `pixels_back` either. After a list cut `replay()` 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_scissor` now restores widened rects when `LEONIDA_SCISSOR_TEST=full` and mesh mode 2 are both set. `LEONIDA_MESH_TEST=scissor` works without `diagnostics`, so that one combination changes in normal builds too. The A/B counters fit the claim. `graphics_draws` counts calls, so an `ExecuteIndirect` of N records counts once and the 4,900 a frame are calls, not records. ON phases also add two `RSSetScissorRects` per 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.md` or `switches.md`, only #2958 gets a new conflict from this one. It's in `draw.rs` at the `DrawIndexedInstanced` site, on adjacent lines, and keeping both sides fixes it. The others that conflict already conflict with `main` in 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 commented 2026-12-02 21:01:22 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by EdenBendheim on 2026-12-02T21:01:22Z.


RUN (in-game RTX 3090 300 s stress gate, 14-PR combined batch) — PASS covering exact head 1065952da5fb0f12c354d8782568132c22c836ed.

  • Base & build: Merged cleanly via git merge --no-ff onto main b41763227 (diagnostics,dlss,mimalloc, exe_sha16 = c47eeb717f761d9d; changed-file clean-room scan exit 0; workspace test targets compiled).
  • Batch heads (14 PRs): #3200 d1a91afd1, #3198 80a627bb1, #3191 93b47ac9d, #3189 c182fc392, #3176 ae0075d9a, #3168 337388052, #3164 1065952da, #3146 ebc0253ff, #3124 64600ef0c, #3069 311d33a40, #3031 8df1bfce7, #3029 e49404808, #3054 ff53fd8b9, #3010 d645712a3.
  • Hardware & setup: Windows 11, Ryzen 9 5900X (32 GB RAM), NVIDIA GeForce RTX 3090 24 GB, driver 610.88, Series X profile, 2560x1440, -NoFrameGen, scripts/game-gate.ps1 (301.3 s in world, LEONIDA_EXP_NO_PIXELS off/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).
Metric 14-PR Batch (c47eeb717f761d9d) main b41763227 baseline (cf499737bf684f6a)
Gate verdict / exit PASS (clean, 0 reasons, 0 warnings) PASS (clean, 0 reasons, 0 warnings)
World time 301.3 s (4,504 frames) 305.6 s
Device lost / crashes / missed pipeline waits 0 / 0 / 0 0 / 0 / 0
Rendered FPS (median) / p95 frame time 20.10 FPS / 69.76 ms 19.13 FPS / 74.01 ms
Median draws/frame / longest present gap 8,048 / 5.222 s 7,983 / 2.358 s

Verdict: PASS for the 300 s default-off in-game stability gate on 1065952da. (We also plan a dedicated LEONIDA_AB=10,LEONIDA_EXP_NO_PIXELS RTX 3090 measurement next.)

(AI-assisted verification: gemini-4-neon + gpt-6.2-astra.)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7358675725 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3164#issuecomment-7358675725). Originally posted by [EdenBendheim](https://github.com/EdenBendheim) on 2026-12-02T21:01:22Z. --- **RUN (in-game RTX 3090 300 s stress gate, 14-PR combined batch)** — **PASS** covering exact head `1065952da5fb0f12c354d8782568132c22c836ed`. - **Base & build:** Merged cleanly via `git merge --no-ff` onto `main` `b41763227` (`diagnostics,dlss,mimalloc`, `exe_sha16 = c47eeb717f761d9d`; changed-file clean-room scan exit `0`; workspace test targets compiled). - **Batch heads (`14` PRs):** `#3200` `d1a91afd1`, `#3198` `80a627bb1`, `#3191` `93b47ac9d`, `#3189` `c182fc392`, `#3176` `ae0075d9a`, `#3168` `337388052`, `#3164` `1065952da`, `#3146` `ebc0253ff`, `#3124` `64600ef0c`, `#3069` `311d33a40`, `#3031` `8df1bfce7`, `#3029` `e49404808`, `#3054` `ff53fd8b9`, `#3010` `d645712a3`. - **Hardware & setup:** Windows 11, Ryzen 9 5900X (32 GB RAM), NVIDIA GeForce RTX 3090 24 GB, driver `610.88`, Series X profile, `2560x1440`, `-NoFrameGen`, `scripts/game-gate.ps1` (`301.3 s` in world, `LEONIDA_EXP_NO_PIXELS` off/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`). | Metric | 14-PR Batch (`c47eeb717f761d9d`) | `main` `b41763227` baseline (`cf499737bf684f6a`) | |---|---:|---:| | Gate verdict / exit | **PASS** (`clean`, `0` reasons, `0` warnings) | **PASS** (`clean`, `0` reasons, `0` warnings) | | World time | `301.3 s` (`4,504` frames) | `305.6 s` | | Device lost / crashes / missed pipeline waits | `0` / `0` / `0` | `0` / `0` / `0` | | Rendered FPS (median) / p95 frame time | `20.10 FPS` / `69.76 ms` | `19.13 FPS` / `74.01 ms` | | Median draws/frame / longest present gap | `8,048` / `5.222 s` | `7,983` / `2.358 s` | **Verdict:** **PASS** for the 300 s default-off in-game stability gate on `1065952da`. *(We also plan a dedicated `LEONIDA_AB=10,LEONIDA_EXP_NO_PIXELS` RTX 3090 measurement next.)* *(AI-assisted verification: `gemini-4-neon` + `gpt-6.2-astra`.)*
fiestorra commented 2026-12-02 23:54:02 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-02T23:54:02Z.


VERIFY-3164 — Windows nativo: la suite pasa, y el arreglo no tiene test porque el camino está tras un interruptor apagado

Own commit 1065952da — draw.rs (two code lines + doc), tests/scissor.rs (comments)

Ran at the head

cargo test -p leonida-gpu --lib draw     36 passed; 0 failed; 5 ignored

The change, and it is a real bug: pixels_off used self.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 inside if 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 constructible from 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.rs is "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

  • The LEONIDA_EXP_NO_PIXELS path: it needs a D3D12 device and a title's scissor list.
  • A suggestion, if the author wants one: a unit test can build the list state and call pixels_off with the switch forced on (an ab::pick seam), which would make this fix reachable by the suite.

Written with an AI assistant.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7362559472 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3164#issuecomment-7362559472). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-02T23:54:02Z. --- ## VERIFY-3164 — Windows nativo: la suite pasa, **y el arreglo no tiene test porque el camino está tras un interruptor apagado** | | | |---|---| | Own commit | `1065952da` — `draw.rs` (two code lines + doc), `tests/scissor.rs` (comments) | **Ran at the head** ``` cargo test -p leonida-gpu --lib draw 36 passed; 0 failed; 5 ignored ``` **The change, and it is a real bug**: `pixels_off` used `self.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 inside `if 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 constructible` from 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.rs` is **"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 - **The `LEONIDA_EXP_NO_PIXELS` path**: it needs a D3D12 device and a title's scissor list. - **A suggestion, if the author wants one**: a unit test can build the list state and call `pixels_off` with the switch forced on (an `ab::pick` seam), **which would make this fix reachable by the suite**. Written with an AI assistant.
Lanworm commented 2026-12-03 07:47:29 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Lanworm on 2026-12-03T07:47:29Z.


Thanks to everyone who verified this. e4dfc90 answers the three points raised:

  • A test that can fail on the fix (@fiestorra). The scissors State::no_pixels sets are now chosen by a small pure function, no_pixel_scissors(title, on) in draw.rs, covered by no_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.py cannot build the new test against main, where the function does not exist.
  • Debug layer (@Kal0s-design). When LEONIDA_EXP_NO_PIXELS is named in LEONIDA_AB, the host's info queue now gets a storage deny filter for D3D12_MESSAGE_ID_DRAW_EMPTY_SCISSOR_RECTANGLE (695). This is diagnostics builds only. It compiles and the suite passes; I have not run the port under LEONIDA_D3D12_DEBUG=1 to see the log stay quiet.
  • Counter wording (@Kal0s-design). The graphics_draws doc and findings.md now 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.
  • Without diagnostics: 696 passed.
  • test_d3d12_switches.py and check_no_game_data.py on the changed files: pass.

@EdenBendheim, thanks for the gate run; an LEONIDA_AB=10,LEONIDA_EXP_NO_PIXELS number 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).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7371432458 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3164#issuecomment-7371432458). Originally posted by [Lanworm](https://github.com/Lanworm) on 2026-12-03T07:47:29Z. --- Thanks to everyone who verified this. `e4dfc90` answers the three points raised: - **A test that can fail on the fix (@fiestorra).** The scissors `State::no_pixels` sets are now chosen by a small pure function, `no_pixel_scissors(title, on)` in `draw.rs`, covered by `no_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.py` cannot build the new test against `main`, where the function does not exist. - **Debug layer (@Kal0s-design).** When `LEONIDA_EXP_NO_PIXELS` is named in `LEONIDA_AB`, the host's info queue now gets a storage deny filter for `D3D12_MESSAGE_ID_DRAW_EMPTY_SCISSOR_RECTANGLE` (695). This is diagnostics builds only. It compiles and the suite passes; I have not run the port under `LEONIDA_D3D12_DEBUG=1` to see the log stay quiet. - **Counter wording (@Kal0s-design).** The `graphics_draws` doc and `findings.md` now 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. - Without diagnostics: 696 passed. - `test_d3d12_switches.py` and `check_no_game_data.py` on the changed files: pass. @EdenBendheim, thanks for the gate run; an `LEONIDA_AB=10,LEONIDA_EXP_NO_PIXELS` number 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 commented 2026-12-03 08:00:06 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-03T08:00:06Z.


RUN (in game, one pull request), its head merged with git merge --no-ff onto main d9b618f10: #3164 e4dfc9012. 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.

What Result
Device lost / device removed 0
Exceptions, panics, hang watchdog, GPU stall, title suspended 0
Process alive at the end yes, stopped by the time limit
Rendered fps, last 240 s (48 samples) median 15.1, mean 14.6
Rendered fps, last 120 s median 14.7
Time under 5 fps in the world 3 %

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; -PrecompileUsed was used, so the default start (every known pipeline precompiled) was not exercised. LEONIDA_EXP_NO_PIXELS is 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).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7371694179 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3164#issuecomment-7371694179). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-03T08:00:06Z. --- RUN (in game, one pull request), its head merged with `git merge --no-ff` onto main `d9b618f10`: #3164 `e4dfc9012`. 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. | What | Result | |---|---| | Device lost / device removed | 0 | | Exceptions, panics, hang watchdog, GPU stall, title suspended | 0 | | Process alive at the end | yes, stopped by the time limit | | Rendered fps, last 240 s (48 samples) | median 15.1, mean 14.6 | | Rendered fps, last 120 s | median 14.7 | | Time under 5 fps in the world | 3 % | 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; `-PrecompileUsed` was used, so the default start (every known pipeline precompiled) was not exercised. `LEONIDA_EXP_NO_PIXELS` is 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 commented 2026-12-03 08:04:38 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-03T08:04:38Z.


Rechecked e4dfc901 merged onto main d9b618f1. The Windows MSVC diagnostics build under Wine 11.22 ran the draw suite with 28 passes and three existing ignores, including no_pixels_empties_the_titles_scissors_only. A scratch control restored the original lower clamp inside no_pixel_scissors and kept the new test. It failed on the zero-scissor case: Some([RECT { 0, 0, 0, 0 }]) instead of None. The debug-layer filter compiled in the diagnostics build. The execution check here covered the scissor regression.

I also paired this head with #3291 6b0ee46b and 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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7371791473 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3164#issuecomment-7371791473). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-03T08:04:38Z. --- Rechecked `e4dfc901` merged onto `main` `d9b618f1`. The Windows MSVC diagnostics build under Wine 11.22 ran the draw suite with 28 passes and three existing ignores, including `no_pixels_empties_the_titles_scissors_only`. A scratch control restored the original lower clamp inside `no_pixel_scissors` and kept the new test. It failed on the zero-scissor case: `Some([RECT { 0, 0, 0, 0 }])` instead of `None`. The debug-layer filter compiled in the diagnostics build. The execution check here covered the scissor regression. I also paired this head with #3291 `6b0ee46b` and 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.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3164:upstream-pr/3164'
git switch 'upstream-pr/3164'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3164'
git switch 'upstream-pr/3164'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3164'
git switch 'upstream-pr/3164'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3164'
git switch 'main'
git merge --squash 'upstream-pr/3164'
git switch 'main'
git merge --ff-only 'upstream-pr/3164'
git switch 'main'
git merge 'upstream-pr/3164'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!3164
No description provided.