Shaders: read explicit packed input padding as zero #621

Closed
github-bot wants to merge 2 commits from gh-pr/621/head into gh-pr/621/base
Owner

@⁠Halfect on GitHub · 2026-11-24 05:44 UTC · original
Halfect:fix/packed-input-explicit-row2 → main · +143 −4 · 1 files · 2 commits · closed without merging

Stacked on #592 at 35bf153; only 7e5c7c8 is new here. Once #592 merges, this is a one-commit follow-up.

What

The six programs left by #592 explicitly name a second packed-input row (row2 != row), but their input signature declares fewer halves in that row than the interpolation reads. Those trailing halves are packing padding.

packed_input_half now distinguishes that case from a missing half under an inferred partner:

  • Explicit second row: preserve every declared channel and read undeclared trailing halves as zero.
  • Inferred second row: keep refusing a missing half, so the inference cannot silently replace real data with zero.
  • Non-packed and flat-input behavior is unchanged.

Adds a synthetic regression test with four halves in the first row and two in the explicit second row. It checks the real second-row channel, both zero-padding positions, and that the same gap still fails with an inferred partner.

Offline title measurement

Local v1.0.2.1 shader archive, translate --validate --list --jobs 1, comparing #592 35bf153 with this head 7e5c7c8:

Result #592 This head
Vertex + pixel emitted 12,341 12,341
Vertex + pixel DXIL-validated 12,265 12,265
Compute emitted / validated 1,440 / 1,417 1,440 / 1,417
Mesh emitted / validated 8,163 / 8,101 8,163 / 8,101

Across 25,889 matched program labels, this revision has 0 DXIL validation gains and 0 losses. The six programs that previously gained validation against the older #592 7139712 now stop earlier at the unrelated a scalar memory read as data error in both runs. That earlier failure masks this case at title level, so the synthetic regression is the direct behavioral check for this revision; the earlier +6 result is not claimed for this head.

Checks

  • cargo test -p victory-shader: 91 passed, 0 failed, 1 benchmark ignored.
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 152 files ok.
  • Release build: passed.

Offline translation and DXIL validation only; no title executable, world run, shader contents, or extracted data. AI-assisted (Kimi).

