GPU: the compare of card copies hashes each 64 KiB piece with a group of threads (a pass 0.2-0.8 ms -> 0.002-0.11 ms on an RTX 5090) #992
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!992
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-992"
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?
@PiloteCode on GitHub · 2026-11-25 15:20 UTC · original
PiloteCode:pr/card-compare→main· +295 −27 · 9 files · 5 commits · openBased on
0b0074e0. Three commits:Two clippy fixes for
main, without whichcargo clippy --workspace --all-targets -- -D warningsfails on0b0074e0, with or without--all-features:unnecessary_sort_byindraw.rs, the bench'sdepth_writtennever read,placed_filler_twinsunused without diagnostics;manual_is_multiple_ofinshadow.rs, which came withmain's later sessions.Our other open PRs carry the same two changes, so they merge in any order.
The change, in
host.rs(CARD_COMPARE) and the tests inindirect.rs.What was wrong
The hash and compare passes over host copies in the card's memory (
CARD_COMPARE: the pieces sent up before each submission, and the declared ranges after it) gave each 64 KiB piece one thread. That thread walked the piece's 4,096 steps of 16 bytes one after the other, so a pass took as long as one such walk, however few pieces it had.The gameplay runs some 270-350 hash passes and about 100 compares a frame, around its ~34 submissions, each behind barriers (1,240-1,380 barriers a frame in timing runs). The timing run's command times never included these passes, so this card time did not show anywhere.
What changes
A group of 256 threads takes a piece:
Both forms flag a piece whose widened bytes changed.
VICTORY_CARD_WIDE_HASH=0keeps the one-thread form; every pass of a run uses the same form.Measured
RTX 5090, a bench of the shader as it was against this form:
In the bench on the card, one changed byte flagged its own piece only. The frame time was not measured with this change alone.
Switches
VICTORY_CARD_WIDE_HASH=0: one thread a piece, as before.Tested
The branch was checked as it is, on
0b0074e0, on the software adapter (the card was taken by other work):cargo test -p victory-gpu --features diagnostics -- --test-threads=1withVICTORY_D3D12_WARP=1: 185 passed, 3 failed, 6 ignored. None of the three is near this change:depth_bounds_pipeline_loads_and_filters_draws: WARP does not reject the pixels outside the depth bounds;warp_budget_saturates_without_wraparound_and_preserves_draw_fields:main's test that #849 and #970 fix, in which the two groups may charge the budget in either order. Run alone three times, it failed twice;profile::tests::the_sampler_finds_threads_and_writes_its_files: run alone three times, it passed each time.Every card-compare test passed, among them the two that run both forms.
cargo clippy --workspace --all-targets --locked -- -D warnings, and the same with--all-features: clean.cargo build --release -p victory,cargo build --profile diag -p victory --features diagnosticsandcargo xtask policypass.New and changed tests:
Overlaps with open pull requests
This PR changes only the hash and compare pass: 256 threads a piece, the old form kept behind a switch, and no change to what is fetched or how.
Not tested
c36971b2) into the card-compare branch: upstream's frame capture, changed-bytes refresh, small buffers on the card and the hashed length; no conflict cf761c5294@PiloteCode on GitHub · 2026-11-25 22:11 UTC · original
Merged
main(c36971b) into the branch: a merge commit on top of the commits already here (cf761c5), then one lint commit. No conflict.Where both sides changed the same code.
main'sc36971band this branch both change the two hash and compare passes ofhost.rs, two lines apart.maingives the pass the bytes its hashes cover (Shadow::card_hashed: the copy's whole buffer, or the title buffer's own bytes withVICTORY_CARD_HASH_LEN=1). This branch dispatches a group a piece (card_groups). The merge has both, and both forms of the compare read that length the same way: a piece ends at it, widened to 16 bytes.VICTORY_CARD_HASH_LEN=1has not been run with the group form: it is off by default, and the tests hash whole buffers.main's notes forc36971bname the cost this PR is about: with every buffer's copy on the card (VICTORY_CARD_BUFFERS_MIN_KB=64), each small copy is hashed over a whole 64 KiB, and the send-and-hash lists rose from 11.6 to 23.0 ms a frame. In the group form, such a piece is 17 loads for each of 256 threads, not 4,096 loads of one thread in a row. How much of the 23.0 ms that takes back is not measured: this branch has not run on the card since the merge.Added after the merge: one lint commit for
main's newer code, the same as on our other open branches:map_entryinfpsbox.rs,collapsible_ifinpipeline/library.rs,manual_is_multiple_ofinqueue.rs,shadow.rs,draw.rsandwatch.rs. Without itcargo clippy --workspace --all-targets --locked -- -D warningsfails onc36971b, with or without--all-features.Checked, the branch as it is (
ad50dc6), every test on the software adapter:cargo clippy --workspace --all-targets --locked -- -D warnings, and the same with--all-features: clean.cargo xtask policy,cargo build --release -p victoryandcargo build --profile diag -p victory --features diagnostics: pass.cargo test -p victory-gpu --features diagnostics -- --test-threads=1withVICTORY_D3D12_WARP=1: 202 passed, 1 failed, 6 ignored. The failure isdepth_bounds_pipeline_loads_and_filters_draws, as onmain(200 passed, 1 failed, 6 ignored): WARP does not reject the pixels outside the depth bounds. The card-compare tests pass (card_compare_forms_flag_alike_on_the_card,warp_card_compare_sees_each_step_of_a_widened_piece,warp_card_compare_stores_the_hash_it_made_when_told). The two other failures of the description's run (warp_budget_saturates_without_wraparound_and_preserves_draw_fieldsand the profile sampler's test) did not come back in this run.cargo test -p victory-shader -- --test-threads=1withVICTORY_WARP=1: 212 passed, 4 failed, 3 ignored, the same four as onmainon the software adapter.cargo test -p victory-hle -- --test-threads=1: 100 + 1 passed, as onmain.cargo test -p victory -p victory-loader: passed.@PiloteCode on GitHub · 2026-11-25 22:54 UTC · original
@Flyander thanks, this is the measurement the description did not have: the pass on a second Blackwell GPU against
mainand the three other parallel forms in one executable, and then in the title.For the record of this PR:
main; at 1,024 pieces the parallel forms meet (67.8–81.4 µs);As you say, the card-list times are the confirmed part and the frame rate of one pair of runs is an observation.
VICTORY_CARD_WIDE_HASH=0stays as the switch back to the serial form.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.