GPU: the indirect window's bound arithmetic was untestable and untested #862
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/fxceless--victory-fork!862
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-862"
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?
@HailLucifer666 on GitHub · 2026-11-25 11:00 UTC · original
HailLucifer666:perf/indirect-window-batching→main· +303 −21 · 2 files · 2 commits · openWhat this is
windowsdecides, from five numbers, whether an indirect record is already clamped in the window and how many records to clamp next. That decision lived inline inState::execute_indirect, behind a live D3D12 device:draw.rshad no test module, and the only test of the clamp path is a WARP test that returns early and passes when WARP cannot start. Its own checker found the last real defect in it (README.md: one list drawing 90 records of 2^24 vertices from a window), and that checker is device-bound too.This pulls the decision out as
serve(declared_stride, declared_records, offset, left, previous, most) -> Serve, total on every input, with 20 tests that need no card.State::execute_indirectkeeps its behaviour, and the gap the checker covers is untouched:check_hitstill runs on the held path, with the step taken from the same window the record was served from.What it does not claim
VICTORY_INDIRECT_WINDOWstays off by default, asREADME.mdsays.bound,bound_ahead, the clamp shader, the WARP skip) is untouched and still untested here.draw.rschanges. The WARP false green inindirect.rsis named, not fixed; fixing it belongs in that file.Behaviour
Identical on every reachable input. Three inputs changed, none reachable: a window with
step == 0(never stored) used to divide by zero and now falls through to the clamp; a window withrecords == 0(never stored) used to underflowrecords - 1; a record count nearu32::MAXnow doubles saturating instead of wrapping.recordsis a parameter rather than a hardcoded1because the first draft of this extraction clamped one record for a call that asked for several — five records would have executed five entries out of a scratch buffer holding one. A test now pins that, and the fallback carries the declared count unchanged, including0.Gates, on
f85101b6The single failure is
inplace::tests::warp_a_title_buffer_in_place_shows_its_bytes_at_its_offset, which fails the same way in a full run onf85101b6without this change (158 passed, 1 failed) and passes when run alone. It is not in a file this PR touches.Six mutation probes, each confirmed present with a diff before its run and each red for the stated reason, are recorded in the test module's header with their exact failing tests.
Attribution
The front-end bottleneck this exists to serve was measured by @dkdknight on an RTX 5080: about 5,000 one-record indirect mesh draws a frame with SM issue around 4%. This PR does not fix that. It makes the arithmetic that safe batching depends on testable on any machine.
A seventh defect, found while probing the sixth (wave 0.1)
servenarrowed the walked step back to the title's declared 12-byte record and thenfloored the record count at one (
want.min(fit).max(1)). Withleftbetween 1 and 31bytes,
fit = left / 32is 0, and that floor turned "no room for a walked record" into"open a window of one" — a 32-byte read where as few as 1 byte remained in the copy.
Nothing faults. D3D12 does not fault an out-of-bounds read inside a buffer, so the bytes
came from further along the same copy and reached
ExecuteIndirectas a silently wrongargument. Nothing in the log would ever have shown it.
The window is now opened only when a whole walked record fits; otherwise the copy keeps its
declared stride.
.max(1)survives only for the case it was written for, a window thatrecorded no records at all.
a_walk_wider_than_the_room_left_is_not_a_walk—left = 31→step: 12;left = 32still opens the window.
a_cap_of_zero_falls_back_to_the_declared_stride— replaces the old name, which assertedthe widening.
byte-identical.
A gate, so a suite that runs nothing cannot report green
Seven indirect tests began
let Some(mut warp) = WarpHarness::new() else { return; };, soon a host with no software adapter they passed having run nothing. They now demand the
adapter, and
cargo xtask test-gatefails a run that executed no tests, a run whoseannounced count disagrees with its reported one (how ignored tests used to vanish from the
total), and any
WarpHarness::new()inindirect.rswithout the.expect.This is not padding: it is the mechanism that would have caught the original problem, which
was a test that reported on arithmetic it never exercised.
Honest status of the suite on this head
cargo test -p victory-gpu --lib -- --test-threads=1— 159 passed, 1 failed, 4 ignored,the failure being
indirect::tests::warp_budget_saturates_without_wraparound_and_preserves_draw_fields,which fails on
f85101b6too and is fixed by #849/#847. Measured across six runs with andsix without these changes: 3 failures each. A single green suite run here is a coin flip and
should not be quoted as evidence.
085ee7c4d21c08ba4d@HailLucifer666 on GitHub · 2026-11-25 11:40 UTC · original
Rebased onto #169 (
eb568071) — this is now headeca8b0f2and must land after #169, not before.That order is not a preference, it is a fact I checked rather than assumed:
git merge-treebetween the two heads reported a real conflict indraw.rs, because #169 wrapsif !clamped { … } else { … }around exactly the window block this PR extractsserve()out of. Landing #862 first leaves #169 wrapping a block that no longer exists in that shape; the reverse order survives.The composition here keeps both: #169's bypass arm is the
!clampedside, and this PR'sserve()-based window logic is theclampedside, unchanged —Serve::Held/Serve::Clamp, thewindow_checkdiagnostics on the held path,bound_ahead, and the 20 device-free window-arithmetic tests all intact. #169's twodone()barriers stay, now overbounded(this PR's binding) rather thanexec_buf.Gate on the combined result (
main+#169+ this), which is the thing that will actually be shipped:The full-suite number is the important one: 181 passed is
main's 161 plus this PR's 20, with zero failures — so the extraction and the bypass do compose at runtime, not just at merge time.@MamaLeVrai on GitHub · 2026-11-25 12:23 UTC · original
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
eca8b0fintomainf85101bin a throwaway tree (no conflict).cargo clippy --workspace --all-targets --locked -- -D warningsfails with exactly the errorsmainitself 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: 577 passed, 0 failed, 11 ignored; run 2: stopped atindirect::tests::warp_budget_saturates_without_wraparound_and_preserves_draw_fields(the one that fails onmainitself most runs here (PR #849 and #847 fix its assertion)) (mainalone: 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.
d21c08ba4dtof63b279bf1@HailLucifer666 on GitHub · 2026-11-26 14:03 UTC · original
Rebased onto the new
#169head (d41db98d); this head is nowf63b279b. One conflict, in thedraw.rstest module: main addeda_bake_draw_names_the_indices_of_its_constants_and_recordswhere this PR adds itsserve()tests, so both are kept. Verified:victory-gpu draw::tests23 passed, 0 failed;clippy -D warningson victory-gpu clean. Merge after#169, as the description says.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.