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

Open
TinkerBell-90 wants to merge 1 commit from upstream-pr/2333 into main
TinkerBell-90 commented 2026-11-25 10:50:36 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by TinkerBell-90 on 2026-11-25T10:50:36Z.


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://github.com/Marvisak/VIctory/issues/1633#issuecomment-7160082364

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.

<!-- greyfinch-sync:Marvisak/VIctory:issue:6602779717 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2333). Originally posted by [TinkerBell-90](https://github.com/TinkerBell-90) on 2026-11-25T10:50:36Z. --- `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://github.com/Marvisak/VIctory/issues/1633#issuecomment-7160082364 **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.
catminou4 commented 2026-11-25 11:05:00 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-25T11:03:06Z.

Review: APPROVED


Tested locally: merged into main 940d32f69b, cargo test -p victory-shader --locked on macOS arm64 — 144 passed, 0 failed, 2 ignored (Windows-gated hardware tests not run here). Approving — buffer byte/half stores of a VGPR's high half (_d).

<!-- greyfinch-sync:Marvisak/VIctory:review:6056392381 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2333#pullrequestreview-6056392381). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-25T11:03:06Z. **Review:** APPROVED --- Tested locally: merged into main 940d32f69b, `cargo test -p victory-shader --locked` on macOS arm64 — 144 passed, 0 failed, 2 ignored (Windows-gated hardware tests not run here). Approving — buffer byte/half stores of a VGPR's high half (_d).
DenRakEiw commented 2026-11-25 12:03:20 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DenRakEiw on 2026-11-25T11:31:42Z.

Review: APPROVED


Verified against origin/main (940d32f) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP:

  • Clean handling of _d16_hi byte/half buffer stores reading the VGPR's high 16 bits.
  • cargo test -p victory-shader half_buffer_stores: 2/2 passed on RTX 5090, 2/2 passed on WARP (including high_half_buffer_stores_take_the_vgprs_high_half).
  • cargo clippy -p victory-shader --all-targets -- -D warnings: 0 warnings.
  • cargo xtask policy: 183 files ok.

AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6056827034 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2333#pullrequestreview-6056827034). Originally posted by [DenRakEiw](https://github.com/DenRakEiw) on 2026-11-25T11:31:42Z. **Review:** APPROVED --- Verified against `origin/main` (`940d32f`) on Windows 11 + NVIDIA GeForce RTX 5090 and WARP: - Clean handling of `_d16_hi` byte/half buffer stores reading the VGPR's high 16 bits. - `cargo test -p victory-shader half_buffer_stores`: 2/2 passed on RTX 5090, 2/2 passed on WARP (including `high_half_buffer_stores_take_the_vgprs_high_half`). - `cargo clippy -p victory-shader --all-targets -- -D warnings`: 0 warnings. - `cargo xtask policy`: 183 files ok. AI-assisted (Gemini 4 Neon).
steven-seagull27 commented 2026-11-25 12:03:37 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by steven-seagull27 on 2026-11-25T11:06:07Z.


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.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7160588027 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2333#issuecomment-7160588027). Originally posted by [steven-seagull27](https://github.com/steven-seagull27) on 2026-11-25T11:06:07Z. --- 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.
Marvisak commented 2026-11-25 16:09:10 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T15:23:11Z.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7166760635 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2333#issuecomment-7166760635). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T15:23:11Z. --- <!-- 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)_
fuzeofficlal commented 2026-11-26 03:03:56 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T02:20:43Z.

Review: COMMENTED


Reviewed and verified against main (63bcca43) on Windows 11 (RTX 5090 + WARP + dxil.dll, VICTORY_D3D12_DEBUG=1) — clean and ready to merge:

  • Shifting VGPR source right by 16 (Bin::LShr) before the existing byte/short store path for buffer_store_byte_d16_hi (0x019) and buffer_store_short_d16_hi (0x01b) mirrors ds_write_b{8,16}_d16_hi and keeps emit/lower.rs at 520,901 B (3,387 B under the 512 KiB cap).

Local verification:

  • emit::stride_tests::high_half_buffer_stores_take_the_vgprs_high_half: passed on both RTX 5090 and WARP (dxil.dll + DEBUG=1)
  • emit::tests 17/17, emit::semantics_tests 34/34
  • cargo clippy --all-targets -p victory-shader -- -D warnings + cargo xtask policy (191 files ok): 0 warnings
<!-- greyfinch-sync:Marvisak/VIctory:review:6067705238 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2333#pullrequestreview-6067705238). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T02:20:43Z. **Review:** COMMENTED --- Reviewed and verified against `main` (`63bcca43`) on Windows 11 (RTX 5090 + WARP + `dxil.dll`, `VICTORY_D3D12_DEBUG=1`) — clean and ready to merge: - Shifting VGPR source right by 16 (`Bin::LShr`) before the existing byte/short store path for `buffer_store_byte_d16_hi` (`0x019`) and `buffer_store_short_d16_hi` (`0x01b`) mirrors `ds_write_b{8,16}_d16_hi` and keeps `emit/lower.rs` at **520,901 B** (**3,387 B** under the 512 KiB cap). **Local verification**: - `emit::stride_tests::high_half_buffer_stores_take_the_vgprs_high_half`: passed on both **RTX 5090** and **WARP** (`dxil.dll` + `DEBUG=1`) - `emit::tests` **17/17**, `emit::semantics_tests` **34/34** - `cargo clippy --all-targets -p victory-shader -- -D warnings` + `cargo xtask policy` (`191 files ok`): 0 warnings
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2333:upstream-pr/2333'
git switch 'upstream-pr/2333'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2333'
git switch 'upstream-pr/2333'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2333'
git switch 'upstream-pr/2333'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2333'
git switch 'main'
git merge --squash 'upstream-pr/2333'
git switch 'main'
git merge --ff-only 'upstream-pr/2333'
git switch 'main'
git merge 'upstream-pr/2333'
git push origin 'main'
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!2331
No description provided.