Shaders: trace a code-table address read from the first lane of a uniform value #1225
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!1225
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1225/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?
@LooperSalty on GitHub · 2026-11-24 16:33 UTC · original
LooperSalty:shaders/first-lane-uniform-code-table→main· +155 −1 · 1 files · 1 commits · closed without mergingFrom a tester working with Claude (AI-assisted); measured on my own machine (i7-13700KF, RTX 4070 Super). No game data in the diff; test programs are synthetic words assembled with llvm-mc.
Complements
ffe310e(waterfall loop over a first-lane table offset): this covers the other form of the same idiom, where the table address is a VGPR sum ofs_getpc_b64and a uniform index, read back to SGPRs withv_readfirstlane_b32befores_load. When every lane holds the same value the first lane's read is that value, so the load is traced through the sum. A per-lane source is still refused, now naming the reason.Measured on an integration tree: ColorDownsampleCS and InitCS now translate and validate (dxil.dll); in the shadow/luminance containers traced 70 -> 72, emitted 56 -> 58.
Two tests (uniform address traced; per-lane address refused by name).
cargo test -p victory-gpu -p victory-shaderis green on this branch (based onorigin/mainffe310e).The console compiler builds the address of a table in the code in VGPRs (s_getpc_b64 plus a uniform index through v_mov/v_lshlrev/v_add_co) and reads it back with v_readfirstlane_b32 before the s_load. When every lane holds the same value the first lane's read is that value, so the load is traced as if it used the VGPR sum directly; a per-lane source is still refused, now by name ("an address read from the first lane of a per-lane value"). Uniformity is decided from scalars, constants and first-lane reads through a list of VALU operations (memoised per value). Two tests: a uniform code-table address is traced (offset and computed index checked); a per-lane one is refused by name. Measured on an integration tree: ColorDownsampleCS and InitCS now translate and validate. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LwHrL6fhkpeG9ByE1rJxrt@SantannaCarlos on GitHub · 2026-11-24 17:10 UTC · original
Checked offline together with #1198 (address map), against the title's shader pack (
victory translate --validate, 32-lane host,dxil.dllvalidator):ColorDownsampleInitCS/ColorDownsampleCS(auto exposure)CS_LaserLightShadowRaytracingmainmain+ #1198emit: s_getpc_b64main+ #1198 + this PRemit: s_getpc_b64So this PR fixes the exposure pair, but with #1198 it stops a program that #1198 (on the #439 stack) translated.
Why: #1198 turns an access whose address has no root parameter into a read of title memory at run time when
runtime_address(why)matches one of its reasons ("an address not from a root parameter", "an address from a phi", "an address loaded from memory", ...). This PR gives a first-lane read of a non-uniform value a reason of its own, "an address read from the first lane of a per-lane value", which is not in that list, so the access is refused where #1198 would have read it. InCS_LaserLightShadowRaytracingthe node address of the BVH walk is picked per lane (v_cndmaskbetweens12ands12 | 48) and read back withv_readfirstlanebefore ans_load: that case. The exposure pair is the one this PR resolves (s_getpc_b64plus a uniform index, built in VALU and read back withv_readfirstlane).Either side can make the two compose: #1198 can add the new reason to
runtime_address(an address read from the first lane is one the translation can rebuild at run time), or this PR can keep the old reason for the first-lane reads it does not resolve.No game data here: program names, counts and refusal messages only.
@pablogonz12 on GitHub · 2026-11-24 17:16 UTC · original
Setup: Linux, RX 9070 XT, RADV (Mesa 26.3.1), dxil-spirv master, spirv-val 1.3. Your head folded onto a base of origin/main
ffe310eplus #1017 (main's host build fails without it:E0425 host_resource), then the four-stage offline check over 768 programs (751-program world dump + 52-program BVH capture, 35 duplicate containers skipped).+2 programs translate and none is lost: "an address not from a root parameter" goes from 3 compute programs to 1, the same two the uniform-address change clears, and no other reason moves. Same 10 SPIR-V validation failures as the base.
Not tested: in-game.
@Zipettte on GitHub · 2026-11-24 17:59 UTC · original
Tested on AMD Radeon RX 7700 XT (RDNA3, gfx1101), driver 32.0.32029.2010, Windows 11, Rust 1.98.1 MSVC at
b00573d:cargo test -p victory-shaderpasses, 122 passed / 0 failed. Workspace baseline on main (ffe310e) is green on the same machine (342 passed).Tested with AI assistance (Claude).
@Rezwo on GitHub · 2026-11-24 18:06 UTC · original
I reproduced the interaction with #1198 using a five-dword synthetic fixture, and found a counterexample to adding the new error string to the runtime-address allowlist unconditionally. This is resource tracking only; no game files, DXIL execution, or GPU run.
fe078c6b00573dGLOBALGLOBALGLOBALIn the
resource.rstest module, this is the extra fixture (generated instruction words; no title data):The instructions are two
v_readfirstlane_b32reads fromv0andv2intos[2:3], thens_load_dwordands_endpgm. Run withcargo test --locked -p victory-shader --lib resource::tests::a_on the combined tree. The two combined runs each passed 17/18, but failed different tests. A composable fix needs to distinguish the code-table case from a runtime pointer before selecting the fallback; the error text alone doesn't carry that distinction.AI-assisted (Codex).
@Rezwo on GitHub · 2026-11-24 18:14 UTC · original
I tested a small follow-up for the interaction with #1198:
github.com/Rezwo/VIctory@2b68329a9fThe runtime-map fallback now checks the SSA dependencies of both address words and the dynamic offset. If a first-lane address depends on s_getpc_b64, it stays out of the runtime map; a uniform code-table access still uses the existing code-table path. This fallback only applies to memory instructions, not descriptor construction.
On the combined #1198 + #1225 tree, the synthetic runtime-pointer test failed before the patch. With the patch, that test and the uniform/per-lane code-table cases pass, including a new case where only the high word depends on the program counter. The locked shader library suite passed 127 tests (1 ignored) with WARP forced, and shader-crate Clippy passed with warnings denied. No title files or in-game test. This is for review or cherry-pick on the combined revisions; no new upstream PR.
AI-assisted (Codex).
@Marvisak on GitHub · 2026-11-25 00:35 UTC · original
Automated triage for the maintainers. Closing because this change is already in
main, ormainhas since replaced the code it patches.Code-table address read back with v_readfirstlane from a uniform VGPR sum: main traces this (resource.rs
reaches_pcthrough lane reads, VGPR adds and phis,CODEaddresses;27c3dc9d).If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.
Pull request closed