fix(shader): follow a half kept below a zeroed word #241

Manually merged
github merged 1 commit from github-bot/gh-241 into main 2026-11-27 04:00:46 +00:00 AGit
Owner

@⁠ShadyUnderLight on GitHub · 2026-11-27 03:36 UTC · original
ShadyUnderLight:fix/half-packing → main · +37 −1 · 2 files · 1 commits · merged 2026-11-27 03:56 UTC

What this changes

One pipeline at the world frame was refused by Metal Shader Converter:

Fragment input(s) `user(half10)` mismatching vertex shader output type(s) or not written by vertex shader

Its vertex program writes parameter 5 as a half and then zeroes the word a lane does not export:

v_cvt_f16_f32 v3, v9
v_mov_b32 v3, 0 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE
exp param5, v3, off, off, off

packed_params judges a parameter by the sources of the values it exports, but read that last write on its own: a literal 0, plain, so the parameter got no HALF10/HALF11 rows. The pixel program interpolates attr5.x with v_interp_p1ll_f16 and so reads HALF10; with no such output the pair does not link and every draw of the pipeline is dropped.

A write to part of a dword that preserves the other bits now follows the value it keeps as well: the bits under the zeroed word are the half. docs/native-host.md records the rule and the refusal it explains.

The pair only reached this check after #239 taught the converter dual-source blending; the two changes are independent.

One side effect worth knowing: a guessed container's hash covers its inferred signatures, so the vertex programs affected get new hashes and are translated once more.

How it was tested

  • cargo test --target x86_64-apple-darwin -p victory-hle -p victory-loader -p victory — 379 passed, 0 failed
  • cargo test -p victory-shader — 306 passed, 0 failed
  • cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings — clean; cargo xtask policy — 369 files ok
  • Ran the game: headless (run-native.sh --headless --seconds 170), before and after

Before: that pair (vertex 62148192acfb1bb1 + pixel aa9cb047b21b22b1) was refused with the message above on every run (two headless runs, one refusal each).

After: no mismatching vertex shader output refusal in four headless runs — 289, 270 and 163 guessed pipelines on the main of the day, 110 on the current main after rebasing. The only conversion refusals left are the known compiler-crash (XPC_ERROR_CONNECTION_INTERRUPTED) ones.

The rebuilt container of that vertex program now exports HALF10/HALF11, the same name, type and four-channel width as the pixel program's HALF10 input.

Unit test emit::graphics::tests::a_half_kept_below_a_zeroed_word_still_counts fails without the change (Plain where Halves is needed) and passes with it.

Checklist

  • No game files, game code, disassembly listings or SDK files are included
  • Guesses about undocumented console behaviour are marked in the code and in docs/native-host.md
  • New diagnostics are behind a VICTORY_* variable and documented — none added
**@⁠ShadyUnderLight** on GitHub · 2026-11-27 03:36 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/241) `ShadyUnderLight:fix/half-packing` → `main` · +37 −1 · 2 files · 1 commits · merged 2026-11-27 03:56 UTC ## What this changes One pipeline at the world frame was refused by Metal Shader Converter: ``` Fragment input(s) `user(half10)` mismatching vertex shader output type(s) or not written by vertex shader ``` Its vertex program writes parameter 5 as a half and then zeroes the word a lane does not export: ``` v_cvt_f16_f32 v3, v9 v_mov_b32 v3, 0 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE exp param5, v3, off, off, off ``` `packed_params` judges a parameter by the sources of the values it exports, but read that last write on its own: a literal 0, plain, so the parameter got no `HALF10`/`HALF11` rows. The pixel program interpolates `attr5.x` with `v_interp_p1ll_f16` and so reads `HALF10`; with no such output the pair does not link and every draw of the pipeline is dropped. A write to part of a dword that preserves the other bits now follows the value it keeps as well: the bits under the zeroed word are the half. `docs/native-host.md` records the rule and the refusal it explains. The pair only reached this check after #239 taught the converter dual-source blending; the two changes are independent. One side effect worth knowing: a guessed container's hash covers its inferred signatures, so the vertex programs affected get new hashes and are translated once more. ## How it was tested - [x] `cargo test --target x86_64-apple-darwin -p victory-hle -p victory-loader -p victory` — 379 passed, 0 failed - [x] `cargo test -p victory-shader` — 306 passed, 0 failed - [x] `cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings` — clean; `cargo xtask policy` — 369 files ok - [x] Ran the game: headless (`run-native.sh --headless --seconds 170`), before and after Before: that pair (`vertex 62148192acfb1bb1` + `pixel aa9cb047b21b22b1`) was refused with the message above on every run (two headless runs, one refusal each). After: no `mismatching vertex shader output` refusal in four headless runs — 289, 270 and 163 guessed pipelines on the main of the day, 110 on the current main after rebasing. The only conversion refusals left are the known compiler-crash (`XPC_ERROR_CONNECTION_INTERRUPTED`) ones. The rebuilt container of that vertex program now exports `HALF10`/`HALF11`, the same name, type and four-channel width as the pixel program's `HALF10` input. Unit test `emit::graphics::tests::a_half_kept_below_a_zeroed_word_still_counts` fails without the change (`Plain` where `Halves` is needed) and passes with it. ## Checklist - [x] No game files, game code, disassembly listings or SDK files are included - [x] Guesses about undocumented console behaviour are marked in the code and in docs/native-host.md - [x] New diagnostics are behind a `VICTORY_*` variable and documented — none added
The world's particle pipeline was refused by the Metal converter with "Fragment
input(s) `user(half10)` mismatching vertex shader output type(s) or not written
by vertex shader". Its vertex program writes parameter 5's dword as a half and
then zeroes the word the lane does not export (`v_cvt_f16_f32 v3, v9`, then
`v_mov_b32 v3, 0 dst_sel:WORD_1 dst_unused:UNUSED_PRESERVE`), and packed_params
read that last write alone as a plain 0: the parameter got no HALF10/HALF11
rows, so the pixel program's f16 interpolation of attr5 had nothing to link to.

A write to part of a dword that preserves the rest now follows the old value it
keeps as well; the bits under the zeroed word are the half.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 03:38:29 +00:00
github manually merged commit 087305379d into main 2026-11-27 04:00:46 +00:00
Author
Owner

@⁠LakshanSivakumar on GitHub · 2026-11-27 03:56 UTC · original · approved these changes

Reviewed and tested together with the other open PRs on main (macOS x86_64 workspace tests, the setup shell tests, and Windows clippy). Thanks!

**@⁠LakshanSivakumar** on GitHub · 2026-11-27 03:56 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/241#pullrequestreview-6083280433) · **approved these changes** Reviewed and tested together with the other open PRs on main (macOS x86_64 workspace tests, the setup shell tests, and Windows clippy). Thanks!
This discussion has been locked. Commenting is limited to contributors.
No description provided.