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
Fixes D3D12 aliasing-barrier over-emission (and missing intra-list handoffs) for physical-page aliased transient render targets introduced in 6ba7fa8 (VICTORY_ALIAS_TARGETS=1):
Read-only command lists no longer receive prelude aliasing barriers (host.rs):HostList::prelude() previously pushed a D3D12_RESOURCE_BARRIER_TYPE_ALIASING (NULL -> resource) for every aliased RT in states, even when the list only read the RT (PIXEL_SHADER_RESOURCE, NON_PIXEL_SHADER_RESOURCE, COPY_SOURCE, DEPTH_READ). Under D3D12 aliasing rules, an aliasing barrier targeting an RT/DSV invalidates its prior contents and compression metadata until re-initialized via Clear*/DiscardResource/Copy*, causing read-after-write corruption across command lists.
Same-resource read-modify-write no longer receives spurious aliasing barriers (host.rs, alias_rt.rs):HostList::transition() previously emitted ALIASING(NULL -> resource) on every intra-list transition of an aliased RT into a write state even when no other aliased resource touched its physical pages in between (e.g., RTV -> SRV -> RTV or cross-list multi-pass blending).
Each aliased HostTexture now carries its coalesced physical AliasFootprint (section + sorted (start_page, count) runs) instead of a bare bool.
ListAliasTracker (per HostList, cleared on HostList::reset()) tracks touched physical page spans during recording:
Read-only touches never emit an aliasing barrier, and record the read span so a later write to a different overlapping alias in the same list emits an intra-list aliasing barrier after the read (rather than in the prelude, which would invalidate the earlier read).
Writes that overlap a prior touch by a different alias in the same list emit an intra-list ALIASING(NULL -> resource) barrier immediately (including when the new alias is Vacant in states or re-enters the same write state).
First-touch writes with no prior conflicting touch in the list are recorded as prelude candidates.
At submission time in HostList::prelude(), alias_rt::resolve_prelude() checks prelude candidates against the global per-section OwnerTable (cleared on section_gone()), emitting a prelude aliasing barrier only when any page is currently owned by a different resource, and advances global ownership with the list's writes. Read-only lists skip locking global alias_rt state altogether.
How it was tested
GPU / environment: Windows 11 x64, NVIDIA RTX 5080 (D3D12 Resource Heap Tier 2, Tiled Resources Tier 4), Rust MSVC (--locked). Synthetic unit and D3D12 hardware tests only (no game files or assets).
Before: Every command list touching an aliased RT emitted a prelude ALIASING(NULL -> resource) barrier regardless of read/write state or active page owner, and every intra-list write transition on the same resource emitted another aliasing barrier while first-use intra-list alias handoffs (Vacant in states) emitted none inside the list.
After:
cargo test --locked -p victory-gpu --lib -- alias_rt --nocapture: 6 passed, 0 failed, including 4 new ownership/handoff unit tests (read_only_list_emits_no_aliasing_barrier, same_resource_rmw_emits_no_spurious_aliasing_barrier, cross_list_and_partial_overlap_handoffs_emit_prelude_barrier, intra_list_read_then_alias_write_defers_barrier_past_read) and a synthetic D3D12 hardware test (aliased_rt_read_after_write_and_handoff_on_d3d12) exercising two 64x64 R8G8B8A8_UNORM reserved RTs aliased onto the same 64 KiB Tier-2 heap tile across read-after-write, cross-list handoff, and intra-list read-then-alias-write command lists with pixel readback verification.
Test report for #1887 (head bf8a6d6), merged --no-ff onto main 568c5e5. 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.
alias_rt:: tests (-- alias_rt::, 6 tests): all pass, 3/3 runs. That covers the four new ownership/handoff
tests, coalesce_runs_merges_contiguous_tile_ranges and the D3D12 test.
The four ownership/handoff tests and coalesce_runs_merges_contiguous_tile_ranges are CPU-only.
aliased_rt_read_after_write_and_handoff_on_d3d12 reaches the device.
It makes its own device on the system default adapter (D3D12CreateDevice(None, ...)).
It returns early, and so counts as passed, if there is no device or the resource heap or tiled resources tier
is below 2.
I added temporary prints (not committed). In every run the device was on "NVIDIA GeForce RTX 3070", with
resource heap tier 2 and tiled resources tier 4, and every pixel check ran and passed. So these passes are real
runs, not skips.
I also ran the module three more times with VICTORY_D3D12_WARP=1 --features diagnostics. The D3D12 test does
not read that switch: it ran on the RTX 3070 each time and passed. There is no WARP coverage of this test as
written.
Negative control:ListAliasTracker::resolve_prelude no longer asks for any prelude aliasing barrier. 3 of the 6
tests fail, the same with and without the switch above:
cross_list_and_partial_overlap_handoffs_emit_prelude_barrier (alias_rt.rs:827): [] instead of [2];
intra_list_read_then_alias_write_defers_barrier_past_read (alias_rt.rs:864): [] instead of [100];
aliased_rt_read_after_write_and_handoff_on_d3d12 (alias_rt.rs:1119): [] instead of [1]. That is the test's
own check of the tracker's output for the cross-list handoff, before list 3 is recorded. So it stops there and
does not show what the missing barrier would do to pixels on this card.
The other three (read-only list, same-resource read-modify-write, coalescing) still pass, as expected: none of them
needs a prelude barrier.
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
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.
What it changes
Fixes D3D12 aliasing-barrier over-emission (and missing intra-list handoffs) for physical-page aliased transient render targets introduced in
6ba7fa8(VICTORY_ALIAS_TARGETS=1):host.rs):HostList::prelude()previously pushed aD3D12_RESOURCE_BARRIER_TYPE_ALIASING(NULL -> resource) for every aliased RT instates, even when the list only read the RT (PIXEL_SHADER_RESOURCE,NON_PIXEL_SHADER_RESOURCE,COPY_SOURCE,DEPTH_READ). Under D3D12 aliasing rules, an aliasing barrier targeting an RT/DSV invalidates its prior contents and compression metadata until re-initialized viaClear*/DiscardResource/Copy*, causing read-after-write corruption across command lists.host.rs,alias_rt.rs):HostList::transition()previously emittedALIASING(NULL -> resource)on every intra-list transition of an aliased RT into a write state even when no other aliased resource touched its physical pages in between (e.g.,RTV -> SRV -> RTVor cross-list multi-pass blending).alias_rt.rs,resource.rs,host.rs):HostTexturenow carries its coalesced physicalAliasFootprint(section+ sorted(start_page, count)runs) instead of a barebool.ListAliasTracker(perHostList, cleared onHostList::reset()) tracks touched physical page spans during recording:ALIASING(NULL -> resource)barrier immediately (including when the new alias isVacantinstatesor re-enters the same write state).HostList::prelude(),alias_rt::resolve_prelude()checks prelude candidates against the global per-sectionOwnerTable(cleared onsection_gone()), emitting a prelude aliasing barrier only when any page is currently owned by a different resource, and advances global ownership with the list's writes. Read-only lists skip locking globalalias_rtstate altogether.How it was tested
--locked). Synthetic unit and D3D12 hardware tests only (no game files or assets).ALIASING(NULL -> resource)barrier regardless of read/write state or active page owner, and every intra-list write transition on the same resource emitted another aliasing barrier while first-use intra-list alias handoffs (Vacantinstates) emitted none inside the list.cargo test --locked -p victory-gpu --lib -- alias_rt --nocapture: 6 passed, 0 failed, including 4 new ownership/handoff unit tests (read_only_list_emits_no_aliasing_barrier,same_resource_rmw_emits_no_spurious_aliasing_barrier,cross_list_and_partial_overlap_handoffs_emit_prelude_barrier,intra_list_read_then_alias_write_defers_barrier_past_read) and a synthetic D3D12 hardware test (aliased_rt_read_after_write_and_handoff_on_d3d12) exercising two64x64 R8G8B8A8_UNORMreserved RTs aliased onto the same 64 KiB Tier-2 heap tile across read-after-write, cross-list handoff, and intra-list read-then-alias-write command lists with pixel readback verification.cargo test --locked -p victory-gpu --lib -- --test-threads=1: 594 passed, 0 failed, 44 ignored.cargo clippy --locked -p victory-gpu --lib --tests: zero warnings in touched code (alias_rt.rs, modified hunks inhost.rsandresource.rs).cargo testpassed for the crates it touches: yes (victory-gpu).Checked for overlap
alias_rtphysical-page ownership or fixHostList::prelude()/transition()aliasing barriers).