shader: lower buffer_load_format_x in mesh EXECZ skips and element zero (Part of #3703) #3722

Manually merged
github merged 1 commit from github-bot/gh-3720 into main 2026-12-01 11:23:13 +00:00 AGit
Owner

@⁠timbot103 on GitHub · 2026-12-01 10:53 UTC · original
timbot103:shader/mesh-buffer-load-format-x → main · +82 −7 · 2 files · 1 commits · merged 2026-12-01 11:20 UTC

Refs #3705.

Summary

Lowers buffer_load_format_x inside open EXECZ skips and for unindexed literal element zero in the C++ mesh frontend (src/gfx1013_direct_mesh.inl):

  • Open EXEC skips & element zero: Admits buffer_load_format_x (i.op == 0) when (full_exec || exec_skip) and addressing is either idxen (0x2000) or unindexed literal element zero (0x0000, already accepted by decode()). When idxen is clear, emits index 0 without reading vaddr.
  • Lane & uniformity soundness:
    • Records partial_writes when !full_exec so pre-skip VGPR values are preserved via select/phi and fresh destinations under a lane count retain value_limits.
    • Propagates uniform_values under full_exec and active_uniform under whole_wave_execution() && !branch only when uniform(index) == index.
    • Guards group_uniform propagation for buffer_load_format on full_exec so a lane-masked select cannot be marked group-uniform.
    • Rejects descriptor bases past SGPR 105 (base + 4 > 106).
  • Fail-closed controls: Keeps narrowed EXEC without an enclosing s_cbranch_execz, non-heap table descriptors, multi-channel buffer_load_format_xy/xyz/xyzw, non-zero offsets, per-lane v_readfirstlane_b32, and unmasked reads of lane-bounded destinations strictly refused.

Verification

Windows 11 (26200), MSVC 19.44, Ninja, Windows SDK 10.0.26100. Source-built tests only; added positive cases (element-0, per-lane skip preserve, whole-wave lane-limit skip + readfirstlane, SAVEEXEC then arm, heap_tokens inside skip) and negative controls in tests/native_direct_mesh_check.py.

  • Debug (dev preset):
    • ctest --preset dev --no-tests=error -R '^native_direct_|^startup_mesh57_real_shape$|^startup_mesh57_execz_diagnostics$' -V -> 4/4 passed (native_direct_container, native_direct_mesh, startup_mesh57_execz_diagnostics, startup_mesh57_real_shape)
  • Release (release preset):
    • ctest --preset release --no-tests=error -R '^native_direct_|^startup_mesh57_real_shape$|^startup_mesh57_execz_diagnostics$' -V -> 4/4 passed
  • git diff --check HEAD^ HEAD clean.

AI-assisted.

**@⁠timbot103** on GitHub · 2026-12-01 10:53 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3720) `timbot103:shader/mesh-buffer-load-format-x` → `main` · +82 −7 · 2 files · 1 commits · merged 2026-12-01 11:20 UTC Refs #3705. ## Summary Lowers `buffer_load_format_x` inside open `EXECZ` skips and for unindexed literal element zero in the C++ mesh frontend (`src/gfx1013_direct_mesh.inl`): - **Open EXEC skips & element zero:** Admits `buffer_load_format_x` (`i.op == 0`) when `(full_exec || exec_skip)` and addressing is either `idxen` (`0x2000`) or unindexed literal element zero (`0x0000`, already accepted by `decode()`). When `idxen` is clear, emits index `0` without reading `vaddr`. - **Lane & uniformity soundness:** - Records `partial_writes` when `!full_exec` so pre-skip VGPR values are preserved via `select`/`phi` and fresh destinations under a lane count retain `value_limits`. - Propagates `uniform_values` under `full_exec` and `active_uniform` under `whole_wave_execution() && !branch` only when `uniform(index) == index`. - Guards `group_uniform` propagation for `buffer_load_format` on `full_exec` so a lane-masked `select` cannot be marked group-uniform. - Rejects descriptor bases past SGPR 105 (`base + 4 > 106`). - **Fail-closed controls:** Keeps narrowed EXEC without an enclosing `s_cbranch_execz`, non-heap table descriptors, multi-channel `buffer_load_format_xy/xyz/xyzw`, non-zero offsets, per-lane `v_readfirstlane_b32`, and unmasked reads of lane-bounded destinations strictly refused. ## Verification Windows 11 (26200), MSVC 19.44, Ninja, Windows SDK 10.0.26100. Source-built tests only; added positive cases (element-0, per-lane skip preserve, whole-wave lane-limit skip + `readfirstlane`, `SAVEEXEC` then arm, `heap_tokens` inside skip) and negative controls in `tests/native_direct_mesh_check.py`. - **Debug (`dev` preset):** - `ctest --preset dev --no-tests=error -R '^native_direct_|^startup_mesh57_real_shape$|^startup_mesh57_execz_diagnostics$' -V` -> **4/4 passed** (`native_direct_container`, `native_direct_mesh`, `startup_mesh57_execz_diagnostics`, `startup_mesh57_real_shape`) - **Release (`release` preset):** - `ctest --preset release --no-tests=error -R '^native_direct_|^startup_mesh57_real_shape$|^startup_mesh57_execz_diagnostics$' -V` -> **4/4 passed** - `git diff --check HEAD^ HEAD` clean. AI-assisted.
The mesh frontend previously lowered buffer_load_format_x only under full
EXEC and with IDXEN set, even though the shared decoder already accepts the
unindexed element-zero form and sibling mesh memory loads (image_load,
MTBUF, buffer_load_dword) already run inside open EXECZ skips.

- Admit buffer_load_format_x when (full_exec || exec_skip) and addressing
  is either IDXEN (0x2000) or literal element zero (0x0000), keeping
  multi-channel _xy/_xyz/_xyzw, non-zero offsets, and unguarded narrowed
  EXEC strictly refused.
- Reject descriptor bases past SGPR 105 (base + 4 > 106) and keep the
  R32_UINT resource-heap contract required for both root-constant and
  heap-token descriptors.
- Use literal element index 0 when IDXEN is clear without reading vaddr.
- Record partial_writes when !full_exec so pre-skip values are preserved
  with select/phi and fresh values under a lane count keep value_limits.
- Propagate uniform_values under full_exec and active_uniform under
  whole_wave_execution() && !branch when uniform(index) == index; guard
  group_uniform propagation on full_exec so a lane-masked select cannot be
  marked group-uniform.

Source-built tests and negative controls in tests/native_direct_mesh_check.py
pass in both Debug and Release presets.

AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 10:53:40 +00:00
github manually merged commit 8109ff6d59 into main 2026-12-01 11:23:13 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-01 11:20 UTC · original · approved these changes

Reviewed the indexed and literal-zero paths and EXEC skip bookkeeping. Integrated native_direct_mesh passed locally, including positive and refusal cases.

**@⁠R0Y00** on GitHub · 2026-12-01 11:20 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3720#pullrequestreview-6130198440) · **approved these changes** Reviewed the indexed and literal-zero paths and EXEC skip bookkeeping. Integrated native_direct_mesh passed locally, including positive and refusal cases.
This discussion has been locked. Commenting is limited to contributors.
No description provided.