shader: accept wave-uniform readfirstlane in pixel loops #3904
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3904"
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 lukaslw-lab on 2026-12-03T00:42:05Z.
Change
The direct gfx1013 pixel compiler accepts
v_readfirstlane_b32inside a loop when the value is the same in every lane. Before, every such read was refused withgraphics readfirstlane requires a wave-uniform reaching value. Inside a loop, a value's input dependencies are complete only after all blocks and back edges are emitted, and the uniform-value tracking skips loops.finish_loop_dependencies(), as loop branch conditions already are. A read is accepted when its value depends on no stage input. Every loop branch has passed the varying check, so all lanes run the same trips.Part of #3814 (row L1, claim). No overlap: the open pixel PRs that touch
uniform_vector_valuesall keep!loop_dependencies.Verification
Commit
03c365c04(on0b83a346b; the headfead4acd5is the same change rebased without conflicts onto2f2901cbd, rerun results will follow in a comment) on Windows 10 22H2 (build 19045), MSVC 19.52.37029, CMake 4.3.1, Python 3.13.7, DXC 1.9.2609.5. Draws need shader model 6.6, so both builds useOFFSCREEN_AGILITY_620_DIR(Agility SDK 1.620.2) andOFFSCREEN_WARP_DIR(WARP 1.0.22.0); D3D12 debug layer on. GPU: NVIDIA GeForce RTX 3080 Ti, driver 32.0.16.1047.Negative control: with
src/gfx1013_direct_graphics.inlfrommain(0b83a346b),native_pixel_loop_readfirstlane_controlsfails at the first case:native compute +0xc: graphics readfirstlane requires a wave-uniform reaching value.No capability skips.
tests/bidi_controls_check.pyandtests/docs_links_check.pypass. On the in-box Windows 10 runtime the draw tests of this family (this one,native_pixel_cmpx_if_else_warp,native_pixel_loop_entry_inputs_*) fail at PSO creation (Shader must be vs_6_2…), with and without this change.Offline census: every distinct slot 86 pixel stage of the capture behind #3814 through
compile_dxil gfx1013-mesh86-ps, main72cc7c7f4vs the same plus this change. Counts only, no shader bytes:graphics readfirstlane requires a wave-uniform reaching valueunsupported wave64 scalar mask operationNo stage gained or lost; this change clears the refusal and exposes the next one. In the stages I disassembled, that is
s_cselect_b64 sN, exec, 0inside the loop (row L2 on the #3814 board).Evidence and follow-up
native_direct_container_check.patched_pixel), MIT. Two loops are drawn on an 8×2 target, each checked against its trip count; a wrong trip count is the mismatch control for each draw. Four refusals plus a positive control: the same loop with the UAV store but no readfirstlane translates.s_cselect_b64 sN, exec, 0select in a loop; L3, in a loop every phi at a CMPX-arm merge counts as varying, also for registers the arm does not write. That also blocks loop counters that cross such an arm.Checklist
AI-assisted: prepared with Claude Code; the commands and results above were run on the author's PC.
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-03T00:57:03Z.
Rerun on the PR head
fead4acd5(main2f2901cbd, which adds #3839 to the pixel path), same host and builds as in the description:ctest … -R '^(native_pixel_(loop_|cmpx|compare_mask|dxil|waterfall)|native_graphics_wqm_|native_direct_container$)', dev-agility2f2901cbdvs this headunsupported wave64 scalar mask operationThe 24 now include #3839's
native_pixel_waterfall_w6_{controls,warp,hardware}; the waterfall stages are unchanged by this PR.The failing Windows CI test,
native_mesh_entry_registers_ir, is not from this change: this PR touches no mesh file, and it fails the same way locally at this head (AssertionError: ('wave-varying-branch', '')). #3838 added a case that expects av_readfirstlane_b32after a wave-varying SCC branch to be refused; #3894, merged shortly before, accepts that read at a converged full-EXEC join. Main at2f2901cbdhas both.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T01:53:13Z.
Review: COMMENTED
Independently verified
c5e1d5e4with MSVC Debug on Windows 11 build 26300. ctest --preset dev --no-tests=error -j 1 -R "^native_pixel_loop_(readfirstlane|entry_inputs)_(controls|warp|hardware)$": 6/6 passed, no skips. WARP and RTX 4060 Laptop (616.56) drew both counter cases and the existing entry-input cases. Removing only the deferred dependency check admitted varying-source and failed the control, and the restored compiler passed. Main has now picked up #3845. The trial merge has one hunk at the variable declarations: retain both vcc_skip_joins/vcc_skip_saves/vcc_skip_restores from main and loop_first_lane_reads from this PR. Please rerun this selection after rebasing.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T01:56:22Z.
I also trial-merged
c5e1d5e4with main at06251bd5. Keeping both sets of declarations resolved the only conflict. MSVC Debug, ctest --preset dev --no-tests=error -j 1 -R "^(native_pixel_loop_(readfirstlane|entry_inputs)(controls|warp|hardware)|native_pixel_varying_vcc_branch(controls|warp|hardware))$": 9/9 on the combined tree, including WARP and RTX 4060 Laptop, zero skips. The trial was local.Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-03T04:29:37Z.
Merged
main(430552934) into the branch asf5a822a33, keeping both declaration sets at the conflict as you described; the PR diff againstmainis unchanged (4 files, +181/−1).native_pixel_loop_(readfirstlane|entry_inputs)_*,native_pixel_varying_vcc_branch_*),-j 1native_pixel_(loop_|cmpx|compare_mask|dxil|waterfall|varying),native_graphics_wqm_,native_direct_container)Windows 10 build 19045, WARP 1.0.22.0 and RTX 3080 Ti (32.0.16.1047), Agility SDK 1.620.2, no skips.
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T04:36:45Z.
Review: APPROVED
Re-reviewed
f5a822a3withmain368a045d. The merge resolution retains both the existing varying-VCC declarations and the loop first-lane records. The current diff still applies the input-dependency, quad-vote and UAV refusal after loop dependencies settle. My earlier dependency-check mutation applies to the same guard, which is unchanged in this revision. MSVC Debugctest --preset dev --no-tests=error -j 1 --output-on-failure -R '^native_pixel_(loop_(readfirstlane|entry_inputs)|varying_vcc_branch|masked_region_alu|exec_writelane_vcc)_(controls|warp|hardware)$'passed 15/15 on the combined tree, including #3840 and #3834. Windows build 26300, WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656, D3D12 debug layer enabled, no capability skips.