shader: lower mesh param0..param12 exports and gfx2hlsl pixel linkage #2427

Manually merged
github merged 2 commits from gh-pr/2427/head into gh-pr/2427/base 2026-11-27 00:51:13 +00:00
Owner

@⁠R0D4X on GitHub · 2026-11-25 16:26 UTC · original
R0D4X:feat/mesh-param12-linkage → main · +718 −32 · 8 files · 2 commits · merged 2026-11-26 07:18 UTC

Summary

  • Implement #2413 Item T4 (Parameter exports up to param12 and their pairing with the pixel stage inputs) across the bounded mesh translators and gfx2hlsl.py.
  • Add tools/mesh_param_link.py (MAX_PARAM = 12 per AMD RDNA 2 ISA §10.2 EXP target 32 + N, MAX_VERTEX_VECTORS = 32 per D3D12 SM 6.5 vertex output limit) with ParamLinkage, validate_linkage, merge_wave_params, hlsl_param_fields, and hlsl_param_writes (dense PARAM0..PARAM12, nointerpolation uint4 FPARAM*, HPARAML*/HPARAMH* binary16 halves, and zero-initialized unexported gap slots), preserving legacy TEXCOORD0 for param0-only callers without an explicit ParamLinkage.
  • Extend tools/mesh_entry_aot.py and tools/mesh_dynamic_aot.py to decode and validate exp param0..exp param12 across waves and dynamic variants (keeping CLI __main__ untouched to avoid overlap with #2394/#2407).
  • Add MeshPixelStage(Pipeline) (sharing Pipeline._init_pixel_context()) and mesh_plain_params handling in tools/startup/gfx2hlsl.py to translate paired pixel shaders (linear, flat v_interp_mov_f32 p0, plain-32-bit v_interp_p1ll_f16/v_interp_p2_f16, and depth-only stages) and validate attribute coverage against the mesh exports.
  • Add tests/mesh_param_link_check.py, register mesh_param_link_{controls,warp,hardware} in CMakeLists.txt, and wire tests/mesh_param_link_check.py into pixel-binary (llvm-mc-15) and python-linux in .github/workflows/windows.yml.

Refs #2413, #1998

Verification

  • Base commit: 7092683a (upstream/main)
  • Branch commit: 8f995344 (feat/mesh-param12-linkage)
  • Host environment: Windows 11 x64 (26300.9974), DXC 1.9.2602.17
  • WARP: Microsoft Basic Render Driver (1414:008c), driver 10.0.26100.9818, D3D12 debug layer enabled
  • Hardware GPU: NVIDIA GeForce RTX 5080 (10de:2c02), driver 32.0.16.2124, D3D12 debug layer enabled

Commands and Observed Results

.\out\pe-env\Scripts\python.exe -B tests/mesh_param_link_check.py
.\out\pe-env\Scripts\python.exe -B tests/mesh_clip_cull_check.py
.\out\pe-env\Scripts\python.exe -B tests/mesh_dynamic_geometry_check.py
.\out\pe-env\Scripts\python.exe -B tests/mesh_dynamic_aot_check.py
.\out\pe-env\Scripts\python.exe -B tests/mesh_heap_sampler_check.py
.\out\pe-env\Scripts\python.exe -B tests/mesh_lane_spill_check.py
.\out\pe-env\Scripts\python.exe -B tests/mesh_join_descriptor_check.py
.\out\pe-env\Scripts\python.exe -B tests/mesh_loop_census_check.py
.\out\pe-env\Scripts\python.exe -B tests/startup_gfx2hlsl_interp_f16_check.py
.\out\pe-env\Scripts\python.exe -B tests/startup_translator_check.py
.\out\pe-env\Scripts\python.exe -B tests/startup_tools_lint_check.py
.\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py
.\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py
git diff --check upstream/main...HEAD
ctest --preset dev --no-tests=error -j 1 -R '^(mesh_param_link_|mesh_attribute_draw_|mesh_clip_cull_controls|startup_tools_lint$)' -V
ctest --preset release --no-tests=error -j 1 -R '^mesh_param_link_' -V
  • Observed: all Python/neighbor/lint/docs/bidi checks passed (docs_links_check.py: 19 files / 464 links; bidi_controls_check.py: 1723 files; git diff --check: clean).
  • On-disk self-mutation test (MAX_PARAM = 12 -> 15 in tools/mesh_param_link.py): caught (rc=1) and reverted cleanly.
  • dev: 6 passed, 0 skipped, 0 failed (startup_tools_lint 0.15 s, mesh_param_link_controls 0.44 s, mesh_attribute_draw_hardware 2.37 s, mesh_param_link_hardware 2.71 s, mesh_attribute_draw_warp 0.87 s, mesh_param_link_warp 1.11 s; debug_errors=0 debug_warnings=0, all 5 ms_6_5+ps_6_0 draws pixels=1024 mismatches=0, both GPU negative controls caught at 992 and 1024 mismatched pixels).
  • release: 3 passed, 0 skipped, 0 failed (controls 0.44 s, hardware 2.31 s, warp 1.10 s; debug_errors=0 debug_warnings=0).
  • Note: tests/mesh_param_link_check.py binary llvm-mc-15 was not run locally (llvm-mc is not installed on this Windows host) and is wired into the Ubuntu pixel-binary CI job.
  • Scope note: these passing fixtures verify param0..param12 export and MeshPixelStage pixel pairing in isolation; they do not establish full-game startup or slot-57 runtime DispatchMesh forwarding.
**@⁠R0D4X** on GitHub · 2026-11-25 16:26 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2427) `R0D4X:feat/mesh-param12-linkage` → `main` · +718 −32 · 8 files · 2 commits · merged 2026-11-26 07:18 UTC ## Summary - Implement #2413 Item T4 (*Parameter exports up to `param12` and their pairing with the pixel stage inputs*) across the bounded mesh translators and `gfx2hlsl.py`. - Add `tools/mesh_param_link.py` (`MAX_PARAM = 12` per AMD RDNA 2 ISA §10.2 `EXP` target `32 + N`, `MAX_VERTEX_VECTORS = 32` per D3D12 SM 6.5 vertex output limit) with `ParamLinkage`, `validate_linkage`, `merge_wave_params`, `hlsl_param_fields`, and `hlsl_param_writes` (dense `PARAM0..PARAM12`, `nointerpolation uint4 FPARAM*`, `HPARAML*`/`HPARAMH*` binary16 halves, and zero-initialized unexported gap slots), preserving legacy `TEXCOORD0` for `param0`-only callers without an explicit `ParamLinkage`. - Extend `tools/mesh_entry_aot.py` and `tools/mesh_dynamic_aot.py` to decode and validate `exp param0`..`exp param12` across waves and dynamic variants (keeping CLI `__main__` untouched to avoid overlap with #2394/#2407). - Add `MeshPixelStage(Pipeline)` (sharing `Pipeline._init_pixel_context()`) and `mesh_plain_params` handling in `tools/startup/gfx2hlsl.py` to translate paired pixel shaders (linear, flat `v_interp_mov_f32 p0`, plain-32-bit `v_interp_p1ll_f16`/`v_interp_p2_f16`, and depth-only stages) and validate attribute coverage against the mesh exports. - Add `tests/mesh_param_link_check.py`, register `mesh_param_link_{controls,warp,hardware}` in `CMakeLists.txt`, and wire `tests/mesh_param_link_check.py` into `pixel-binary` (`llvm-mc-15`) and `python-linux` in `.github/workflows/windows.yml`. Refs #2413, #1998 ## Verification - **Base commit:** `7092683a` (`upstream/main`) - **Branch commit:** `8f995344` (`feat/mesh-param12-linkage`) - **Host environment:** Windows 11 x64 (`26300.9974`), DXC `1.9.2602.17` - **WARP:** `Microsoft Basic Render Driver` (`1414:008c`), driver `10.0.26100.9818`, D3D12 debug layer enabled - **Hardware GPU:** `NVIDIA GeForce RTX 5080` (`10de:2c02`), driver `32.0.16.2124`, D3D12 debug layer enabled ### Commands and Observed Results ```powershell .\out\pe-env\Scripts\python.exe -B tests/mesh_param_link_check.py .\out\pe-env\Scripts\python.exe -B tests/mesh_clip_cull_check.py .\out\pe-env\Scripts\python.exe -B tests/mesh_dynamic_geometry_check.py .\out\pe-env\Scripts\python.exe -B tests/mesh_dynamic_aot_check.py .\out\pe-env\Scripts\python.exe -B tests/mesh_heap_sampler_check.py .\out\pe-env\Scripts\python.exe -B tests/mesh_lane_spill_check.py .\out\pe-env\Scripts\python.exe -B tests/mesh_join_descriptor_check.py .\out\pe-env\Scripts\python.exe -B tests/mesh_loop_census_check.py .\out\pe-env\Scripts\python.exe -B tests/startup_gfx2hlsl_interp_f16_check.py .\out\pe-env\Scripts\python.exe -B tests/startup_translator_check.py .\out\pe-env\Scripts\python.exe -B tests/startup_tools_lint_check.py .\out\pe-env\Scripts\python.exe -B tests/docs_links_check.py .\out\pe-env\Scripts\python.exe -B tests/bidi_controls_check.py git diff --check upstream/main...HEAD ctest --preset dev --no-tests=error -j 1 -R '^(mesh_param_link_|mesh_attribute_draw_|mesh_clip_cull_controls|startup_tools_lint$)' -V ctest --preset release --no-tests=error -j 1 -R '^mesh_param_link_' -V ``` - Observed: all Python/neighbor/lint/docs/bidi checks passed (`docs_links_check.py`: 19 files / 464 links; `bidi_controls_check.py`: 1723 files; `git diff --check`: clean). - On-disk self-mutation test (`MAX_PARAM = 12` -> `15` in `tools/mesh_param_link.py`): caught (`rc=1`) and reverted cleanly. - `dev`: **6 passed, 0 skipped, 0 failed** (`startup_tools_lint` 0.15 s, `mesh_param_link_controls` 0.44 s, `mesh_attribute_draw_hardware` 2.37 s, `mesh_param_link_hardware` 2.71 s, `mesh_attribute_draw_warp` 0.87 s, `mesh_param_link_warp` 1.11 s; `debug_errors=0 debug_warnings=0`, all 5 `ms_6_5`+`ps_6_0` draws `pixels=1024 mismatches=0`, both GPU negative controls caught at 992 and 1024 mismatched pixels). - `release`: **3 passed, 0 skipped, 0 failed** (`controls` 0.44 s, `hardware` 2.31 s, `warp` 1.10 s; `debug_errors=0 debug_warnings=0`). - Note: `tests/mesh_param_link_check.py binary llvm-mc-15` was not run locally (`llvm-mc` is not installed on this Windows host) and is wired into the Ubuntu `pixel-binary` CI job. - Scope note: these passing fixtures verify `param0`..`param12` export and `MeshPixelStage` pixel pairing in isolation; they do not establish full-game startup or slot-57 runtime `DispatchMesh` forwarding.
Add shared parameter-export and pixel-input linkage (param0..param12, AMD RDNA 2 ISA section 10.2 EXP target 32+N, D3D12 32-vector signature limit) in tools/mesh_param_link.py and wire it into tools/mesh_entry_aot.py, tools/mesh_dynamic_aot.py, and MeshPixelStage in tools/startup/gfx2hlsl.py.

