shader: lower multi-component typed buffer loads in mesh (Part of #3703) #3848

Manually merged
github merged 5 commits from github-bot/gh-3846 into gh-pr/3846/base 2026-12-03 04:17:55 +00:00 AGit
Owner

@⁠timbot103 on GitHub · 2026-12-02 08:48 UTC · original
timbot103:shader/mesh-buffer-load-format-xyzw → main · +298 −27 · 6 files · 5 commits · merged 2026-12-03 04:15 UTC

Part of #3705.

Summary

Targets the #2 remaining wall from the 2 Dec stacked mesh census (buffer_load_format_xyzw, 164 programs):

  • Extends direct mesh buffer_load_format lowering in src/gfx1013_direct_mesh.inl to support 1- through 4-component descriptor-table typed loads (buffer_load_format_x, _xy, _xyz, _xyzw) on wave32 and wave64, including EXECZ skips and SAVEEXEC arms (recording partial_writes for all format_width destinations).
  • Tightens scalar_count to format_width for group-uniform propagation (uniform_values + group_uniform) and clears exchanged_group whenever a multi-component table load spans v5.
  • Preserves the single-component R32_UINT resource-heap contract (format_width == 1) and refuses wider resource-heap loads without a runtime contract.

Verification

  • Built compile_dxil in Debug (dev) and Release (release) with zero new C++20 /W4 warnings on edited lines.
  • ctest --preset pr --no-tests=error --output-on-failure -R '^native_mesh_buffer_load_format_ir$': passed (46 validated DXIL modules + 26 expected refusals).
  • Debug (dev) and Release (release): 3/3 passed (native_mesh_buffer_load_format_ir|native_direct_mesh|native_direct_container), zero skips.
  • tests/bidi_controls_check.py, tests/docs_links_check.py, and git diff --check origin/main..HEAD passed.
  • Opened as Draft under #3514's 5-PR ready cap.
**@⁠timbot103** on GitHub · 2026-12-02 08:48 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3846) `timbot103:shader/mesh-buffer-load-format-xyzw` → `main` · +298 −27 · 6 files · 5 commits · merged 2026-12-03 04:15 UTC Part of #3705. ### Summary Targets the #2 remaining wall from the 2 Dec stacked mesh census (`buffer_load_format_xyzw`, 164 programs): - Extends direct mesh `buffer_load_format` lowering in `src/gfx1013_direct_mesh.inl` to support 1- through 4-component descriptor-table typed loads (`buffer_load_format_x`, `_xy`, `_xyz`, `_xyzw`) on wave32 and wave64, including `EXECZ` skips and `SAVEEXEC` arms (recording `partial_writes` for all `format_width` destinations). - Tightens `scalar_count` to `format_width` for group-uniform propagation (`uniform_values` + `group_uniform`) and clears `exchanged_group` whenever a multi-component table load spans `v5`. - Preserves the single-component `R32_UINT` resource-heap contract (`format_width == 1`) and refuses wider resource-heap loads without a runtime contract. ### Verification - Built `compile_dxil` in Debug (`dev`) and Release (`release`) with zero new C++20 `/W4` warnings on edited lines. - `ctest --preset pr --no-tests=error --output-on-failure -R '^native_mesh_buffer_load_format_ir$'`: passed (**46 validated DXIL modules + 26 expected refusals**). - Debug (`dev`) and Release (`release`): 3/3 passed (`native_mesh_buffer_load_format_ir|native_direct_mesh|native_direct_container`), zero skips. - `tests/bidi_controls_check.py`, `tests/docs_links_check.py`, and `git diff --check origin/main..HEAD` passed. - Opened as Draft under `#3514`'s 5-PR ready cap.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 08:51:17 +00:00
Author
Owner

@⁠lukaslw-lab on GitHub · 2026-12-02 09:34 UTC · original · approved these changes

Reviewed 5bddf66d (draft) by reading the diff and running an offline mesh census of this PR alone; not otherwise built or run.

