Repository navigation
Conversation
RSSetViewports and RSSetScissorRects kept what they set (for the list's next segment) in a new Vec per call; they now refill the one the list already has. ResourceBarrier built its host barriers in a Vec per call; up to seven title barriers (and the buffer UAV barrier added after them) now go through a stack array, more than that through a Vec as before. Same host calls, same arguments, same order. Measured with the list bench (perf/list-call-bench, RTX 4060 Laptop, median of 7 interleaved runs, ns a call): RSSetViewports 50 -> 23, RSSetScissorRects 56 -> 28, ResourceBarrier one texture transition 312 -> 262, one buffer UAV 191 -> 145. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Dukestar69
left a comment
There was a problem hiding this comment.
Reviewed the diff and verified locally on Windows 11 x64 (RTX 5090):
- Reusing
Fixed::{viewports, scissors}backing vectors viakeep()and using an inline 8-slot stack buffer (spilling toVecfor>= 8barriers, preserving room for the trailingUAV_BARRIER) cleanly removes per-call heap allocations on hot command-list recording paths. cargo test -p victory-gpu --lib draw:: -- --test-threads=1(RTX 5090): 21 passed, 0 failed (includingkept_viewports_and_scissors_are_the_last_set).cargo test -p victory-gpu --lib list:: -- --test-threads=1(RTX 5090): 5 passed, 0 failed (includingbarriers_beyond_the_stack_room_all_reach_the_list).cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.
Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
|
WARP verification of #3297 (synthetic tests only, no game files, no physical GPU). Commits
Environment
New tests, head vs control
Both tests pass on main too. This PR is a no-behaviour-change refactor, and these tests guard the behaviour, so they are not expected to fail before the fix. Both return early if no host GPU exists, and I did not independently confirm the WARP host path was taken. I did not run the perf bench, so I can't speak to the nanosecond figures. Full
The one failure is Not tested
AI use: Claude Code (Claude Sonnet 5.5) |
|
Independent local verification on Windows 11 x64, Intel Arc B580 12 GB (12 cores), at this PR's head Result: victory-gpu lib: 2 known baseline failures + timing flake (passed on re-run); both new allocation-removal tests passed. Both clippy runs exit 0 (-D warnings, both feature sets). The B580 baseline failures pristine main also hits are: victory-gpu descriptor::host::tests::dynamic_slots_are_held_until_released + memory::tests::lists_share_a_table_and_copies_keep_their_views (#1744/#1829); victory-shader emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros + emit::valu_tests::fspx_programs_run_with_the_hardwares_dot_products. No PR regressions. Synthetic tests only; no game data used. Full log kept locally. — borosf |
Removes the per-call allocations in three list setters that #2586's per-call table (comment 7195391455) pointed at.
Change
Only
crates/victory-gpuchanges.draw.rs:RSSetViewportsandRSSetScissorRectskeep what they set for the list's next segment (Fixed, replayed byState::cut). They used to keep it in a newVecper call (to_vec()). Now they refill theVecthe list already has (keep), so only a list's first call allocates. The host call gets the title's slice as before.list.rs:ResourceBarrierbuilt its host barriers in a newVecper call. Up to seven title barriers, plus the buffer UAV barrier that may follow them, now go into a stack array. More than seven go into aVecas before.The host calls, their arguments and their order are the same as before.
Measured
The list bench from KainanP/VIctory@perf/list-call-bench (
pipeline::list_bench,#[ignore],cargo test -p victory-gpu --release list_bench -- --ignored --nocapture). Each row is the best of 5 × 20,000 calls. Both builds ran 7 times interleaved, and the table gives the median. RTX 4060 Laptop GPU, Core i7-14650HX, Windows 11, release. Four unrelated Python jobs were using the CPU throughout, which is why the builds were interleaved.RSSetViewports, 1 (0xa8)RSSetScissorRects, 1 (0xb0)ResourceBarrier, 1 texture transition (0xd0)ResourceBarrier, 1 buffer UAV (0xd0)A second set of 7 runs in the opposite order gave 48→22, 54→28, 304→264 and 189→143. The draw, dispatch and indirect rows don't go through this code. Across the two sets they moved by 1–3% in both directions, within the run-to-run spread.
Not measured: a game frame. The gain is about 25–50 ns per call. How much that adds up to per frame depends on how many viewport, scissor and barrier calls a frame makes, and I don't have that count from a game run.
Tests
New tests (synthetic, no game data):
list::tests::barriers_beyond_the_stack_room_all_reach_the_list: 3, 7, 8 and 21 barriers per call, texture transitions mixed with buffer UAV barriers, sent through the title's method. After each call, every texture's tracked state is the last one asked for. Then the list runs. With the loop cut to the first seven barriers, the test fails at 8.draw::tests::kept_viewports_and_scissors_are_the_last_set: the kept viewports and scissors are the last ones set, whatever the earlier counts were, andState::cutreplays them.cargo test -p victory-gpu --release --lib, with the same failures as on main 63bcca4:dynamic_slots_are_held_until_releasedandlists_share_a_table_and_copies_keep_their_views.memory_tests::heap_direct_texture_reads_mark_their_heap_indexwas skipped because it access-violates on main here.a_texture_written_in_one_format_reads_in_another_through_a_placed_view, which also fails on main.--features diagnostics,VICTORY_D3D12_WARP=1,--test-threads=1): 248 passed, 0 failed.Also passing:
cargo clippy -p victory-gpu --all-targets -- -D warnings, with and without--all-features, andcargo xtask policy.Unrelated to this PR:
shadow::tests::partial_refresh_under_marked_range_updates_saved_bytessometimes fails in the parallel run on main 63bcca4 too (2 of 30 runs on RTX).Overlaps
keep(&mut self.fixed.viewports, viewports). GPU: clamp viewport and scissor counts and normalize inverted scissor rects #3176's scissorVecholds the normalized rects. ThatVeccould be the one kept, or its rects could be written into the keptVecwithkeep.barrieraround aVecit edits in place (push_host_barrier/emit_barriers). If GPU: flush before depth-twin copies and coalesce duplicate transitions in ResourceBarrier #3129 is merged first, the barrier half of this PR should be dropped in favour of GPU: flush before depth-twin copies and coalesce duplicate transitions in ResourceBarrier #3129's version. The viewport and scissor half doesn't touch GPU: flush before depth-twin copies and coalesce duplicate transitions in ResourceBarrier #3129's code.AI use: Claude Code (Claude Opus 5.5) wrote the change and the tests, ran the measurements and drafted this description.
🤖 Generated with Claude Code