shader: extend mesh heap and scalar memory proofs (Part of #3703) #3835

Merged
timbot103 merged 4 commits from upstream-pr/3835 into main 2026-12-03 01:48:02 +00:00
timbot103 commented 2026-12-02 08:10:12 +00:00 (Migrated from github.com)

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


Extends mesh resource-heap root-constant provenance beyond #3719 ("mesh heap slot lacks masked root constant provenance", 544 programs) and lowers verified root-SRV / fixed-table s_load_dword* scalar memory forms ("mesh scalar memory needs a verified guest root mapping: s_load_dwordx4", 77 programs) in src/gfx1013_direct_mesh.inl.

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

Summary

  • src/gfx1013_direct_mesh.inl:
    • Extended heap-slot root provenance: Propagates RootBits (((root >> shift) & mask) + base) through v_bfe_u32 / s_bfe_u32, v_and_b32 / s_and_b32 (both operand orders), v_lshrrev_b32 / s_lshr_b32, v_lshlrev_b32 / s_lshl_b32, v_add_nc_u32 / s_add_{u32,i32}, v_or_b32 / s_or_b32 (disjoint bit add), s_mul_i32, v_readfirstlane_b32 (at full EXEC), s_cselect_b32 / v_cndmask_b32 (identical proofs on both inputs), and CFG phi joins (matching proofs on both edges). Allows 4- and 8-dword typed heap fetches to fold aligned immediate byte offsets into MeshHeapRead::base.
    • Root-SRV & fixed-table scalar loads: Accepts s_load_dword* from verified Symbol::Type::root_address pairs (with matching high half) at immediate or proven constant SGPR offsets, and s_load_dwordx4 from declared root descriptor tables at aligned constant SGPR offsets validated against the table's descriptor ranges. Keeps GPU buffer words ineligible for CPU root-constant selectors and refuses unproven/unaligned/out-of-range offsets.
  • tests/native_mesh_heap_provenance_smem_check.py + tests/cmake/native_mesh_heap_provenance_smem.cmake:
    • native_mesh_heap_provenance_smem_ir (runs in pr CTest preset): 18 accepted cases verified against selector reports and DXIL + 27 fail-closed refusal controls.

Verification

Host: Windows 11 (10.0.26200.9974), MSVC C++20 /W4 (zero warnings in edited lines). Base origin/main f365f125.

  • ctest --preset pr --no-tests=error -R "^native_mesh_heap_provenance_smem_ir$": 1/1 passed (18 positive + 27 refusals).
  • Debug (dev) & Release (release): 3/3 passed in both configs (native_mesh_heap_provenance_smem_ir, native_direct_mesh, native_direct_container).
  • tests/bidi_controls_check.py, tests/docs_links_check.py, git diff --check origin/main..HEAD: all clean.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5602457318 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3835). Originally posted by [timbot103](https://github.com/timbot103) on 2026-12-02T08:10:12Z. --- Extends mesh resource-heap root-constant provenance beyond #3719 (`"mesh heap slot lacks masked root constant provenance"`, 544 programs) and lowers verified root-SRV / fixed-table `s_load_dword*` scalar memory forms (`"mesh scalar memory needs a verified guest root mapping: s_load_dwordx4"`, 77 programs) in `src/gfx1013_direct_mesh.inl`. Part of #3703. Refs #3641, #3719. *(Opened as Draft per #3514 until an active review slot frees.)* ## Summary - **`src/gfx1013_direct_mesh.inl`:** - **Extended heap-slot root provenance:** Propagates `RootBits` (`((root >> shift) & mask) + base`) through `v_bfe_u32` / `s_bfe_u32`, `v_and_b32` / `s_and_b32` (both operand orders), `v_lshrrev_b32` / `s_lshr_b32`, `v_lshlrev_b32` / `s_lshl_b32`, `v_add_nc_u32` / `s_add_{u32,i32}`, `v_or_b32` / `s_or_b32` (disjoint bit add), `s_mul_i32`, `v_readfirstlane_b32` (at full EXEC), `s_cselect_b32` / `v_cndmask_b32` (identical proofs on both inputs), and CFG `phi` joins (matching proofs on both edges). Allows 4- and 8-dword typed heap fetches to fold aligned immediate byte offsets into `MeshHeapRead::base`. - **Root-SRV & fixed-table scalar loads:** Accepts `s_load_dword*` from verified `Symbol::Type::root_address` pairs (with matching high half) at immediate or proven constant SGPR offsets, and `s_load_dwordx4` from declared root descriptor tables at aligned constant SGPR offsets validated against the table's descriptor ranges. Keeps GPU buffer words ineligible for CPU root-constant selectors and refuses unproven/unaligned/out-of-range offsets. - **`tests/native_mesh_heap_provenance_smem_check.py` + `tests/cmake/native_mesh_heap_provenance_smem.cmake`:** - `native_mesh_heap_provenance_smem_ir` (runs in `pr` CTest preset): 18 accepted cases verified against selector reports and DXIL + 27 fail-closed refusal controls. ## Verification Host: Windows 11 (`10.0.26200.9974`), MSVC C++20 `/W4` (zero warnings in edited lines). Base `origin/main` `f365f125`. - `ctest --preset pr --no-tests=error -R "^native_mesh_heap_provenance_smem_ir$"`: **1/1 passed** (18 positive + 27 refusals). - **Debug (`dev`) & Release (`release`):** 3/3 passed in both configs (`native_mesh_heap_provenance_smem_ir`, `native_direct_mesh`, `native_direct_container`). - `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:13:02 +00:00 (Migrated from github.com)

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

Review: APPROVED


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

Verdict: approve. Each new RootBits step keeps ((root >> shift) & mask) + base exact, and the new scalar loads go through the existing bounded root and table paths. No MUST.

  • SHOULD Run a before/after m86 census on f365f125 for the real gain on the 544 + 77. Clearing provenance can expose the next wall, and v_readfirstlane_b32 now forwards a root-derived source as-is under full EXEC (gfx1013_direct_mesh.inl:2455), so the census would also show any changed refusal. Follow-up is fine.
  • Checked, no finding:
    • Operand order (:235): v_lshrrev/v_lshlrev take the shift from src[0], v_bfe_u32 its width from src[2], and shift amounts use the low 5 bits.
    • Shifts, extracts and masks refuse a non-zero base. OR counts as ADD only with no base and no shared mask bits. ADD requires a masked selector, and add_slot_base (:229) keeps mask + base within the slot range. A scaled value accepts only a 32-byte-aligned ADD or OR.
    • s_cselect/v_cndmask and phi joins carry a proof only when both inputs have identical bits, so the selected value equals either one. Proofs come only from entry constants: loaded words are never added.
    • Root s_load_dword* (:1736): the high half must match, and the folded constant offset then reaches the shared root path, which refuses spans over 64 KB and passes the span to root_buffer_handle. A fixed-table s_load_dwordx4 needs a 32-byte-aligned slot inside a declared range, with APPEND offsets resolved in order (:1762).
    • A heap fetch with an immediate offset adds immediate >> 5 slots to the selector and moves the symbolic word offsets back by the same bytes, so the descriptor words stay relative to the fetched record.

Tests: native_mesh_heap_provenance_smem_ir (18 cases, 27 refusals) is in the pr filter.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6146934594 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3835#pullrequestreview-6146934594). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-12-02T08:13:02Z. **Review:** APPROVED --- Reviewed `5feae82d` (draft) by reading the diff; not built or run. **Verdict: approve.** Each new `RootBits` step keeps `((root >> shift) & mask) + base` exact, and the new scalar loads go through the existing bounded root and table paths. No MUST. - **SHOULD** Run a before/after `m86` census on `f365f125` for the real gain on the 544 + 77. Clearing provenance can expose the next wall, and `v_readfirstlane_b32` now forwards a root-derived source as-is under full EXEC (`gfx1013_direct_mesh.inl:2455`), so the census would also show any changed refusal. Follow-up is fine. - Checked, no finding: - Operand order (`:235`): `v_lshrrev`/`v_lshlrev` take the shift from `src[0]`, `v_bfe_u32` its width from `src[2]`, and shift amounts use the low 5 bits. - Shifts, extracts and masks refuse a non-zero `base`. OR counts as ADD only with no base and no shared mask bits. ADD requires a masked selector, and `add_slot_base` (`:229`) keeps `mask + base` within the slot range. A scaled value accepts only a 32-byte-aligned ADD or OR. - `s_cselect`/`v_cndmask` and phi joins carry a proof only when both inputs have identical bits, so the selected value equals either one. Proofs come only from entry constants: loaded words are never added. - Root `s_load_dword*` (`:1736`): the high half must match, and the folded constant offset then reaches the shared root path, which refuses spans over 64 KB and passes the span to `root_buffer_handle`. A fixed-table `s_load_dwordx4` needs a 32-byte-aligned slot inside a declared range, with APPEND offsets resolved in order (`:1762`). - A heap fetch with an immediate offset adds `immediate >> 5` slots to the selector and moves the symbolic word offsets back by the same bytes, so the descriptor words stay relative to the fetched record. Tests: `native_mesh_heap_provenance_smem_ir` (18 cases, 27 refusals) is in the `pr` filter.
lukaslw-lab commented 2026-12-02 20:27:30 +00:00 (Migrated from github.com)

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

Review: APPROVED


Re-review on 70d66873 (rebased on 5770f14e: vector_exec and uniform_alu_source from main).

Verdict: approve.

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

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

Same as the earlier head. The range-diff against my reviewed head contains only main's renames. The heap-slot refusal is the first refusal of many programs here, but none of them moves.

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. 544 programs stop first at the heap-slot refusal there, and none of them moves.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6158376888 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3835#pullrequestreview-6158376888). Originally posted by [lukaslw-lab](https://github.com/lukaslw-lab) on 2026-12-02T20:27:30Z. **Review:** APPROVED --- Re-review on `70d66873` (rebased on `5770f14e`: `vector_exec` and `uniform_alu_source` from main). **Verdict: approve.** Census, same capture and method as before (6,685 distinct mesh programs), main `5770f14e` vs this head: | | Programs | |---|---:| | Translate, main / with this PR | 1,047 / 1,047 | | Lost / gained / first refusal moved | 0 / 0 / 0 | Same as the earlier head. The range-diff against my reviewed head contains only main's renames. The heap-slot refusal is the first refusal of many programs here, but none of them moves. 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. 544 programs stop first at the heap-slot refusal there, and none of them moves. AI-assisted.
timbot103 commented 2026-12-02 23:04:55 +00:00 (Migrated from github.com)

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


Merged main (67862ee4) into this branch; the reviewed commit 70d66873 is unchanged.

  • The conflict was in gfx1013_direct_mesh.inl. The resolution keeps this PR's root-proven slot displacements together with main's opaque GPU-selected texture descriptors.
  • 1095b0d4 makes the Texture1D consumer apply the shift and displacement recorded in the manifest. A new IR control caught the mismatch.

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 13/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:7361539447 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3835#issuecomment-7361539447). Originally posted by [timbot103](https://github.com/timbot103) on 2026-12-02T23:04:55Z. --- Merged `main` (`67862ee4`) into this branch; the reviewed commit `70d66873` is unchanged. - The conflict was in `gfx1013_direct_mesh.inl`. The resolution keeps this PR's root-proven slot displacements together with main's opaque GPU-selected texture descriptors. - `1095b0d4` makes the Texture1D consumer apply the shift and displacement recorded in the manifest. A new IR control caught the mismatch. 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 13/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:59:42 +00:00 (Migrated from github.com)

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


705d91ab makes this PR independent of #3833.

#3833 allows DLC/GLC cache-policy bits on read-only scalar loads in the shared decoder, and mesh lowering uses that decoder. With both PRs merged, this PR's root-glc-dlc refusal control therefore compiled. Accepting those bits on a read-only load is correct, so the control, not the compiler, was out of date.

The control now uses a reserved SMEM address bit, which is refused with or without #3833, so it still checks that unsupported addressing fails closed.

Tests on main c42b7ce3, with and without #3833 merged:

  • native_mesh_heap_provenance_smem_ir passes in Debug and Release.
  • The mesh filter passed 14/14 in Debug and 11/14 in Release.
  • The 3 Release failures are the existing asynchronous WARP allocation fixtures. They also fail on clean main and pass with X2W_SYNC_MESH_REQUESTS=1.

The RTX 5080 checks pass.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7362671233 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3835#issuecomment-7362671233). Originally posted by [timbot103](https://github.com/timbot103) on 2026-12-02T23:59:42Z. --- `705d91ab` makes this PR independent of #3833. #3833 allows DLC/GLC cache-policy bits on read-only scalar loads in the shared decoder, and mesh lowering uses that decoder. With both PRs merged, this PR's `root-glc-dlc` refusal control therefore compiled. Accepting those bits on a read-only load is correct, so the control, not the compiler, was out of date. The control now uses a reserved SMEM address bit, which is refused with or without #3833, so it still checks that unsupported addressing fails closed. Tests on main `c42b7ce3`, with and without #3833 merged: - `native_mesh_heap_provenance_smem_ir` passes in Debug and Release. - The mesh filter passed 14/14 in Debug and 11/14 in Release. - The 3 Release failures are the existing asynchronous WARP allocation fixtures. They also fail on clean main and pass with `X2W_SYNC_MESH_REQUESTS=1`. The RTX 5080 checks pass.
timbot103 commented 2026-12-03 01:14:47 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by timbot103 on 2026-12-03T01:14:47Z.


Marked Ready for review now that the previous batch (#3832, #3838, #3839, #3844, #3847) has merged. This keeps us within 5 non-draft PRs per #3514. The branch merges cleanly into current main, and CI is green at this head.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7364122537 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3835#issuecomment-7364122537). Originally posted by [timbot103](https://github.com/timbot103) on 2026-12-03T01:14:47Z. --- Marked Ready for review now that the previous batch (#3832, #3838, #3839, #3844, #3847) has merged. This keeps us within 5 non-draft PRs per #3514. The branch merges cleanly into current main, and CI is green at this head.
R0Y00 commented 2026-12-03 01:47:57 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T01:47:57Z.

Review: APPROVED


Independently reviewed 705d91ab. At joins the selector survives only when its reaching root and every selector field agree. The byte displacement is folded into the selector once, and the encoded offset and table range are checked before publishing. Built compile_dxil on MSVC Debug and ran ctest --preset dev --no-tests=error -j 1 --output-on-failure -R "^(native_mesh_heap_provenance_smem_ir|native_direct_mesh)$": 2/2 passed. Removing the immediate alignment test made unaligned-heap-immediate translate and failed the fixture. The restored head passed again. This is compiler IR/selector verification.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6162300594 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3835#pullrequestreview-6162300594). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-03T01:47:57Z. **Review:** APPROVED --- Independently reviewed 705d91ab. At joins the selector survives only when its reaching root and every selector field agree. The byte displacement is folded into the selector once, and the encoded offset and table range are checked before publishing. Built compile_dxil on MSVC Debug and ran ctest --preset dev --no-tests=error -j 1 --output-on-failure -R "^(native_mesh_heap_provenance_smem_ir|native_direct_mesh)$": 2/2 passed. Removing the immediate alignment test made unaligned-heap-immediate translate and failed the fixture. The restored head passed again. This is compiler IR/selector verification.
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!3835
No description provided.