Skip to content

shader: extend lane-local lowering in masked pixel regions (Part of #3814) - #3840

Draft
timbot103 wants to merge 1 commit into
R0Y00:mainfrom
timbot103:shader/pixel-masked-region-alu
Draft

timbot103 wants to merge 1 commit into
R0Y00:mainfrom
timbot103:shader/pixel-masked-region-alu

Conversation

@timbot103

Copy link
Copy Markdown
Contributor

Part of #3814.

Summary

Extends lane-local lowering inside flattened masked pixel regions (GraphicsMaskRegions SAVEEXEC and CMPX partitions) so additional read-only and lane-local operations lower with select-predicated VGPR writes instead of refusing with masked graphics region requires lane-local vector arithmetic:

  • Accepts s_clause and all three v_fma_mix* forms (v_fma_mix_f32, v_fma_mixlo_f16, v_fma_mixhi_f16).
  • Accepts fixed-binding explicit-LOD/gradient texture operations (image_load, image_load_mip, image_sample_d, image_sample_l, image_sample_lz, image_sample_c_lz) and fixed-table buffer_load_dword / buffer_load_format loads, guarding inactive-lane buffer addresses to element 0 and recording the minimum required view size on the binding.
  • Accepts arm-local v_cmp_* vcc, ... (consumed by v_cndmask_b32), fixed-offset bound-table s_buffer_load_dword*, and numeric scalar ALU (s_movk_i32, s_mov_b32, s_add_u32, s_lshl_b32, s_cselect_b32), expiring every arm-written SGPR/VCC/SCC at the complement and restore boundaries and refusing any overwrite of the saved EXEC pair.
  • Tightens helper_result_unobserved to require alu.graphics_predicate == coverage_predicate so narrower flattened arms never drop the incoming-value select.

Verification

  • ctest --preset pr --no-tests=error --output-on-failure -R '^native_pixel_masked_region_alu_controls$': passed (16 accepted DXIL cases + 24 refusal controls).
  • Debug (out/build/dev) and Release (out/build/release): 15/15 passed in each build with zero skips, including 14 exact 8×2 GPU readback draws on both WARP (10.0.26100.9818) and NVIDIA GeForce RTX 5080 (32.0.16.2140) on Windows 11 (26200.9974), plus offscreen_check --self-test in both builds. Negative controls differed on the exact 6 inactive pixels starting at (0,0).
  • tests/bidi_controls_check.py, tests/docs_links_check.py, and git diff --check origin/main..HEAD passed with zero new /W4 warnings on edited lines.
  • Opened as Draft under #3514's 5-PR ready cap; ready to promote once a review slot opens.

@lukaslw-lab lukaslw-lab left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 5c1c21d0 (draft) by reading the diff; not built or run.

Verdict: approve. Each newly flattened operation is safe to run for inactive lanes, and every scalar it writes expires where a skipped wave could differ. No MUST.

  • SHOULD Run a before/after ps86 census on f365f125. Besides the 344 targeted stages, pixel CMPX arms now go through flattened_op (gfx1013_direct_graphics.inl:1389), so VCC written in an arm now expires at the restore, where it used to stay readable. Expiring it is right, because the guest's v_cmp leaves 0 for lanes outside the arm. But a stage that read that VCC after the arm would now be refused, and the census would show whether any did.
  • NIT This also conflicts with #3829 in gfx1013_direct_graphics.inl, which makes #3829 conflict with four open pixel PRs. Merging #3829 last would keep that to one rebase.
  • Checked, no finding:
    • Speculation (:1002): images need a fixed descriptor (< 16) and either a texel load or an explicit-LOD or gradient sample with a constant sampler, so nothing depends on derivatives or another lane. A buffer read clamps an inactive lane's address to element 0 (gfx1013_direct_compute.inl:1060, :1086), and the binding's required size grows to cover it.
    • Scalars: only s_movk/s_mov/s_add_u32/s_lshl_b32/s_cselect on numeric operands, and fixed-offset s_buffer_load on a fixed descriptor. A write to the saved EXEC pair is refused. expire_arms (:1058) expires the first arm's writes at the complement and both arms' writes at the restore, SCC and VCC included.
    • helper_result_unobserved (:2156) now also requires the predicate to be the coverage predicate, so a narrower arm keeps its select.
    • masked-scalar was replaced by masked-scalar-escape: the scalar write is now accepted, and its later use outside the arm is refused. That is the intended change, not a weaker test.

Tests: _controls (16 cases, 24 refusals) is in the pr filter. The 14 WARP and hardware draws ran only locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants