Repository navigation
Shaders: trace multi-term, scaled, masked, and phi-joined addresses in resource tracking - #645
nathanbzrr wants to merge 1 commit into
Conversation
LAKSHYA-cmd-tech
left a comment
There was a problem hiding this comment.
Tested on Windows 11 with Rust 1.98.1 (x86_64-pc-windows-msvc).
- cargo test -p victory-shader: all 77 tests passed cleanly (0 failed).
- All 5 resource address tracking tests ( wo_term_dynamic_addresses_produce_rel_offset,
oot_constants_dword0_is_offset_not_base, scaled_subtracted_add3_addk_and_aligned_or_addresses, high_half_carry_va_mask_and_table_carry, and phi_joined_and_loop_carried_addresses) passed. - All 3 end-to-end DXIL compute dispatch tests (
oot_srv_s_lshl2_add_u32_with_root_constant_dword0,
oot_srv_two_term_v_add_co_and_v_lshl_add,
oot_srv_loop_carried_pointer_induction_phi) passed. - cargo xtask policy: 151 files ok.
- Verified DAG sum tracing with cycle-safe Phi base validation, SSA-dominance-safe relative offset lowering in emit/lower.rs, and GFX10 address op lowering. Resolves key blockers for raytracing/BVH compute shaders in #614.
|
I tested PR #645 ( I found one carry case the tracker still accepts: s_add_u32 s0, s4, s10
s_cmp_eq_u32 s10, 0
s_addc_u32 s1, s5, 0Here Download the tested source patch With the patch applied, the tracker rejected all three cases. All 12 valid WARP reads returned the expected values, and all 78 shader tests passed. Only the valid reads were dispatched on WARP. The effect on the opening cutscene in #255 is still untested. AI-assisted. |
|
Offline translation and validation of Setup:
What changed:
Caveat: these numbers are from
|
|
Measured on the full retail shader pack (26,503 containers) with CS 1721 / 1698 (+28 validated): "resources: an address from a phi" 28 → 4 and "an address not from a root parameter" 73 → 64. VS/PS +4 validated, MS unchanged. |
A title heap of 2^20 descriptors plus the 2^18 dynamic range asked for a 1,310,720-view shader-visible heap. NVIDIA creates it without an error, but the runtime refuses it (debug layer Marvisak#645, CREATE_DESCRIPTOR_HEAP_INVALID) and the device is removed once it is used (upstream Marvisak#735, RTX 4060 Laptop). The sizing only fell back when creation failed, so it never did there. Heap sizes are now planned against the device's limit: what D3D12_OPTIONS19 reports as MaxViewDescriptorHeapSize (Agility runtimes), else the spec's 1,000,000. The larger dynamic range where it fits on top of every title slot, else the smaller one, else the title's slots are cut so the smaller one still fits, as the old cap did. The diagnosis is LAKSHYA-cmd-tech's (fork branch fix/gpu-resource-format-flags-and-heap-limit); this takes the limit from the device instead of a constant. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
catminou4
left a comment
There was a problem hiding this comment.
Conflicts with current main (ffe310e) — resource.rs (+1326/-96) and lower.rs (+593) are both hot after the recent shader merges; needs a rebase before anything else.
I can't responsibly approve a 2329-line tracer rework on a conflicted base without running it, and the merged tree is exactly where the five "Defect A-E" fixes interact with #566's waterfall changes. The structure (SSA-dominance-safe relative offsets, multi-term/scaled/masked/phi-joined address tracing) sounds like the right direction for the resource-tracking failures, and the +295 lines in valu_tests.rs suggest host coverage on Windows.
After a rebase I'll run cargo test -p victory-shader --locked on macOS and do a full pass on the tracer invariants (the sums cache from #139 and the dominance reasoning are the parts most likely to interact badly with other in-flight PRs).
Marvisak#645) Track multi-term, scaled, masked, and phi-joined resource addresses in resource.rs and lower relative offsets safely across SSA phis in lower.rs; adapt valu_tests::run_root_srv_cases for heap guard slots.
|
Measured on Linux (RX 9070 XT, RADV/Mesa 26.3.1, GE-Proton11-14, vkd3d-proton master), head 499bd98 merged onto a tree that already carries other merged fixes (its offline base is 692 of 751 of the world shader set, not main's number):
|
…n resource tracking # Conflicts: # crates/victory-shader/src/emit/lower.rs # crates/victory-shader/src/emit/valu_tests.rs # crates/victory-shader/src/resource.rs
499bd98 to
6817902
Compare
|
Rebased onto Rebase integration (
|
|
Closing this PR as superseded by recent
Thanks @catminou4 and @xiao47576-glitch for the detailed reviews! |
Codex P1 on Marvisak#645: kind and four are i32, so the leaf test must use pred::IULT, not the floating-point unordered ULT. Refs Marvisak#474. Co-authored-by: JMAN730 <JMAN730@users.noreply.github.com>
…-miss-474-111a Shaders: lower image_bvh intersect as a miss (Marvisak#474)
Summary
Fixes five resource-address tracking failures in
crates/victory-shader/src/resource.rsand adds SSA-dominance-safe relative offset lowering incrates/victory-shader/src/emit/lower.rsblocking compute, raytracing/BVH, and multi-term buffer shaders:RootType::Constantsdword 0 was treated as a pointer base wheneverparam_ofsaw dword0, colliding with real base pointers ("an address not from a root parameter","an offset from a root parameter", or"an address from a root parameter that is no address").(base + row) + col, orbase + dynplussoffset/vaddr) discardedbase.s_addk_i32,s_lshl{1..4}_add_u32,v_lshl_add_u32,v_add3_u32,v_add_nc_i32, subtractions on the minuend, aligned constants_or_b32/v_or_b32, and address-localv_mov_b32->v_readfirstlane_b32/v_readlane_b32) were untraced.v_add_co_ci_u32(want, 0, _), skipped table dynamic carries (high == None), and did not strip VA-preservingandmasks (mask & 0xFF == 0xFF).if/else) and loop-carried induction pointerPhis failed immediately with"an address from a phi".Changes (
crates/victory-shader/src/resource.rs,emit/lower.rs,emit/valu_tests.rs)RelOffset { value, base, extra_dynamic }toAddress(keepingAddress: Copyand keepingdynamicpopulated for downstream readers such astranslate.rs).sum_valuetoTable,ResourceHeap,SamplerHeap, andDescriptor.Phibase validation (requiring at least one non-cyclic edge and a matchingbaseacross all non-cyclic edges), multi-term retention (multi: bool), and all listed GFX10 address ops without double-countings.offsetorextra_dynamic.high_half,carried(Term, Term), andSource::Builtmask stripping (set_bits) to acceptv_add_co_ci_u32,Term::Const(0)table carries, VA masks, and high-half phis.address_offsetandrel_offsetinemit/lower.rswith per-call local caching for non-phi expressions and globaladdr_phiscaching resolved infill_phisto preserve DXIL SSA dominance across blocks, wired intoflat(),code_smem(), andbuilt_offset().resource.rsand 3 end-to-end DXIL + D3D12 GPU/WARP compute dispatch tests (root_srv_*) inemit/valu_tests.rs.Verification
Isolated verification on branch
shader/resource-address-tracing(499bd98):rustfmt --edition 2024 --config skip_children=true --check crates/victory-shader/src/resource.rs crates/victory-shader/src/emit/lower.rs crates/victory-shader/src/emit/valu_tests.rs(passed)cargo test -p victory-shader -- --test-threads=1(77 passed, 0 failed, 0 ignored)VICTORY_D3D12_WARP=1 VICTORY_D3D12_DEBUG=1 cargo test -p victory-shader root_srv_ -- --test-threads=1(3 passed, 0 failed, 0 ignored, 74 filtered out)cargo clippy -p victory-shader --all-targets(0 warnings)cargo xtask policy(151 files ok)No game files. AI-assisted; reviewed and verified with the tests above.