Shaders: ignore missing prior values on v_fma_mixlo_f16 and v_fma_mixhi_f16 #56

Open
IAmTheSween wants to merge 1 commit from upstream-pr/56 into main
IAmTheSween commented 2026-11-25 07:06:27 +00:00 (Migrated from github.com)
First-time contributor

Imported from Zettrox/ztrx. Originally posted by IAmTheSween on 2026-11-25T06:39:33Z.


Fixes all 8 deferred pixel shaders failing in emit with "the first half of an interpolation" (including 38bf0814e721a1b3 and 78f3f2fc53a69531 named in #38).

Cause

When a v_interp_p1ll_f16 / v_interp_p2_f16 pair uses loaded barycentrics, the first half evaluates as a Val::Missing("the first half of an interpolation") placeholder because v_interp_p2_f16 lowers the interpolation directly and writes the interpolated value to its own destination. In the deferred pixel shaders, the register allocator then reuses the first half's dead register as the destination of v_fma_mixlo_f16 (0x290 in 38bf0814e721a1b3). Unlike write_half and low_half, the v_fma_mixlo_f16 / v_fma_mixhi_f16 path propagated self.i32_of(o)? on the prior register contents when merging the untouched half, carrying the placeholder forward to color export mrt1.

What is in it

  • crates/victory-shader/src/emit/lower.rs: extracts Lower::place_half (merging the written 16-bit half with the prior register contents, or 0 if unlowered/unpreserved) and uses it in v_fma_mixlo_f16 / v_fma_mixhi_f16, write_half, and low_half.
  • crates/victory-shader/src/emit/mod.rs: adds regression test mixed_f16_write_over_interp_first_half_lowers_and_validates covering both v_fma_mixlo_f16 and v_fma_mixhi_f16 overwriting dead v_interp_p1ll_f16 destination registers, validated against dxil.dll.

Shader pack check

Checked all 8 "the first half of an interpolation" pixel shaders in the title's shader pack (victory.exe translate --validate --list):

  • 8/8 now emit DXIL and pass dxil.dll validation (10.0.26100.0) with 0 remaining "the first half of an interpolation" failures (5ddcaa08d4a51215, 464ea474374b8ecd, 38bf0814e721a1b3, 007bb29b393d08c5, 8445dcb2b63aa197, 288c43f50bc7abee, 78f3f2fc53a69531, 15547db9d31b056b).
  • Verified RTX 5070 pipeline creation on 38bf0814e721a1b3 (1 emitted, 1 validated, 1 pipelines).

Tested

  • Hardware: NVIDIA GeForce RTX 5070, Windows 11 x64, Windows SDK dxil.dll 10.0.26100.0.
  • cargo clippy --workspace --all-targets --locked -- -D warnings: passed (0 warnings).
  • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passed (0 warnings).
  • cargo test --workspace --locked -- --test-threads=1: all suites passed with 0 failures (victory 1, victory_core 11, victory_formats 24 / 4 ignored, victory_game 2, victory_gpu 110 / 1 ignored, victory_hle 95 + no_dll_planting 1, victory_loader 24 + load_probe 2 + title_dlls 1, victory_pe 7, victory_pipeline 4, victory_shader 211 / 2 ignored, xtask 4). Single-threaded execution was used for the full workspace run due to pre-existing WARP device contention when victory_gpu GPU tests run concurrently (valu_tests.rs:198).

AI use

Written with Antigravity.

<!-- greyfinch-sync:Zettrox/ztrx:issue:6598809368 --> Imported from [Zettrox/ztrx](https://github.com/Zettrox/ztrx/pull/56). Originally posted by [IAmTheSween](https://github.com/IAmTheSween) on 2026-11-25T06:39:33Z. --- Fixes all 8 deferred pixel shaders failing in `emit` with `"the first half of an interpolation"` (including `38bf0814e721a1b3` and `78f3f2fc53a69531` named in #38). ### Cause When a `v_interp_p1ll_f16` / `v_interp_p2_f16` pair uses loaded barycentrics, the first half evaluates as a `Val::Missing("the first half of an interpolation")` placeholder because `v_interp_p2_f16` lowers the interpolation directly and writes the interpolated value to its own destination. In the deferred pixel shaders, the register allocator then reuses the first half's dead register as the destination of `v_fma_mixlo_f16` (`0x290` in `38bf0814e721a1b3`). Unlike `write_half` and `low_half`, the `v_fma_mixlo_f16` / `v_fma_mixhi_f16` path propagated `self.i32_of(o)?` on the prior register contents when merging the untouched half, carrying the placeholder forward to color export `mrt1`. ### What is in it - **`crates/victory-shader/src/emit/lower.rs`**: extracts `Lower::place_half` (merging the written 16-bit half with the prior register contents, or `0` if unlowered/unpreserved) and uses it in `v_fma_mixlo_f16` / `v_fma_mixhi_f16`, `write_half`, and `low_half`. - **`crates/victory-shader/src/emit/mod.rs`**: adds regression test `mixed_f16_write_over_interp_first_half_lowers_and_validates` covering both `v_fma_mixlo_f16` and `v_fma_mixhi_f16` overwriting dead `v_interp_p1ll_f16` destination registers, validated against `dxil.dll`. ### Shader pack check Checked all 8 `"the first half of an interpolation"` pixel shaders in the title's shader pack (`victory.exe translate --validate --list`): - 8/8 now emit DXIL and pass `dxil.dll` validation (`10.0.26100.0`) with 0 remaining `"the first half of an interpolation"` failures (`5ddcaa08d4a51215`, `464ea474374b8ecd`, `38bf0814e721a1b3`, `007bb29b393d08c5`, `8445dcb2b63aa197`, `288c43f50bc7abee`, `78f3f2fc53a69531`, `15547db9d31b056b`). - Verified RTX 5070 pipeline creation on `38bf0814e721a1b3` (`1 emitted, 1 validated, 1 pipelines`). ### Tested - Hardware: NVIDIA GeForce RTX 5070, Windows 11 x64, Windows SDK `dxil.dll` `10.0.26100.0`. - `cargo clippy --workspace --all-targets --locked -- -D warnings`: passed (0 warnings). - `cargo clippy --workspace --all-targets --all-features --locked -- -D warnings`: passed (0 warnings). - `cargo test --workspace --locked -- --test-threads=1`: all suites passed with 0 failures (`victory` 1, `victory_core` 11, `victory_formats` 24 / 4 ignored, `victory_game` 2, `victory_gpu` 110 / 1 ignored, `victory_hle` 95 + `no_dll_planting` 1, `victory_loader` 24 + `load_probe` 2 + `title_dlls` 1, `victory_pe` 7, `victory_pipeline` 4, `victory_shader` 211 / 2 ignored, `xtask` 4). Single-threaded execution was used for the full workspace run due to pre-existing WARP device contention when `victory_gpu` GPU tests run concurrently (`valu_tests.rs:198`). ### AI use Written with Antigravity.
carlosmegino commented 2026-11-25 11:10:48 +00:00 (Migrated from github.com)
Author
First-time contributor

Imported from Zettrox/ztrx. Originally posted by carlosmegino on 2026-11-25T10:19:42Z.


Independent local validation of commit 9fe511eb77fa1220bacf05c20e1854fe1dc8861c on Windows 11 x64, i7-8700K, RTX 5070 Ti, driver 621.01, Rust 1.98.1, Windows SDK 10.0.26100.0 (dxil.dll 1.9.2602.17).

  • Applied only the new synthetic regression to the original lowering first: it failed with Unsupported: the first half of an interpolation. With the complete original patch, the regression passes.
  • Ran the existing offline translator against the same eight affected shaders listed in this PR, with --validate --pipelines --list --jobs 2 and VICTORY_HOST_MAX_WAVE=32. The exact preserved 90b529f878a470fec9bf07b7be316bc769a12232 diagnostic executable emitted 0/8 (all eight failed at the interpolation check). The patched build emitted 8/8, validated 8/8 and created 8/8 test pipelines on the default hardware D3D12 device; WARP was not enabled.
  • cargo test -p victory-shader --all-features --locked -- --test-threads=1: 211 passed, 0 failed, 2 ignored.
  • cargo test --workspace --locked -- --test-threads=1: 497 passed, 0 failed, 7 ignored.
  • Release and diagnostics builds and both workspace CI Clippy configurations passed. Global fmt still reports existing reference formatting differences.

The tested local stack also contains opt-in telemetry and a diagnostics input helper; neither changes shader lowering or graphics defaults. The original patch was cherry-picked with its author and source commit retained. Logs, shader bytes and game-derived material remain local.

These are translator/validator/test-pipeline results. The pipeline harness uses generated companion stages/default state; actual title PSOs, rendered correctness and gameplay FPS still require runtime validation. The translation CLI exits zero even for individual shader failures, so the comparison checks its counters rather than only its exit code.

<!-- greyfinch-sync:Zettrox/ztrx:comment:7159543649 --> Imported from [Zettrox/ztrx](https://github.com/Zettrox/ztrx/pull/56#issuecomment-7159543649). Originally posted by [carlosmegino](https://github.com/carlosmegino) on 2026-11-25T10:19:42Z. --- Independent local validation of commit `9fe511eb77fa1220bacf05c20e1854fe1dc8861c` on Windows 11 x64, i7-8700K, RTX 5070 Ti, driver 621.01, Rust 1.98.1, Windows SDK 10.0.26100.0 (`dxil.dll` 1.9.2602.17). - Applied only the new synthetic regression to the original lowering first: it failed with `Unsupported: the first half of an interpolation`. With the complete original patch, the regression passes. - Ran the existing offline translator against the same eight affected shaders listed in this PR, with `--validate --pipelines --list --jobs 2` and `VICTORY_HOST_MAX_WAVE=32`. The exact preserved `90b529f878a470fec9bf07b7be316bc769a12232` diagnostic executable emitted 0/8 (all eight failed at the interpolation check). The patched build emitted 8/8, validated 8/8 and created 8/8 test pipelines on the default hardware D3D12 device; WARP was not enabled. - `cargo test -p victory-shader --all-features --locked -- --test-threads=1`: 211 passed, 0 failed, 2 ignored. - `cargo test --workspace --locked -- --test-threads=1`: 497 passed, 0 failed, 7 ignored. - Release and diagnostics builds and both workspace CI Clippy configurations passed. Global fmt still reports existing reference formatting differences. The tested local stack also contains opt-in telemetry and a diagnostics input helper; neither changes shader lowering or graphics defaults. The original patch was cherry-picked with its author and source commit retained. Logs, shader bytes and game-derived material remain local. These are translator/validator/test-pipeline results. The pipeline harness uses generated companion stages/default state; actual title PSOs, rendered correctness and gameplay FPS still require runtime validation. The translation CLI exits zero even for individual shader failures, so the comparison checks its counters rather than only its exit code.
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/56:upstream-pr/56'
git switch 'upstream-pr/56'

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