Skip to content

Tests: the warp budget test accepts either group winning the budget race - #847

Open
Roy-0406 wants to merge 1 commit into
fxceless:mainfrom
Roy-0406:fix/warp-budget-group-race
Open

Roy-0406 wants to merge 1 commit into
fxceless:mainfrom
Roy-0406:fix/warp-budget-group-race

Conversation

@Roy-0406

Copy link
Copy Markdown

indirect::tests::warp_budget_saturates_without_wraparound_and_preserves_draw_fields fails intermittently.

Cause. The test clamps 128 records, two groups of 64. The clamp shader charges records in lane order within a group, but the two groups race for the budget word with a compare and swap (indirect.rs, the while (before < BUDGET) loop). Whichever group charges first keeps its first two real draws: records 1 and 2, or 64 and 65. The test required 1 and 2.

Measured on WARP (RTX 4070 machine, single test thread): the old test failed in 8 of 10 runs on its own; with a temporary log of the kept record, every failure kept record 64. In the full suite it passed more often, which is why it slips through.

Change. The test accepts [1, 2] or [64, 65] and names the records kept when it fails. Everything else it checks is unchanged: the budget saturates without wrapping, the source is untouched, every other draw is emptied, and the remaining fields of every record are kept. The shader is not touched.

Proof. The fixed test passes 20 of 20 runs alone; cargo test -p victory-gpu --lib passes 3 of 3 (159 passed); cargo xtask policy --staged ok.

Note on CI. Both clippy jobs already fail on main without this change (placed_filler_twins never used, sort_unstable_by_key in draw.rs, depth_written never read); #841 fixes those.

Not in this PR, seen while testing: watch::tests::a_write_is_reported_at_every_checked_view failed once in 10 parallel runs of the GPU tests (0 of 15 serial), and one parallel run of the GPU test binary ended in 0xc0000005 (not reproduced in 10 more runs).

🤖 Generated with Claude Code

warp_budget_saturates_without_wraparound_and_preserves_draw_fields clamps
128 records, two groups of 64. The clamp charges records in lane order
within a group, but the two groups race for the budget word with a compare
and swap, so whichever group charges first keeps its first two real draws:
1 and 2, or 64 and 65. The test required 1 and 2 and failed in 8 of 10
runs on its own here (WARP, single test thread); the group that won was
group 1 every time it failed.

The test now accepts either pair and names the records kept when it fails.
Everything else it checks is unchanged: the budget saturates without
wrapping, the source is untouched, every other draw is emptied and the
remaining fields of every record are kept. 20 of 20 runs pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MamaLeVrai

Copy link
Copy Markdown

Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present. I merged this PR's head 520179a into main f85101b in a throwaway tree (no conflict). cargo clippy --workspace --all-targets --locked -- -D warnings fails with exactly the errors main itself has on this machine (placed_filler_twins, depth_written, a sort; PR #841 fixes them), also with --all-features; this PR adds none. cargo test --workspace --locked: run 1: 555 passed, 0 failed, 11 ignored; run 2: 555 passed, 0 failed, 11 ignored (main alone: 555 passed, 0 failed, 11 ignored). The title was not run, so this says nothing about in-game effect. No game data.

AI-assisted (Claude Code); no game data.

HelmXGaming added a commit to HelmXGaming/victory-fork that referenced this pull request Nov 25, 2026
…copy queue, indirect windows, profiler; all behind switches)

Brings in 9376fd6 too. On this NVIDIA laptop 9376fd6 hung the device
twice by default (its write-watch shortcut, fxceless#670); VICTORY_VIEW_ASK=1
avoided it. Test with that set.

Conflict in indirect.rs, kept from both sides:
- The clamp shader keeps upstream's per-group budget charge and its
  MOST_DRAW guard, and this side's dispatch in parts (SPLIT records for
  one compute dispatch past 65,535 groups in x, the prologue's indirect
  light gather). This side's wide-dispatch counters in budget words 3-4
  are dropped: upstream no longer reads or zeroes them.
- clamp_into (upstream's state-tracked scratch) takes this side's `how`
  bits (AHEAD, IN_PARTS) instead of a bool; bound_split goes through it.
- The split test reads back like upstream's tests (INDIRECT_ARGUMENT ->
  COPY_SOURCE).

