Shaders: read explicit packed input padding as zero #621

Closed
Halfect wants to merge 2 commits from upstream-pr/621 into main
Halfect commented 2026-11-24 05:44:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Halfect on 2026-11-24T05:44:42Z.


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).

<!-- greyfinch-sync:Marvisak/VIctory:issue:6575497174 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/621). Originally posted by [Halfect](https://github.com/Halfect) on 2026-11-24T05:44:42Z. --- 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).
LAKSHYA-cmd-tech commented 2026-11-24 06:54:01 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by LAKSHYA-cmd-tech on 2026-11-24T05:59:59Z.

Review: APPROVED


Tested on Windows 11 with Rust 1.98.1 (x86_64-pc-windows-msvc).

  • cargo test -p victory-shader: all 71 tests passed cleanly, including packed_pixel_inputs_find_their_second_row and explicit_packed_input_tail_is_padding.
  • cargo xtask policy: passed (151 files ok).
  • Verified packed pixel input second-row padding vs inferred partner behavior in crates/victory-shader/src/emit/lower.rs.
<!-- greyfinch-sync:Marvisak/VIctory:review:6034414689 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/621#pullrequestreview-6034414689). Originally posted by [LAKSHYA-cmd-tech](https://github.com/LAKSHYA-cmd-tech) on 2026-11-24T05:59:59Z. **Review:** APPROVED --- Tested on Windows 11 with Rust 1.98.1 (x86_64-pc-windows-msvc). - cargo test -p victory-shader: all 71 tests passed cleanly, including packed_pixel_inputs_find_their_second_row and explicit_packed_input_tail_is_padding. - cargo xtask policy: passed (151 files ok). - Verified packed pixel input second-row padding vs inferred partner behavior in crates/victory-shader/src/emit/lower.rs.
slint6614-dev commented 2026-11-24 09:06:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by slint6614-dev on 2026-11-24T08:43:50Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7126490660 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/621#issuecomment-7126490660). Originally posted by [slint6614-dev](https://github.com/slint6614-dev) on 2026-11-24T08:43:50Z. --- 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.
catminou4 commented 2026-11-24 11:03:44 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T10:19:47Z.

Review: COMMENTED


Conflicts with current main (ffe310e) in lower.rs — needs a rebase.

Static review: the safety line is right — padding reads as zero only for an explicit second row (row2 != row in the metadata); an inferred partner still errors, so inference can't silently turn real data into zeroes. half_input_partners picks the next unnamed 16-bit row in row order, skipping rows already named by entries or other packed pairs, and the two tests cover both the inference and the explicit-padding cases. One thing to double-check on rebase: packed_input_half returning Ok(None) now feeds the f16 && explicit_second_row zero path in the caller — make sure the None from a non-f16 packed read can't reach that branch (the caller gates on pack2 && f16, so it looks fine).

Rebase and I'll run the suite.

<!-- greyfinch-sync:Marvisak/VIctory:review:6037424572 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/621#pullrequestreview-6037424572). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T10:19:47Z. **Review:** COMMENTED --- Conflicts with current main (`ffe310e`) in `lower.rs` — needs a rebase. Static review: the safety line is right — padding reads as zero only for an *explicit* second row (`row2 != row` in the metadata); an inferred partner still errors, so inference can't silently turn real data into zeroes. `half_input_partners` picks the next unnamed 16-bit row in row order, skipping rows already named by entries or other packed pairs, and the two tests cover both the inference and the explicit-padding cases. One thing to double-check on rebase: `packed_input_half` returning `Ok(None)` now feeds the `f16 && explicit_second_row` zero path in the caller — make sure the `None` from a *non*-f16 packed read can't reach that branch (the caller gates on `pack2 && f16`, so it looks fine). Rebase and I'll run the suite.
catminou4 commented 2026-11-24 11:03:44 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T11:03:14Z.

Review: APPROVED


Rebased onto current main (ffe310e) — merges cleanly now, and cargo test -p victory-shader --locked on the merged tree (macOS arm64, rustc 1.98.1) → 98 passed / 0 failed / 1 ignored.

The substance is unchanged from my earlier static review: padding reads as zero only for an explicit second row (row2 != row); inferred partners still error, so inference can't turn real data into zeroes. half_input_partners picks the next unnamed 16-bit row in row order, skipping rows named by entries or other packed pairs. Both tests (partner inference, explicit padding) still cover the change. The f16 && explicit_second_row zero path in the caller is gated on f16 as intended.

<!-- greyfinch-sync:Marvisak/VIctory:review:6038035223 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/621#pullrequestreview-6038035223). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T11:03:14Z. **Review:** APPROVED --- Rebased onto current main (`ffe310e`) — merges cleanly now, and `cargo test -p victory-shader --locked` on the merged tree (macOS arm64, rustc 1.98.1) → **98 passed / 0 failed / 1 ignored**. The substance is unchanged from my earlier static review: padding reads as zero only for an explicit second row (`row2 != row`); inferred partners still error, so inference can't turn real data into zeroes. `half_input_partners` picks the next unnamed 16-bit row in row order, skipping rows named by entries or other packed pairs. Both tests (partner inference, explicit padding) still cover the change. The `f16 && explicit_second_row` zero path in the caller is gated on f16 as intended.
Halfect commented 2026-11-24 11:04:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Halfect on 2026-11-24T10:31:11Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7128888597 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/621#issuecomment-7128888597). Originally posted by [Halfect](https://github.com/Halfect) on 2026-11-24T10:31:11Z. --- 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.
MichaelSmithAI commented 2026-11-24 11:04:19 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by MichaelSmithAI on 2026-11-24T10:42:52Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7129146252 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/621#issuecomment-7129146252). Originally posted by [MichaelSmithAI](https://github.com/MichaelSmithAI) on 2026-11-24T10:42:52Z. --- 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.
Halfect commented 2026-11-24 14:04:43 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Halfect on 2026-11-24T13:23:54Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7132771621 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/621#issuecomment-7132771621). Originally posted by [Halfect](https://github.com/Halfect) on 2026-11-24T13:23:54Z. --- 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.
Yaekai commented 2026-11-24 17:04:40 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Yaekai on 2026-11-24T16:41:45Z.


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!
<!-- greyfinch-sync:Marvisak/VIctory:comment:7138065065 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/621#issuecomment-7138065065). Originally posted by [Yaekai](https://github.com/Yaekai) on 2026-11-24T16:41:45Z. --- 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`!
Halfect commented 2026-11-24 17:04:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Halfect on 2026-11-24T16:50:17Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7138283630 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/621#issuecomment-7138283630). Originally posted by [Halfect](https://github.com/Halfect) on 2026-11-24T16:50:17Z. --- 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.
upstream-sync closed this pull request 2026-11-25 01:04:30 +00:00
Marvisak commented 2026-11-25 01:07:47 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:26:12Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7148507912 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/621#issuecomment-7148507912). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T00:26:12Z. --- 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

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
Marvisak/VIctory!621
No description provided.