shader: follow the two v_fma_mix halves over an unknown input, in either order (#372) #374

Merged
tiagonogueiraa-bit merged 2 commits from upstream-pr/374 into main 2026-11-27 16:04:48 +00:00
tiagonogueiraa-bit commented 2026-11-27 14:31:36 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by tiagonogueiraa-bit on 2026-11-27T14:31:36Z.


Refs #372

Shape. The title's pixel programs pack two f16 results into a register that still holds an input they are done with: the barycentric v0/v1, or the first half of an interpolation.

v_fma_mixlo_f16 v1, ...   ; low half written, high half kept (still the barycentric)
v_fma_mixhi_f16 v1, ...   ; high half replaced
exp mrt0, v1, v1, v31, v31 compr

The title also uses the other order, mixhi then mixlo. A mixlo over a value with no DXIL form was already recorded as unknown, with the low half it made in low16. But a mixhi refused such a value outright, though it keeps only the low half, so the pair was refused at the compr export.

Change.

  • mixlo and mixhi each record the half they write (low16, and a new high16) when the half they keep is unknown.
  • The other one, finding that entry, keeps the known half and makes the value whole.

Entries exist only for those mix results, so anything else that reads such a value is refused as before. A kept half that is exported or read stays refused too: some corpus shaders export v0 after a mixlo alone.

By-output corpus sweep. 12,020 containers from my own boot-to-menus run (Series S), native host options, main 905e7aa against this head:

Stage Gained Lost Changed Other reason now
pixel 90 0 0 2
vertex 1 0 0 0
compute 0 0 0 0

The gained shaders were refused as:

  • "barycentrics read directly": 69;
  • "the first half of an interpolation": 18;
  • "a lane mask holding lanes elsewhere read as data: not written by a scalar ALU instruction": 3;
  • "a descriptor built around a table in the code": 1 (vertex).

The last two name what the kept half held. Each of the 91 has the mix pairs.

Other reason now (2). 0c8db95efb988e5b and 2aa82161639e8bc1 go from "barycentrics read directly" to "the first half of an interpolation". A mixhi with no known low half no longer refuses at once, so a later read names the other unknown input.

Gained (91)

pixel_029d548f88d98ffb pixel_062d982f8346c04b pixel_09f3d46a82d99c58 pixel_0e1a08a22ee3132f pixel_15c2f90009b10f9d pixel_180bc5af6ff93809 pixel_181660f355dac898 pixel_1a0d8e0942c34611 pixel_1e530691dfab8112 pixel_1ec2619a3b10d477 pixel_1f4a5c797a1dc7f6 pixel_2243c6609fb40883 pixel_243cceec4f97e8ba pixel_247b75b8993d189a pixel_25b0717d9ab60e63 pixel_277be906fdeb516f pixel_2b54e3abf4d463e5 pixel_2e00b44b8dd0edda pixel_2ed96d94af485cda pixel_2f0e4c7c8c4852d5 pixel_30ab6e3cae9b9a33 pixel_3776dccc72b01c97 pixel_397e6bbbbf6ffbd2 pixel_3a1cebdac9d33638 pixel_3fc2fe4adf8ee60a pixel_40ff342c14110639 pixel_434e90767db5ceba pixel_47e6be385c9ac713 pixel_48145a032e0879b4 pixel_4972293e509a9d1c pixel_49b8104459fd1158 pixel_4da2a6c518231117 pixel_4e8b4217942fda09 pixel_50a7f2f74dafa0ca pixel_510b0281ebef1caf pixel_52538532fe9cbb27 pixel_551aa629beb6ebc4 pixel_59085b1d29495c31 pixel_5c44582351fd3b01 pixel_5f99d12f794f3f80 pixel_612aac3e3bbeb381 pixel_64e17b1cdf1069ba pixel_6612302a04255126 pixel_66a41d7f2c03f41b pixel_67543938966077f0 pixel_67952d5c064a4e4e pixel_6d4760634bac8389 pixel_6fa77e1c415a5a59 pixel_73e578e579a3365d pixel_74fb320c3bf19ab3 pixel_75bf4600de0e475a pixel_7acf0da3406a144a pixel_803e7d60899d9473 pixel_84356c8e3855d721 pixel_87a8cc39a53634fb pixel_89a97fffbc876da2 pixel_8b49e7d1ece74f9f pixel_8ef7ce2eeed16ff3 pixel_907096eabad21c1f pixel_97a7685ab8de3b69 pixel_9d52470a2ef81951 pixel_a249f2a98b7a2374 pixel_a924a5868cb44900 pixel_aa06394e93213f48 pixel_aa07c06fd383041a pixel_b3af2bbbcdc7f4bf pixel_b797101b59cde586 pixel_bc0a846a4341e56d pixel_bc7a45b1ec68c53a pixel_c8d813eefd3bd9b3 pixel_cb5e29a3434de6e2 pixel_cd4ce7a986eedd78 pixel_d082b3237c38c779 pixel_d318d17882f1ca36 pixel_d84a367e0f078cbf pixel_d84ef2a21575da4e pixel_dcce79d25e133c50 pixel_e367dd700da78d5e pixel_e47b3d789ee8d5cf pixel_e5b901a00e119b52 pixel_e8052c52eceabbeb pixel_e9f6e7f312da39d6 pixel_eb383662a56ab84b pixel_ed04a0dc72cb2726 pixel_ee61e5cd98a30595 pixel_f016b8da663c3ff1 pixel_fa39f2f311833088 pixel_fdbcf36cab4c05bf pixel_ff9daddf8c95c41e pixel_fffd5769a0319523 vertex_69eba4d73f119f58

Test. mesh_tests::a_half_kept_by_mixlo_and_replaced_by_mixhi_draws_without_the_barycentric (victory-gpu, on Metal with MSC 4.0 beta 3). A guessed pixel program interpolates param0 with v0/v1, then packs (1.0, 0.5) into v1 with mixlo/mixhi and exports it compr, in both orders. It draws (1.0, 0.5, 1.0, 1.0) over the whole target. On main the program is refused ("barycentrics read directly").

Checks.

  • cargo test -p victory-shader -p victory-hle -p victory -p victory-gpu -p victory-metal -p xtask: 955 passed, 0 failed, 10 ignored.
  • Windows clippy -D warnings: clean.
  • cargo xtask policy: ok.

docs/native-host.md has a section on it. @Olima34, for the board.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:5528330042 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/374). Originally posted by [tiagonogueiraa-bit](https://github.com/tiagonogueiraa-bit) on 2026-11-27T14:31:36Z. --- Refs #372 **Shape.** The title's pixel programs pack two f16 results into a register that still holds an input they are done with: the barycentric `v0`/`v1`, or the first half of an interpolation. ``` v_fma_mixlo_f16 v1, ... ; low half written, high half kept (still the barycentric) v_fma_mixhi_f16 v1, ... ; high half replaced exp mrt0, v1, v1, v31, v31 compr ``` The title also uses the other order, `mixhi` then `mixlo`. A `mixlo` over a value with no DXIL form was already recorded as unknown, with the low half it made in `low16`. But a `mixhi` refused such a value outright, though it keeps only the low half, so the pair was refused at the `compr` export. **Change.** - `mixlo` and `mixhi` each record the half they write (`low16`, and a new `high16`) when the half they keep is unknown. - The other one, finding that entry, keeps the known half and makes the value whole. Entries exist only for those `mix` results, so anything else that reads such a value is refused as before. A kept half that is exported or read stays refused too: some corpus shaders export `v0` after a `mixlo` alone. **By-output corpus sweep.** 12,020 containers from my own boot-to-menus run (Series S), native host options, main `905e7aa` against this head: | Stage | Gained | Lost | Changed | Other reason now | |---|---|---|---|---| | pixel | 90 | 0 | 0 | 2 | | vertex | 1 | 0 | 0 | 0 | | compute | 0 | 0 | 0 | 0 | The gained shaders were refused as: - "barycentrics read directly": 69; - "the first half of an interpolation": 18; - "a lane mask holding lanes elsewhere read as data: not written by a scalar ALU instruction": 3; - "a descriptor built around a table in the code": 1 (vertex). The last two name what the kept half held. Each of the 91 has the `mix` pairs. **Other reason now (2).** `0c8db95efb988e5b` and `2aa82161639e8bc1` go from "barycentrics read directly" to "the first half of an interpolation". A `mixhi` with no known low half no longer refuses at once, so a later read names the other unknown input. <details><summary>Gained (91)</summary> pixel_029d548f88d98ffb pixel_062d982f8346c04b pixel_09f3d46a82d99c58 pixel_0e1a08a22ee3132f pixel_15c2f90009b10f9d pixel_180bc5af6ff93809 pixel_181660f355dac898 pixel_1a0d8e0942c34611 pixel_1e530691dfab8112 pixel_1ec2619a3b10d477 pixel_1f4a5c797a1dc7f6 pixel_2243c6609fb40883 pixel_243cceec4f97e8ba pixel_247b75b8993d189a pixel_25b0717d9ab60e63 pixel_277be906fdeb516f pixel_2b54e3abf4d463e5 pixel_2e00b44b8dd0edda pixel_2ed96d94af485cda pixel_2f0e4c7c8c4852d5 pixel_30ab6e3cae9b9a33 pixel_3776dccc72b01c97 pixel_397e6bbbbf6ffbd2 pixel_3a1cebdac9d33638 pixel_3fc2fe4adf8ee60a pixel_40ff342c14110639 pixel_434e90767db5ceba pixel_47e6be385c9ac713 pixel_48145a032e0879b4 pixel_4972293e509a9d1c pixel_49b8104459fd1158 pixel_4da2a6c518231117 pixel_4e8b4217942fda09 pixel_50a7f2f74dafa0ca pixel_510b0281ebef1caf pixel_52538532fe9cbb27 pixel_551aa629beb6ebc4 pixel_59085b1d29495c31 pixel_5c44582351fd3b01 pixel_5f99d12f794f3f80 pixel_612aac3e3bbeb381 pixel_64e17b1cdf1069ba pixel_6612302a04255126 pixel_66a41d7f2c03f41b pixel_67543938966077f0 pixel_67952d5c064a4e4e pixel_6d4760634bac8389 pixel_6fa77e1c415a5a59 pixel_73e578e579a3365d pixel_74fb320c3bf19ab3 pixel_75bf4600de0e475a pixel_7acf0da3406a144a pixel_803e7d60899d9473 pixel_84356c8e3855d721 pixel_87a8cc39a53634fb pixel_89a97fffbc876da2 pixel_8b49e7d1ece74f9f pixel_8ef7ce2eeed16ff3 pixel_907096eabad21c1f pixel_97a7685ab8de3b69 pixel_9d52470a2ef81951 pixel_a249f2a98b7a2374 pixel_a924a5868cb44900 pixel_aa06394e93213f48 pixel_aa07c06fd383041a pixel_b3af2bbbcdc7f4bf pixel_b797101b59cde586 pixel_bc0a846a4341e56d pixel_bc7a45b1ec68c53a pixel_c8d813eefd3bd9b3 pixel_cb5e29a3434de6e2 pixel_cd4ce7a986eedd78 pixel_d082b3237c38c779 pixel_d318d17882f1ca36 pixel_d84a367e0f078cbf pixel_d84ef2a21575da4e pixel_dcce79d25e133c50 pixel_e367dd700da78d5e pixel_e47b3d789ee8d5cf pixel_e5b901a00e119b52 pixel_e8052c52eceabbeb pixel_e9f6e7f312da39d6 pixel_eb383662a56ab84b pixel_ed04a0dc72cb2726 pixel_ee61e5cd98a30595 pixel_f016b8da663c3ff1 pixel_fa39f2f311833088 pixel_fdbcf36cab4c05bf pixel_ff9daddf8c95c41e pixel_fffd5769a0319523 vertex_69eba4d73f119f58 </details> **Test.** `mesh_tests::a_half_kept_by_mixlo_and_replaced_by_mixhi_draws_without_the_barycentric` (`victory-gpu`, on Metal with MSC 4.0 beta 3). A guessed pixel program interpolates param0 with `v0`/`v1`, then packs (1.0, 0.5) into `v1` with `mixlo`/`mixhi` and exports it `compr`, in both orders. It draws (1.0, 0.5, 1.0, 1.0) over the whole target. On main the program is refused ("barycentrics read directly"). **Checks.** - `cargo test -p victory-shader -p victory-hle -p victory -p victory-gpu -p victory-metal -p xtask`: 955 passed, 0 failed, 10 ignored. - Windows clippy `-D warnings`: clean. - `cargo xtask policy`: ok. `docs/native-host.md` has a section on it. @Olima34, for the board.
tiagonogueiraa-bit commented 2026-11-27 14:39:00 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by tiagonogueiraa-bit on 2026-11-27T14:39:00Z.


Rebased onto main 728845d. The only conflict was a test appended at the end of mesh_tests.rs, and both tests are kept. I re-ran the by-output sweep against 728845d, with identical numbers: +91 (90 pixel, 1 vertex), 0 lost, 0 changed, 2 with another reason. Tests: 961 passed, 0 failed. Windows clippy and policy are clean.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7221050209 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/374#issuecomment-7221050209). Originally posted by [tiagonogueiraa-bit](https://github.com/tiagonogueiraa-bit) on 2026-11-27T14:39:00Z. --- Rebased onto main `728845d`. The only conflict was a test appended at the end of `mesh_tests.rs`, and both tests are kept. I re-ran the by-output sweep against `728845d`, with identical numbers: +91 (90 pixel, 1 vertex), 0 lost, 0 changed, 2 with another reason. Tests: 961 passed, 0 failed. Windows clippy and policy are clean.
LakshanSivakumar commented 2026-11-27 16:05:16 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T16:05:16Z.


Merged in be7dc1b5 with the other shader PRs from tonight. Ran the tests (native arm64), Windows clippy, the policy check and a release build on the merged tree, and swept my full corpus of 21,600 shaders before and after: 0 lost, 352 newly translated, every changed output accounted for. I have not run the game on it yet. Thanks.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7222840152 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/374#issuecomment-7222840152). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-27T16:05:16Z. --- Merged in be7dc1b5 with the other shader PRs from tonight. Ran the tests (native arm64), Windows clippy, the policy check and a release build on the merged tree, and swept my full corpus of 21,600 shaders before and after: 0 lost, 352 newly translated, every changed output accounted for. I have not run the game on it yet. 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!374
No description provided.