Shaders: unpack 16-bit vertex inputs into the low half #1519

Open
github-bot wants to merge 2 commits from github-bot/gh-1519 into main AGit
Owner

@⁠Bloh09 on GitHub · 2026-11-24 18:42 UTC · original
Bloh09:bloh09/shader-16bit-vertex-inputs → main · +132 −7 · 2 files · 2 commits · open

Unpack 16-bit vertex attributes into the low half of the VGPR, the way the fetch shader leaves them. Host loadInput is 32-bit, so float16 goes through legacyF32ToF16 and integers are masked to 16 bits.

Part of #1512.

Tested on a Linux box with no GPU and no game files: cargo test --frozen -p victory-shader (97 passed, 1 ignored) and cargo xtask policy (154 files ok). The new test fails on main with "a 16-bit input is not supported".

Untested on hardware; would appreciate someone running a vertex shader with 16-bit inputs.

AI-assisted (Grok Bot), reviewed by me.

Skipped: packed fetch (two 16-bit values per dword). VsInput has no pack flags, so that stays refused until the stage data carries them.

**@⁠Bloh09** on GitHub · 2026-11-24 18:42 UTC · [original](https://github.com/Marvisak/VIctory/pull/1519) `Bloh09:bloh09/shader-16bit-vertex-inputs` → `main` · +132 −7 · 2 files · 2 commits · open Unpack 16-bit vertex attributes into the low half of the VGPR, the way the fetch shader leaves them. Host loadInput is 32-bit, so float16 goes through legacyF32ToF16 and integers are masked to 16 bits. Part of #1512. Tested on a Linux box with no GPU and no game files: `cargo test --frozen -p victory-shader` (97 passed, 1 ignored) and `cargo xtask policy` (154 files ok). The new test fails on main with "a 16-bit input is not supported". Untested on hardware; would appreciate someone running a vertex shader with 16-bit inputs. AI-assisted (Grok Bot), reviewed by me. Skipped: packed fetch (two 16-bit values per dword). VsInput has no pack flags, so that stays refused until the stage data carries them.
The fetch shader leaves a 16-bit attribute in the low half of a VGPR.
The host load is 32-bit, so convert float16 with legacyF32ToF16 and
mask integer values. Part of #1512.
The 16-bit vertex input test now checks for legacyF32ToF16 on floats
and the 0xFFFF mask on integers, not just that lowering succeeds.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:34:53 +00:00
Author
Owner

@⁠MichaelSmithAI on GitHub · 2026-11-24 18:53 UTC · original

The requested hardware check passed on 55bf86f with an RTX 4090 under Wine/GE 3.2. The test input layout used actual R16_FLOAT, R16_SINT, and R16_UINT elements. The translated vertex shader converted each resulting VGPR word as an unsigned 32-bit integer to an exactly representable float, and a passthrough pixel shader exposed it for readback. Microsoft’s DXIL validator accepted the vertex shader.

Input values (float, signed, unsigned) VGPR words read back at all four pixels
−0.875, −1234, 65244 0x0000bb00, 0x0000fb2e, 0x0000fedc
1.5, 32767, 33059 0x00003e00, 0x00007fff, 0x00008123

In particular, the negative signed input retained its low 16 bits and cleared the upper half. This exercises unpacked inputs, one attribute per VGPR. Packed pairs and title rendering remain unmeasured.

**@⁠MichaelSmithAI** on GitHub · 2026-11-24 18:53 UTC · [original](https://github.com/Marvisak/VIctory/pull/1519#issuecomment-7141293145) The requested hardware check passed on `55bf86f` with an RTX 4090 under Wine/GE 3.2. The test input layout used actual `R16_FLOAT`, `R16_SINT`, and `R16_UINT` elements. The translated vertex shader converted each resulting VGPR word as an unsigned 32-bit integer to an exactly representable float, and a passthrough pixel shader exposed it for readback. Microsoft’s DXIL validator accepted the vertex shader. | Input values (float, signed, unsigned) | VGPR words read back at all four pixels | | --- | --- | | −0.875, −1234, 65244 | `0x0000bb00`, `0x0000fb2e`, `0x0000fedc` | | 1.5, 32767, 33059 | `0x00003e00`, `0x00007fff`, `0x00008123` | In particular, the negative signed input retained its low 16 bits and cleared the upper half. This exercises unpacked inputs, one attribute per VGPR. Packed pairs and title rendering remain unmeasured.
Author
Owner

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

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

Result: no count changes against main, and the tests pass on Ada.

Offline. I merged head 55bf86f 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 both, 0 gained, 0 lost. No program changes its failure reason either.

This is the expected result for a correctness fix whose instructions sit behind the earlier failures on main. The count shows that the change rejects nothing. It does not show whether the output is right.

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:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/1519#issuecomment-7142277075) ### Offline measurement on a retail dump, and the shader tests on Ada **Result: no count changes against `main`, and the tests pass on Ada.** **Offline.** I merged head 55bf86f 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 both, 0 gained, 0 lost. No program changes its failure reason either. This is the expected result for a correctness fix whose instructions sit behind the earlier failures on `main`. The count shows that the change rejects nothing. It does not show whether the output is right. **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

@⁠geiyiliyabumo on GitHub · 2026-11-24 19:34 UTC · original

Verified commit 55bf86f on Windows 11 / AMD Radeon RX 9060 XT (RDNA4, gfx1200, SM 6.6) + WARP:

  • cargo test -p victory-shader --lib: 121 passed, 0 failed, 1 ignored (all 16-bit vertex input unpacking and GPU tests pass).

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

**@⁠geiyiliyabumo** on GitHub · 2026-11-24 19:34 UTC · [original](https://github.com/Marvisak/VIctory/pull/1519#issuecomment-7142293290) Verified commit `55bf86f` on **Windows 11 / AMD Radeon RX 9060 XT (RDNA4, `gfx1200`, SM 6.6)** + **WARP**: - `cargo test -p victory-shader --lib`: **121 passed, 0 failed, 1 ignored** (all 16-bit vertex input unpacking and GPU tests pass). *AI-assisted; synthetic tests only, no game files.*
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 03:29 UTC · original · edited 2026-11-25 16:06 UTC

Automated triage for the maintainers.

This pull request no longer merges cleanly into main (conflicts in crates/victory-shader/src/emit/bitcode.rs). It will be reviewed once it is rebased onto the current main. The earlier verdict (merge-candidate) was for an older state of main.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 03:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/1519#issuecomment-7151960711) · edited 2026-11-25 16:06 UTC <!-- victory-triage v1 head=1f658a6bba897de0e65cc973c1b3c5215824d8eb verdict=needs-rebase at=2026-11-25T16:03:40Z --> Automated triage for the maintainers. This pull request no longer merges cleanly into `main` (conflicts in `crates/victory-shader/src/emit/bitcode.rs`). It will be reviewed once it is rebased onto the current `main`. The earlier verdict (merge-candidate) was for an older state of `main`. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠Bloh09 on GitHub · 2026-11-25 03:43 UTC · original

Test now asserts the unpacked low-half values for float16 and int; victory-shader tests and policy pass on 2d3537f.

**@⁠Bloh09** on GitHub · 2026-11-25 03:43 UTC · [original](https://github.com/Marvisak/VIctory/pull/1519#issuecomment-7152179479) Test now asserts the unpacked low-half values for float16 and int; victory-shader tests and policy pass on 2d3537f.
Author
Owner

@⁠Bloh09 on GitHub · 2026-11-25 04:05 UTC · original

Rebased on 940d32f and set view_marks in the test's Parts; victory-shader tests (145 pass), clippy and policy clean.

**@⁠Bloh09** on GitHub · 2026-11-25 04:05 UTC · [original](https://github.com/Marvisak/VIctory/pull/1519#issuecomment-7152520303) Rebased on 940d32f and set view_marks in the test's Parts; victory-shader tests (145 pass), clippy and policy clean.
Author
Owner

@⁠StExpeditus on GitHub · 2026-11-25 09:21 UTC · original

Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200, driver 621.24. Branch at 1f658a6. cargo test --workspace --locked --no-fail-fast -> 697 passed, 5 failed, 10 ignored. The failures are the same 5 pre-existing NVIDIA 1M-view-heap-cap failures (also on main; see my reports on #2030 and #1940). Nothing introduced by this PR fails on this machine.

**@⁠StExpeditus** on GitHub · 2026-11-25 09:21 UTC · [original](https://github.com/Marvisak/VIctory/pull/1519#issuecomment-7158212599) **Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200, driver 621.24.** Branch at `1f658a6`. `cargo test --workspace --locked --no-fail-fast` -> 697 passed, 5 failed, 10 ignored. The failures are the same 5 pre-existing NVIDIA 1M-view-heap-cap failures (also on main; see my reports on #2030 and #1940). Nothing introduced by this PR fails on this machine.
This pull request has changes conflicting with the target branch.
  • crates/victory-shader/src/emit/bitcode.rs
  • crates/victory-shader/src/emit/lower.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1519/head:github-bot/gh-1519'
git switch 'github-bot/gh-1519'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1519'
git switch 'github-bot/gh-1519'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1519'
git switch 'github-bot/gh-1519'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1519'
git switch 'main'
git merge --squash 'github-bot/gh-1519'
git switch 'main'
git merge --ff-only 'github-bot/gh-1519'
git switch 'main'
git merge 'github-bot/gh-1519'
git push origin 'main'
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!1519
No description provided.