Shaders: buffer byte and half stores of a VGPR's high half (_d16_hi) #2333

Open
github-bot wants to merge 1 commit from github-bot/gh-2333 into main AGit
Owner

@⁠TinkerBell-90 on GitHub · 2026-11-25 10:50 UTC · original
TinkerBell-90:shaders-buffer-store-d16-hi → main · +81 −3 · 2 files · 1 commits · open

buffer_store_byte_d16_hi and buffer_store_short_d16_hi were refused by name, so a program using one did not translate. They now store bits 16-23 or 16-31 of their VGPR, through the same two atomics on the dword as buffer_store_byte and buffer_store_short (and the same limits: no store by index, the field does not cross a dword).

Claimed in #1633: #1633

Test: stride_tests::high_half_buffer_stores_take_the_vgprs_high_half. 32 lanes store a half and a byte from the high half of a VGPR whose low half is junk, two or four lanes per dword.

Run here: Linux, tests built for x86_64-pc-windows-gnu and run under Wine + vkd3d-proton on an RTX 3070. There is no WARP in this setup, so both loops of the test run on the card.

  • The new test passes. It fails without the change (Unsupported { what: "buffer_store_short_d16_hi" }) and when the field is taken from bit 0 (the junk lands).
  • victory-shader on GPU: 243 passed, 5 failed, 3 ignored. Main 940d32f on the same host: 242 passed and the same 5 failures (the three hardware conversion and fusing checks, a_heap_buffer_read_where_no_buffer_view_is_reads_zeros, stub_pipeline_is_created).
  • cargo test -p victory-shader --lib on Linux: 144 passed. Clippy for windows-msvc with -D warnings: clean. rustfmt: no new differences. cargo xtask policy: ok.

Not tested with the game. #2003 adds the _d16 loads and #2208 changes how the plain byte and half stores write; this touches the same lines of buffer() but not the same cases.

AI-assisted.