Supports dense PARAM0..PARAM12 declarations, nointerpolation FPARAM* flat copies, HPARAML*/HPARAMH* binary16 halves, depth-only zero-param pairing, and preserves legacy TEXCOORD0 linkage for param0-only callers while refusing param13+, incomplete exports, variant signature mismatches, missing pixel attributes, and >32-vector signatures. Add tests/mesh_param_link_check.py covering pure-Python controls, guard mutations, llvm-mc assembly round-trips, and ms_6_5 + ps_6_0 D3D12 draws.

Refs #2413, #1998
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 00:51:13 +00:00
github manually merged commit 9b33360af2 into gh-pr/2427/base 2026-11-27 00:51:13 +00:00
Author
Owner

@⁠tedin7 on GitHub · 2026-11-25 19:24 UTC · original · reviewed

Review of head 8f995344 (comment only).

Result: code looks sound. Not merged by us yet because the branch is 60 commits behind main (limit 20).

Checked:

  • tools/mesh_param_link.py: slot range 0..12, flat and binary16 slots must be exported, 32-vector limit, per-wave merge requires every slot to cover every vertex. Legacy TEXCOORD0 path for param0-only callers is kept.
  • gfx2hlsl.py: _init_pixel_context split keeps the Pipeline.__init__ behaviour. MeshPixelStage rejects pixel reads of attributes the mesh stage does not export, and binary16 reads of non-plain slots.
  • CI on this head: Linux Python checks, gfx1013 fixtures and Windows build all green. The author's Windows run is on this head.
  • Sibling tables: the windows.yml additions wire the new check into pixel-binary and python-linux. No other open or merged PR covers this slice (search "param12 mesh").

