gfx2hlsl: extend the uniform compute load proof to multi-register loads #2446
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2454"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by NiiRoZz on 2026-11-25T17:14:18Z.
Depends on #2446: this branch is stacked on it, so the diff shows that commit too until it merges; this pull request then holds one commit. Refs #2274.
What / Why
The entry-block rule for a compute buffer load with a uniform address (#2446) covers one destination register. Compilers also load pairs and quads (
buffer_load_format_xy v[2:3],buffer_load_dwordx4 v[8:11]) and read one component withv_readfirstlane_b32.Change
Accept
buffer_load_dwordx2/x3/x4andbuffer_load_format_xy/xyz/xyzwunder the same conditions (compute, entry block, exec known, uniform address). Each destination register is marked uniform, but the range must have exactly the length the opcode writes (otherwise a register the load leaves alone could be marked). No recompute expression is recorded.Tests
python -B tests/startup_gfx2hlsl_readfirstlane_uniform_check.py: 0 failed. Positives: x2 first/second word, x4 last word, overwriting a varying register, formatted xy. Negatives: x2 into three registers, x2 into one register, varying offset, a register outside the loaded range. Alltests/startup_gfx2hlsl_*.pyandtests/startup_translator_check.py: exit 0.Measured (256 compute requests)
First refusal
v_readfirstlane_b32: 115 before, 95 after (20 move on; next: s_pack_ll_b32 42, v_mul_hi_u32 35, src_scc in s_add_u32 14, buffer store without offen 12, formatted load descriptor words 10).Limits (why there is no "past the entry block" PR)
The remaining readfirstlane refusals past the entry block are about ten different shapes (loads past a join, exec narrowed between a recompute chain's parts, loaded vectors in later blocks, image_load, per-lane values), none above 8 requests. The one general idea, accepting a copy of a uniform VGPR when exec is known past the entry block, flips three existing refusal tests in
startup_gfx2hlsl_readfirstlane_recompute_check.py(scalar rewritten or reloaded between definition and read). I did not change those tests; it is a maintainer decision whether copy semantics make them obsolete. Not touched: SGPR proofs across joins (#2274).🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T18:25:52Z.
Review: COMMENTED
Review of head
a485968(comment only, no Windows run on my side; the PR body lists no Windows results, so nothing here covers any SHA on Windows).Checked against origin/main:
tools/startup/gfx2hlsl.py(UNIFORM_LOAD_WORDS, theloadedgate,loaded_regs): the destination range must have exactly the length the opcode writes, tfe/lds style modifiers are rejected by the modifier whitelist, and the recompute expression is dropped for every loaded register. I found no correctness problem.Commands run locally:
python3 -B tests/startup_gfx2hlsl_readfirstlane_uniform_check.py-> 0 failedgit diff --check origin/main...HEAD-> cleanpython3 tests/docs_links_check.pyandpython3 tests/bidi_controls_check.py-> OK== countto>= count) -> the test fails (good, it guards the length rule).buffer_load_dwordx3word count from 3 to 4 -> the test still passes.Finding (P2, non-blocking): the x3 opcodes (
buffer_load_dwordx3,buffer_load_format_xyz) have no test, so a wrong word count there goes unnoticed (mutation 2). Suggest one positive (v[2:4]) and one negative (x3 into two or four registers) case next to the existing x2/x4 ones.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-25T18:26:48Z.
Six mutations: three caught, three survive — and one survivor is load-bearing against a translator crash
Baseline:
Readfirstlane uniformity checks: 0 failed, wholestartup_gfx2hlsl_*family green.candidate[2] - candidate[1] + 1 == count)buffer_load_dwordx2(2 → 3)len(ops) == 4droppedself.tracks_uniformity()requirement droppedThe
len(ops) == 4survivor is load-bearing, and the failure is a crashThis one is not cosmetic. With the conjunct removed, a short operand list reaches the new condition and reads
ops[3]before anything else refuses it:buffer_load_dword v1, off(two operands) crashes the same way. The existing operand-count refusal lives inbuffer_address, which this condition is evaluated before, so today the conjunct is the only thing standing between a short list andtranslator crash in buffer_load_dword: IndexError— the exact marker the refusal census reads as a translator defect rather than as text the translator does not lower.That makes it the one I would pin first, and it is one case: a three-operand
buffer_load_dwordin a compute program, asserting the refusal text and not an exception. Cheap, and it turns an unstated ordering dependency into a tested property.The other two survivors
('idxen', 'offen', 'glc', 'slc', 'dlc')plusoffset:is what keepstfe/lds/ swizzle forms out. Widening it to accept anything is invisible to the fixture, so no case exercises a modifier outside that set.tracks_uniformity()dropped: the whole proof is about tracking, so dropping the gate should be visible somewhere; it is not. Worth a case where uniformity tracking is off (a barrier or a non-entry block) and the load must not be treated as uniform.Neither of these two changes an output I could observe, so I am reporting them as unexercised rather than as defects.
What the three caught rows establish
The width check catching
x2mis-sized to 3 words is the interesting one: it means the fixture distinguishes a load's word count from its destination range, rather than asserting the expression text loosely. The uniform-descriptor rule and the width rule are the two that decide whether a value is really lane-invariant, and both are pinned.AI-assisted; the six mutations and the crash probe were run locally on Windows 11 build 26300.9974.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T02:39:35Z.
Merged origin/main into this branch (no conflicts, no rebase, no force-push); main's arity_check is fixed (#2659) so the earlier block is gone. New head:
a84a6c82.Commands executed locally:
git merge origin/main(clean; CMakeLists.txt foreach/endforeach balanced 370/370)python3 tests/startup_gfx2hlsl_readfirstlane_uniform_check.py(0 failed),tests/docs_links_check.py,tests/bidi_controls_check.py,git diff --check origin/main...HEAD: all okx2w_pipe.py win2025 2454 --patch <merge delta> --wait 7200: build and Python checks PASS (exit 0)AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T02:51:12Z.
Merged current
maininto this branch again (merge commit54f08ec85, no rebase, no force push). The PR had gone back into conflict after the wave-index uniformity work landed.tests/startup_gfx2hlsl_readfirstlane_uniform_check.py: this PR's multi-register load cases andmain's wave-index and thread-id-base cases were added at the same spot. Both blocks are kept, and each loop keeps its owncheck(... refused ...)line.tools/startup/gfx2hlsl.pymerged without conflicts.54f08ec85:python3 tests/startup_gfx2hlsl_readfirstlane_uniform_check.py(0 failed),python3 tests/startup_gfx2hlsl_compute_check.pyok,python3 tests/docs_links_check.pyok,python3 tests/bidi_controls_check.pyok,git diff --checkclean.Squash merge is queued for when this head's CI is green.
AI-assisted; commands listed were executed locally.