Verdict: approve. Typed table loads of 1–4 components go through the shared typed-buffer path, and the widened uniformity and v5 bookkeeping follow the component count. No MUST.

Census, f365f125 + this PR alone, same capture as #3705 (6,685 mesh programs): 1,036 translate on both builds, none lost, no validation failures. 35 programs move off v_readfirstlane_b32, because the loaded words are now uniform: 17 to ds_swizzle_b32, 10 to s_load_dwordx4, 5 to the VCC whole-wave mask. The 164-program buffer_load_format_xyzw wall appears only after other PRs clear earlier walls, so this capture cannot show it directly.

  • NIT This conflicts with #3808 and #3792 in lower_mesh.
  • Checked, no finding:
    • Dropping the explicit addressing check is safe. The decoder admits buffer_load_format only with IDXEN-only (or, direct, no) addressing, no 0x02000000 bit and SOFFSET inline 0 (gfx1013_compute_native.cpp:290), so no OFFEN or per-lane offset can reach the uniform rule.
    • format_width = op + 1 (gfx1013_direct_mesh.inl:1447) now drives scalar_count, partial_writes under narrowed EXEC (:1765) and the group-uniform marking, so a wider load no longer marks or leaves stale VGPRs beyond its destination.
    • Uniform table loads are now also wave-uniform (:2590) only under the existing full-EXEC, no-store, uniform-index rule.
    • A multi-component destination that spans v5 clears exchanged_group (:2606), which the old single-register check missed.
    • The resource-heap R32_UINT path stays width 1, and wider heap loads remain refused.

Tests: native_mesh_buffer_load_format_ir (46 modules, 26 refusals) is in the pr filter.

**@⁠lukaslw-lab** on GitHub · 2026-12-02 09:34 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3846#pullrequestreview-6148151571) · **approved these changes** Reviewed `5bddf66d` (draft) by reading the diff and running an offline mesh census of this PR alone; not otherwise built or run. **Verdict: approve.** Typed table loads of 1–4 components go through the shared typed-buffer path, and the widened uniformity and `v5` bookkeeping follow the component count. No MUST. Census, `f365f125` + this PR alone, same capture as #3705 (6,685 mesh programs): 1,036 translate on both builds, **none lost**, no validation failures. 35 programs move off `v_readfirstlane_b32`, because the loaded words are now uniform: 17 to `ds_swizzle_b32`, 10 to `s_load_dwordx4`, 5 to the VCC whole-wave mask. The 164-program `buffer_load_format_xyzw` wall appears only after other PRs clear earlier walls, so this capture cannot show it directly. - **NIT** This conflicts with #3808 and #3792 in `lower_mesh`. - Checked, no finding: - Dropping the explicit addressing check is safe. The decoder admits `buffer_load_format` only with IDXEN-only (or, direct, no) addressing, no `0x02000000` bit and SOFFSET inline 0 (`gfx1013_compute_native.cpp:290`), so no OFFEN or per-lane offset can reach the uniform rule. - `format_width = op + 1` (`gfx1013_direct_mesh.inl:1447`) now drives `scalar_count`, `partial_writes` under narrowed EXEC (`:1765`) and the group-uniform marking, so a wider load no longer marks or leaves stale VGPRs beyond its destination. - Uniform table loads are now also wave-uniform (`:2590`) only under the existing full-EXEC, no-store, uniform-index rule. - A multi-component destination that spans `v5` clears `exchanged_group` (`:2606`), which the old single-register check missed. - The resource-heap R32_UINT path stays width 1, and wider heap loads remain refused. Tests: `native_mesh_buffer_load_format_ir` (46 modules, 26 refusals) is in the `pr` filter.
github-bot force-pushed github-bot/gh-3846 from 9e3c6f1131 to 2117867b5d 2026-12-02 12:37:55 +00:00 Compare
Author
Owner

@⁠lukaslw-lab on GitHub · 2026-12-02 20:27 UTC · original · approved these changes