**@⁠TinkerBell-90** on GitHub · 2026-11-25 10:50 UTC · [original](https://github.com/Marvisak/VIctory/pull/2333) `TinkerBell-90:shaders-buffer-store-d16-hi` → `main` · +81 −3 · 2 files · 1 commits · open `buffer_store_byte_d16_hi` and `buffer_store_short_d16_hi` were refused by name, so a program using one did not translate. They now store bits 16-23 or 16-31 of their VGPR, through the same two atomics on the dword as `buffer_store_byte` and `buffer_store_short` (and the same limits: no store by index, the field does not cross a dword). Claimed in #1633: https://git.gtahub.st/github/Marvisak--VIctory/issues/1633 **Test**: `stride_tests::high_half_buffer_stores_take_the_vgprs_high_half`. 32 lanes store a half and a byte from the high half of a VGPR whose low half is junk, two or four lanes per dword. **Run here**: Linux, tests built for `x86_64-pc-windows-gnu` and run under Wine + vkd3d-proton on an RTX 3070. There is no WARP in this setup, so both loops of the test run on the card. - The new test passes. It fails without the change (`Unsupported { what: "buffer_store_short_d16_hi" }`) and when the field is taken from bit 0 (the junk lands). - victory-shader on GPU: 243 passed, 5 failed, 3 ignored. Main `940d32f` on the same host: 242 passed and the same 5 failures (the three hardware conversion and fusing checks, `a_heap_buffer_read_where_no_buffer_view_is_reads_zeros`, `stub_pipeline_is_created`). - `cargo test -p victory-shader --lib` on Linux: 144 passed. Clippy for windows-msvc with `-D warnings`: clean. rustfmt: no new differences. `cargo xtask policy`: ok. Not tested with the game. #2003 adds the `_d16` loads and #2208 changes how the plain byte and half stores write; this touches the same lines of `buffer()` but not the same cases. AI-assisted.
buffer_store_byte_d16_hi and buffer_store_short_d16_hi were refused by
name, so a program using one did not translate. They store bits 16-23 or
16-31 of their VGPR through the same two atomics on the dword as
buffer_store_byte and buffer_store_short.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:02:35 +00:00
Author
Owner

@⁠steven-seagull27 on GitHub · 2026-11-25 11:06 UTC · original

Confirmed on native Windows D3D12 at 6d0f5f9 with an RTX 5080 and built-in Microsoft WARP, in separate processes. Both adapters passed the PR's packed test: all 32 halfwords and 32 bytes matched, and all eight trailing dwords stayed zero.

I also split the two instructions and prefilled the UAV with 0xab897654 to check the neighboring fields. On each adapter, the high-half byte store matched 128/128 dwords across byte positions 0–3, and the high-half short store matched 64/64 dwords across byte positions 0 and 2. For example, lane 5 stored 0x45 at byte position 1 and read back 0xab894554, preserving all three neighboring bytes.

On the exact parent 940d32f, the isolated cases each stopped during lowering with the corresponding unsupported opcode, before dispatch. The ordinary byte and short store controls returned 64/64 correct dwords per adapter on both revisions. These were synthetic 32-thread compute dispatches. Both device identities were checked, including the loaded system WARP DLL.

**@⁠steven-seagull27** on GitHub · 2026-11-25 11:06 UTC · [original](https://github.com/Marvisak/VIctory/pull/2333#issuecomment-7160588027) Confirmed on native Windows D3D12 at `6d0f5f9` with an **RTX 5080 and built-in Microsoft WARP**, in separate processes. Both adapters passed the PR's packed test: all 32 halfwords and 32 bytes matched, and all eight trailing dwords stayed zero. I also split the two instructions and prefilled the UAV with `0xab897654` to check the neighboring fields. On each adapter, the high-half byte store matched **128/128 dwords** across byte positions 0–3, and the high-half short store matched **64/64 dwords** across byte positions 0 and 2. For example, lane 5 stored `0x45` at byte position 1 and read back `0xab894554`, preserving all three neighboring bytes. On the exact parent `940d32f`, the isolated cases each stopped during lowering with the corresponding unsupported opcode, before dispatch. The ordinary byte and short store controls returned **64/64 correct dwords per adapter** on both revisions. These were synthetic 32-thread compute dispatches. Both device identities were checked, including the loaded system WARP DLL.
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 15:23 UTC · original

Automated triage for the maintainers.

Merge candidate (worth a look). This adds buffer_store_byte_d16_hi and buffer_store_short_d16_hi to Lower::buffer in lower.rs, through the existing byte/half store path (two atomics on the dword) with the data shifted right by 16 first. That matches the RDNA2 ISA, where these opcodes store bits 23:16 and 31:16 of the VGPR. I decoded the test's MUBUF words by hand (opcodes 0x1B and 0x19, matching gfx10/opcodes.rs; vaddr, vdata, srsrc and offset fields right) and the expected buffer contents match. Another contributor reports the test passing on native RTX and on WARP with neighbouring bytes preserved. It touches the same lines as #2003 and #2208, but not the same cases. CI: passing.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 15:23 UTC · [original](https://github.com/Marvisak/VIctory/pull/2333#issuecomment-7166760635) <!-- victory-triage v1 head=6d0f5f92fd8d6a0d9a70c7c66c9f9249e18427c1 verdict=merge-candidate at=2026-11-25T15:31:00Z --> Automated triage for the maintainers. **Merge candidate (worth a look).** This adds `buffer_store_byte_d16_hi` and `buffer_store_short_d16_hi` to `Lower::buffer` in `lower.rs`, through the existing byte/half store path (two atomics on the dword) with the data shifted right by 16 first. That matches the RDNA2 ISA, where these opcodes store bits 23:16 and 31:16 of the VGPR. I decoded the test's MUBUF words by hand (opcodes 0x1B and 0x19, matching `gfx10/opcodes.rs`; vaddr, vdata, srsrc and offset fields right) and the expected buffer contents match. Another contributor reports the test passing on native RTX and on WARP with neighbouring bytes preserved. It touches the same lines as #2003 and #2208, but not the same cases. CI: passing. --- _Generated by [Claude Code](https://claude.ai/code)_
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

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