Shaders: ignore dead interpolation halves in mixed f16 writes #86

Open
starnotes-xj wants to merge 1 commit from upstream-pr/86 into main
starnotes-xj commented 2026-11-25 10:11:21 +00:00 (Migrated from github.com)
First-time contributor

Imported from Zettrox/ztrx. Originally posted by starnotes-xj on 2026-11-25T09:28:52Z.


A mixed v_fma_mixlo_f16 / v_fma_mixhi_f16 write can reuse a dead v_interp_p1ll_f16 destination. The emitter currently calls i32_of on that prior register value and fails the whole program with "the first half of an interpolation", although the placeholder is not a value the mixed write needs to preserve.

This change treats only that exact placeholder as zero for the untouched half. Other missing values still fail as before, so unrelated lowering bugs are not hidden.

Reproduction

The game's shader pack contains two pixel programs stopped by this:

  • PS_DeferredTextured_c5fd36bb_Wrapped (38bf0814e721a1b3)
  • PS_DeferredTextured_9e3a1555_Wrapped (78f3f2fc53a69531)

Before, both reported emit: the first half of an interpolation. With the patch, translate --validate --pipelines reports both validated and their D3D12 pipelines created on an NVIDIA RTX 4060 Laptop (driver 621.14).

Tests

  • Added a synthetic pixel-shader regression covering both v_fma_mixlo_f16 and v_fma_mixhi_f16 after a dead v_interp_p1ll_f16.
  • Verified the new test fails on the old code with the same error and passes with the patch.
  • cargo test -p victory-shader --lib -- --test-threads=1: 211 passed, 0 failed, 2 ignored.
  • cargo clippy --workspace --all-targets --locked -- -D warnings: passed.

I did not claim a full workspace run: in this environment an unrelated victory-hle test (title_file_calls_land_in_the_host_folder) fails at its host fopen assertion before and after this change.

