Shaders: lower native 16-bit buffer stores #426

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

@⁠ToxicmaggotRP on GitHub · 2026-11-24 03:15 UTC · original
ToxicmaggotRP:shader/buffer-store-short-dxil → main · +151 −6 · 3 files · 5 commits · closed without merging

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)

**@⁠ToxicmaggotRP** on GitHub · 2026-11-24 03:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/426) `ToxicmaggotRP:shader/buffer-store-short-dxil` → `main` · +151 −6 · 3 files · 5 commits · closed without merging 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)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:03:27 +00:00
github-bot closed this pull request 2026-11-26 04:03:28 +00:00
Author
Owner

@⁠DaviTostes on GitHub · 2026-11-24 03:36 UTC · original

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** on GitHub · 2026-11-24 03:36 UTC · [original](https://github.com/Marvisak/VIctory/pull/426#issuecomment-7121258016) 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).
Author
Owner

@⁠DaviTostes on GitHub · 2026-11-24 03:50 UTC · original

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.

**@⁠DaviTostes** on GitHub · 2026-11-24 03:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/426#issuecomment-7121477915) 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`.
Author
Owner

@⁠slint6614-dev on GitHub · 2026-11-24 10:16 UTC · original

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.

**@⁠slint6614-dev** on GitHub · 2026-11-24 10:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/426#issuecomment-7128563487) 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.

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