Shaders: trace multi-term, scaled, masked, and phi-joined addresses in resource tracking #645
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!645
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/645/head"
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?
@nathanbzrr on GitHub · 2026-11-24 06:06 UTC · original
nathanbzrr:shader/resource-address-tracing→main· +2388 −117 · 3 files · 1 commits · closed without mergingSummary
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.
@ghost on GitHub · 2026-11-24 08:13 UTC · original
Offline translation and validation of
499bd98againstmainatd2a4bae: +32 programs validate, 0 regressions.Setup:
shaders.rpfplus its executable and 16 DLLs: 26,148 programs.victory translate --validate --list, validated with DXC 1.9 (1.9.2609.5).mainplus #235 for the Linux build, and a local hook that runsdxvoff Windows; neither touches translation.What changed:
main, not with this PR): 0.resources: an address from a phi(Defect E).resources: an address not from a root parameter.an address not from a root parametertoemit: a descriptor read only as data. It was refused onmaintoo, so this isn't a regression.an address from a phi. All 4 are in the same shader group and fail at nearly the same offset (0x508/0x510), so they are likely one pattern the phi tracing doesn't yet accept.Caveat: these numbers are from
mainatd2a4bae.mainhas moved since (nowdd273df).crates/victory-shader/src/emit/valu_tests.rsconflicts with #140 (v_cmp_class_f16), which first appears at merge80c0d12.main. I can rerun after a rebase.@xiao47576-glitch on GitHub · 2026-11-24 07:49 UTC · original · edited 2026-11-24 08:31 UTC
I tested PR #645 (
499bd98) againstmain(d2a4bae) on Windows Server 2025 using D3D12 WARP. Main rejected a root SRV plus a byte offset from the first root-constant dword. On this PR, both operand orders read the expected values at offsets 0, 4, 48, and 112 bytes, plus a fixed 12-byte load offset.I found one carry case the tracker still accepts:
Here
s[4:5]holds the root SRV address ands10is the byte offset. When the offset is zero, the comparison sets SCC to 1 even though the low add produced no carry. The tracker also accepts a high add with immediate 1 and a signed low add.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.
@slint6614-dev on GitHub · 2026-11-24 09:24 UTC · original
Measured on the full retail shader pack (26,503 containers) with
victory translate --validate --pipelines(pipelines created on an AMD RX 9070, Windows 11, dxil.dll from SDK 10.0.26100). Counts are emitted / validated / pipelines. This PR conflicts with current main (lower.rs), so it was measured on its own base, against main1f858b0before #612 (VS/PS 12272 / 12172, CS 1693 / 1670, MS 8191 / 8129).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.
@pablogonz12 on GitHub · 2026-11-24 16:20 UTC · original
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):
victory translateof the 751-program world set: 692 -> 700; all 700 pass dxil-spirv andspirv-val --target-env vulkan1.3and build a RADV pipeline.cargo test -p victory-shader --lib: 122 pass, 1 known pre-existing failure, 1 ignored; no new failures.cargo xwin clippy --workspace --all-targets --target x86_64-pc-windows-msvc -- -D warnings: clean.Not tested: in-game on this branch; native Windows.
@nathanbzrr on GitHub · 2026-11-24 21:55 UTC · original
Rebased onto
origin/main(ffe310e) at6817902and addressed the scalar-carry review finding.@catminou4 @xiao47576-glitch
Rebase integration (
ffe310e)#566waterfall tracking/lowering incrates/victory-shader/src/resource.rsandcrates/victory-shader/src/emit/lower.rs, preserving the 4-argumentresource::track(..., st)signature (#801).#612'sread_phisworklist inemit/lower.rs(fill_phis) alongsidepending_addr_phis.#140(v_cmp_class_f16_matches_rdna2) and wrappedrun_root_srv_caseswithONE_AT_A_TIME.lock()(#433) incrates/victory-shader/src/emit/valu_tests.rs.Soundness fix (
s_addc_u32/s_subb_u32carry)crates/victory-shader/src/resource.rssos_addc_u32ands_subb_u32require:Term::Const(c) if c == 0, rejecting non-zero immediates), andsccvalue traceable to a matchings_add_u32on the corresponding low-half value (including loop-carriedphiinduction chains), rejecting clobberedsccproducers (s_cmp_eq_u32,s_add_i32, or unrelateds_add_u32).resource::tests::scalar_carry_requires_matching_add_u32_scc_and_zero_const.Verification (
6817902)rustfmt --edition 2024 --check crates/victory-shader/src/emit/valu_tests.rs: clean (resource.rsandemit/lower.rsonly retain pre-existing upstream formatting diffs onorigin/main).cargo clippy --workspace --all-targets --locked -- -D warnings: clean.cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: clean.cargo test --workspace --locked:351 passed; 0 failed; 6 ignored(victory-shader:129 passed; 0 failed; 1 ignored;xtask:4 passed).VICTORY_WARP=1 cargo test -p victory-shader --locked -- root_srv:3 passed; 0 failed.@nathanbzrr on GitHub · 2026-11-24 22:03 UTC · original
Closing this PR as superseded by recent
main(70564ae):27c3dc9(Shaders and GPU: title memory at raw addresses through a page table, decision 0005) and0f63757(GPU: root views of programs that use title memory go through the page table) now intercept the data-computed address failure classes inTracer::address()(including"an address from a phi","an address with two computed terms","an address with an untracked high half","an address not from a root parameter", and"an address from a root parameter that is no address") and route them through theMEMORYpage table, alongsideUSER_DATAhandling for spilled compute root parameters.27c3dc9~2,388-line tracer rework would conflict with decision 0005 and0f63757's root-view page-table aliasing model; any remaining descriptor-heap address edge cases can be targeted cleanly in a focused follow-up PR onmain.Thanks @catminou4 and @xiao47576-glitch for the detailed reviews!
Pull request closed