Re-review on 2117867b (rebased on 5770f14e: vector_exec from main; MUBUF format loads widened to op 0–3).

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 0 / 0
First refusal moved 35, all from v_readfirstlane_b32 (see the update)

The earlier head moved 35 against f365f125. Checked: format_width is op+1 only for buffer_load_format op 0–3, partial writes cover every component, and the one-component path keeps the R32_UINT runtime contract.

Update: the first run was on a main that refused 257 programs early (my #3709, #3894; fixed by #3895). I reran main 5770f14e and this head, both with that fix: 35 moved, 0 lost, 0 gained, all from v_readfirstlane_b32: to ds_swizzle_b32 17, s_load_dwordx4 root mapping 10, VCC branch without a whole-wave mask 5, v_min_f32 3. The earlier head also moved 35; my first run here showed 3 because of the masking. Main has since merged #3792 in the same code (uniform buffer loads), so the rebase needs care there.

AI-assisted.

**@⁠lukaslw-lab** on GitHub · 2026-12-02 20:27 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3846#pullrequestreview-6158378418) · **approved these changes** Re-review on `2117867b` (rebased on `5770f14e`: `vector_exec` from main; MUBUF format loads widened to `op` 0–3). **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 | 0 / 0 | | First refusal moved | 35, all from `v_readfirstlane_b32` (see the update) | The earlier head moved 35 against `f365f125`. Checked: `format_width` is `op+1` only for `buffer_load_format` `op` 0–3, partial writes cover every component, and the one-component path keeps the R32_UINT runtime contract. Update: the first run was on a main that refused 257 programs early (my #3709, #3894; fixed by #3895). I reran main `5770f14e` and this head, both with that fix: 35 moved, 0 lost, 0 gained, all from `v_readfirstlane_b32`: to `ds_swizzle_b32` 17, `s_load_dwordx4` root mapping 10, `VCC branch without a whole-wave mask` 5, `v_min_f32` 3. The earlier head also moved 35; my first run here showed 3 because of the masking. Main has since merged #3792 in the same code (uniform buffer loads), so the rebase needs care there. AI-assisted.
# Conflicts:
#	src/gfx1013_direct_mesh.inl
The uniformity probe added on main ran before shared typed-buffer validation and materialized an undefined index even when a wider destination overflowed. Look up reaching values without reading them so the typed load still owns operand and destination validation.
Author
Owner

@⁠timbot103 on GitHub · 2026-12-02 23:05 UTC · original

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

  • The two conflict hunks keep per-component uniformity for each written component, the v5 invalidation, and main's nested-CMPX instruction tracking.
  • 36a6376a makes the uniformity probe inspect reaching values without reading operands before load validation. A destination overflow now reports its own diagnostic again.

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 14/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 (#3834, #3837, #3840, #3844, #3845 and #3848) 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** on GitHub · 2026-12-02 23:05 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3846#issuecomment-7361541798) Merged `main` (`67862ee4`) into this branch; the reviewed commit `2117867b` is unchanged. - The two conflict hunks keep per-component uniformity for each written component, the `v5` invalidation, and main's nested-CMPX instruction tracking. - `36a6376a` makes the uniformity probe inspect reaching values without reading operands before load validation. A destination overflow now reports its own diagnostic again. 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 14/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 (#3834, #3837, #3840, #3844, #3845 and #3848) 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.
Author
Owner

@⁠timbot103 on GitHub · 2026-12-03 01:30 UTC · original

Merged main (f3ab02fe) into this branch; the only conflict was the docs/experiments.md index, where both entries are kept. The mesh filter passes in Debug and Release, and so does the PR preset (1/1). The remaining failures also fail on clean f3ab02fe: native_mesh_entry_registers_ir (a #3840/#3894 test interaction, with a fix PR coming) and the asynchronous WARP allocation fixtures, which pass with X2W_SYNC_MESH_REQUESTS=1.

**@⁠timbot103** on GitHub · 2026-12-03 01:30 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3846#issuecomment-7364428276) Merged `main` (`f3ab02fe`) into this branch; the only conflict was the `docs/experiments.md` index, where both entries are kept. The mesh filter passes in Debug and Release, and so does the PR preset (1/1). The remaining failures also fail on clean `f3ab02fe`: `native_mesh_entry_registers_ir` (a #3840/#3894 test interaction, with a fix PR coming) and the asynchronous WARP allocation fixtures, which pass with `X2W_SYNC_MESH_REQUESTS=1`.
Author
Owner

@⁠timbot103 on GitHub · 2026-12-03 04:01 UTC · original

Merged main (41a83a9a, which includes #3909) into this branch; the merge was clean. The mesh filter passed 19/19 in Debug. Release passed 16/19; the 3 failures are the existing asynchronous WARP allocation fixtures, which pass with X2W_SYNC_MESH_REQUESTS=1. native_mesh_entry_registers_ir passes again, and the PR preset passed 1/1.

**@⁠timbot103** on GitHub · 2026-12-03 04:01 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3846#issuecomment-7367176394) Merged `main` (`41a83a9a`, which includes #3909) into this branch; the merge was clean. The mesh filter passed 19/19 in Debug. Release passed 16/19; the 3 failures are the existing asynchronous WARP allocation fixtures, which pass with `X2W_SYNC_MESH_REQUESTS=1`. `native_mesh_entry_registers_ir` passes again, and the PR preset passed 1/1.
Author
Owner

@⁠timbot103 on GitHub · 2026-12-03 04:01 UTC · original

Marked Ready for review now that slots have freed up, keeping within 5 non-draft PRs per #3516. The branch merges cleanly with current main.

**@⁠timbot103** on GitHub · 2026-12-03 04:01 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3846#issuecomment-7367181510) Marked Ready for review now that slots have freed up, keeping within 5 non-draft PRs per #3516. The branch merges cleanly with current `main`.
github-bot changed target branch from main to gh-pr/3846/base 2026-12-03 04:17:50 +00:00
github manually merged commit 04d96ff888 into gh-pr/3846/base 2026-12-03 04:17:55 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-03 04:15 UTC · original · approved these changes

Independently reviewed 04d96ff8 and tested it both as submitted and in a clean trial merge onto 43055293 after #3844. The descriptor-table case uses the shared typed load and tracks all written components through EXECZ joins. The resource-heap path still requires one component. MSVC Debug ctest --preset dev --no-tests=error -j 1 -V -R '^(native_mesh_readfirstlane_active_controls|native_mesh_buffer_load_format_ir)$' passed 2/2 on the combined tree: 46 validated DXIL modules and 26 expected refusals in the new suite. Removing just the exchanged_group invalidation for a wide load that starts below and overwrites v5 fails the typed-load fixture. Limiting only mark_uniform_buffer_load() to one component still passes these fixtures because the group-uniform path also marks outputs on fully uniform loads. I restored both edits. This verification is DXIL validation and refusal coverage.

**@⁠R0Y00** on GitHub · 2026-12-03 04:15 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3846#pullrequestreview-6163591287) · **approved these changes** Independently reviewed `04d96ff8` and tested it both as submitted and in a clean trial merge onto `43055293` after #3844. The descriptor-table case uses the shared typed load and tracks all written components through EXECZ joins. The resource-heap path still requires one component. MSVC Debug `ctest --preset dev --no-tests=error -j 1 -V -R '^(native_mesh_readfirstlane_active_controls|native_mesh_buffer_load_format_ir)$'` passed 2/2 on the combined tree: 46 validated DXIL modules and 26 expected refusals in the new suite. Removing just the `exchanged_group` invalidation for a wide load that starts below and overwrites v5 fails the typed-load fixture. Limiting only `mark_uniform_buffer_load()` to one component still passes these fixtures because the group-uniform path also marks outputs on fully uniform loads. I restored both edits. This verification is DXIL validation and refusal coverage.
This discussion has been locked. Commenting is limited to contributors.
No description provided.