shader: lower partial-channel typed and _d16_hi buffer stores #279

Closed
github-bot wants to merge 0 commits from github-bot/gh-279 into main AGit
Owner

@⁠Texbirds on GitHub · 2026-12-01 08:37 UTC · original
Texbirds:pr/typed-buffer-stores → main · +48 −5 · 3 files · 68 commits · closed without merging

Supersedes #238 (rebased onto rewritten main 297f58a, port of Marvisak/VIctory#3377 adapted to FoxHound's raw-view structured buffer lowering).

Summary

  • Lowers partial-channel typed buffer stores (buffer_store_format_{x,xy,xyz}, buffer_store_format_d16_{x,xy,xyz}, buffer_store_format_d16_hi_x) via guarded load-modify-store (bufferLoad + bufferStore with mask 0xF and TYPED_UAV_LOADS).
  • Branches on VIEW_INTEGER (self.integer_view(src)?) to use an integer handle (10 | u, 0x405) for integer views and float handle (10 | u, 0x409) for float views so untouched channels are preserved bit-exact (including NaN-shaped integer bit patterns).
  • Adds _d16_hi high-half extraction for buffer_store_byte_d16_hi, buffer_store_short_d16_hi, and buffer_store_format_d16_hi_x, and refuses non-zero soffset / base offsets on typed stores.
  • Leaves FoxHound's existing structured-to-raw folding, dword-straddling narrow path, and full-width (count == 4) typed buffer stores untouched so already-translated shaders remain unchanged.
  • No title shader names in code or comments.

Testing

  • cargo run --locked -p xtask -- policy (295 files ok)
  • cargo clippy --locked -p victory-shader --tests -- -D warnings (0 warnings)
  • cargo test --locked -p victory-shader -- buffer_store: 4/4 passed (DXIL validation + hardware RTX 3080 Ti & D3D12 WARP execution covering float/uint partial typed stores, d16_hi_x, and dword-straddling short_d16_hi)

