Shaders: lower native 16-bit buffer stores #426

Closed
ToxicmaggotRP wants to merge 5 commits from upstream-pr/426 into main
ToxicmaggotRP commented 2026-11-24 03:15:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by ToxicmaggotRP on 2026-11-24T03:15:08Z.


Refs #274.

GFX10 exposes buffer_store_short and buffer_store_short_d16_hi. The opcode table already decodes them, but the buffer lowering rejected both because it only handled dword and typed-format stores.

  • Lower both short stores to DXIL rawBufferStore.i16, preserving the 2-byte write width.
  • Select the low or high half of the source VGPR as required by the opcode.
  • Set the DXIL native-low-precision shader flag and corresponding SFI0 feature bit.
  • Add synthetic shader tests for both forms, including a nonzero byte offset.

Validation status

  • cargo test -p victory-shader: not run; Rust toolchain unavailable in this environment.
  • DXIL validator and D3D12/WARP execution: tests added, not run here.
  • GTA VI / XboxBvhBuilder runtime: not tested.
  • No game assets used.

AI ASSISTED (CHATGPT)

<!-- greyfinch-sync:Marvisak/VIctory:issue:6573804354 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/426). Originally posted by [ToxicmaggotRP](https://github.com/ToxicmaggotRP) on 2026-11-24T03:15:08Z. --- Refs #274. GFX10 exposes `buffer_store_short` and `buffer_store_short_d16_hi`. The opcode table already decodes them, but the buffer lowering rejected both because it only handled dword and typed-format stores. - Lower both short stores to DXIL `rawBufferStore.i16`, preserving the 2-byte write width. - Select the low or high half of the source VGPR as required by the opcode. - Set the DXIL native-low-precision shader flag and corresponding SFI0 feature bit. - Add synthetic shader tests for both forms, including a nonzero byte offset. **Validation status** - `cargo test -p victory-shader`: not run; Rust toolchain unavailable in this environment. - DXIL validator and D3D12/WARP execution: tests added, not run here. - GTA VI / XboxBvhBuilder runtime: not tested. - No game assets used. AI ASSISTED (CHATGPT)
DaviTostes commented 2026-11-24 06:55:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DaviTostes on 2026-11-24T03:36:40Z.


Verified 4793ed5 on Arch Linux x86_64 (rustc 1.98.1, cargo test -p victory-shader): 56 passed, 0 failed, 0 ignored.

Not covered: Windows/Wine execution of the new store paths (shader tests here are parser/emit only) and title behaviour (no game data on this machine).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7121258016 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/426#issuecomment-7121258016). Originally posted by [DaviTostes](https://github.com/DaviTostes) on 2026-11-24T03:36:40Z. --- Verified `4793ed5` on **Arch Linux x86_64** (rustc 1.98.1, `cargo test -p victory-shader`): **56 passed, 0 failed, 0 ignored**. Not covered: Windows/Wine execution of the new store paths (shader tests here are parser/emit only) and title behaviour (no game data on this machine).
DaviTostes commented 2026-11-24 06:55:33 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DaviTostes on 2026-11-24T03:50:54Z.


Re-checked the new head e421755 (“test(shader): verify short stores preserve adjacent halfwords”) on Arch Linux x86_64 (rustc 1.98.1): cargo test -p victory-shader 56 passed, 0 failed, 0 ignored — same as 4793ed5.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7121477915 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/426#issuecomment-7121477915). Originally posted by [DaviTostes](https://github.com/DaviTostes) on 2026-11-24T03:50:54Z. --- Re-checked the new head `e421755` (“test(shader): verify short stores preserve adjacent halfwords”) on **Arch Linux x86_64** (rustc 1.98.1): `cargo test -p victory-shader` **56 passed, 0 failed, 0 ignored** — same as `4793ed5`.
slint6614-dev commented 2026-11-24 11:04:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by slint6614-dev on 2026-11-24T10:16:55Z.


AMD hardware check, Windows 11, Adrenalin driver: RX 9070 (RDNA4) and Ryzen 9600X iGPU (RDNA2, gfx1036), each picked as the hardware device of run_cases (local adapter-selection patch, not part of this PR); cargo test -p victory-shader --release valu_tests at the PR head. Negative control: the PR's non-test files reverted to its merge base, its new tests kept.

Both new tests fail on both AMD GPUs at the PR head, and the failure does not come from the hardware. The emitted module is rejected by the validator before it reaches the GPU:

buffer_store_short_preserves_the_adjacent_high_halfword
buffer_store_short_d16_hi_preserves_the_adjacent_low_halfword
DXIL validation failed: "error: Flags must match usage.
note: Flags declared=1073741824, actual=1073741856"

The module uses a feature whose shader flag (0x20 here) is not declared. The same failure happens with dxil.dll from Windows SDK 10.0.26100. Where no dxil.dll is found the check is skipped, which may be why it passed elsewhere.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7128563487 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/426#issuecomment-7128563487). Originally posted by [slint6614-dev](https://github.com/slint6614-dev) on 2026-11-24T10:16:55Z. --- AMD hardware check, Windows 11, Adrenalin driver: RX 9070 (RDNA4) and Ryzen 9600X iGPU (RDNA2, gfx1036), each picked as the hardware device of `run_cases` (local adapter-selection patch, not part of this PR); `cargo test -p victory-shader --release valu_tests` at the PR head. Negative control: the PR's non-test files reverted to its merge base, its new tests kept. Both new tests **fail on both AMD GPUs at the PR head**, and the failure does not come from the hardware. The emitted module is rejected by the validator before it reaches the GPU: ``` buffer_store_short_preserves_the_adjacent_high_halfword buffer_store_short_d16_hi_preserves_the_adjacent_low_halfword DXIL validation failed: "error: Flags must match usage. note: Flags declared=1073741824, actual=1073741856" ``` The module uses a feature whose shader flag (0x20 here) is not declared. The same failure happens with `dxil.dll` from Windows SDK 10.0.26100. Where no `dxil.dll` is found the check is skipped, which may be why it passed elsewhere.
catminou4 commented 2026-11-24 14:03:57 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Test-merge with current main (ffe310e) conflicts — needs a rebase. Main moved recently (PR #566 waterfall loops touched lower.rs/resource.rs/valu_tests.rs), so shader PRs opened before it need rebasing. I'll re-review once it merges cleanly.

<!-- greyfinch-sync:Marvisak/VIctory:review:6039897429 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/426#pullrequestreview-6039897429). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T13:19:31Z. **Review:** COMMENTED --- Test-merge with current main (`ffe310e`) **conflicts** — needs a rebase. Main moved recently (PR #566 waterfall loops touched `lower.rs`/`resource.rs`/`valu_tests.rs`), so shader PRs opened before it need rebasing. I'll re-review once it merges cleanly.
upstream-sync closed this pull request 2026-11-24 23:04:09 +00:00

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