**@⁠Halfect** on GitHub · 2026-11-24 05:44 UTC · [original](https://github.com/Marvisak/VIctory/pull/621) `Halfect:fix/packed-input-explicit-row2` → `main` · +143 −4 · 1 files · 2 commits · closed without merging Stacked on #592 at `35bf153`; only `7e5c7c8` is new here. Once #592 merges, this is a one-commit follow-up. ## What The six programs left by #592 explicitly name a second packed-input row (`row2 != row`), but their input signature declares fewer halves in that row than the interpolation reads. Those trailing halves are packing padding. `packed_input_half` now distinguishes that case from a missing half under an inferred partner: - **Explicit second row:** preserve every declared channel and read undeclared trailing halves as zero. - **Inferred second row:** keep refusing a missing half, so the inference cannot silently replace real data with zero. - Non-packed and flat-input behavior is unchanged. Adds a synthetic regression test with four halves in the first row and two in the explicit second row. It checks the real second-row channel, both zero-padding positions, and that the same gap still fails with an inferred partner. ## Offline title measurement Local v1.0.2.1 shader archive, `translate --validate --list --jobs 1`, comparing #592 `35bf153` with this head `7e5c7c8`: | Result | #592 | This head | |---|---:|---:| | Vertex + pixel emitted | 12,341 | **12,341** | | Vertex + pixel DXIL-validated | 12,265 | **12,265** | | Compute emitted / validated | 1,440 / 1,417 | **1,440 / 1,417** | | Mesh emitted / validated | 8,163 / 8,101 | **8,163 / 8,101** | Across **25,889 matched program labels**, this revision has **0 DXIL validation gains and 0 losses**. The six programs that previously gained validation against the older #592 `7139712` now stop earlier at the unrelated `a scalar memory read as data` error in both runs. That earlier failure masks this case at title level, so the synthetic regression is the direct behavioral check for this revision; the earlier +6 result is not claimed for this head. ## Checks - `cargo test -p victory-shader`: **91 passed, 0 failed, 1 benchmark ignored**. - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: **152 files ok**. - Release build: passed. Offline translation and DXIL validation only; no title executable, world run, shader contents, or extracted data. AI-assisted (Kimi).
Pixel inputs packing two 16-bit rows per dword (pack2) whose metadata
leaves the second row out (row2 = row) had no second row, so reading
its halves failed: "a packed input half no element holds". The second
row is now found as the output side finds it (half_outputs): the next
16-bit row of the input signature that no input entry names, taken in
row order, after the rows the metadata does give.

translate --validate on shaders.rpf: vertex/pixel 12172 -> 12289
validated; 6 programs whose metadata names a second row still stop
there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:10:24 +00:00
github-bot closed this pull request 2026-11-26 04:10:24 +00:00
Author
Owner

@⁠slint6614-dev on GitHub · 2026-11-24 08:43 UTC · original

Measured on the full retail shader pack (26,503 containers) with victory translate --validate --pipelines (pipelines created on an AMD RX 9070, Adrenalin, Windows 11; dxil.dll from SDK 10.0.26100), against main 1f858b0. Counts are emitted / validated / pipelines.

VS/PS "packed input half no element holds"
main 12272 / 12172 / 12272 172
#621 12395 / 12295 / 12395 0
#176 12389 / 12289 / 12389 6
#592 12389 / 12289 / 12389 6

#621 clears all 172 (+123 validated pixel programs); #176 and #592 give identical results (+117, 6 left). CS and MS unchanged in all three.

**@⁠slint6614-dev** on GitHub · 2026-11-24 08:43 UTC · [original](https://github.com/Marvisak/VIctory/pull/621#issuecomment-7126490660) Measured on the full retail shader pack (26,503 containers) with `victory translate --validate --pipelines` (pipelines created on an AMD RX 9070, Adrenalin, Windows 11; dxil.dll from SDK 10.0.26100), against main 1f858b0. Counts are emitted / validated / pipelines. | | VS/PS | "packed input half no element holds" | |---|---|---| | main | 12272 / 12172 / 12272 | 172 | | #621 | 12395 / **12295** / 12395 | 0 | | #176 | 12389 / 12289 / 12389 | 6 | | #592 | 12389 / 12289 / 12389 | 6 | #621 clears all 172 (+123 validated pixel programs); #176 and #592 give identical results (+117, 6 left). CS and MS unchanged in all three.
Author
Owner

@⁠Halfect on GitHub · 2026-11-24 10:31 UTC · original

Rebased onto the updated #592 35bf153 and pushed 7e5c7c8 after your review. A git merge-tree --write-tree check against current main ffe310e also resolves cleanly.

The non-f16 path cannot reach the new zero fallback: packed_input_half is called only under pack2 && f16, and the fallback itself is gated by f16 && explicit_second_row.

Rebased checks: 91 passed, 0 failed, 1 ignored; Clippy, cargo xtask policy (152 files), and the release build passed. The updated full-archive A/B is 0 gained / 0 lost because the previous six cases now stop earlier at the unrelated a scalar memory read as data; the PR body records that explicitly. Ready for another test run.

**@⁠Halfect** on GitHub · 2026-11-24 10:31 UTC · [original](https://github.com/Marvisak/VIctory/pull/621#issuecomment-7128888597) Rebased onto the updated #592 `35bf153` and pushed `7e5c7c8` after your review. A `git merge-tree --write-tree` check against current main `ffe310e` also resolves cleanly. The non-f16 path cannot reach the new zero fallback: `packed_input_half` is called only under `pack2 && f16`, and the fallback itself is gated by `f16 && explicit_second_row`. Rebased checks: **91 passed, 0 failed, 1 ignored**; Clippy, `cargo xtask policy` (152 files), and the release build passed. The updated full-archive A/B is **0 gained / 0 lost** because the previous six cases now stop earlier at the unrelated `a scalar memory read as data`; the PR body records that explicitly. Ready for another test run.
Author
Owner

@⁠MichaelSmithAI on GitHub · 2026-11-24 10:42 UTC · original

Retested 7e5c7c8 on its exact parent 35bf153 with the source-built pixel padding control. Microsoft DXV accepted the emitted pixel shader, and its DXIL was byte-identical to the prior fb6a9c1 fixture output.

On the RTX 4090 through Wine 11.22 and vkd3d-proton 3.1, the translated shader and independent DXC HLSL reference both returned [0.125, -2.5, +0, +0] in all 64 pixels. The neighboring row carries [8, 16, 32, 64] to distinguish zero padding from reading that row. Both replays completed successfully. This is a source-built check of explicit row padding. The full-archive comparison and the six scalar-read refusals are covered by your separate run.

**@⁠MichaelSmithAI** on GitHub · 2026-11-24 10:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/621#issuecomment-7129146252) Retested `7e5c7c8` on its exact parent `35bf153` with the source-built pixel padding control. Microsoft DXV accepted the emitted pixel shader, and its DXIL was byte-identical to the prior `fb6a9c1` fixture output. On the RTX 4090 through Wine 11.22 and vkd3d-proton 3.1, the translated shader and independent DXC HLSL reference both returned `[0.125, -2.5, +0, +0]` in all 64 pixels. The neighboring row carries `[8, 16, 32, 64]` to distinguish zero padding from reading that row. Both replays completed successfully. This is a source-built check of explicit row padding. The full-archive comparison and the six scalar-read refusals are covered by your separate run.
Author
Owner

@⁠Halfect on GitHub · 2026-11-24 13:23 UTC · original

Thanks @⁠MichaelSmithAI for the source-built retest on 7e5c7c8 — good to have the DXV acceptance and the matching [0.125, -2.5, +0, +0] replays confirmed on both the translated shader and the DXC reference. Nothing further from my side on this head; ready for review.

**@⁠Halfect** on GitHub · 2026-11-24 13:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/621#issuecomment-7132771621) Thanks @⁠MichaelSmithAI for the source-built retest on `7e5c7c8` — good to have the DXV acceptance and the matching `[0.125, -2.5, +0, +0]` replays confirmed on both the translated shader and the DXC reference. Nothing further from my side on this head; ready for review.
Author
Owner

@⁠Yaekai on GitHub · 2026-11-24 16:41 UTC · original

Independent verification on Windows 11 + NVIDIA RTX 3070 (Rust 1.98.1) at head 7e5c7c8:

  • cargo test -p victory-shader --lib -- --skip valu_tests --skip waterfall_tests: 78 passed, 0 failed.
  • cargo clippy -p victory-shader -- -D warnings: 0 warnings.
  • Live GTA VI (1.0.2.1, --console series-s, 19-min world run): no regressions. Ready to merge once rebased on main!
**@⁠Yaekai** on GitHub · 2026-11-24 16:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/621#issuecomment-7138065065) Independent verification on Windows 11 + NVIDIA RTX 3070 (Rust 1.98.1) at head `7e5c7c8`: - `cargo test -p victory-shader --lib -- --skip valu_tests --skip waterfall_tests`: 78 passed, 0 failed. - `cargo clippy -p victory-shader -- -D warnings`: 0 warnings. - Live GTA VI (`1.0.2.1`, `--console series-s`, 19-min world run): no regressions. Ready to merge once rebased on `main`!
Author
Owner

@⁠Halfect on GitHub · 2026-11-24 16:50 UTC · original

Thanks @⁠Yaekai for the independent run — tests, clippy, and a 19-minute live world run with no regressions is a strong check.

On the rebase: this branch is stacked on #592 by design (its diff touches the explicit-second-row case that #592's inferred pairing leaves behind), so it can't move directly onto main without #592's half_input_partners. The moment #592 lands I'll rebase onto main and it becomes the one-commit follow-up the body describes. A git merge-tree --write-tree check of the stack against current main (ffe310e) already resolves cleanly.

**@⁠Halfect** on GitHub · 2026-11-24 16:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/621#issuecomment-7138283630) Thanks @⁠Yaekai for the independent run — tests, clippy, and a 19-minute live world run with no regressions is a strong check. On the rebase: this branch is stacked on #592 by design (its diff touches the explicit-second-row case that #592's inferred pairing leaves behind), so it can't move directly onto `main` without #592's `half_input_partners`. The moment #592 lands I'll rebase onto `main` and it becomes the one-commit follow-up the body describes. A `git merge-tree --write-tree` check of the stack against current `main` (`ffe310e`) already resolves cleanly.
Author
Owner

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

Automated triage for the maintainers. Closing because this change is already in main, or main has since replaced the code it patches.

Stacked on #592; the 'padding' halves it reads as zero were an artifact of the row-pair rule. Main's first-fit rule maps every half read to a declared channel (4,773 of 4,773 pack2 pixel shaders).

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:26 UTC · [original](https://github.com/Marvisak/VIctory/pull/621#issuecomment-7148507912) Automated triage for the maintainers. Closing because this change is already in `main`, or `main` has since replaced the code it patches. Stacked on #592; the 'padding' halves it reads as zero were an artifact of the row-pair rule. Main's first-fit rule maps every half read to a declared channel (4,773 of 4,773 pack2 pixel shaders). 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!621
No description provided.