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

Merged
ShadyUnderLight merged 1 commit from upstream-pr/241 into main 2026-11-27 03:56:55 +00:00
ShadyUnderLight commented 2026-11-27 03:36:09 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by ShadyUnderLight on 2026-11-27T03:36:09Z.


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
<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:5520729131 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/241). Originally posted by [ShadyUnderLight](https://github.com/ShadyUnderLight) on 2026-11-27T03:36:09Z. --- ## 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
LakshanSivakumar commented 2026-11-27 03:56:52 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T03:56:52Z.

Review: APPROVED


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

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:review:6083280433 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/241#pullrequestreview-6083280433). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-27T03:56:52Z. **Review:** APPROVED --- Reviewed and tested together with the other open PRs on main (macOS x86_64 workspace tests, the setup shell tests, and Windows clippy). Thanks!
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
LakshanSivakumar/Native-Victory-macOS!241
No description provided.