feat: keep wave-uniformity through pure integer VALU ops in gfx2hlsl #2714
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2722"
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 tedin7 on 2026-11-26T03:32:08Z.
Part of #1723
What this unblocks:
v_readfirstlane_b32of an integer-computed uniform VGPR past the entry block (the "requires a proven uniform source" refusal) in compute shaders.What changed
UNIFORM_VALUnow includes the pure 32-bit integer ops: add/sub/subrev, and/or/xor/not, lshl/lshr/ashr, mul_lo, mul_u32_u24, min/max (u32/i32).uniform_expr) can read it back.Why it is correct
v_lshrrev_b32is unchanged.What stays refused
Tests
Extends
startup_compute_readfirstlane_check.py: a(s27 + s27) << 1chain read withv_readfirstlane_b32after a branch and a loop, WARP GPU readback vs the CPU reference, a dropped-read mutation control, and two refusal controls (thread-id source, lane-mask source). The new case fails on current main and passes with this change.Verification
python3 -B tests/startup_compute_readfirstlane_check.pyfails on main (refusal) and passes on this branch.tests/startup_*check.pypass on this branch.adb3b7d7: dev^startup_compute_readfirstlane|^startup_gfx2hlsl253/253 passed; dev and release^startup_compute_readfirstlane|^startup_gfx2hlsl_readfirstlane5/5 passed each (including the WARP readback of the integer chain).Commands (run per preset
devandrelease):AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T04:30:53Z.
Review: COMMENTED
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
1016363fd9ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T04:42:10Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T04:42:13Z.
Review: COMMENTED
No description provided.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T04:17:22Z.
@MasterDomino Independent Stage-2 gate review of head
adb3b7d7: PASS, marked Ready.tests/startup_compute_readfirstlane_check.pyfails onorigin/mainand passes here; droppingv_add_nc_u32fromUNIFORM_VALUmakes it fail.tests/startup_gfx2hlsl_readfirstlane_uniform_check.pyfailed on the first head (a shift of a constant-overwrittenv0was accepted). The update is right: the constant write reaches the shift on every path, so200 >> 6is the same in every lane. Overwritingv0on one branch path only, with a lane value, with a lane-mask scalar, after adding a per-lane value, or with unknown EXEC are all still refused, and the real thread-id shift controls (groups of 65 and 128,v1, loaded or swappedv0) are unchanged.min,xorand lane-mask operands in the integer chain are refused.Commands executed:
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T04:17:28Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
1016363ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T04:30:53Z.
Code review location:
tools/startup/gfx2hlsl.py; line 919This extends a public translator capability by accepting previously refused integer-computed first-lane reads, but neither
README.mdnordocs/experiments.mdis updated. The existing uniform-sources experiment entry omits the newly permitted operations and the added integer-chain/constant-shift readback controls. Update the relevant capability and experiment documentation with the supported/refused scope and reproduction/results;AGENTS.mdexplicitly requires a corresponding documentation update when a public capability changes.AGENTS.md reference: AGENTS.md:L314-L315
Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T04:30:53Z.
Code review location:
tools/startup/gfx2hlsl.py; line 917For a uniform VGPR reused as both operands, these entries make
Stage.one()substitute the entire previousuniform_exprtwice, causing exponential growth. A Linux repro using a 300-byte compute fixture containing 30v_add_nc_u32 v10, v10, v10instructions translates with the parent allowlist but raisesMemoryErrorwith this allowlist under a 256 MiB address-space limit, even without a first-lane read of that chain. The expressions are built eagerly regardless of whether recomputation is needed, so tiny, previously translatable integer shaders can now exhaust gigabytes of RAM. Bound expression size or preserve shared subexpressions instead of duplicating their text.Useful? React with 👍 / 👎.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T04:42:10Z.
Code review location:
tools/startup/gfx2hlsl.py; line 919Docs added in
2a6265c58:docs/experiments.md(section "Startup translator: uniform sources of v_readfirstlane_b32") now lists the integer ops, the refused sources, the expression limit and the GPU readback controls (dropped-int-read,dropped-const-shift).AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T04:42:13Z.
Code review location:
tools/startup/gfx2hlsl.py; line 917Fixed in
2a6265c58: the recompute text of a VGPR is kept only up toUNIFORM_EXPR_LIMIT(4096 chars); past it the VGPR has no recomputable expression (an entry-block read still copies the VGPR). New check intests/startup_gfx2hlsl_readfirstlane_uniform_check.py: 22 doublings (v7 = v7 + v7) keep a bounded expression; without the fix the expression is 37,748,729 chars. Win2025 dev+release--regex readfirstlane: 5/5 passed.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-26T05:35:23Z.
Review: APPROVED
Approving
2a6265c5(8 commits behindmain, merges cleanly).The new ops. The added ops are lane-local and table-lowered, with shift counts masked. Every existing guard still applies to them:
vccorexec);The thread-id shift path is unchanged, and turning "v0 overwritten by a constant" from a refusal into an accepted case is correct.
No shader-cache revision is needed:
offstores that were refused before;Environment: Windows 11 build 26300; AMD Radeon RX 9070 XT (driver 32.0.32029.2010); WARP 10.0.26100.9818; debug layer on, 0 errors; dev preset.
Runs:
ctest --preset dev --no-tests=error -R '^startup_compute_readfirstlane|^startup_gfx2hlsl': 260 passed, 0 skipped, 1 failed. The failure isstartup_gfx2hlsl_fma_mix_dispatch_hardware, which fails the same way onmainon this adapter (#2746), so it's unrelated. A trial merge withmainpassed the 114 non-GPU checks.Mutants, run against the five readfirstlane tests:
v_add_nc_u32failsstartup_compute_readfirstlaneand the uniform check;v_mbcnt_lo_u32_b32orv_cndmask_b32to the allowlist survives.Optional follow-up: a refusal control for a lane-dependent op (for example
v_mbcnt_lo_u32_b32 v7, -1, 0, thenv_readfirstlane_b32 s9, v7), so a later allowlist edit can't slip one in. Nit:UNIFORM_EXPR_LIMITnow separates theRUN_TIME_SYMBOLScomment from its constant.AI-assisted; commands listed were executed locally.