shader(lower): store bit-assembled packed 4-channel texels via textureStore.i32 #259

Manually merged
github merged 1 commit from gh-pr/259/head into gh-pr/259/base 2026-12-01 20:23:42 +00:00
Owner

@⁠Androtim on GitHub · 2026-11-30 17:23 UTC · original
Androtim:feat/iter252-shader-packed-word-int-store → main · +93 −3 · 2 files · 1 commits · merged 2026-11-30 19:18 UTC

Summary

  • Detect bit-assembled packed texels written to all four channels (packed_word) inside image_store lowering (crates/victory-shader/src/emit/lower.rs) and emit textureStore.i32 directly (sharing the integer store emission path with single-channel counter stores).
  • Prevents float store encoding from flushing NaN-aliased bit patterns (such as packed R9G9B9E5 texels written to R32_UINT views) to zero on NVIDIA GPUs.
  • Add unit test a_packed_word_is_stored_bit_for_bit in crates/victory-shader/src/emit/size_tests.rs verifying bit-exact 0x7F80_0001 storage on hardware and WARP.

Verification

  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-shader --lib emit::size_tests:: -> 9 passed; 0 failed
  • cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-shader --lib emit::lower -> 20 passed; 0 failed; 1 ignored
  • cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets -- -D warnings -> clean
  • cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --features diagnostics -- -D warnings -> clean
  • Note: PR files (lower.rs, size_tests.rs) introduce zero xtask policy violations; the only xtask policy violation observed on this branch is the pre-existing crates/victory-gpu/src/host.rs size limit on main, which is resolved by the sibling chore/iter252-host-extract-refresh-tests PR.
