Repository navigation
Shaders: trace a code-table address read from the first lane of a uniform value - #1225
LooperSalty wants to merge 1 commit into
Conversation
…form value
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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LwHrL6fhkpeG9ByE1rJxrt
…form value Upstream: Marvisak#1225 by @LooperSalty
|
Checked offline together with #1198 (address map), against the title's shader pack (
So 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 Either side can make the two compose: #1198 can add the new reason to No game data here: program names, counts and refusal messages only. |
Adapt the lane-uniform CODE provenance proof from Looper_Salty (Marvisak#1225) and cover the sign-extended shifted index in the exposure shaders.
|
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
+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. |
|
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.
In the #[test]
fn a_per_lane_runtime_pointer_stays_on_the_address_map() {
let resources = track_words(
&[0x7E04_0500, 0x7E06_0502, 0xF400_0181, 0xFA00_0000, S_ENDPGM],
&[],
HwStage::Cs,
);
assert_eq!(resources.scalar.as_slice(), &[((0, 2), at(GLOBAL, 0))]);
}The instructions are two AI-assisted (Codex). |
|
I tested a small follow-up for the interaction with #1198: Rezwo@2b68329 The 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). |
…orm value
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. Upstream measured
ColorDownsampleCS and InitCS translating on an integration tree.
Applied as is (XTP's resource.rs is upstream's at ffe310e but for
formatting); the review's fixes are two commits on.
Ported from Marvisak/VIctory#1225 (head b00573d) by LooperSalty
Co-authored-by: Looper_Salty <106304476+LooperSalty@users.noreply.github.com>
|
Automated triage for the maintainers. Closing because this change is already in Code-table address read back with v_readfirstlane from a uniform VGPR sum: main traces this (resource.rs 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. |
From 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 of
s_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).