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

Closed
Bloh09 wants to merge 1 commit from upstream-pr/1519 into main
Bloh09 commented 2026-11-24 18:42:43 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Bloh09 on 2026-11-24T18:42:43Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5478205233 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1519). Originally posted by [Bloh09](https://github.com/Bloh09) on 2026-11-24T18:42:43Z. --- 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.
DenRakEiw commented 2026-11-24 18:57:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-24T18:57:08Z.

Review: APPROVED


Verified locally merged onto origin/main (Windows 11 x64, Rust 1.98.1 MSVC):

  • cargo test -p victory-shader --lib a_16_bit_vertex_input_is_unpacked_to_the_low_half — passed
  • cargo clippy -p victory-shader --all-targets — 0 warnings
  • cargo xtask policy — ok

Clean low-half unpacking of 16-bit vertex inputs (legacyF32ToF16 for float16 and 0xFFFF mask for integer formats) with targeted unit test coverage. Looks good.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6045440638 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1519#pullrequestreview-6045440638). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-24T18:57:08Z. **Review:** APPROVED --- Verified locally merged onto `origin/main` (Windows 11 x64, Rust 1.98.1 MSVC): - `cargo test -p victory-shader --lib a_16_bit_vertex_input_is_unpacked_to_the_low_half` — passed - `cargo clippy -p victory-shader --all-targets` — 0 warnings - `cargo xtask policy` — ok Clean low-half unpacking of 16-bit vertex inputs (`legacyF32ToF16` for float16 and `0xFFFF` mask for integer formats) with targeted unit test coverage. Looks good. AI-assisted (Gemini 4 Neon).
MichaelSmithAI commented 2026-11-24 19:04:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by MichaelSmithAI on 2026-11-24T18:53:20Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7141293145 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1519#issuecomment-7141293145). Originally posted by [MichaelSmithAI](https://github.com/MichaelSmithAI) on 2026-11-24T18:53:20Z. --- 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.
sinan-cmyk commented 2026-11-24 20:03:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by sinan-cmyk on 2026-11-24T19:33:51Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7142277075 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1519#issuecomment-7142277075). Originally posted by [sinan-cmyk](https://github.com/sinan-cmyk) on 2026-11-24T19:33:51Z. --- ### 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).
geiyiliyabumo commented 2026-11-24 20:03:13 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by geiyiliyabumo on 2026-11-24T19:34:32Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7142293290 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1519#issuecomment-7142293290). Originally posted by [geiyiliyabumo](https://github.com/geiyiliyabumo) on 2026-11-24T19:34:32Z. --- 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.*
catminou4 commented 2026-11-25 03:48:09 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T03:48:09Z.

Review: CHANGES_REQUESTED


Merge with current main (940d32f69b) breaks compilation — verified locally after git merge origin/main:

error[E0063]: missing field `view_marks` in initializer of `Parts<'_>`
error: could not compile `victory-shader` (lib test) due to 1 previous error

Main added the view_marks field to Parts after this PR was opened; a rebase that initializes the new field should fix it. Unpack 16-bit vertex inputs into the low half looks like the right direction — I will re-test after the rebase.

<!-- greyfinch-sync:Marvisak/VIctory:review:6051578119 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1519#pullrequestreview-6051578119). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T03:48:09Z. **Review:** CHANGES_REQUESTED --- Merge with current main (940d32f69b) breaks compilation — verified locally after `git merge origin/main`: ``` error[E0063]: missing field `view_marks` in initializer of `Parts<'_>` error: could not compile `victory-shader` (lib test) due to 1 previous error ``` Main added the `view_marks` field to `Parts` after this PR was opened; a rebase that initializes the new field should fix it. Unpack 16-bit vertex inputs into the low half looks like the right direction — I will re-test after the rebase.
Marvisak commented 2026-11-25 04:06:54 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T03:29:17Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7151960711 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1519#issuecomment-7151960711). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T03:29:17Z. --- <!-- 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)_
Bloh09 commented 2026-11-25 04:07:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Bloh09 on 2026-11-25T03:43:15Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7152179479 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1519#issuecomment-7152179479). Originally posted by [Bloh09](https://github.com/Bloh09) on 2026-11-25T03:43:15Z. --- Test now asserts the unpacked low-half values for float16 and int; victory-shader tests and policy pass on 2d3537f.
Bloh09 commented 2026-11-25 04:07:14 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Bloh09 on 2026-11-25T04:05:30Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7152520303 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1519#issuecomment-7152520303). Originally posted by [Bloh09](https://github.com/Bloh09) on 2026-11-25T04:05:30Z. --- Rebased on 940d32f and set view_marks in the test's Parts; victory-shader tests (145 pass), clippy and policy clean.
StExpeditus commented 2026-11-25 10:07:40 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by StExpeditus on 2026-11-25T09:21:04Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7158212599 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1519#issuecomment-7158212599). Originally posted by [StExpeditus](https://github.com/StExpeditus) on 2026-11-25T09:21:04Z. --- **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.
andrewpozdnakov7-jpg commented 2026-11-27 12:15:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-27T12:15:26Z.


The current-main branch at dd9c239 merges exact PR head 1f658a6 with 63bcca4 and preserves both original commits. It resolves the conflicts in bitcode.rs and lower.rs. The test inspects the instructions selected by the current writer, retains view_marks: false, and lives in a separate test module to leave room below the file-size limit.

With the same fixture on 63bcca4, lowering stops at a 16-bit input is not supported. The branch passed the fixture for FP16, signed and unsigned 16-bit inputs. dxil.dll validated all three vertex shaders. The forced-WARP shader suite was 299 passed / 4 failed / 3 ignored, compared with 297 / 6 / 3 on main with the fixture. All four failures also appear on main. Strict shader Clippy and the asset policy passed.

@catminou4, this is the branch you can use to recheck the earlier build issue. @Bloh09, it can be fast-forwarded from 1f658a6. If you fold in the merge-resolution changes, please retain Git attribution or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.

AI-assisted with Codex. Synthetic tests only.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7218024205 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1519#issuecomment-7218024205). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-27T12:15:26Z. --- The [current-main branch](https://github.com/andrewpozdnakov7-jpg/VIctory/tree/review/pr1519-current-main) at `dd9c239` merges exact PR head `1f658a6` with `63bcca4` and preserves both original commits. It resolves the conflicts in `bitcode.rs` and `lower.rs`. The test inspects the instructions selected by the current writer, retains `view_marks: false`, and lives in a separate test module to leave room below the file-size limit. With the same fixture on `63bcca4`, lowering stops at `a 16-bit input is not supported`. The branch passed the fixture for FP16, signed and unsigned 16-bit inputs. `dxil.dll` validated all three vertex shaders. The forced-WARP shader suite was 299 passed / 4 failed / 3 ignored, compared with 297 / 6 / 3 on main with the fixture. All four failures also appear on main. Strict shader Clippy and the asset policy passed. @catminou4, this is the branch you can use to recheck the earlier build issue. @Bloh09, it can be fast-forwarded from `1f658a6`. If you fold in the merge-resolution changes, please retain Git attribution or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`. AI-assisted with Codex. Synthetic tests only.
Bloh09 commented 2026-11-28 16:03:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Bloh09 on 2026-11-28T16:03:21Z.


Rebased on 63bcca4 (head 1bb2d44), conflicts were the new test fields and tests in lower.rs/bitcode.rs. victory-shader lib tests (173 pass), clippy and policy clean on Linux.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7241939318 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1519#issuecomment-7241939318). Originally posted by [Bloh09](https://github.com/Bloh09) on 2026-11-28T16:03:21Z. --- Rebased on 63bcca4 (head 1bb2d44), conflicts were the new test fields and tests in lower.rs/bitcode.rs. victory-shader lib tests (173 pass), clippy and policy clean on Linux.
andrewpozdnakov7-jpg commented 2026-11-28 16:14:45 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-28T16:14:45Z.


I checked the rebased head 1bb2d44 on Windows with app-local WARP 1.0.22 and Agility SDK 1.620.2. With a generated full-screen triangle, main 63bcca4 stops at “a 16-bit input is not supported.” The rebased head produces a DXIL vertex shader that passes the validator and creates a pipeline with actual R16_FLOAT, R16_SINT and R16_UINT inputs.

The three attributes were converted to exactly representable float values after unpacking, passed through the pixel shader and read back. All four pixels in each row matched these full VGPR words:

Input set Float word Signed word Unsigned word
−0.875, −1234, 65244 0000bb00 0000fb2e 0000fedc
1.5, 32767, 33059 00003e00 00007fff 00008123
−0.0, −32768, 65535 00008000 00008000 0000ffff

The rebased unit test and all 34 lowerer tests pass. Strict shader Clippy, the asset policy and Windows CI on this head are green. This covers the unpacked vertex-input path on WARP. MichaelSmithAI's earlier RTX 4090 result is on 55bf86f.

The head is current and mergeable. The next step is for the maintainer to revisit the review after the rebase.

AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7242087274 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1519#issuecomment-7242087274). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-28T16:14:45Z. --- I checked the rebased head 1bb2d44 on Windows with app-local WARP 1.0.22 and Agility SDK 1.620.2. With a generated full-screen triangle, main 63bcca4 stops at “a 16-bit input is not supported.” The rebased head produces a DXIL vertex shader that passes the validator and creates a pipeline with actual R16_FLOAT, R16_SINT and R16_UINT inputs. The three attributes were converted to exactly representable float values after unpacking, passed through the pixel shader and read back. All four pixels in each row matched these full VGPR words: | Input set | Float word | Signed word | Unsigned word | | --- | --- | --- | --- | | −0.875, −1234, 65244 | 0000bb00 | 0000fb2e | 0000fedc | | 1.5, 32767, 33059 | 00003e00 | 00007fff | 00008123 | | −0.0, −32768, 65535 | 00008000 | 00008000 | 0000ffff | The rebased unit test and all 34 lowerer tests pass. Strict shader Clippy, the asset policy and [Windows CI on this head](https://github.com/Marvisak/VIctory/actions/runs/46163064274/job/141034488955) are green. This covers the unpacked vertex-input path on WARP. MichaelSmithAI's earlier RTX 4090 result is on 55bf86f. The head is current and mergeable. The next step is for the maintainer to revisit the review after the rebase. AI-assisted with OpenAI Codex.
Bloh09 commented 2026-11-28 22:26:27 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Bloh09 on 2026-11-28T22:26:27Z.


Closing, moving my work elsewhere.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7246737055 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1519#issuecomment-7246737055). Originally posted by [Bloh09](https://github.com/Bloh09) on 2026-11-28T22:26:27Z. --- Closing, moving my work elsewhere.

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!1518
No description provided.