shader: extend native pixel descriptor waterfalls (Part of #3814) #3839

Merged
timbot103 merged 3 commits from upstream-pr/3839 into main 2026-12-03 00:26:04 +00:00
timbot103 commented 2026-12-02 08:23:13 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-02T08:23:13Z.


Extends native pixel descriptor waterfall recognition (PixelWaterfalls, item W6 of #3814, ~115 stages) across s_clause, v_cmp_eq + s_and_saveexec partition forms, non-in-place slot shifts, aligned SMEM immediate offsets, and additional read-only image operations.

Part of #3814. Refs #3210, #3640, #3641, #3703, #3823.
(Opened as Draft per #3514 until an active review slot frees.)

Summary

  • src/gfx1013_pixel_waterfall.inl:
    • Accepts s_clause in idle, both operand orders for v_cmp_eq_{i32,u32} / v_cmpx_eq_{i32,u32}, and wave32/wave64 v_cmp_eq_{i32,u32} + immediate s_and_saveexec_{b32,b64} (through VCC or SGPR pairs, poisoning compare/save destinations and checking all register overlap hazards).
    • Accepts non-in-place s_lshl_b32 sOff, sKey, 5 (poisoning sOff), aligned 32-byte SMEM immediate offsets ((load.b & 31) == 0), and additional read-only float SRV image opcodes (image_load_mip 1, image_get_resinfo 14, image_sample_d 34, image_sample_l 36, image_gather4_l 68, image_gather4_lz 71) alongside 0, 32, and 39.
    • Keeps biased samples, implicit gathers, comparison samples, unaligned offsets, invalid mask inputs, register overlaps, and escaped scratch values strictly refused.
  • src/gfx1013_direct_graphics.inl & src/gfx1013_direct_compute.inl:
    • Shifts proven bound-table and resource-heap waterfall spans by descriptor.offset / 32 with 32-bit wrap checks, and clears saved_exec/invariant_entry_masks/compare_masks/broken_compare_masks on poisoned waterfall scratch registers.
  • tests/native_pixel_waterfall_w6_check.py + tests/cmake/native_pixel_waterfall_w6.cmake + tests/native_sampled_pixel_gpu.cpp + docs/experiments/native-pixel-waterfall-w6.md + README.md:
    • native_pixel_waterfall_w6_controls (runs in pr CTest preset): 11 translated shapes + 16 refusal controls.
    • native_pixel_waterfall_w6_{warp,hardware}: 4 GPU draws matching all 28 covered pixels + 4 sentinel pixels on WARP and RTX 5080.

Verification

Host: Windows 11 (10.0.26200.9974), MSVC C++20 /W4 (zero warnings on edited lines), inbox WARP (10.0.26100.9818), NVIDIA GeForce RTX 5080 (32.0.16.2140; D3D12 debug layer unavailable). Base origin/main f365f125.

  • ctest --preset pr --no-tests=error -R "^native_pixel_waterfall_w6_controls$": 1/1 passed (11 positive + 16 refusals).
  • Debug (dev) & Release (release): 11/11 passed in both configs (native_pixel_waterfall_w6_*, native_indexed_pixel_texture_*, native_sampled_pixel_*, native_direct_container, native_graphics_wqm_*), zero skips.
  • tests/bidi_controls_check.py, tests/docs_links_check.py, git diff --check origin/main..HEAD: all clean.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5602636586 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3839). Originally posted by [timbot103](https://github.com/timbot103) on 2026-12-02T08:23:13Z. --- Extends native pixel descriptor waterfall recognition (`PixelWaterfalls`, item **W6** of #3814, ~115 stages) across `s_clause`, `v_cmp_eq + s_and_saveexec` partition forms, non-in-place slot shifts, aligned SMEM immediate offsets, and additional read-only image operations. Part of #3814. Refs #3210, #3640, #3641, #3703, #3823. *(Opened as Draft per #3514 until an active review slot frees.)* ## Summary - **`src/gfx1013_pixel_waterfall.inl`:** - Accepts `s_clause` in `idle`, both operand orders for `v_cmp_eq_{i32,u32}` / `v_cmpx_eq_{i32,u32}`, and wave32/wave64 `v_cmp_eq_{i32,u32}` + immediate `s_and_saveexec_{b32,b64}` (through VCC or SGPR pairs, poisoning compare/save destinations and checking all register overlap hazards). - Accepts non-in-place `s_lshl_b32 sOff, sKey, 5` (poisoning `sOff`), aligned 32-byte SMEM immediate offsets (`(load.b & 31) == 0`), and additional read-only float SRV image opcodes (`image_load_mip` `1`, `image_get_resinfo` `14`, `image_sample_d` `34`, `image_sample_l` `36`, `image_gather4_l` `68`, `image_gather4_lz` `71`) alongside `0`, `32`, and `39`. - Keeps biased samples, implicit gathers, comparison samples, unaligned offsets, invalid mask inputs, register overlaps, and escaped scratch values strictly refused. - **`src/gfx1013_direct_graphics.inl` & `src/gfx1013_direct_compute.inl`:** - Shifts proven bound-table and resource-heap waterfall spans by `descriptor.offset / 32` with 32-bit wrap checks, and clears `saved_exec`/`invariant_entry_masks`/`compare_masks`/`broken_compare_masks` on poisoned waterfall scratch registers. - **`tests/native_pixel_waterfall_w6_check.py` + `tests/cmake/native_pixel_waterfall_w6.cmake` + `tests/native_sampled_pixel_gpu.cpp` + `docs/experiments/native-pixel-waterfall-w6.md` + `README.md`:** - `native_pixel_waterfall_w6_controls` (runs in `pr` CTest preset): 11 translated shapes + 16 refusal controls. - `native_pixel_waterfall_w6_{warp,hardware}`: 4 GPU draws matching all 28 covered pixels + 4 sentinel pixels on WARP and RTX 5080. ## Verification Host: Windows 11 (`10.0.26200.9974`), MSVC C++20 `/W4` (zero warnings on edited lines), inbox WARP (`10.0.26100.9818`), NVIDIA GeForce RTX 5080 (`32.0.16.2140`; D3D12 debug layer unavailable). Base `origin/main` `f365f125`. - `ctest --preset pr --no-tests=error -R "^native_pixel_waterfall_w6_controls$"`: **1/1 passed** (11 positive + 16 refusals). - **Debug (`dev`) & Release (`release`):** 11/11 passed in both configs (`native_pixel_waterfall_w6_*`, `native_indexed_pixel_texture_*`, `native_sampled_pixel_*`, `native_direct_container`, `native_graphics_wqm_*`), zero skips. - `tests/bidi_controls_check.py`, `tests/docs_links_check.py`, `git diff --check origin/main..HEAD`: all clean.
lukaslw-lab commented 2026-12-02 08:29:08 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-02T08:29:08Z.

Review: APPROVED


Reviewed 7e2560a1 (draft) by reading the diff; not built or run.

Verdict: approve. Each new waterfall form still selects exactly the lanes whose key equals the read key, and every new scratch register is poisoned. No MUST.

  • SHOULD Run a before/after ps86 census on f365f125. The W6 row (~115) comes from the shape sample. The waterfall walls on main (the key, descriptor and EXEC copies overlap 376, the slot key is not shifted 252, the image does not use the descriptor 121) show how many stages reach this matcher, and the census would show how many it now clears.
  • NIT The poisoned-register loop (gfx1013_direct_graphics.inl:2221) is also edited by #3834 (drop_compare_mask). This version already erases the compare masks, so on rebase it can absorb #3834's call.
  • Checked, no finding:
    • Compare form (gfx1013_pixel_waterfall.inl:69): v_cmp_eq into VCC or a pair, then an s_and_saveexec at cmp.next on that destination, gives the same partition as v_cmpx_eq. Both destinations are checked against the key, descriptor and EXEC copies, and are forgotten after the loop (:148). The key may be on either side of the compare.
    • A non-in-place shift must read the key and write an ordinary SGPR. The load must use that register as its offset, and the overlap checks cover it.
    • Immediate offsets: an aligned load.b (:92) becomes descriptor.offset. In the lowering (:2248), the key is converted from bytes to slots before base_slot is added, the span moves by the same amount, and the wrap is checked. The bound-table path now accepts only offsets that are multiples of 32.
    • readonly_image adds only explicit-LOD forms plus get_resinfo and load_mip. Biased samples, implicit gathers and compares stay out.

Tests: _controls (11 shapes, 16 refusals) is in the pr filter. _warp/_hardware (the offset mode at mip 1, plus sentinels) ran only locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6147149522 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3839#pullrequestreview-6147149522). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-12-02T08:29:08Z. **Review:** APPROVED --- Reviewed `7e2560a1` (draft) by reading the diff; not built or run. **Verdict: approve.** Each new waterfall form still selects exactly the lanes whose key equals the read key, and every new scratch register is poisoned. No MUST. - **SHOULD** Run a before/after `ps86` census on `f365f125`. The W6 row (~115) comes from the shape sample. The waterfall walls on main (`the key, descriptor and EXEC copies overlap` 376, `the slot key is not shifted` 252, `the image does not use the descriptor` 121) show how many stages reach this matcher, and the census would show how many it now clears. - **NIT** The poisoned-register loop (`gfx1013_direct_graphics.inl:2221`) is also edited by #3834 (`drop_compare_mask`). This version already erases the compare masks, so on rebase it can absorb #3834's call. - Checked, no finding: - Compare form (`gfx1013_pixel_waterfall.inl:69`): `v_cmp_eq` into VCC or a pair, then an `s_and_saveexec` at `cmp.next` on that destination, gives the same partition as `v_cmpx_eq`. Both destinations are checked against the key, descriptor and EXEC copies, and are forgotten after the loop (`:148`). The key may be on either side of the compare. - A non-in-place shift must read the key and write an ordinary SGPR. The load must use that register as its offset, and the overlap checks cover it. - Immediate offsets: an aligned `load.b` (`:92`) becomes `descriptor.offset`. In the lowering (`:2248`), the key is converted from bytes to slots before `base_slot` is added, the span moves by the same amount, and the wrap is checked. The bound-table path now accepts only offsets that are multiples of 32. - `readonly_image` adds only explicit-LOD forms plus `get_resinfo` and `load_mip`. Biased samples, implicit gathers and compares stay out. Tests: `_controls` (11 shapes, 16 refusals) is in the `pr` filter. `_warp`/`_hardware` (the offset mode at mip 1, plus sentinels) ran only locally.
lukaslw-lab commented 2026-12-02 10:34:37 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-02T10:34:37Z.


Census follow-up for the SHOULD in my review: f365f125 + this PR alone, same capture and method as #3814 (6,436 distinct pixel stages). Counts only. None lost, no validation failures.

Build Pixel translated Moved
f365f125 272 —
f365f125 + #3839 272 252

All 252 pixel descriptor waterfall: the slot key is not shifted to a descriptor byte offset stages now pass that check and stop at pixel descriptor waterfall: the image does not use the descriptor loaded at the read key. The 376 the key, descriptor and EXEC copies overlap stages do not move.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7342672768 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3839#issuecomment-7342672768). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-12-02T10:34:37Z. --- Census follow-up for the SHOULD in my review: `f365f125` + this PR alone, same capture and method as #3814 (6,436 distinct pixel stages). Counts only. **None lost**, no validation failures. | Build | Pixel translated | Moved | |---|---:|---:| | `f365f125` | 272 | — | | `f365f125` + #3839 | 272 | 252 | All 252 `pixel descriptor waterfall: the slot key is not shifted to a descriptor byte offset` stages now pass that check and stop at `pixel descriptor waterfall: the image does not use the descriptor loaded at the read key`. The 376 `the key, descriptor and EXEC copies overlap` stages do not move.
lukaslw-lab commented 2026-12-02 20:27:32 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-02T20:27:32Z.

Review: APPROVED


Re-review on 18bac983 (rebased on 5770f14e, plus track wave32 waterfall EXEC copies by register).

Verdict: approve.

Census, same capture and method as before (6,436 distinct pixel stages), main 5770f14e vs this head:

Stages
Translate, main / with this PR 272 / 272
Lost / gained 0 / 0
First refusal moved 252: the slot key is not shifted to a descriptor → the image does not use the descriptor load

Same as the earlier head. The new commit is right: in wave32 EXEC is one SGPR, so preserves_exec now follows s_mov_b32 copies and clobbers single registers instead of aligned pairs. The added cases cover a valid odd SGPR and a clobber of the same register.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6158377507 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3839#pullrequestreview-6158377507). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-12-02T20:27:32Z. **Review:** APPROVED --- Re-review on `18bac983` (rebased on `5770f14e`, plus `track wave32 waterfall EXEC copies by register`). **Verdict: approve.** Census, same capture and method as before (6,436 distinct pixel stages), main `5770f14e` vs this head: | | Stages | |---|---:| | Translate, main / with this PR | 272 / 272 | | Lost / gained | 0 / 0 | | First refusal moved | 252: `the slot key is not shifted to a descriptor` → `the image does not use the descriptor load` | Same as the earlier head. The new commit is right: in wave32 EXEC is one SGPR, so `preserves_exec` now follows `s_mov_b32` copies and clobbers single registers instead of aligned pairs. The added cases cover a valid odd SGPR and a clobber of the same register. AI-assisted.
timbot103 commented 2026-12-02 22:58:41 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-02T22:58:41Z.


Merged main (67862ee4) into this branch (cf89def5). The merge was clean, and the reviewed commits e99e2414 and 18bac983 are unchanged; no follow-up fix was needed.

Tests, Windows 11 26200 with RTX 5080 and WARP:

  • native_pixel_|native_graphics_|native_direct_container passed 39/39 in Debug and 39/39 in Release.
  • The PR preset passed 3/3.
  • A full Debug build of every target, including native_compute_pack_refusal_check, succeeded.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7361404804 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3839#issuecomment-7361404804). Originally posted by [timbot103](https://github.com/timbot103) on 2026-12-02T22:58:41Z. --- Merged `main` (`67862ee4`) into this branch (`cf89def5`). The merge was clean, and the reviewed commits `e99e2414` and `18bac983` are unchanged; no follow-up fix was needed. Tests, Windows 11 26200 with RTX 5080 and WARP: - `native_pixel_|native_graphics_|native_direct_container` passed 39/39 in Debug and 39/39 in Release. - The PR preset passed 3/3. - A full Debug build of every target, including `native_compute_pack_refusal_check`, succeeded.
timbot103 commented 2026-12-02 23:47:31 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-02T23:47:31Z.


Marked Ready for review now that #3827 and #3829 have merged, keeping to 5 non-draft PRs per #3514. CI is green at this head. All 17 open PRs from this batch were also merged together onto main c42b7ce3. That combined tree passes a full build, and the only problems it showed were pre-existing main flakes plus one #3833/#3835 fixture issue that does not involve this PR; the #3835 fix is coming.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7362430024 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3839#issuecomment-7362430024). Originally posted by [timbot103](https://github.com/timbot103) on 2026-12-02T23:47:31Z. --- Marked Ready for review now that #3827 and #3829 have merged, keeping to 5 non-draft PRs per #3514. CI is green at this head. All 17 open PRs from this batch were also merged together onto main `c42b7ce3`. That combined tree passes a full build, and the only problems it showed were pre-existing main flakes plus one #3833/#3835 fixture issue that does not involve this PR; the #3835 fix is coming.
R0Y00 commented 2026-12-03 00:24:49 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T00:24:49Z.

Review: APPROVED


Independently reviewed this head. The selected descriptor span sets the base once, and scratch writes clear the previous provenance. MSVC x64 Debug passed the source-built native_pixel_waterfall_w6_controls suite (11 translations, 16 refusals), plus the WARP and RTX 4060 Laptop cases (four per adapter, each checking 28 covered pixels and four untouched sentinels). Ran ctest --preset dev --no-tests=error -j 1 --output-on-failure -R '^native_pixel_waterfall_w6_'. Setting the descriptor base slot to zero failed the control at the two reflected SRV offsets. The restored head passed again. The trial merge against 0b83a346b was clean.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6161510650 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3839#pullrequestreview-6161510650). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-03T00:24:49Z. **Review:** APPROVED --- Independently reviewed this head. The selected descriptor span sets the base once, and scratch writes clear the previous provenance. MSVC x64 Debug passed the source-built `native_pixel_waterfall_w6_controls` suite (11 translations, 16 refusals), plus the WARP and RTX 4060 Laptop cases (four per adapter, each checking 28 covered pixels and four untouched sentinels). Ran `ctest --preset dev --no-tests=error -j 1 --output-on-failure -R '^native_pixel_waterfall_w6_'`. Setting the descriptor base slot to zero failed the control at the two reflected SRV offsets. The restored head passed again. The trial merge against `0b83a346b` was clean.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!3839
No description provided.