<!-- greyfinch-sync:Zettrox/ztrx:issue:6601354284 --> Imported from [Zettrox/ztrx](https://github.com/Zettrox/ztrx/pull/86). Originally posted by [starnotes-xj](https://github.com/starnotes-xj) on 2026-11-25T09:28:52Z. --- A mixed `v_fma_mixlo_f16` / `v_fma_mixhi_f16` write can reuse a dead `v_interp_p1ll_f16` destination. The emitter currently calls `i32_of` on that prior register value and fails the whole program with `"the first half of an interpolation"`, although the placeholder is not a value the mixed write needs to preserve. This change treats only that exact placeholder as zero for the untouched half. Other missing values still fail as before, so unrelated lowering bugs are not hidden. ## Reproduction The game's shader pack contains two pixel programs stopped by this: - `PS_DeferredTextured_c5fd36bb_Wrapped` (`38bf0814e721a1b3`) - `PS_DeferredTextured_9e3a1555_Wrapped` (`78f3f2fc53a69531`) Before, both reported `emit: the first half of an interpolation`. With the patch, `translate --validate --pipelines` reports both validated and their D3D12 pipelines created on an NVIDIA RTX 4060 Laptop (driver 621.14). ## Tests - Added a synthetic pixel-shader regression covering both `v_fma_mixlo_f16` and `v_fma_mixhi_f16` after a dead `v_interp_p1ll_f16`. - Verified the new test fails on the old code with the same error and passes with the patch. - `cargo test -p victory-shader --lib -- --test-threads=1`: 211 passed, 0 failed, 2 ignored. - `cargo clippy --workspace --all-targets --locked -- -D warnings`: passed. I did not claim a full workspace run: in this environment an unrelated `victory-hle` test (`title_file_calls_land_in_the_host_folder`) fails at its host `fopen` assertion before and after this change.
Artking175 commented 2026-11-25 13:06:13 +00:00 (Migrated from github.com)
Author
First-time contributor

Imported from Zettrox/ztrx. Originally posted by Artking175 on 2026-11-25T12:31:19Z.


Independent Windows retest on an RTX 2060. I compared #80 at 2f46873 with the same tree plus this PR's patch at 8079d11. The system runtime reported Shader Model 6.5, so both test builds used an isolated Agility SDK setup and reported SM 6.6.

  • The control failed the targeted regression at 0x1c with the first half of an interpolation.
  • The candidate passed the targeted regression for both v_fma_mixlo_f16 and v_fma_mixhi_f16 in the isolated setup. An earlier candidate run outside that setup reported a Pipeline State Validation mismatch.
  • The shader suite went from 198 passed to 199 passed. The same 22 GPU tests failed in both builds because the test processes reported no SM 6.6 hardware or WARP device. Each run also had 2 ignored tests.

This confirms the synthetic regression on a second NVIDIA configuration. The two title shader hashes still need an offline run on this machine.

<!-- greyfinch-sync:Zettrox/ztrx:comment:7162486584 --> Imported from [Zettrox/ztrx](https://github.com/Zettrox/ztrx/pull/86#issuecomment-7162486584). Originally posted by [Artking175](https://github.com/Artking175) on 2026-11-25T12:31:19Z. --- Independent Windows retest on an RTX 2060. I compared [#80](https://github.com/Zettrox/ztrx/pull/80) at `2f46873` with the same tree plus this PR's patch at `8079d11`. The system runtime reported Shader Model 6.5, so both test builds used an isolated Agility SDK setup and reported SM 6.6. - The control failed the targeted regression at `0x1c` with `the first half of an interpolation`. - The candidate passed the targeted regression for both `v_fma_mixlo_f16` and `v_fma_mixhi_f16` in the isolated setup. An earlier candidate run outside that setup reported a Pipeline State Validation mismatch. - The shader suite went from 198 passed to 199 passed. The same 22 GPU tests failed in both builds because the test processes reported no SM 6.6 hardware or WARP device. Each run also had 2 ignored tests. This confirms the synthetic regression on a second NVIDIA configuration. The two title shader hashes still need an offline run on this machine.
starnotes-xj commented 2026-11-25 13:06:13 +00:00 (Migrated from github.com)
Author
First-time contributor

Imported from Zettrox/ztrx. Originally posted by starnotes-xj on 2026-11-25T12:44:29Z.


Both title shaders the comment mentions now have an offline run on a second NVIDIA machine (RTX 4060 Laptop, 8 GB, Windows 11, driver 621.14, system Agility SDK).

Method: found the two containers by their hash in shaders.rpf (26,503 containers), dumped each one (8,148 and 8,164 bytes), then ran victory translate --validate --pipelines on each. Control is 90b529f (main, without this PR); candidate is 8079d11 + the same two files this PR touches.

container control 90b529f candidate 8079d11
#38bf0814e721a1b3 PS_DeferredTextured_c5fd36bb fails at 0x1464: the first half of an interpolation (0 emitted) 1 emitted, 1 validated (dxil.dll 10.0.26100.0), 1 pipeline created
#78f3f2fc53a69531 PS_DeferredTextured_9e3a1555 fails at 0x1464: same reason (0 emitted) 1 emitted, 1 validated, 1 pipeline created

Both are deferred G-buffer material shaders (825 IR instructions each, 22 interpolations), so they are not a corner case: without the patch nothing of either program is emitted.

That agrees with the synthetic regression result: the control refuses at the dead interpolation half, the candidate emits code the D3D12 runtime accepts and a PSO for it is made on a real NVIDIA adapter.

<!-- greyfinch-sync:Zettrox/ztrx:comment:7162790289 --> Imported from [Zettrox/ztrx](https://github.com/Zettrox/ztrx/pull/86#issuecomment-7162790289). Originally posted by [starnotes-xj](https://github.com/starnotes-xj) on 2026-11-25T12:44:29Z. --- Both title shaders the comment mentions now have an offline run on a second NVIDIA machine (RTX 4060 Laptop, 8 GB, Windows 11, driver 621.14, system Agility SDK). Method: found the two containers by their hash in `shaders.rpf` (26,503 containers), dumped each one (8,148 and 8,164 bytes), then ran `victory translate --validate --pipelines` on each. Control is `90b529f` (main, without this PR); candidate is `8079d11` + the same two files this PR touches. | container | control `90b529f` | candidate `8079d11` | |---|---|---| | `#38bf0814e721a1b3` `PS_DeferredTextured_c5fd36bb` | fails at `0x1464`: `the first half of an interpolation` (0 emitted) | 1 emitted, 1 **validated** (dxil.dll 10.0.26100.0), 1 **pipeline created** | | `#78f3f2fc53a69531` `PS_DeferredTextured_9e3a1555` | fails at `0x1464`: same reason (0 emitted) | 1 emitted, 1 **validated**, 1 **pipeline created** | Both are deferred G-buffer material shaders (825 IR instructions each, 22 interpolations), so they are not a corner case: without the patch nothing of either program is emitted. That agrees with the synthetic regression result: the control refuses at the dead interpolation half, the candidate emits code the D3D12 runtime accepts and a PSO for it is made on a real NVIDIA adapter.
Artking175 commented 2026-11-25 16:13:09 +00:00 (Migrated from github.com)
Author
First-time contributor

Imported from Zettrox/ztrx. Originally posted by Artking175 on 2026-11-25T16:08:38Z.


Offline retest on RTX 2060 (driver 531.41), with app-local Agility SDK 1.608.2 and DXIL validator from DXC 1.8.2505.32. I ran translate --jobs 1 --validate --pipelines --list on the same local 1.0.2.1 shader archive.

The two reported containers, 38bf0814e721a1b3 and 78f3f2fc53a69531, both refused at 0x1464 on main (90b529f). On the exact PR revision 8079d11, both emitted DXIL, validated and created D3D12 PSOs. The same A/B held when applying #86 on top of #80. This adds independent RTX 2060 evidence to the RTX 4060 Laptop result.

<!-- greyfinch-sync:Zettrox/ztrx:comment:7167630877 --> Imported from [Zettrox/ztrx](https://github.com/Zettrox/ztrx/pull/86#issuecomment-7167630877). Originally posted by [Artking175](https://github.com/Artking175) on 2026-11-25T16:08:38Z. --- Offline retest on RTX 2060 (driver 531.41), with app-local Agility SDK 1.608.2 and DXIL validator from DXC 1.8.2505.32. I ran `translate --jobs 1 --validate --pipelines --list` on the same local 1.0.2.1 shader archive. The two reported containers, `38bf0814e721a1b3` and `78f3f2fc53a69531`, both refused at `0x1464` on `main` (`90b529f`). On the exact PR revision `8079d11`, both emitted DXIL, validated and created D3D12 PSOs. The same A/B held when applying #86 on top of #80. This adds independent RTX 2060 evidence to the RTX 4060 Laptop result.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/86:upstream-pr/86'
git switch 'upstream-pr/86'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/86'
git switch 'upstream-pr/86'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/86'
git switch 'upstream-pr/86'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/86'
git switch 'main'
git merge --squash 'upstream-pr/86'
git switch 'main'
git merge --ff-only 'upstream-pr/86'
git switch 'main'
git merge 'upstream-pr/86'
git push origin 'main'
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
Zettrox/ztrx!86
No description provided.