shader: extend mesh image load contracts (Part of #3703) #3846

Manually merged
github merged 3 commits from github-bot/gh-3844 into gh-pr/3844/base 2026-12-03 00:42:41 +00:00 AGit
Owner

@⁠timbot103 on GitHub · 2026-12-02 08:42 UTC · original
timbot103:shader/mesh-image-load-contract → main · +360 −41 · 6 files · 3 commits · merged 2026-12-03 00:39 UTC

Part of #3705.

Summary

Extends mesh image_load and image_load_mip lowering (mesh image load lacks a remapped Texture1D heap contract, 193 programs in #3705):

  • Accepts any nonzero dmask (1..15), packs selected channels into consecutive VGPRs, preserves inactive lanes and neighboring registers under narrowed EXEC (vec_count), and supports both UNORM settings, read-only cache hints (GLC/DLC/SLC), and NSA mip addressing.
  • Supports Texture1D via the mesh heap slot map as well as Texture1D, Texture2D, and Texture2DArray from bound SRV descriptor tables (verified against reflection or root descriptor-table SRV ranges).
  • Rejects integer texture formats in bind_native_mesh86 for mesh table views (since emitted DXIL uses textureLoad.f32), and keeps invalid/overwritten descriptors, R128, LWE/TFE, and D16 refused in this path.

Verification

  • Built compile_dxil and startup_indirect_draw_indexed in both 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_image_contract_ir$': passed (14 positive DXIL cases + 29 refusal controls).
  • Debug (dev) and Release (release): 3/3 passed (native_mesh_image_contract_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:42 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3844) `timbot103:shader/mesh-image-load-contract` → `main` · +360 −41 · 6 files · 3 commits · merged 2026-12-03 00:39 UTC Part of #3705. ### Summary Extends mesh `image_load` and `image_load_mip` lowering (`mesh image load lacks a remapped Texture1D heap contract`, 193 programs in #3705): - Accepts any nonzero `dmask` (`1..15`), packs selected channels into consecutive VGPRs, preserves inactive lanes and neighboring registers under narrowed EXEC (`vec_count`), and supports both UNORM settings, read-only cache hints (GLC/DLC/SLC), and NSA mip addressing. - Supports `Texture1D` via the mesh heap slot map as well as `Texture1D`, `Texture2D`, and `Texture2DArray` from bound SRV descriptor tables (verified against reflection or root descriptor-table SRV ranges). - Rejects integer texture formats in `bind_native_mesh86` for mesh table views (since emitted DXIL uses `textureLoad.f32`), and keeps invalid/overwritten descriptors, R128, LWE/TFE, and D16 refused in this path. ### Verification - Built `compile_dxil` and `startup_indirect_draw_indexed` in both 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_image_contract_ir$'`: passed (14 positive DXIL cases + 29 refusal controls). - Debug (`dev`) and Release (`release`): 3/3 passed (`native_mesh_image_contract_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:45:27 +00:00
Author
Owner

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

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

Verdict: approve. Every new image-load form packs its DMASK channels into exactly the VGPRs the guest writes. Bound-table loads need a declared SRV slot, and integer formats are refused at bind time. No MUST.

  • SHOULD Reconcile with #3838 before either leaves draft. Both rewrite the same mesh Texture1D heap load (gfx1013_direct_mesh.inl:1818): #3838 adds D16 there with a float-exact runtime gate, while this PR still refuses D16 (bit 31 in the 0xfde00000 mask). Whichever lands second has to merge the DMASK/NSA/mip handling with the D16 packing, and vec_count is defined in both.
  • SHOULD Run a before/after m86 census on f365f125. The bind-time integer refusal (native_mesh86.inl:457) also applies to MS table textures that main binds today, so the census plus a draw-time count would show whether any existing pipeline now fails to bind.
  • NIT This also conflicts with #3808.
  • Checked, no finding:
    • vec_count = popcount(DMASK) (:1518) drives the destination overflow check, the inactive-lane preservation and partial_writes, so neighbouring VGPRs keep their values under narrowed EXEC.
    • Operand checks (:1818): R128, TFE, LWE, A16 and D16 are refused. UNORM and GLC/SLC/DLC are accepted, which is right for integer texel coordinates on a read-only load. image_load_mip reads the level from the next address VGPR, or from the NSA word.
    • Bound tables (:1822): only 1D, 2D and 2D-array. The slot must lie in a reflected table record, or in an SRV range of the root table with APPEND offsets resolved in order (:1851), and then goes through the shared image_io.

Tests: native_mesh_image_contract_ir (14 cases, 29 refusals) is in the pr filter.

**@⁠lukaslw-lab** on GitHub · 2026-12-02 08:49 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3844#pullrequestreview-6147419011) · **approved these changes** Reviewed `ace75bfb` (draft) by reading the diff; not built or run. **Verdict: approve.** Every new image-load form packs its DMASK channels into exactly the VGPRs the guest writes. Bound-table loads need a declared SRV slot, and integer formats are refused at bind time. No MUST. - **SHOULD** Reconcile with #3838 before either leaves draft. Both rewrite the same mesh Texture1D heap load (`gfx1013_direct_mesh.inl:1818`): #3838 adds D16 there with a float-exact runtime gate, while this PR still refuses D16 (bit 31 in the `0xfde00000` mask). Whichever lands second has to merge the DMASK/NSA/mip handling with the D16 packing, and `vec_count` is defined in both. - **SHOULD** Run a before/after `m86` census on `f365f125`. The bind-time integer refusal (`native_mesh86.inl:457`) also applies to MS table textures that `main` binds today, so the census plus a draw-time count would show whether any existing pipeline now fails to bind. - **NIT** This also conflicts with #3808. - Checked, no finding: - `vec_count` = popcount(DMASK) (`:1518`) drives the destination overflow check, the inactive-lane preservation and `partial_writes`, so neighbouring VGPRs keep their values under narrowed EXEC. - Operand checks (`:1818`): R128, TFE, LWE, A16 and D16 are refused. UNORM and GLC/SLC/DLC are accepted, which is right for integer texel coordinates on a read-only load. `image_load_mip` reads the level from the next address VGPR, or from the NSA word. - Bound tables (`:1822`): only 1D, 2D and 2D-array. The slot must lie in a reflected table record, or in an SRV range of the root table with APPEND offsets resolved in order (`:1851`), and then goes through the shared `image_io`. Tests: `native_mesh_image_contract_ir` (14 cases, 29 refusals) is in the `pr` filter.
Author
Owner

@⁠lukaslw-lab on GitHub · 2026-12-02 09:23 UTC · original

Census follow-up for the SHOULD in my review: f365f125 + this PR alone, same capture and method as #3705 / #3816 (6,685 distinct mesh programs, 6,436 pixel stages). Counts only.

Build Mesh translated Lost vs main
f365f125 1,036 —
f365f125 + #3846 1,107 (+71) 0

All 193 mesh image load lacks a remapped Texture1D heap contract programs move. 71 translate, and the rest stop at a later wall. No validation failures. This is offline only, so the bind-time integer-format refusal is not exercised here.

**@⁠lukaslw-lab** on GitHub · 2026-12-02 09:23 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3844#issuecomment-7340809967) Census follow-up for the SHOULD in my review: `f365f125` + this PR alone, same capture and method as #3705 / #3816 (6,685 distinct mesh programs, 6,436 pixel stages). Counts only. | Build | Mesh translated | Lost vs main | |---|---:|---:| | `f365f125` | 1,036 | — | | `f365f125` + #3846 | **1,107** (+71) | 0 | All 193 `mesh image load lacks a remapped Texture1D heap contract` programs move. 71 translate, and the rest stop at a later wall. No validation failures. This is offline only, so the bind-time integer-format refusal is not exercised here.
Resolved conflict in src/gfx1013_direct_mesh.inl against #3806 (5545de92): kept the #3844 image_load lowering, DMASK/bound-table contracts, and partial_writes tracking while adopting #3806's vector_exec predicate on both the image_load and mtbuf branches.
github-bot force-pushed github-bot/gh-3844 from 9f0142ec14 to 0b4fe284e6 2026-12-02 12:37:57 +00:00 Compare
Author
Owner

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

Re-review on 0b4fe284 (rebased on 5770f14e: vector_exec from main in the image and MTBUF conditions).

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,143
Gained 96 (all from mesh image load lacks a remapped Texture1D heap contract)
Lost 0
First refusal moved 122: to v_med3_f32 43, position mask 40, packed vertex export 33, v_readfirstlane_b32 6

The earlier head gained 71 against f365f125. The extra 25 stopped at unsupported mesh scalar branch destination on the earlier head; main has since merged the scalar loops (#3709). Main has since merged #3760 and #3714, which add the table texture load and the integer-format refusal this PR also adds (lower_mesh, native_mesh86.inl). The rebase should drop or merge those parts and will need a fresh census.

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: 96 gained, 122 moved, 0 lost. The numbers above are unchanged.

AI-assisted.

**@⁠lukaslw-lab** on GitHub · 2026-12-02 20:27 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3844#pullrequestreview-6158378078) · **approved these changes** Re-review on `0b4fe284` (rebased on `5770f14e`: `vector_exec` from main in the image and MTBUF conditions). **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,143** | | Gained | 96 (all from `mesh image load lacks a remapped Texture1D heap contract`) | | Lost | 0 | | First refusal moved | 122: to `v_med3_f32` 43, position mask 40, packed vertex export 33, `v_readfirstlane_b32` 6 | The earlier head gained 71 against `f365f125`. The extra 25 stopped at `unsupported mesh scalar branch destination` on the earlier head; main has since merged the scalar loops (#3709). Main has since merged #3760 and #3714, which add the table texture load and the integer-format refusal this PR also adds (`lower_mesh`, `native_mesh86.inl`). The rebase should drop or merge those parts and will need a fresh census. 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: 96 gained, 122 moved, 0 lost. The numbers above are unchanged. AI-assisted.
Share the table and remapped Texture1D paths across level-zero and mip loads. Preserve the separate full-descriptor heap path and use the merged Mesh86 table format validator.
A seeded destination now preserves its incoming value when EXEC excludes the lane. Assert that the selected value reaches the export and keep a refusal for a destination with no incoming value.
Author
Owner

@⁠timbot103 on GitHub · 2026-12-02 22:57 UTC · original

Merged main (67862ee4) into this branch (3199466a); the reviewed commit 0b4fe284 is unchanged.

  • main now covers part of this PR's scope through #3714 and #3760: the 32-bit level-zero bound Texture1D/2D/2DArray loads, the four-channel level-zero remapped Texture1D load, and the separate three-channel UNORM full-descriptor load. The merge keeps main's integer-view validator and full-descriptor path. On top of those it adds this PR's mip, NSA, sparse remapped DMASK and descriptor-range checks.
  • 1596e0a1 updates the EXEC fixture after the merge. It checks that inactive lanes are preserved across a masked table-load join, and still refuses a genuinely undefined destination.

Tests, Windows 11 26200 with RTX 5080 and WARP:

  • ctest --preset pr --no-tests=error -R '^native_mesh_image_contract_ir$' passed 1/1.
  • In Debug, native_direct_mesh|native_direct_container|native_mesh_|startup_mesh86_table_texture_probe passed 15/15.
  • In Release the same filter passed 13 of 15. The 2 failures were the existing asynchronous WARP allocation fixtures (accepted=1 refused=0), and both passed with X2W_SYNC_MESH_REQUESTS=1.
  • A full Debug build of every target, including native_compute_pack_refusal_check, succeeded.

The census gain from the earlier re-review (+96 programs on 5770f14e) was measured before main absorbed part of this scope, so the net gain on the new main is probably smaller.

**@⁠timbot103** on GitHub · 2026-12-02 22:57 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3844#issuecomment-7361385235) Merged `main` (`67862ee4`) into this branch (`3199466a`); the reviewed commit `0b4fe284` is unchanged. - `main` now covers part of this PR's scope through #3714 and #3760: the 32-bit level-zero bound Texture1D/2D/2DArray loads, the four-channel level-zero remapped Texture1D load, and the separate three-channel UNORM full-descriptor load. The merge keeps main's integer-view validator and full-descriptor path. On top of those it adds this PR's mip, NSA, sparse remapped DMASK and descriptor-range checks. - `1596e0a1` updates the EXEC fixture after the merge. It checks that inactive lanes are preserved across a masked table-load join, and still refuses a genuinely undefined destination. Tests, Windows 11 26200 with RTX 5080 and WARP: - `ctest --preset pr --no-tests=error -R '^native_mesh_image_contract_ir$'` passed 1/1. - In Debug, `native_direct_mesh|native_direct_container|native_mesh_|startup_mesh86_table_texture_probe` passed 15/15. - In Release the same filter passed 13 of 15. The 2 failures were the existing asynchronous WARP allocation fixtures (`accepted=1 refused=0`), and both passed with `X2W_SYNC_MESH_REQUESTS=1`. - A full Debug build of every target, including `native_compute_pack_refusal_check`, succeeded. The census gain from the earlier re-review (+96 programs on `5770f14e`) was measured before main absorbed part of this scope, so the net gain on the new main is probably smaller.
Author
Owner

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

Marked Ready for review now that #3829 and #3831 have merged, keeping to 5 non-draft PRs per #3516. 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 #3835/#3835 fixture issue that does not involve this PR; the #3837 fix is coming.

**@⁠timbot103** on GitHub · 2026-12-02 23:47 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3844#issuecomment-7362427248) Marked Ready for review now that #3829 and #3831 have merged, keeping to 5 non-draft PRs per #3516. 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 #3835/#3835 fixture issue that does not involve this PR; the #3837 fix is coming.
github-bot changed target branch from main to gh-pr/3844/base 2026-12-03 00:42:36 +00:00
github manually merged commit 1596e0a1aa into gh-pr/3844/base 2026-12-03 00:42:41 +00:00
Author
Owner

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

Independently reviewed this head. The packed write count drives EXEC joins and the explicit raw SRV range check rejects gaps. MSVC Debug: ctest --preset dev --no-tests=error -j 1 --output-on-failure -R '^(native_mesh_image_contract_ir|native_direct_mesh|native_direct_container)$' passed 3/3. Removing only the raw SRV range refusal made table-gap translate and failed the fixture. The restored head passed again.

**@⁠R0Y00** on GitHub · 2026-12-03 00:39 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3844#pullrequestreview-6161653826) · **approved these changes** Independently reviewed this head. The packed write count drives EXEC joins and the explicit raw SRV range check rejects gaps. MSVC Debug: ctest --preset dev --no-tests=error -j 1 --output-on-failure -R '^(native_mesh_image_contract_ir|native_direct_mesh|native_direct_container)$' passed 3/3. Removing only the raw SRV range refusal made table-gap translate and failed the fixture. The restored head passed again.
This discussion has been locked. Commenting is limited to contributors.
No description provided.