Repository navigation
Shaders: uniform phis (loop counters) under v_readfirstlane addresses (stacked on #1225) - #1231
LooperSalty wants to merge 2 commits 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
Stacked on the first-lane code-table change. A code-table lookup walked by a loop counter (s_getpc_b64 + 4*i, i a VGPR phi whose exit is uniform) was refused as "an address read from the first lane of a per-lane value". A phi is now uniform when its arguments are and no lane-divergent branch (or loop it can leave lane by lane) can send lanes to it along different edges (greatest fixed point; divergent branches taint the joins and loops they reach). Uniform exits recognised: execz, scc of uniform values, vcc from comparisons of uniform values. v_readlane_b32 is uniform too, and a guarded VALU write needs its old value uniform. Measured on an integration tree: PrefilterAndIntegrateIrradianceSH and IrradianceCache_IntegrateIrradianceSH now translate and validate (dxil.dll); compute programs emitted 2212 -> 2214 there. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LwHrL6fhkpeG9ByE1rJxrt
|
We found a case where the old and new VGPR values are each uniform, but the value after restoring EXEC differs across lanes. In a 64-lane group, initialize v4 to 0 everywhere, set EXEC to lanes 10–63, write 42 to v4, restore EXEC, then read v4 with We used this PR’s classifier at For this PR’s address tracer, the question is whether |
|
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, and no other reason moves. Same 10 SPIR-V validation failures as the base. Not tested: in-game. |
Stacked on the first-lane code-table change. A code-table lookup walked by a loop counter (s_getpc_b64 + 4*i, i a VGPR phi whose exit is uniform) was refused as "an address read from the first lane of a per-lane value". A phi is now uniform when its arguments are and no lane-divergent branch (or loop it can leave lane by lane) can send lanes to it along different edges (greatest fixed point; divergent branches taint the joins and loops they reach). Uniform exits recognised: execz, scc of uniform values, vcc from comparisons of uniform values. v_readlane_b32 is uniform too, and a guarded VALU write needs its old value uniform. Upstream measured PrefilterAndIntegrateIrradianceSH and IrradianceCache_IntegrateIrradianceSH translating and validating on an integration tree. Applied as is; several of these uniformity rules do not hold in XTP's lowerings and are replaced in the next commit. Ported from Marvisak/VIctory#1231 (head 8996aeb) 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 Stacked on #1225 (uniform loop-counter phis under first-lane code addresses): main's 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.
Stacked on #1225: the first commit of this branch is #1225's, review only the last one. It extends the uniformity test added there to phis, so a code-table lookup walked by a loop counter (
s_getpc_b64+ 4*i, i a VGPR phi with a uniform exit) is traced instead of refused as "an address read from the first lane of a per-lane value".A phi is uniform when its arguments are and no lane-divergent branch (or loop it can leave lane by lane) can send lanes to it along different edges (greatest fixed point). Recognised uniform exits:
execz,sccof uniform values,vccfrom comparisons of uniform values.v_readlane_b32is uniform; a guarded VALU write needs its old value uniform. The post-dominator helper is a private copy inresource/uniform.rs, so this does not depend on any other open PR.Measured on an integration tree: PrefilterAndIntegrateIrradianceSH and IrradianceCache_IntegrateIrradianceSH now translate and validate (dxil.dll); compute programs emitted 2212 -> 2214 there.
cargo test -p victory-gpu -p victory-shaderis green on this branch (based onorigin/mainffe310e + #1225).