**@⁠Androtim** on GitHub · 2026-11-30 17:23 UTC · [original](https://github.com/Androtim/MiniVI/pull/259) `Androtim:feat/iter252-shader-packed-word-int-store` → `main` · +93 −3 · 2 files · 1 commits · merged 2026-11-30 19:18 UTC ## Summary - Detect bit-assembled packed texels written to all four channels (`packed_word`) inside `image_store` lowering (`crates/victory-shader/src/emit/lower.rs`) and emit `textureStore.i32` directly (sharing the integer store emission path with single-channel counter stores). - Prevents float store encoding from flushing NaN-aliased bit patterns (such as packed `R9G9B9E5` texels written to `R32_UINT` views) to zero on NVIDIA GPUs. - Add unit test `a_packed_word_is_stored_bit_for_bit` in `crates/victory-shader/src/emit/size_tests.rs` verifying bit-exact `0x7F80_0001` storage on hardware and WARP. ## Verification - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-shader --lib emit::size_tests::` -> `9 passed; 0 failed` - `cargo +1.98.1-x86_64-pc-windows-gnu test -p victory-shader --lib emit::lower` -> `20 passed; 0 failed; 1 ignored` - `cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets -- -D warnings` -> clean - `cargo +1.98.1-x86_64-pc-windows-gnu clippy --workspace --all-targets --features diagnostics -- -D warnings` -> clean - Note: PR files (`lower.rs`, `size_tests.rs`) introduce zero `xtask policy` violations; the only `xtask policy` violation observed on this branch is the pre-existing `crates/victory-gpu/src/host.rs` size limit on `main`, which is resolved by the sibling `chore/iter252-host-extract-refresh-tests` PR.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 20:23:40 +00:00
github manually merged commit a1fee036a0 into gh-pr/259/base 2026-12-01 20:23:42 +00:00
Author
Owner

@⁠Androtim on GitHub · 2026-11-30 18:03 UTC · original

Automated triage for the maintainers (not an approval).

Verdict: needs-gpu-test · CI (check): passing

Automated Review — PR #259

Verdict: needs-gpu-test (CI passing; logic and scoping look clean, warrants a local real-GPU smoke test).

What was checked

  • crates/victory-shader/src/emit/lower.rs:
    • Lower::packed_word traces v[reg..reg + 4] through up to 8 v_mov_b32 vector copies and matches when all 4 channels resolve to the same SSA Value written by one of the 7 bit-assembly VALU ops (v_or_b32, v_or3_b32, v_lshl_or_b32, v_and_or_b32, v_bfi_b32, v_perm_b32, v_alignbit_b32).
    • image_store lowering unifies single-channel counter stores (0x105) and non-d16 packed-word stores (0x405) onto textureStore.i32 (dx.op.textureStore.i32, opcode 67), avoiding float NaN canonicalization/flushing on integer views.
  • crates/victory-shader/src/emit/size_tests.rs:
    • Adds a_packed_word_is_stored_bit_for_bit covering a v_or_b32-assembled signaling-NaN bit pattern (0x7F80_0001) broadcast across v[3:6] into View::UintTextureUav(1, 1).

Notes / Edge cases to watch during GPU testing

  1. Heuristic false-positive risk on float/UNORM UAVs: packed_word infers an integer UAV solely from the producing VALU op and 4-channel broadcast. If a shader computes a float via v_bfi_b32, v_or_b32, or v_and_or_b32 (e.g., sign-bit manipulation or bit-select) and broadcasts it to all 4 channels of a FLOAT/UNORM UAV, emitting textureStore.i32 (0x405) would cause a format-family mismatch. A real-GPU smoke test across game scenes (and ideally with D3D12 debug layer enabled) will confirm no regressions.
  2. 4-component 0x405 (uint4) handle on 1-component R32_UINT UAVs: Works in size_tests.rs on WARP/hardware, but worth confirming clean behavior on real NVIDIA/AMD/Intel drivers alongside R9G9B9E5/R32_UINT workloads.
  3. Minor: v_mov_b32 tracing in packed_word does not inspect Fields::Valu modifiers (e.g., DPP/SDWA if decoded under the same mnemonic), and writer scans self.x.p.blocks linearly per lookup—fine for typical shader sizes, just worth keeping in mind.

This is an automated review and does not constitute formal maintainer approval.


Generated with Antigravity CLI (agy).

**@⁠Androtim** on GitHub · 2026-11-30 18:03 UTC · [original](https://github.com/Androtim/MiniVI/pull/259#issuecomment-7287284890) <!-- minivi-triage v1 head=a1fee036a02b5a32aa0aa199e3fdffae29addf2c verdict=needs-gpu-test ci=passing at=2026-11-30T18:04:27Z --> Automated triage for the maintainers (not an approval). **Verdict:** `needs-gpu-test` · **CI (`check`):** `passing` ### Automated Review — PR #259 **Verdict:** `needs-gpu-test` (CI passing; logic and scoping look clean, warrants a local real-GPU smoke test). #### What was checked - **[`crates/victory-shader/src/emit/lower.rs`](crates/victory-shader/src/emit/lower.rs)**: - `Lower::packed_word` traces `v[reg..reg + 4]` through up to 8 `v_mov_b32` vector copies and matches when all 4 channels resolve to the same SSA `Value` written by one of the 7 bit-assembly VALU ops (`v_or_b32`, `v_or3_b32`, `v_lshl_or_b32`, `v_and_or_b32`, `v_bfi_b32`, `v_perm_b32`, `v_alignbit_b32`). - `image_store` lowering unifies single-channel counter stores (`0x105`) and non-`d16` packed-word stores (`0x405`) onto `textureStore.i32` (`dx.op.textureStore.i32`, opcode 67), avoiding float NaN canonicalization/flushing on integer views. - **[`crates/victory-shader/src/emit/size_tests.rs`](crates/victory-shader/src/emit/size_tests.rs)**: - Adds `a_packed_word_is_stored_bit_for_bit` covering a `v_or_b32`-assembled signaling-NaN bit pattern (`0x7F80_0001`) broadcast across `v[3:6]` into `View::UintTextureUav(1, 1)`. #### Notes / Edge cases to watch during GPU testing 1. **Heuristic false-positive risk on float/UNORM UAVs**: `packed_word` infers an integer UAV solely from the producing VALU op and 4-channel broadcast. If a shader computes a float via `v_bfi_b32`, `v_or_b32`, or `v_and_or_b32` (e.g., sign-bit manipulation or bit-select) and broadcasts it to all 4 channels of a `FLOAT`/`UNORM` UAV, emitting `textureStore.i32` (`0x405`) would cause a format-family mismatch. A real-GPU smoke test across game scenes (and ideally with D3D12 debug layer enabled) will confirm no regressions. 2. **4-component `0x405` (`uint4`) handle on 1-component `R32_UINT` UAVs**: Works in `size_tests.rs` on WARP/hardware, but worth confirming clean behavior on real NVIDIA/AMD/Intel drivers alongside `R9G9B9E5`/`R32_UINT` workloads. 3. **Minor**: `v_mov_b32` tracing in `packed_word` does not inspect `Fields::Valu` modifiers (e.g., DPP/SDWA if decoded under the same mnemonic), and `writer` scans `self.x.p.blocks` linearly per lookup—fine for typical shader sizes, just worth keeping in mind. *This is an automated review and does not constitute formal maintainer approval.* --- _Generated with Antigravity CLI (`agy`)._
Author
Owner

@⁠Androtim on GitHub · 2026-11-30 19:18 UTC · original

Hardware verification on RTX 4060 Ti (Series X 1440p parity, DLSS Quality, origin/main 440d7d7 + #259):

  • cargo test -p victory (lib): 37 passed; 0 failed
  • cargo test -p victory-shader --lib lower -- --test-threads=1: 21 passed; 0 failed; 1 ignored
  • cargo test -p victory-shader --lib emit::wave64_tests -- --test-threads=1: 19 passed; 0 failed
  • cargo test -p victory-shader --lib emit::size_tests -- --test-threads=1: 9 passed; 0 failed (including _packed_word_is_stored_bit_for_bit)
  • cargo test -p victory-gpu --lib -- --test-threads=1: 624 passed; 1 failed; 39 ignored (descriptor::host::tests::views_off_their_elements_get_a_copy_of_their_bytes, which passed 1 passed; 0 failed standalone; #259 only touches crates/victory-shader/src/emit/{lower,size_tests}.rs)
  • erify-wave10 (cold cache, 45s open world): 5.0 fps, 9757 draws, VRAM 6921/5995 MB,
**@⁠Androtim** on GitHub · 2026-11-30 19:18 UTC · [original](https://github.com/Androtim/MiniVI/pull/259#issuecomment-7289190143) Hardware verification on RTX 4060 Ti (Series X 1440p parity, DLSS Quality, origin/main 440d7d7 + #259): - cargo test -p victory (lib): 37 passed; 0 failed - cargo test -p victory-shader --lib lower -- --test-threads=1: 21 passed; 0 failed; 1 ignored - cargo test -p victory-shader --lib emit::wave64_tests -- --test-threads=1: 19 passed; 0 failed - cargo test -p victory-shader --lib emit::size_tests -- --test-threads=1: 9 passed; 0 failed (including _packed_word_is_stored_bit_for_bit) - cargo test -p victory-gpu --lib -- --test-threads=1: 624 passed; 1 failed; 39 ignored (descriptor::host::tests::views_off_their_elements_get_a_copy_of_their_bytes, which passed 1 passed; 0 failed standalone; #259 only touches crates/victory-shader/src/emit/{lower,size_tests}.rs) - erify-wave10 (cold cache, 45s open world): 5.0 fps, 9757 draws, VRAM 6921/5995 MB,
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/Androtim--MiniVI!259
No description provided.