Repository navigation
GPU: the indirect window's bound arithmetic was untestable and untested - #862
HailLucifer666 wants to merge 2 commits into
Conversation
272ce13 to
eca8b0f
Compare
|
Rebased onto #169 ( That order is not a preference, it is a fact I checked rather than assumed: The composition here keeps both: #169's bypass arm is the Gate on the combined result ( The full-suite number is the important one: 181 passed is |
|
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 AI-assisted (Claude Code); no game data. |
3c1acba to
d21c08b
Compare
d21c08b to
f63b279
Compare
|
Rebased onto the new |
What 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.