Checklist from #238

  • Rebased cleanly onto current main (297f58a)
  • Translator census before/after (happy to leave on hold for the next translator batch; don't have a local title shader corpus here to run the full census)
  • In-game check of a pass using these stores
**@⁠Texbirds** on GitHub · 2026-12-01 08:37 UTC · [original](https://github.com/readmet3xt-lab/foxhound/pull/279) `Texbirds:pr/typed-buffer-stores` → `main` · +48 −5 · 3 files · 68 commits · closed without merging Supersedes #238 (rebased onto rewritten `main` `297f58a`, port of `Marvisak/VIctory#3377` adapted to FoxHound's raw-view structured buffer lowering). ### Summary - Lowers partial-channel typed buffer stores (`buffer_store_format_{x,xy,xyz}`, `buffer_store_format_d16_{x,xy,xyz}`, `buffer_store_format_d16_hi_x`) via guarded load-modify-store (`bufferLoad` + `bufferStore` with mask `0xF` and `TYPED_UAV_LOADS`). - Branches on `VIEW_INTEGER` (`self.integer_view(src)?`) to use an integer handle `(10 | u, 0x405)` for integer views and float handle `(10 | u, 0x409)` for float views so untouched channels are preserved bit-exact (including NaN-shaped integer bit patterns). - Adds `_d16_hi` high-half extraction for `buffer_store_byte_d16_hi`, `buffer_store_short_d16_hi`, and `buffer_store_format_d16_hi_x`, and refuses non-zero `soffset` / base offsets on typed stores. - Leaves FoxHound's existing structured-to-raw folding, dword-straddling `narrow` path, and full-width (`count == 4`) typed buffer stores untouched so already-translated shaders remain unchanged. - No title shader names in code or comments. ### Testing - `cargo run --locked -p xtask -- policy` (`295 files ok`) - `cargo clippy --locked -p victory-shader --tests -- -D warnings` (0 warnings) - `cargo test --locked -p victory-shader -- buffer_store`: **4/4 passed** (DXIL validation + hardware RTX 3080 Ti & D3D12 WARP execution covering float/uint partial typed stores, `d16_hi_x`, and dword-straddling `short_d16_hi`) ### Checklist from #238 - [x] Rebased cleanly onto current `main` (`297f58a`) - [ ] Translator census before/after (happy to leave on hold for the next translator batch; don't have a local title shader corpus here to run the full census) - [ ] In-game check of a pass using these stores
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 08:42:23 +00:00
github-bot force-pushed github-bot/gh-279 from 9d8c9941c1 to c5332bab4c 2026-12-01 08:47:34 +00:00 Compare
Author
Owner

@⁠Aniseto on GitHub · 2026-12-01 08:48 UTC · original

Ran the buffer_store tests at c5332ba on an NVIDIA Blackwell desktop part with 16 GB of VRAM.

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB, mesh shaders) driver 32.0.16.2140 (621.40), Intel Core i5-12400F, 64 GB RAM, rustc 1.98.1 (48a229cea 2026-09-01), MSVC 14.44.35207, debug build, detached worktree at the exact PR head, own CARGO_TARGET_DIR, no local patches.

cargo test -q --locked -p victory-shader -- buffer_store -- --test-threads=1
4 passed; 0 failed; 0 ignored; 295 filtered out      (exit 0)

All four buffer_store tests pass here, the same count the description reports on an RTX 3080 Ti and WARP. This is a second host for the translator's partial-channel and _d16_hi store cases; the description's hardware execution on its own card was not repeated with a title.

Not tested: the full workspace suite, clippy, a retail title, a visual check of partial typed stores in a scene, AMD adapters, Wine, release profile, game data.

AI-assisted (OpenCode), model: MiMo-V2.6-Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.

**@⁠Aniseto** on GitHub · 2026-12-01 08:48 UTC · [original](https://github.com/readmet3xt-lab/foxhound/pull/279#issuecomment-7305816984) Ran the `buffer_store` tests at `c5332ba` on an NVIDIA Blackwell desktop part with 16 GB of VRAM. Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB, mesh shaders) driver 32.0.16.2140 (621.40), Intel Core i5-12400F, 64 GB RAM, rustc 1.98.1 (48a229cea 2026-09-01), MSVC 14.44.35207, debug build, detached worktree at the exact PR head, own `CARGO_TARGET_DIR`, no local patches. ``` cargo test -q --locked -p victory-shader -- buffer_store -- --test-threads=1 4 passed; 0 failed; 0 ignored; 295 filtered out (exit 0) ``` All four `buffer_store` tests pass here, the same count the description reports on an RTX 3080 Ti and WARP. This is a second host for the translator's partial-channel and `_d16_hi` store cases; the description's hardware execution on its own card was not repeated with a title. Not tested: the full workspace suite, clippy, a retail title, a visual check of partial typed stores in a scene, AMD adapters, Wine, release profile, game data. AI-assisted (OpenCode), model: **MiMo-V2.6-Flash Free** - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
Author
Owner

@⁠bannnned on GitHub · 2026-12-01 10:45 UTC · original · reviewed

I found two issues in targeted tests at this head: an untouched channel changes on the new partial-store path, and an existing full-width store with a zero offset no longer translates.

**@⁠bannnned** on GitHub · 2026-12-01 10:45 UTC · [original](https://github.com/readmet3xt-lab/foxhound/pull/279#pullrequestreview-6129695392) · **reviewed** I found two issues in targeted tests at this head: an untouched channel changes on the new partial-store path, and an existing full-width store with a zero offset no longer translates.
@ -0,0 +85,4 @@
fargs.push(mask_all);
self.s.op(
self.cur,
"bufferStore.f32",
Author
Owner

@⁠bannnned on GitHub · 2026-12-01 10:45 UTC · original

[P2] Preserve the stored bits of channels outside the write mask

I ran the synthetic buffer_store_format_xy case on an RTX 5070 Ti with an R8G8B8A8_SNORM UAV. The word changed from 0x81800000 to 0x81813f7f. In addition to the intended X/Y update, the untouched Z byte changed from 0x80 to 0x81. Both bytes load as -1.0, and the typed store writes the canonical encoding. A later raw view can observe the byte change as a result of a store that only targets X/Y.

Could we use a format-aware raw update that writes only the intended bytes where supported? The SNORM endpoint would make a regression test for untouched channels. A full-element load/store can also write back stale neighbor values if another invocation updates a different channel between the two operations.

**@⁠bannnned** on GitHub · 2026-12-01 10:45 UTC · [original](https://github.com/readmet3xt-lab/foxhound/pull/279#discussion_r4752895720) **[P2] Preserve the stored bits of channels outside the write mask** I ran the synthetic `buffer_store_format_xy` case on an RTX 5070 Ti with an `R8G8B8A8_SNORM` UAV. The word changed from `0x81800000` to `0x81813f7f`. In addition to the intended X/Y update, the untouched Z byte changed from `0x80` to `0x81`. Both bytes load as `-1.0`, and the typed store writes the canonical encoding. A later raw view can observe the byte change as a result of a store that only targets X/Y. Could we use a format-aware raw update that writes only the intended bytes where supported? The SNORM endpoint would make a regression test for untouched channels. A full-element load/store can also write back stale neighbor values if another invocation updates a different channel between the two operations.
@ -12812,3 +12839,1 @@
// of a float format.
if count != 4 || *offen || *offset != 0 {
return Err("a typed buffer store of some channels or at an offset");
if *offen || *offset != 0 || has_base_off {
Author
Owner

@⁠bannnned on GitHub · 2026-12-01 10:45 UTC · original

[P2] Accept a provably zero scalar offset in existing full-width stores

I tested buffer_store_format_xyzw with inline zero and with s6 defined by s_mov_b32 s6, 0. The base 297f58a translates both forms. At c5332ba, the SGPR form is rejected with a typed buffer store at an offset. has_soffset sees the operand encoding even though the effective address is identical. A pipeline using the SGPR form could lose its draw or dispatch after this change.

Could we accept a scalar offset proven to be zero by the translator and add this case alongside typed_buffer_store_refuses_nonzero_soffset?

**@⁠bannnned** on GitHub · 2026-12-01 10:45 UTC · [original](https://github.com/readmet3xt-lab/foxhound/pull/279#discussion_r4752895734) **[P2] Accept a provably zero scalar offset in existing full-width stores** I tested `buffer_store_format_xyzw` with inline zero and with `s6` defined by `s_mov_b32 s6, 0`. The base `297f58a` translates both forms. At `c5332ba`, the SGPR form is rejected with `a typed buffer store at an offset`. `has_soffset` sees the operand encoding even though the effective address is identical. A pipeline using the SGPR form could lose its draw or dispatch after this change. Could we accept a scalar offset proven to be zero by the translator and add this case alongside `typed_buffer_store_refuses_nonzero_soffset`?
Author
Owner

@⁠readmet3xt-lab on GitHub · 2026-12-01 11:38 UTC · original

Checked: nothing harmful in it, it merges and passes the lint check. Because it changes a run at default settings (or code on the submission path), it is not merged to main directly: it is on the batch being tested for the next release, as one commit with you as its author. Nothing is needed from you now; the result of the run will be posted here.

**@⁠readmet3xt-lab** on GitHub · 2026-12-01 11:38 UTC · [original](https://github.com/readmet3xt-lab/foxhound/pull/279#issuecomment-7309923854) Checked: nothing harmful in it, it merges and passes the lint check. Because it changes a run at default settings (or code on the submission path), it is not merged to main directly: it is on the batch being tested for the next release, as one commit with you as its author. Nothing is needed from you now; the result of the run will be posted here.
Author
Owner

@⁠Texbirds on GitHub · 2026-12-01 12:01 UTC · original

Thanks @⁠readmet3xt-lab, @⁠Aniseto, and @⁠bannnned!

Pushed 62773bc addressing @⁠bannnned's review:

  1. Provably-zero SGPR soffset (P2): has_soffset now checks so != self.s.m.i32(0) after lowering the operand, so s_mov_b32 s6, 0 is accepted on both full-width and partial typed stores. Added typed_buffer_store_accepts_provably_zero_soffset alongside typed_buffer_store_refuses_nonzero_soffset (5/5 buffer_store tests pass with dxil.dll, RTX 3080 Ti, and WARP).
  2. Untouched channel SNORM bit preservation (P2): Good catch — DXIL requires mask 0xF on typed bufferStore, and the view's DXGI_FORMAT is only known at runtime (the host descriptor heap does not currently carry per-slot format IDs or aliased raw UAVs for typed views). Documented that limitation in buffer_store.rs; if a title observes raw-aliased 0x80 SNORM bytes or concurrent cross-channel writes, a follow-up with host-side format metadata + raw aliasing would be the right layer.
**@⁠Texbirds** on GitHub · 2026-12-01 12:01 UTC · [original](https://github.com/readmet3xt-lab/foxhound/pull/279#issuecomment-7310532236) Thanks @⁠readmet3xt-lab, @⁠Aniseto, and @⁠bannnned! Pushed `62773bc` addressing @⁠bannnned's review: 1. **Provably-zero SGPR `soffset` (P2):** `has_soffset` now checks `so != self.s.m.i32(0)` after lowering the operand, so `s_mov_b32 s6, 0` is accepted on both full-width and partial typed stores. Added `typed_buffer_store_accepts_provably_zero_soffset` alongside `typed_buffer_store_refuses_nonzero_soffset` (5/5 `buffer_store` tests pass with `dxil.dll`, RTX 3080 Ti, and WARP). 2. **Untouched channel SNORM bit preservation (P2):** Good catch — DXIL requires mask `0xF` on typed `bufferStore`, and the view's `DXGI_FORMAT` is only known at runtime (the host descriptor heap does not currently carry per-slot format IDs or aliased raw UAVs for typed views). Documented that limitation in `buffer_store.rs`; if a title observes raw-aliased `0x80` SNORM bytes or concurrent cross-channel writes, a follow-up with host-side format metadata + raw aliasing would be the right layer.
Author
Owner

@⁠Aniseto on GitHub · 2026-12-01 12:16 UTC · original

This is a new response on the same thread as my report at c5332ba (#279); the head moved to 62773bc (provably-zero SGPR soffset on typed stores), so I am not editing that comment.

Ran the buffer_store tests at 62773bc on an NVIDIA Blackwell desktop part with 16 GB of VRAM.

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB, mesh shaders) driver 32.0.16.2140 (621.40), Intel Core i5-12400F, 64 GB RAM, rustc 1.98.1 (48a229cea 2026-09-01), MSVC 14.44.35207, debug build, detached worktree at the exact PR head, own CARGO_TARGET_DIR, no local patches.

cargo test -q --locked -p victory-shader -- buffer_store -- --test-threads=1
5 passed; 0 failed; 0 ignored; 295 filtered out      (exit 0)

All five buffer_store tests pass at the new head, one more than the four at c5332ba; the added typed_buffer_store_accepts_provably_zero_soffset case is included. The description's RTX 3080 Ti and WARP execution was not repeated here, and no title was run.

Not tested: the full workspace suite, a retail title, WARP as a separate device, AMD adapters, Wine, release profile, game data.

AI-assisted (OpenCode), model: MiMo-V2.6-Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.

**@⁠Aniseto** on GitHub · 2026-12-01 12:16 UTC · [original](https://github.com/readmet3xt-lab/foxhound/pull/279#issuecomment-7310887771) This is a new response on the same thread as my report at `c5332ba` (https://git.gtahub.st/github/readmet3xt-lab--foxhound/pulls/279); the head moved to `62773bc` (provably-zero SGPR `soffset` on typed stores), so I am not editing that comment. Ran the `buffer_store` tests at `62773bc` on an NVIDIA Blackwell desktop part with 16 GB of VRAM. Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB, mesh shaders) driver 32.0.16.2140 (621.40), Intel Core i5-12400F, 64 GB RAM, rustc 1.98.1 (48a229cea 2026-09-01), MSVC 14.44.35207, debug build, detached worktree at the exact PR head, own `CARGO_TARGET_DIR`, no local patches. ``` cargo test -q --locked -p victory-shader -- buffer_store -- --test-threads=1 5 passed; 0 failed; 0 ignored; 295 filtered out (exit 0) ``` All five `buffer_store` tests pass at the new head, one more than the four at `c5332ba`; the added `typed_buffer_store_accepts_provably_zero_soffset` case is included. The description's RTX 3080 Ti and WARP execution was not repeated here, and no title was run. Not tested: the full workspace suite, a retail title, WARP as a separate device, AMD adapters, Wine, release profile, game data. AI-assisted (OpenCode), model: **MiMo-V2.6-Flash Free** - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.
github-bot force-pushed github-bot/gh-279 from 62773bc070 to 797e8f649f 2026-12-01 19:11:11 +00:00 Compare
Author
Owner

@⁠readmet3xt-lab on GitHub · 2026-12-01 21:09 UTC · original

Thank you for the update. The new commits are being retested together with the version already in the build.

**@⁠readmet3xt-lab** on GitHub · 2026-12-01 21:09 UTC · [original](https://github.com/readmet3xt-lab/foxhound/pull/279#issuecomment-7325829856) Thank you for the update. The new commits are being retested together with the version already in the build.
github-bot closed this pull request 2026-12-02 07:54:53 +00:00

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.