victory-shader: emit zero for padding halves in f16 pixel input interpolation #1291

Closed
github-bot wants to merge 1 commit from gh-pr/1291/head into gh-pr/1291/base
Owner

@⁠bartikele on GitHub · 2026-11-24 17:10 UTC · original
bartikele:shader-packed-input-padding-half → main · +80 −1 · 2 files · 1 commits · closed without merging

In Lower::interp, when lowering an _f16 interpolation of a 16-bit pixel input and half(...) returns None (a padding half with no matching SigElement, e.g. the 4th half of a 3-component packed f16 input), emit 0 (self.s.m.i32(0)) instead of failing with a packed input half no element holds.

This matches the existing mode == 1 (flat dword) branch in Lower::interp, which already uses .unwrap_or(z) for padding halves.

Adds unit test emit::tests::reading_a_packed_input_padding_half_yields_zero (including dxil.dll validation).

Tested with:

  • cargo clippy -p victory-shader --all-targets --locked -- -D warnings
  • cargo test -p victory-shader --locked
**@⁠bartikele** on GitHub · 2026-11-24 17:10 UTC · [original](https://github.com/Marvisak/VIctory/pull/1291) `bartikele:shader-packed-input-padding-half` → `main` · +80 −1 · 2 files · 1 commits · closed without merging In `Lower::interp`, when lowering an `_f16` interpolation of a 16-bit pixel input and `half(...)` returns `None` (a padding half with no matching `SigElement`, e.g. the 4th half of a 3-component packed `f16` input), emit `0` (`self.s.m.i32(0)`) instead of failing with `a packed input half no element holds`. This matches the existing `mode == 1` (flat dword) branch in `Lower::interp`, which already uses `.unwrap_or(z)` for padding halves. Adds unit test `emit::tests::reading_a_packed_input_padding_half_yields_zero` (including `dxil.dll` validation). Tested with: - `cargo clippy -p victory-shader --all-targets --locked -- -D warnings` - `cargo test -p victory-shader --locked`
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:26:35 +00:00
github-bot closed this pull request 2026-11-26 04:26:35 +00:00
Author
Owner

@⁠geiyiliyabumo on GitHub · 2026-11-24 17:30 UTC · original

Independent verification of \94dbc0a\ on Windows 11 / AMD Radeon RX 9060 XT (RDNA4, \gfx1200) / Rust 1.98.1 MSVC:

  • Merge check vs \main\ (\ fe310e): clean
  • \cargo test -p victory-shader --lib: 121 passed, 0 failed, 1 ignored (including
    eading_a_packed_input_padding_half_yields_zero\ with live \dxil.dll\ validation)
  • \cargo clippy -p victory-shader --all-targets -- -D warnings\ (default and --all-features): clean
  • \cargo xtask policy: 154 files ok

Clean, minimal 1-line fix in \emit/lower.rs:5543\ with a targeted end-to-end \dxil.dll-validated test.

AI-assisted; synthetic tests only, no game files.

**@⁠geiyiliyabumo** on GitHub · 2026-11-24 17:30 UTC · [original](https://github.com/Marvisak/VIctory/pull/1291#issuecomment-7139291202) Independent verification of \94dbc0a\ on **Windows 11 / AMD Radeon RX 9060 XT (RDNA4, \gfx1200\) / Rust 1.98.1 MSVC**: - Merge check vs \main\ (\ fe310e\): clean - \cargo test -p victory-shader --lib\: **121 passed, 0 failed, 1 ignored** (including \ eading_a_packed_input_padding_half_yields_zero\ with live \dxil.dll\ validation) - \cargo clippy -p victory-shader --all-targets -- -D warnings\ (default and \--all-features\): clean - \cargo xtask policy\: 154 files ok Clean, minimal 1-line fix in \emit/lower.rs:5543\ with a targeted end-to-end \dxil.dll\-validated test. *AI-assisted; synthetic tests only, no game files.*
Author
Owner

@⁠Halfect on GitHub · 2026-11-24 17:49 UTC · original

Heads-up on the overlap: this is the same failure site and motivation as #621 (fix/packed-input-explicit-row2, stacked on #592), so the two PRs collide at lower.rs:5543. The difference is the semantics of the zero, and it matters for correctness.

What this PR does: every None from half() in the _f16 branch becomes zero — regardless of why the half is missing.

What #592 + #621 do instead, and why: #592's body documents why a blanket zero was rejected there ("Why not just read 0"): the diagnostic showed a large share of the failing reads are halves 4–7 next to a 4-channel first row, i.e. the second row's real data that the metadata left out (row2 == row). Reading those as zero silently replaces real interpolated values. fiestorra's probe on the retail pack quantified the split (comment on #592): of 1,048 failing half-reads, 828 have a named second row that is shorter than the read (the case your test fixture exercises, and the one #621 zeroes), but 220 have no partner row in the metadata at all — under this PR those 220 read zero instead of the adjacent row that #592's inferred pairing supplies, which is exactly the silent-data-loss case #592 argued against.

So the stacked pair covers both shapes with the distinction preserved: #592 supplies the omitted second row, and #621 reads zero only for undeclared trailing halves of an explicitly named second row (packing padding), keeping the inferred-partner case strict. #621 carries a synthetic regression for that distinction, plus a DXV-accepted hardware readback (RTX 4090/Wine) and an independent Windows run with a 19-minute live world test.

If the maintainer prefers this simpler one-liner, it would be good to make the trade-off explicit in the body: it re-opens the 220-read class that #592 closes, with zeros where the neighboring row holds real data. Otherwise this duplicates #621 and probably closes in favor of the stack. AI-assisted (Kimi).

**@⁠Halfect** on GitHub · 2026-11-24 17:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/1291#issuecomment-7139765426) Heads-up on the overlap: this is the same failure site and motivation as #621 (`fix/packed-input-explicit-row2`, stacked on #592), so the two PRs collide at `lower.rs:5543`. The difference is the semantics of the zero, and it matters for correctness. **What this PR does:** every `None` from `half()` in the `_f16` branch becomes zero — regardless of why the half is missing. **What #592 + #621 do instead, and why:** #592's body documents why a blanket zero was rejected there ("Why not just read 0"): the diagnostic showed a large share of the failing reads are halves 4–7 next to a 4-channel first row, i.e. the *second row's real data* that the metadata left out (`row2 == row`). Reading those as zero silently replaces real interpolated values. fiestorra's probe on the retail pack quantified the split ([comment on #592](https://git.gtahub.st/github/Marvisak--VIctory/pulls/592)): of 1,048 failing half-reads, **828** have a named second row that is shorter than the read (the case your test fixture exercises, and the one #621 zeroes), but **220** have *no* partner row in the metadata at all — under this PR those 220 read zero instead of the adjacent row that #592's inferred pairing supplies, which is exactly the silent-data-loss case #592 argued against. So the stacked pair covers both shapes with the distinction preserved: #592 supplies the omitted second row, and #621 reads zero *only* for undeclared trailing halves of an **explicitly named** second row (packing padding), keeping the inferred-partner case strict. #621 carries a synthetic regression for that distinction, plus a DXV-accepted hardware readback (RTX 4090/Wine) and an independent Windows run with a 19-minute live world test. If the maintainer prefers this simpler one-liner, it would be good to make the trade-off explicit in the body: it re-opens the 220-read class that #592 closes, with zeros where the neighboring row holds real data. Otherwise this duplicates #621 and probably closes in favor of the stack. AI-assisted (Kimi).
Author
Owner

@⁠muhammed-aksoy on GitHub · 2026-11-24 17:54 UTC · original

I tested 94dbc0a together with #1285 (e34f8c3) on ffe310e. Windows cargo test --locked -p victory-shader -- --test-threads=1 passed 124 tests with zero failures and one ignored at local merge 6d40e1b, with the Windows SDK DXIL validator configured. This covers the padding-half test alongside the SDWA fixtures. AI-assisted.

**@⁠muhammed-aksoy** on GitHub · 2026-11-24 17:54 UTC · [original](https://github.com/Marvisak/VIctory/pull/1291#issuecomment-7139872827) I tested `94dbc0a` together with #1285 (`e34f8c3`) on `ffe310e`. Windows `cargo test --locked -p victory-shader -- --test-threads=1` passed 124 tests with zero failures and one ignored at local merge `6d40e1b`, with the Windows SDK DXIL validator configured. This covers the padding-half test alongside the SDWA fixtures. AI-assisted.
Author
Owner

@⁠adamdotpy on GitHub · 2026-11-24 19:07 UTC · original

Reviewed at head 94dbc0a (worktree on the PR head, isolated target dir, Windows 11 / Rust 1.98.1). Findings, ranked:

1. The change is right and now consistent with the flat path. In the v_interp_* lowering (lower.rs:5543), the packed-f16 path read half(self, h + high)? and refused with "a packed input half no element holds" when the signature row doesn't provide that half. That half is padding of a pack2 attribute, and the input assembler zero-fills undeclared components — the same mode == 1 flat path right below already did .unwrap_or(zero) for both halves. The PR makes the f16 path do the same (unwrap_or_else(|| i32(0))), so packed and flat interpolation now agree instead of one refusing.

2. Verified here. The new reading_a_packed_input_padding_half_yields_zero builds a PS with a packed f16 input (mask 0b0011, pack2), interpolates attr0.y high half (v_interp_p1ll_f16 / v_interp_p2_f16) and exports — emit succeeds and the DXIL passes dxil.dll validation when present (it ran here, no skip). cargo test -p victory-shader --lib padding_half 1 passed; full lib 121 passed / 0 failed / 1 ignored.

3. Checks: cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings clean; cargo build --release -p victory builds; rustfmt --edition 2024 --check — lower.rs shows only main's 3 pre-existing hunks, mod.rs has one new hunk in the added test code (mod.rs:811; main's 671 is pre-existing). Cosmetic only, CI has no fmt job.

4. Note, not a defect: the test pins that emit succeeds and validates, not the emitted zero on the GPU — the zero-fill behavior itself is asserted by inspection of the unwrap_or_else arm. A run_cases-style readback of the interpolated padding half would pin it on hardware if you want that; the flat path's existing behavior is the precedent either way. This turns a refusal into a translation for shaders reading padding halves, which matches how undeclared attribute components read on the console.

Nothing found that would block this.

**@⁠adamdotpy** on GitHub · 2026-11-24 19:07 UTC · [original](https://github.com/Marvisak/VIctory/pull/1291#issuecomment-7141635534) Reviewed at head `94dbc0a` (worktree on the PR head, isolated target dir, Windows 11 / Rust 1.98.1). Findings, ranked: **1. The change is right and now consistent with the flat path.** In the `v_interp_*` lowering (`lower.rs:5543`), the packed-f16 path read `half(self, h + high)?` and refused with "a packed input half no element holds" when the signature row doesn't provide that half. That half is padding of a `pack2` attribute, and the input assembler zero-fills undeclared components — the same `mode == 1` flat path right below already did `.unwrap_or(zero)` for both halves. The PR makes the f16 path do the same (`unwrap_or_else(|| i32(0))`), so packed and flat interpolation now agree instead of one refusing. **2. Verified here.** The new `reading_a_packed_input_padding_half_yields_zero` builds a PS with a packed f16 input (`mask 0b0011`, `pack2`), interpolates `attr0.y` high half (`v_interp_p1ll_f16` / `v_interp_p2_f16`) and exports — emit succeeds and the DXIL passes `dxil.dll` validation when present (it ran here, no skip). `cargo test -p victory-shader --lib padding_half` 1 passed; full lib 121 passed / 0 failed / 1 ignored. **3. Checks:** `cargo clippy -p victory-shader --all-targets --all-features --locked -- -D warnings` clean; `cargo build --release -p victory` builds; `rustfmt --edition 2024 --check` — `lower.rs` shows only main's 3 pre-existing hunks, `mod.rs` has one new hunk in the added test code (`mod.rs:811`; main's 671 is pre-existing). Cosmetic only, CI has no fmt job. **4. Note, not a defect:** the test pins that emit *succeeds* and validates, not the emitted zero on the GPU — the zero-fill behavior itself is asserted by inspection of the `unwrap_or_else` arm. A `run_cases`-style readback of the interpolated padding half would pin it on hardware if you want that; the flat path's existing behavior is the precedent either way. This turns a refusal into a translation for shaders reading padding halves, which matches how undeclared attribute components read on the console. Nothing found that would block this.
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-24 19:50 UTC · original

Offline measurement on a retail dump, and the shader tests on Ada

Result: +117 programs over main, 0 lost.

Offline. I merged head 94dbc0a onto main ffe310e (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 21,724 on main, 21,841 with this PR.

Failure on main Gained
emit: a packed input half no element holds 117

All 117 are among the programs that #1402 gains through #176. This PR and the packed-half PRs measured in #1247 (#176, #621, #592, 117 programs each) look like one set.

Tests: with the same merge, cargo test --locked -p victory-shader --lib passed 121, failed 0. The bitcode benchmark is ignored, as on main, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, with VICTORY_WARP unset.

No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

**@⁠sinan-cmyk** on GitHub · 2026-11-24 19:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/1291#issuecomment-7142665592) ### Offline measurement on a retail dump, and the shader tests on Ada **Result: +117 programs over `main`, 0 lost.** **Offline.** I merged head 94dbc0a onto `main` ffe310e (clean merge) and ran `victory translate --validate --list` on `shaders.rpf` (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with `main` program by program (25,889 programs). Validated: 21,724 on `main`, 21,841 with this PR. | Failure on `main` | Gained | |---|---| | emit: a packed input half no element holds | 117 | All 117 are among the programs that #1402 gains through #176. This PR and the packed-half PRs measured in #1247 (#176, #621, #592, 117 programs each) look like one set. **Tests:** with the same merge, `cargo test --locked -p victory-shader --lib` passed 121, failed 0. The bitcode benchmark is ignored, as on `main`, where 120 pass. The run was on an RTX 4070 SUPER (Ada, 32-lane waves, driver 32.0.16.1088), the default adapter, with `VICTORY_WARP` unset. No shader names or data are included, per the asset policy. AI-assisted (Claude Code).
Author
Owner

@⁠sinan-cmyk on GitHub · 2026-11-24 21:18 UTC · original

Stacked on #1402: no change

Result: 0 gained, 0 lost, and no failure reason changes on top of #1402. On main this PR gained 117 programs. #1402 already gains the same 117 through #176.

The merge with #1402 conflicts in one hunk of emit/mod.rs, where both sides only add tests. I kept both. cargo test --locked -p victory-shader --lib on the merge: 138 passed, 0 failed.

Method: victory translate --validate --list on shaders.rpf (1.0.2.1), dxil.dll 1.8.2502.11, compared program by program (25,889 programs), against #1402 at 2310409. AI-assisted (Claude Code). No shader names or data are included, per the asset policy.

**@⁠sinan-cmyk** on GitHub · 2026-11-24 21:18 UTC · [original](https://github.com/Marvisak/VIctory/pull/1291#issuecomment-7144765350) ### Stacked on #1402: no change **Result: 0 gained, 0 lost, and no failure reason changes on top of #1402.** On `main` this PR gained 117 programs. #1402 already gains the same 117 through #176. The merge with #1402 conflicts in one hunk of `emit/mod.rs`, where both sides only add tests. I kept both. `cargo test --locked -p victory-shader --lib` on the merge: 138 passed, 0 failed. Method: `victory translate --validate --list` on `shaders.rpf` (1.0.2.1), dxil.dll 1.8.2502.11, compared program by program (25,889 programs), against #1402 at 2310409. AI-assisted (Claude Code). No shader names or data are included, per the asset policy.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 00:36 UTC · original

Automated triage for the maintainers. Closing because by our reading the change is incorrect or would break something that works today.

Turns the refusal 'a packed input half no element holds' into a silent 0. With main's corrected first-fit packing rule no title pixel shader reads a padding half (4,773 of 4,773 map), so the change only hides a wrong packing model; the padding's real content is whatever the previous stage exported, not 0.

If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

**@⁠Marvisak** on GitHub · 2026-11-25 00:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/1291#issuecomment-7148694460) Automated triage for the maintainers. Closing because by our reading the change is incorrect or would break something that works today. Turns the refusal 'a packed input half no element holds' into a silent 0. With main's corrected first-fit packing rule no title pixel shader reads a padding half (4,773 of 4,773 map), so the change only hides a wrong packing model; the padding's real content is whatever the previous stage exported, not 0. If this is mistaken, reply here with what was missed (or push a change and say so) and it will be looked at again. Thank you for the contribution.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1291
No description provided.