You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
perf(gpu): avoid temporary allocations in single-range descriptor copies - #1616
CopyDescriptors builds two temporary range vectors even when both sides have exactly one range. The source-first fast path keeps the existing kind and null-start checks, snapshots source metadata before destination metadata, and calls the unchanged copy_simple with the smaller count when it is nonzero. Null optional size arrays still mean one descriptor per range. The general multi-range loop, overlap-aware copying, and write-before-mirror ordering are preserved.
How it was tested
Hosted Windows with Rust 1.98.1 on the MSVC target. The D3D12 smoke used the WARP software adapter and synthetic sampler descriptors. The test suite used no game assets.
All 12,233 differential cases matched complete buffers, untouched entries, metadata-alias behavior, and ordered copy and mirror calls.
Locked workspace compilation passed on both revisions. All 98 asset-independent CPU tests passed on each, with 3 ignored and 13 filtered.
Both committed Windows regression tests passed: single_range_dispatch_preserves_complete_descriptor_bytes and general_path_snapshots_metadata_before_overwriting_it. They cover all four heap kinds, overlapping buffers, null optional sizes, unequal and zero counts, and metadata snapshot ordering.
The WARP test passed. It verified real sampler heap lookup and mirroring, including a three-slot copy, an untouched neighbor, and clearing one slot.
All 18 eligible synthetic workloads eliminated two allocator calls and 32 cumulative requested bytes. General-path allocation counts and requested bytes were unchanged.
Synthetic performance and trade-off
Representative hosted production medians from the candidate runner:
Workload
Original
Production
Default single-range preparation
83.493 ns
5.254 ns
Default single-range full copy
87.260 ns
7.100 ns
256-descriptor full copy
121.063 ns
43.280 ns
The latest hosted production comparison also measured these general-path slowdowns. The values are paired median deltas across two passes of 41 alternating pairs.
Full-copy control
Measured overhead
1 source × 4 destination ranges
+2.032 to +2.214 ns
4 source × 1 destination range
+3.273 to +3.633 ns
2 × 2 ranges
+3.938 to +4.462 ns
4 × 4 ranges
+3.453 to +4.530 ns
Zero ranges on both sides
+0.308 ns in both passes
These costs exceeded the same-runner original-versus-original noise for the corresponding controls. The earlier hosted refinement and local production measurements showed smaller overhead. The magnitude varies across builds and environments, and these measurements leave its cause unisolated. The real workload distribution and complete live heap and mirroring latency remain unknown. The evidence supports a synthetic single-range benefit and a measured general-path cost for review.
Production source 59dd62e7d7507457a5c0e6c89b1c2acfcc3420c6. Candidate workflow
Both workflows finished red on identical pre-existing failures in strict affected-crate and workspace Clippy, workspace formatting (4,338 hunks), and the asset-policy size limit for the unchanged crates/victory-shader/src/emit/lower.rs. Compilation, CPU tests, focused Windows tests, WARP, differential checks, and benchmark steps succeeded individually.
github-actionsBot
changed the title
[pr-performance][rendering] perf(gpu): avoid temporary allocations in single-range descriptor copies
perf(gpu): avoid temporary allocations in single-range descriptor copies
Nov 28, 2026
Test report for #1616 (head 59dd62e), merged --no-ff onto main 568c5e5. This PR is based on an older main;
the merge was clean. Synthetic tests only: no title run, no game files.
Setup: RTX 3070, driver 616.56, Windows 11 (10.0.26100), rustc 1.98.1. Every run logged the GPU and driver from nvidia-smi before it started.
Both are CPU-only. They call copy on plain arrays with a null device, so no D3D12 device is used. I also ran them
three times with VICTORY_D3D12_WARP=1 --features diagnostics; they pass the same. The WARP sampler-heap test the
description mentions is not in the diff, so it is not covered here.
Negative controls
A, main's copy with only the two tests added: both pass. That fits a speed-up that keeps the behaviour the
same: the tests guard what main already does.
B, the new single-range fast path copying the source count without limiting it to the destination's
(left instead of left.min(room)): single_range_dispatch_preserves_complete_descriptor_bytesfails, at
the case kind 0, source size 3, destination size null (one descriptor), destination 1. Two descriptors past the
destination's one are overwritten. general_path_snapshots_metadata_before_overwriting_it still passes; it uses
two ranges, so it never reaches the fast path. So the single-range test does catch a fast path that ignores the
destination's size.
The two extra tests are the PR's own. I did not measure the timings in the description.
Not tested: the effect in a title.
Tested with the help of Claude Code (Claude Opus 5.5).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pr-performancePull request: makes it faster or use less memoryrenderingMissing, black, flickering or corrupted graphics
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1572.
What it changes
CopyDescriptorsbuilds two temporary range vectors even when both sides have exactly one range. The source-first fast path keeps the existing kind and null-start checks, snapshots source metadata before destination metadata, and calls the unchangedcopy_simplewith the smaller count when it is nonzero. Null optional size arrays still mean one descriptor per range. The general multi-range loop, overlap-aware copying, and write-before-mirror ordering are preserved.How it was tested
Hosted Windows with Rust 1.98.1 on the MSVC target. The D3D12 smoke used the WARP software adapter and synthetic sampler descriptors. The test suite used no game assets.
single_range_dispatch_preserves_complete_descriptor_bytesandgeneral_path_snapshots_metadata_before_overwriting_it. They cover all four heap kinds, overlapping buffers, null optional sizes, unequal and zero counts, and metadata snapshot ordering.Synthetic performance and trade-off
Representative hosted production medians from the candidate runner:
The latest hosted production comparison also measured these general-path slowdowns. The values are paired median deltas across two passes of 41 alternating pairs.
These costs exceeded the same-runner original-versus-original noise for the corresponding controls. The earlier hosted refinement and local production measurements showed smaller overhead. The magnitude varies across builds and environments, and these measurements leave its cause unisolated. The real workload distribution and complete live heap and mirroring latency remain unknown. The evidence supports a synthetic single-range benefit and a measured general-path cost for review.
Hosted validation
d4b5d51702db615bd0aec74a35b042f60ba4cf62. Baseline workflow59dd62e7d7507457a5c0e6c89b1c2acfcc3420c6. Candidate workflowBoth workflows finished red on identical pre-existing failures in strict affected-crate and workspace Clippy, workspace formatting (4,338 hunks), and the asset-policy size limit for the unchanged
crates/victory-shader/src/emit/lower.rs. Compilation, CPU tests, focused Windows tests, WARP, differential checks, and benchmark steps succeeded individually.Checked for overlap
copy_simple. The range collection change here is independent.AI-assisted with OpenAI Codex.