GPU: copystat counts its counters at compile time; range and drain tests (revives #1188) #2397
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!2397
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2397"
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?
@KainanP on GitHub · 2026-11-25 12:44 UTC · original
KainanP:test/copystat-tests-919→main· +108 −22 · 1 files · 2 commits · openFixes #919.
This revives #1188 by geiyiliyabumo, which was closed because its
counter_enum_matches_array_lengthfailed onmainonce the counter list grew. Their commit (200f5ae) is cherry-picked unchanged onto currentmainwith their name kept on it. One commit of mine follows it (b7ce077) and reworks it per the triage of 2026-11-25. Their range-accumulation test stays, moved onto a local table.What changed after the triage (
crates/victory-gpu/src/copystat.rs)Cgets a last variantCount(documented as not a counter, keep it last), andconst COUNTERS: usize = C::Count as usize;. A counter added before it growsCOUNTwith it. Theinclude_str!test is gone. I choseCountoverC::SavedPages as usize + 1because with the+ 1form a counter appended afterSavedPageswould still need someone to update the constant.parse_mode_maps_known_and_unknown_values(and theparse_modesplit, somode()is back as onmain) andpage_faults_queries_current_process.Counters,Ranges, each withaddandtake), and the globalsCOUNT/RANGESare instances of them.log()drains them throughtake, the same swap-to-zero and sort-by-bytes as before. The tests build their own instances, so the GPU submission andwatchtests counting into the globals at the same time can't affect them. No lock needed:range_accumulates_same_key_and_separates_distinct_ranges: same key accumulates, distinct keys stay apart,takesorts by bytes and empties.take_drains_counters_per_frame: values divided per frame, every other counter zero, and the nexttakecounts from zero.frames <= 0guard dropped. The only caller isMeter::frameinhost.rs. It doesself.copy_stats_frames += 1before the 1 s / 5 s checks and then logsstd::mem::take(&mut self.copy_stats_frames) as f64, so the count is au64of at least 1 and can't be zero, negative or NaN.bindless::logandshadow::log_viewsget the same value unguarded. The guard's test is gone too.Tests, Windows 11 x64,
main940d32f+ these two commits.copystatonly builds with--features diagnosticson Windows (lib.rs):cargo test -p victory-gpu --features diagnostics --locked copystat: 2 passedvictory-gpusuite with--features diagnostics(GPU submission,host,shadowandwatchtests together with these), 5 runs: 146 passed, 0 failed each time. Two tests are skipped in those runs:descriptor::host::tests::dynamic_slots_are_held_until_releasedandmemory::tests::lists_share_a_table_and_copies_keep_their_views. They fail the same way on plainmain940d32fwith--features diagnosticson this machine (descriptor heap smaller thanHEAP_VIEWS), so the failure is not from this PR.copystat+watchfilter, 5 runs: 8 passed each timetakeusingloadinstead ofswap, the drain test fails. Withaddsetting the copy count instead of adding to it, the range test fails.cargo clippy --workspace --all-targets --locked -- -D warningsand the--all-featuresvariant: cleancargo xtask policy: asset policy, 182 files okmainare left alone.Not covered: CI runs
cargo test --workspacewithoutdiagnostics, so these tests still don't run there. Only the--all-featuresclippy job compiles them.200f5aeon its own still has its original tests and guard. The commits are kept separate to keep authorship.No game data used. AI use: Claude Code (Claude Opus 5.5).
🤖 Generated with Claude Code
@Marvisak on GitHub · 2026-11-25 15:01 UTC · original · edited 2026-11-25 18:28 UTC
Automated triage for the maintainers.
After the rebase,
crates/victory-gpu/src/copystat.rsgets the counter-array length from a trailingC::Countvariant instead of the hand-kept61. That61matches main's 61 counters today, but adding a counter without updating it would panic at runtime on indexing. The counter array and range table move into smallCounters/Rangestypes whoseadd/takekeep main's behaviour: swap-to-zero divided by frames, and a range table sorted by bytes and emptied.log()uses them unchanged otherwise. I found nomatchoverCthat the extra variant would break. The PR still merges cleanly with currentmain. The two tests use their own instances, so they cannot race the GPU tests that count into the globals.The points from the earlier triage (include_str test, tests that restated the code, the unreachable
frames <= 0guard) are addressed. The module only builds withdiagnostics, so CI compiles these tests in the--all-featuresclippy step but does not run them.CI:
checkpassing.Generated by Claude Code
@KainanP on GitHub · 2026-11-25 15:24 UTC · original
Thanks for the triage. Reworked in
b7ce077(force-pushed;200f5aeby geiyiliyabumo is kept as is):COUNTERS:Cnow ends with aCountvariant (not a counter, documented to stay last), andconst COUNTERS: usize = C::Count as usize;. Theinclude_str!test is gone. I usedCountrather thanC::SavedPages as usize + 1so that appending a counter needs no change to the constant.parse_mode_maps_known_and_unknown_values(plus theparse_modesplit, somode()is as onmain) andpage_faults_queries_current_processare dropped.Counters/Rangestypes withadd/take, and the globals are instances of them.log()drains throughtake. Both tests use their own instances, so the GPU andwatchtests counting into the globals can't race them. The whole--features diagnosticssuite passed 146/146 in 5 runs. Two tests are skipped:dynamic_slots_are_held_until_releasedandlists_share_a_table_and_copies_keep_their_views, which fail the same way on plainmainhere.Meter::frameincrementscopy_stats_framesbefore it can log and then passestake(..) as f64, so the count is always ≥ 1. I found no zero path.Clippy
-D warnings(default and--all-features) andcargo xtask policyare clean.@KainanP on GitHub · 2026-11-25 16:56 UTC · original
Rebased onto main
67e8ae14(conflict was main's new counters and CountingAlloc in copystat.rs; kept,Countstays last); copystat tests, clippy -D warnings (default/all-features) and xtask policy pass.AI use: Claude Code (Claude Opus 5.5).
@futurepro62 on GitHub · 2026-11-25 23:56 UTC · original
Full-suite run on NVIDIA, since this PR has no test report yet. Tested exact head
7dc8075(on its base67e8ae1).Tested
dxil.dllfrom Windows SDK 10.0.26100 (the loader's default), debug.cargo build --workspace --locked, thencargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 773 passed, 0 failed, 9 ignored.copystat, which only builds with thediagnosticsfeature, so the run above doesn't include them. Run on their own:cargo test -p victory-gpu --lib --locked --features diagnostics copystat:range_accumulates_same_key_and_separates_distinct_rangesandtake_drains_counters_per_framepass (2 passed, 0 failed).--skipleaves out tests that fail on main842b0cbon this card too, not because of this PR:heap_direct_texture_reads_mark_their_heap_indexends thevictory-shadertest process with0xc0000005(#2571), so without the skip the rest of that crate never reports;dynamic_slots_are_held_until_released,lists_share_a_table_and_copies_keep_their_viewsand the twostride_testshit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317);gathers_at_a_level_match_the_hardwarefails on lane 0 (#1744).Not tested
AI use
@catminou4 on GitHub · 2026-11-25 13:19 UTC · original · reviewed
copystat tests and guard for frames <= 0 (revives). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1.
@fuzeofficlal on GitHub · 2026-11-26 19:51 UTC · original · approved these changes
Reviewed and verified
7dc8075ef6929567f30a78d1db0bf8c5e388e28fmerged ontoorigin/main(63bcca43c6a00a758510398fa43096ce7e4f7df0) on Windows 11 x64 (RTX 5090 + Microsoft WARP, Rust 1.98.1 MSVC).Code Audit
const COUNTERS: usize = C::Count as usize(crates/victory-gpu/src/copystat.rs:108-110) eliminates the manual61constant and evaluates to61on currentmain. Audited allcopystat::Creferences acrosscrates/victory-gpu/src/: every site indexes viac as usizewith no exhaustivematchonC.COUNTandRANGESinCounters(L112-130) andRanges(L152-177) preserves the exactswap(0, Relaxed) / framesand sort-by-bytes drain semantics inlog()while letting unit tests run against isolated instances without racing global GPU/watch counters.Local Verification
cargo xtask policy— pass (191 files ok).cargo clippy --locked -p victory-gpu --all-targets -- -D warnings(default and--all-features) — 0 warnings.cargo test --locked -p victory-gpu --features diagnostics --lib copystat::tests::— 2/2 passed.Counters::add/takeandRanges::add/takeplus assertingCOUNTERS == 61— passed cleanly.#1862,#2303, and#2299on63bcca43c6a0builds with 0 clippy warnings (--all-features) and passes all 6 PR tests on both RTX 5090 and WARP.Looks good to merge.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.