Commands run locally on this head:

  • python3 tests/mesh_param_link_check.py -> passed
  • python3 tests/docs_links_check.py -> passed
  • python3 tests/bidi_controls_check.py -> passed
  • git diff --check origin/main...HEAD -> clean
  • Mutation 1: MAX_PARAM = 13 -> the test fails (range control).
  • Mutation 2: disable the "Incomplete vertex parameter" check -> the test fails (KeyError).

Not verified here: the D3D12 WARP draw readback (mesh_param_link_warp / _hardware) only runs on Windows. We did not run it on this head.

Next step for the author: merge or update the branch with main (60 behind), then re-check CI. After that a merger can run Win2025 dev+release on the new head.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-25 19:24 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2427#pullrequestreview-6063657715) · **reviewed** Review of head 8f995344 (comment only). Result: code looks sound. Not merged by us yet because the branch is 60 commits behind main (limit 20). Checked: - `tools/mesh_param_link.py`: slot range 0..12, flat and binary16 slots must be exported, 32-vector limit, per-wave merge requires every slot to cover every vertex. Legacy `TEXCOORD0` path for param0-only callers is kept. - `gfx2hlsl.py`: `_init_pixel_context` split keeps the `Pipeline.__init__` behaviour. `MeshPixelStage` rejects pixel reads of attributes the mesh stage does not export, and binary16 reads of non-plain slots. - CI on this head: Linux Python checks, gfx1013 fixtures and Windows build all green. The author's Windows run is on this head. - Sibling tables: the `windows.yml` additions wire the new check into `pixel-binary` and `python-linux`. No other open or merged PR covers this slice (search "param12 mesh"). Commands run locally on this head: - `python3 tests/mesh_param_link_check.py` -> passed - `python3 tests/docs_links_check.py` -> passed - `python3 tests/bidi_controls_check.py` -> passed - `git diff --check origin/main...HEAD` -> clean - Mutation 1: `MAX_PARAM = 13` -> the test fails (range control). - Mutation 2: disable the "Incomplete vertex parameter" check -> the test fails (KeyError). Not verified here: the D3D12 WARP draw readback (`mesh_param_link_warp` / `_hardware`) only runs on Windows. We did not run it on this head. Next step for the author: merge or update the branch with main (60 behind), then re-check CI. After that a merger can run Win2025 dev+release on the new head. AI-assisted; commands listed were executed locally.
Author
Owner

@⁠R0Y00 on GitHub · 2026-11-26 07:14 UTC · original · approved these changes

Reconciled the shared initialization with current main, including descriptor-write state and the separate main MeshPipeline. The original checks are registered through the current CTest and Linux fragments. Windows Release passed 11 of 11 with no skips, including param0 through param12 draw and negative controls on WARP and RTX 4060 Laptop, plus the existing clip/cull, dynamic mesh, entry and vertex-fetch cases.

**@⁠R0Y00** on GitHub · 2026-11-26 07:14 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2427#pullrequestreview-6069911049) · **approved these changes** Reconciled the shared initialization with current main, including descriptor-write state and the separate main MeshPipeline. The original checks are registered through the current CTest and Linux fragments. Windows Release passed 11 of 11 with no skips, including param0 through param12 draw and negative controls on WARP and RTX 4060 Laptop, plus the existing clip/cull, dynamic mesh, entry and vertex-fetch cases.
This discussion has been locked. Commenting is limited to contributors.
No description provided.