cargo test -p victory-gpu --lib indirect:: texture:: watch:: : 30 passed,
1 failed (warp_budget_saturates_..., the upstream race between two groups
that fxceless#847 describes; not this merge), 2 ignored.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
HailLucifer666 added a commit to HailLucifer666/victory-fork that referenced this pull request Nov 25, 2026
The switch this branch added turned the clamp pass off so `ExecuteIndirect`
could read the title's own argument buffer. `dkdknight` ran it on an RTX
5080, twice, and both runs died with `0xc0000005` writing `0x0` within
seconds. That is the answer the switch deserved: the title's argument
records contain bounds the pass is what enforces, so "read them directly"
is not a fast path, it is a crash with a longer name.

So `0` no longer means "bypass". `clamp_setting` returns `(clamp on, say
so)` and the clamp is on whatever is asked; a run that asked is told once,
with the reason and with what actually answers its complaint. `clamp_is_on`
is consulted where the clamp is first made, so the refusal is spoken even
in a run that never reaches the pass.

That leaves no path for the bypass, so the code is gone rather than
unreachable: the `if !clamped` branch in `draw.rs` and the two `if clamped`
teardowns go with it, and so does `wait_direct`, which existed only to put
a barrier in front of an unclamped execute. Dead code behind a switch that
is now always true is a lie about what the program can do.

The cost the switch was chasing is real -- about five thousand one-record
indirect mesh draws a frame, and SM issue at 4% in `dkdknight`'s Nsight
capture -- and the answer to it is hoisting the clamps out of the
per-record path (`VICTORY_HOIST_CLAMPS`, Phase I), which keeps the bounds
check and stops paying for it once per record.

Probe: `clamp_setting` returns `parse_clamp_enabled(asked)` again -> the new
test fails with `left: (false, true), right: (true, true)` -> restored
byte-identical (sha256 ade38ee886e354e5).

cargo test -p victory-gpu --lib: 161 passed, 1 failed -- the failure is
`warp_budget_saturates...`, the pre-existing flake (fxceless#847/fxceless#849), on a test
this commit does not touch. cargo clippy -p victory-gpu --lib -D warnings:
only the two pre-existing fxceless#841 errors remain.
@HailLucifer666

HailLucifer666 commented Nov 25, 2026 •

Copy link
Copy Markdown

Evidence from a fourth machine (Windows, WARP, this repo's own suite), and one thing your two PRs between them have established that neither body says: this is a regression, not a missing nicety.

main already had an order-independent version of this test — (kept, zeroed) == (2, 126), naming no indices — from 578d459c. f85101b6 (Frame rate, second night) changed that block back to assert!(i == 1 || i == 2, ...), so every branch built on it inherits the failure.

Measured: full suite, four processes at a time, twelve runs on f85101b6 without the patch — 2 of 12 failed with panicked at indirect.rs:1611: the first two real draws fit the budget. With the patch applied, 0 of 12. Idle and serial runs never reproduce it (34 runs clean), which is why it looked machine-specific.

I have opened #970 taking MamaLeVrai's #849 verbatim so the branches under review have it; if #847 lands instead it is equivalent and #970 can be closed unmerged. Credit for the diagnosis is entirely yours — two people on two machines reaching the same cause is stronger evidence than either measurement alone.

HailLucifer666 added a commit to HailLucifer666/victory-fork that referenced this pull request Nov 25, 2026
The switch this branch added turned the clamp pass off so `ExecuteIndirect`
could read the title's own argument buffer. `dkdknight` ran it on an RTX
5080, twice, and both runs died with `0xc0000005` writing `0x0` within
seconds. That is the answer the switch deserved: the title's argument
records contain bounds the pass is what enforces, so "read them directly"
is not a fast path, it is a crash with a longer name.

So `0` no longer means "bypass". `clamp_setting` returns `(clamp on, say
so)` and the clamp is on whatever is asked; a run that asked is told once,
with the reason and with what actually answers its complaint. `clamp_is_on`
is consulted where the clamp is first made, so the refusal is spoken even
in a run that never reaches the pass.

That leaves no path for the bypass, so the code is gone rather than
unreachable: the `if !clamped` branch in `draw.rs` and the two `if clamped`
teardowns go with it, and so does `wait_direct`, which existed only to put
a barrier in front of an unclamped execute. Dead code behind a switch that
is now always true is a lie about what the program can do.

The cost the switch was chasing is real -- about five thousand one-record
indirect mesh draws a frame, and SM issue at 4% in `dkdknight`'s Nsight
capture -- and the answer to it is hoisting the clamps out of the
per-record path (`VICTORY_HOIST_CLAMPS`, Phase I), which keeps the bounds
check and stops paying for it once per record.

Probe: `clamp_setting` returns `parse_clamp_enabled(asked)` again -> the new
test fails with `left: (false, true), right: (true, true)` -> restored
byte-identical (sha256 ade38ee886e354e5).

cargo test -p victory-gpu --lib: 161 passed, 1 failed -- the failure is
`warp_budget_saturates...`, the pre-existing flake (fxceless#847/fxceless#849), on a test
this commit does not touch. cargo clippy -p victory-gpu --lib -D warnings:
only the two pre-existing fxceless#841 errors remain.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants