shader: lower proven mesh entry wave-info reads (Part of #3703) #3838

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

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


Generalizes proven ES+GS entry WaveInSubgroup projections and validates FSSM mesh user-data spans and widths.

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

Summary

  • Accept constant s_bfe_u32 and s_and_b32 projections confined to bits 24 through 27 while s3 holds its entry value. Reads touching other bits and dynamic masks still refuse. After s3 is overwritten, use ordinary scalar arithmetic.
  • Keep wave-local uniformity for WaveInSubgroup. Branching on it clears group_flow so a divergent branch cannot reach a group barrier.
  • Keep main's full-EXEC v_readfirstlane_b32 sDst, v5 shortcut when the reaching group value is known. The pre-exchange fixture verifies that the unshifted group seed and wave number reach POS0. The post-exchange fixture verifies the shifted group value. A read with an unproven seed still refuses.
  • Validate FSSM reflected mesh input ranges and widths within the 32 user SGPRs after s0..s7. Compute-only TGID and thread-ID VGPR assumptions still refuse.

Verification

Rebased on 5770f14e and tested at d2261ce7 on Windows 11 with MSVC and the Windows SDK DXC.

  • native_mesh_entry_registers_ir passed in fresh Debug and Release builds. The test is registered in the pr preset.
  • The original compiler refused the new pre-exchange fixture with unproven mesh entry register 261. The rebased compiler passed it in both configurations.
  • Bidi controls, documentation links, and Git whitespace checks passed.
  • The 6,685-program Mesh86 census on the same base remains pending.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5602554982 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3838). Originally posted by [timbot103](https://github.com/timbot103) on 2026-12-02T08:17:13Z. --- Generalizes proven ES+GS entry `WaveInSubgroup` projections and validates FSSM mesh user-data spans and widths. Part of #3703. Refs #3641. *(Opened as Draft per #3514 until an active review slot frees.)* ## Summary - Accept constant `s_bfe_u32` and `s_and_b32` projections confined to bits 24 through 27 while `s3` holds its entry value. Reads touching other bits and dynamic masks still refuse. After `s3` is overwritten, use ordinary scalar arithmetic. - Keep wave-local uniformity for `WaveInSubgroup`. Branching on it clears `group_flow` so a divergent branch cannot reach a group barrier. - Keep main's full-EXEC `v_readfirstlane_b32 sDst, v5` shortcut when the reaching group value is known. The pre-exchange fixture verifies that the unshifted group seed and wave number reach POS0. The post-exchange fixture verifies the shifted group value. A read with an unproven seed still refuses. - Validate FSSM reflected mesh input ranges and widths within the 32 user SGPRs after `s0..s7`. Compute-only TGID and thread-ID VGPR assumptions still refuse. ## Verification Rebased on `5770f14e` and tested at `d2261ce7` on Windows 11 with MSVC and the Windows SDK DXC. - `native_mesh_entry_registers_ir` passed in fresh Debug and Release builds. The test is registered in the `pr` preset. - The original compiler refused the new pre-exchange fixture with `unproven mesh entry register 261`. The rebased compiler passed it in both configurations. - Bidi controls, documentation links, and Git whitespace checks passed. - The 6,685-program Mesh86 census on the same base remains pending.
lukaslw-lab commented 2026-12-02 08:19:39 +00:00 (Migrated from github.com)

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

Review: APPROVED


Reviewed 3a7dfe0d (draft) by reading the diff; not built or run.

Verdict: approve. The s3[27:24] reads are exact, and the two tightenings fix real gaps. No MUST.

  • SHOULD Run a before/after m86 census on f365f125. The #3703 row (392) counts about 25 different entry registers, and this PR clears only s3 reads confined to WaveInSubgroup. The two tightenings below can also refuse programs that translate today. The census would show the real gain and confirm that none is lost.
  • Checked, no finding:
    • entry_wave_info (gfx1013_direct_mesh.inl:93): for s_bfe_u32 it takes the offset from S1[4:0] and the width from S1[22:16], and accepts only fields inside bits 24–27. The result (wave_number >> (offset-24)) & mask equals the guest field because wave_number is below 16 (at most 4 waves of 64 or 8 of 32). An s_and_b32 mask outside 0x0f000000 falls back to the refusal, SCC is result != 0 for both, and once s3 is written the generic path takes over.
    • v5 guard (:2394): before the exchange, exchanged_group is the seed, which the exchange then shifts right by 7 (:1224). A v_readfirstlane before that point used to return the unshifted seed for every wave. Refusing it is a fix, not a loss.
    • FSSM spans (:129): user_data + count ≤ 32. Type 1 must be 2 words with offset_dwords == 0, where a non-zero offset used to be dropped silently. Types 3 and 5 must be 1 word. The inputs entries are otherwise unchanged (count for type 0, the root-descriptor flag for type 1).

Tests: native_mesh_entry_registers_ir is in the pr filter. It covers the subfields in wave32 and wave64, an overwritten s3, a v5 read before the exchange, and the FSSM range and width refusals.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6147015972 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3838#pullrequestreview-6147015972). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-12-02T08:19:39Z. **Review:** APPROVED --- Reviewed `3a7dfe0d` (draft) by reading the diff; not built or run. **Verdict: approve.** The `s3[27:24]` reads are exact, and the two tightenings fix real gaps. No MUST. - **SHOULD** Run a before/after `m86` census on `f365f125`. The #3703 row (392) counts about 25 different entry registers, and this PR clears only `s3` reads confined to `WaveInSubgroup`. The two tightenings below can also refuse programs that translate today. The census would show the real gain and confirm that none is lost. - Checked, no finding: - `entry_wave_info` (`gfx1013_direct_mesh.inl:93`): for `s_bfe_u32` it takes the offset from `S1[4:0]` and the width from `S1[22:16]`, and accepts only fields inside bits 24–27. The result `(wave_number >> (offset-24)) & mask` equals the guest field because `wave_number` is below 16 (at most 4 waves of 64 or 8 of 32). An `s_and_b32` mask outside `0x0f000000` falls back to the refusal, SCC is `result != 0` for both, and once `s3` is written the generic path takes over. - `v5` guard (`:2394`): before the exchange, `exchanged_group` is the seed, which the exchange then shifts right by 7 (`:1224`). A `v_readfirstlane` before that point used to return the unshifted seed for every wave. Refusing it is a fix, not a loss. - FSSM spans (`:129`): `user_data + count ≤ 32`. Type 1 must be 2 words with `offset_dwords == 0`, where a non-zero offset used to be dropped silently. Types 3 and 5 must be 1 word. The `inputs` entries are otherwise unchanged (`count` for type 0, the root-descriptor flag for type 1). Tests: `native_mesh_entry_registers_ir` is in the `pr` filter. It covers the subfields in wave32 and wave64, an overwritten `s3`, a `v5` read before the exchange, and the FSSM range and width refusals.
lukaslw-lab commented 2026-12-02 08:51:46 +00:00 (Migrated from github.com)

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

Review: CHANGES_REQUESTED


Follow-up to my approval: a mesh census of f365f125 + this PR alone shows that it refuses every captured Mesh86 program. I missed this when reading the diff.

Verdict: changes requested.

Build Mesh programs translated First refusal unproven mesh entry register 261
f365f125 + #3825 1,039 of 6,685 0
f365f125 + #3838 0 of 6,685 6,685

Same capture and method as the #3703 census (compile_dxil … gfx1013-container-ms-texture-heap). Counts only.

  • MUST Nearly every program starts with this prologue (registers as captured):
    s_mov_b64 exec, -1
    v_mbcnt_lo_u32_b32 v0, -1, 0
    v_readfirstlane_b32 s0, v5        ; refused here
    s_bfe_u32 s1, s3, 0x40018
    
    There is no group exchange before it, so exchanged_group == entry_group_seed and the new guard (gfx1013_direct_mesh.inl:2394) sends the read to the generic path, which refuses v5. On main this read takes the exchanged_group shortcut.
  • Two outcomes are possible, and the PR should say which applies:
    • If v_readfirstlane v5 at entry does yield the seed (the source lane's value in this ABI), the guard is too broad. It should refuse only a read between the seed and a matched exchange later in the program.
    • If main's shortcut is wrong here, the 1,039 programs that translate on main read the wrong group value. That would be a correctness bug on main and deserves its own issue with evidence, not a side effect of this PR.
  • My earlier "fix, not a loss" note on the v5 guard was wrong. The s3[27:24] and FSSM parts are unaffected.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6147445979 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3838#pullrequestreview-6147445979). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-12-02T08:51:46Z. **Review:** CHANGES_REQUESTED --- Follow-up to my approval: a mesh census of `f365f125` + this PR alone shows that it refuses every captured Mesh86 program. I missed this when reading the diff. **Verdict: changes requested.** | Build | Mesh programs translated | First refusal `unproven mesh entry register 261` | |---|---:|---:| | `f365f125` + #3825 | 1,039 of 6,685 | 0 | | `f365f125` + #3838 | **0** of 6,685 | **6,685** | Same capture and method as the #3703 census (`compile_dxil … gfx1013-container-ms-texture-heap`). Counts only. - **MUST** Nearly every program starts with this prologue (registers as captured): ``` s_mov_b64 exec, -1 v_mbcnt_lo_u32_b32 v0, -1, 0 v_readfirstlane_b32 s0, v5 ; refused here s_bfe_u32 s1, s3, 0x40018 ``` There is no group exchange before it, so `exchanged_group == entry_group_seed` and the new guard (`gfx1013_direct_mesh.inl:2394`) sends the read to the generic path, which refuses `v5`. On main this read takes the `exchanged_group` shortcut. - Two outcomes are possible, and the PR should say which applies: - If `v_readfirstlane v5` at entry does yield the seed (the source lane's value in this ABI), the guard is too broad. It should refuse only a read between the seed and a matched exchange later in the program. - If main's shortcut is wrong here, the 1,039 programs that translate on main read the wrong group value. That would be a correctness bug on main and deserves its own issue with evidence, not a side effect of this PR. - My earlier "fix, not a loss" note on the `v5` guard was wrong. The `s3[27:24]` and FSSM parts are unaffected.
lukaslw-lab commented 2026-12-02 19:35:38 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by lukaslw-lab on 2026-12-02T19:35:38Z.

Review: APPROVED


Re-review on d2261ce7 (rebased on 5770f14e).

Verdict: approve. This replaces my change request. The entry_group_seed guard is gone, v_readfirstlane_b32 is left untouched, and the new v5-before-exchange prologue case covers the shape I reported.

Census, same capture and method as before (6,685 distinct mesh programs), main 5770f14e vs this head:

Programs
Translate, main 1,047
Translate, with this PR 1,047
Lost / gained / first refusal moved 0 / 0 / 0

The earlier head refused all 6,685 programs at the prologue; this head refuses none of them there. No program in this capture stops first at s3; the remaining unproven mesh entry register refusals are VGPRs (262–314), so no movement is expected from this PR.

Checked in entry_wave_info:

  • s_bfe_u32 reads only bits 24–27 (offset 24–27, width within the field); SCC is the result ≠ 0, as RDNA 2 defines it for both forms.
  • s_and_b32 masks inside 0x0f000000 only; any other bit refuses through graphics_input(3).
  • A written s3 (graphics_registers.count(3)) falls back to the normal path.

NIT: the FSSM user-data range/width check is separate hardening from the wave-info read. It loses nothing here, but one line about it in the PR body would help the next reader.

Update: the first run was on a main that refused 257 programs early (my #3707, #3892; fixed by #3893). I reran main 5770f14e and this head, both with that fix: 0 moved, 0 lost, 0 gained. The numbers above are unchanged.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6157564352 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3838#pullrequestreview-6157564352). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-12-02T19:35:38Z. **Review:** APPROVED --- Re-review on `d2261ce7` (rebased on `5770f14e`). **Verdict: approve.** This replaces my change request. The `entry_group_seed` guard is gone, `v_readfirstlane_b32` is left untouched, and the new `v5-before-exchange` prologue case covers the shape I reported. Census, same capture and method as before (6,685 distinct mesh programs), main `5770f14e` vs this head: | | Programs | |---|---:| | Translate, main | 1,047 | | Translate, with this PR | 1,047 | | Lost / gained / first refusal moved | 0 / 0 / 0 | The earlier head refused all 6,685 programs at the prologue; this head refuses none of them there. No program in this capture stops first at `s3`; the remaining `unproven mesh entry register` refusals are VGPRs (262–314), so no movement is expected from this PR. Checked in `entry_wave_info`: - `s_bfe_u32` reads only bits 24–27 (offset 24–27, width within the field); SCC is the result ≠ 0, as RDNA 2 defines it for both forms. - `s_and_b32` masks inside `0x0f000000` only; any other bit refuses through `graphics_input(3)`. - A written `s3` (`graphics_registers.count(3)`) falls back to the normal path. NIT: the FSSM user-data range/width check is separate hardening from the wave-info read. It loses nothing here, but one line about it in the PR body would help the next reader. Update: the first run was on a main that refused 257 programs early (my #3707, #3892; fixed by #3893). I reran main `5770f14e` and this head, both with that fix: 0 moved, 0 lost, 0 gained. The numbers above are unchanged. AI-assisted.
timbot103 commented 2026-12-02 23:04:57 +00:00 (Migrated from github.com)

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


Merged main (67862ee4) into this branch. The reviewed commit d2261ce7 is unchanged, and no follow-up fix was needed.

Tests, Windows 11 26200 with RTX 5080 and WARP. The mesh filter was native_direct_mesh|native_direct_container|native_mesh_ plus this PR's own tests. Every branch passed a full Debug build of every target, including the C++17 native_compute_pack_refusal_check.

  • Debug passed 16/16. Release passed 15/16, and the PR preset passed 1/1.
  • The Release failures are the existing asynchronous WARP allocation fixtures (accepted=1 refused=0). They also fail on a clean 67862ee4, and every one of them passed with X2W_SYNC_MESH_REQUESTS=1.

All six mesh PRs (#3832, #3835, #3838, #3842, #3843 and #3846) were also merged together onto 67862ee4. That combined tree passed 47/47 in Debug and 47/47 in Release, plus 8/8 under the PR preset. All 15 pairs merge cleanly.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7361540170 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3838#issuecomment-7361540170). Originally posted by [timbot103](https://github.com/timbot103) on 2026-12-02T23:04:57Z. --- Merged `main` (`67862ee4`) into this branch. The reviewed commit `d2261ce7` is unchanged, and no follow-up fix was needed. Tests, Windows 11 26200 with RTX 5080 and WARP. The mesh filter was `native_direct_mesh|native_direct_container|native_mesh_` plus this PR's own tests. Every branch passed a full Debug build of every target, including the C++17 `native_compute_pack_refusal_check`. - Debug passed 16/16. Release passed 15/16, and the PR preset passed 1/1. - The Release failures are the existing asynchronous WARP allocation fixtures (`accepted=1 refused=0`). They also fail on a clean `67862ee4`, and every one of them passed with `X2W_SYNC_MESH_REQUESTS=1`. All six mesh PRs (#3832, #3835, #3838, #3842, #3843 and #3846) were also merged together onto `67862ee4`. That combined tree passed 47/47 in Debug and 47/47 in Release, plus 8/8 under the PR preset. All 15 pairs merge cleanly.
timbot103 commented 2026-12-02 23:47:28 +00:00 (Migrated from github.com)

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


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:7362429174 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3838#issuecomment-7362429174). Originally posted by [timbot103](https://github.com/timbot103) on 2026-12-02T23:47:28Z. --- 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:08 +00:00 (Migrated from github.com)

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

Review: APPROVED


Independently reviewed this head. The wave-info projection is limited to s3 bits 24–27, checks the field bounds before shifting, and preserves ordinary reads after an s3 write. The reflected user-data paths check width and the ES+GS range before assigning registers.

MSVC x64 Debug: ctest --preset dev --no-tests=error -j 1 --output-on-failure -R '^(native_mesh_entry_registers_ir|native_direct_mesh)$' passed 2/2, including the existing refusal cases. The trial merge against 0b83a346b was clean.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6161504857 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3838#pullrequestreview-6161504857). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-03T00:24:08Z. **Review:** APPROVED --- Independently reviewed this head. The wave-info projection is limited to s3 bits 24–27, checks the field bounds before shifting, and preserves ordinary reads after an s3 write. The reflected user-data paths check width and the ES+GS range before assigning registers. MSVC x64 Debug: `ctest --preset dev --no-tests=error -j 1 --output-on-failure -R '^(native_mesh_entry_registers_ir|native_direct_mesh)$'` passed 2/2, including the existing refusal cases. 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!3838
No description provided.