Shaders: a packed word written to all four channels is stored as an integer #4003

Manually merged
github merged 1 commit from github-bot/gh-4003 into gh-pr/4003/base 2026-11-30 16:33:38 +00:00 AGit
Owner

@⁠Saul5662 on GitHub · 2026-11-30 14:15 UTC · original
Saul5662:fix/packed-word-image-store → main · +82 −0 · 2 files · 1 commits · merged 2026-11-30 16:28 UTC

What it changes

The TAA resolves (TAA_Utilities:CS_SceneColorTemporalResolve*, e.g. b2b1ea29bc3987db, the dual-output DOF-aware one) pack R9G9B9E5 into an R32_UINT texture with integer ops (v_or3_b32, v_lshl_or_b32) and write the word to all four channels of an image_store. The lowering always emitted bitcast i32 -> float plus textureStore.f32 through a 4xF32 handle (props fixed at 0x409), so the word travelled as a float. On NVIDIA, words whose bits read as a NaN do not arrive intact: 0x7F800001 came back as 0x7FC00001, and in the game's buffer they ended up 0.

DepthOfField:CS_MainBlur and the tile composite (PS_CompositeIndirectDrawBlend) read that packed copy through the R9G9B9E5 view, so the opening cutscene showed black splotches on Lucia's hoodie wherever the colour's shared exponent and blue mantissa made a NaN bit pattern. Raw capture (VICTORY_DUMP_RAW): of 225,818 non-zero words in the packed texture, none had a NaN pattern; the 4,582 zero texels were exactly the splotches, and a neighbour estimate puts the NaN pattern 40x more often at the holes than elsewhere.

This change: a store whose four channels are the same value assembled from bit fields (v_or_b32, v_or3_b32, v_lshl_or_b32, v_and_or_b32, v_bfi_b32, v_perm_b32, v_alignbit_b32, followed through v_mov_b32 copies) is lowered as textureStore.i32 through a 4xU32 handle (0x405), as the counter store already is. Other stores keep the float path. 144 of 25,693 programs translate differently: the TAA resolves, the screen-probe temporal resolves, water (transmission volumetrics, underwater mask, tessellation), voxelization and the terrain indirection remap.

How it was tested

  • GPU and profile: RTX 3060 12 GB, Linux (Proton Experimental + vkd3d-proton), Series S, 720p, DLSS off, frame generation off, ray tracing off.
  • Before: black splotches on the hoodie in the first seconds of the police-car cutscene (screenshots 1-2 s in).
  • After: the hoodie is clean in the same shots, depth of field intact.
  • New test emit::size_tests::a_packed_word_is_stored_bit_for_bit: stores 0x7F800001 built with v_or_b32 to all four channels of a uint texture and reads it back. Passes on the RTX 3060; with the change disabled it fails (0x7FC00001). The WARP run is skipped here (no SM 6.6 WARP device under Wine).
  • For shader changes, the wave sizes tested: the game's programs are wave64 on a 32-lane host; the new test is wave32.
  • cargo test passed for the crates it touches: victory-shader --lib under Wine on the RTX 3060: 458 passed, 5 failed, 9 ignored. The 5 failures do not involve image stores and so cannot reach this change (filter3d_tests::by_hand_and_by_the_card_agree, opt::hw_tests::split_lds_wave32_read_after_read_barrier_coalescing_and_parity, intersect_tests::flat_global_stores_and_atomics_fence_uavs_at_group_barriers_across_waves, tests::stub_pipeline_is_created (vkd3d accepts the altered digest), valu_tests::whole_wave_sections_keep_rounding_mode_changes); they look specific to Wine/vkd3d on this card. cargo clippy -p victory-shader reports four errors that are already on main (lower/analysis.rs, lower.rs unused import, native.rs argument count), none in this change.
  • Not checked in game: the other changed programs' scenes (water, screen probes indoors).

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #1730 and #1826 (R32 <-> R9G9B9E5 alias copies, which this does not touch); no open PR changes image store typing.

AI use: Claude Code (Claude Opus 5.5) found the cause, wrote the change and the test, ran the checks and wrote this text. Label: [pr-fix].

🤖 Generated with Claude Code

**@⁠Saul5662** on GitHub · 2026-11-30 14:15 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4003) `Saul5662:fix/packed-word-image-store` → `main` · +82 −0 · 2 files · 1 commits · merged 2026-11-30 16:28 UTC ## What it changes The TAA resolves (`TAA_Utilities:CS_SceneColorTemporalResolve*`, e.g. `b2b1ea29bc3987db`, the dual-output DOF-aware one) pack R9G9B9E5 into an R32_UINT texture with integer ops (`v_or3_b32`, `v_lshl_or_b32`) and write the word to all four channels of an `image_store`. The lowering always emitted `bitcast i32 -> float` plus `textureStore.f32` through a 4xF32 handle (`props` fixed at `0x409`), so the word travelled as a float. On NVIDIA, words whose bits read as a NaN do not arrive intact: `0x7F800001` came back as `0x7FC00001`, and in the game's buffer they ended up 0. `DepthOfField:CS_MainBlur` and the tile composite (`PS_CompositeIndirectDrawBlend`) read that packed copy through the R9G9B9E5 view, so the opening cutscene showed black splotches on Lucia's hoodie wherever the colour's shared exponent and blue mantissa made a NaN bit pattern. Raw capture (`VICTORY_DUMP_RAW`): of 225,818 non-zero words in the packed texture, none had a NaN pattern; the 4,582 zero texels were exactly the splotches, and a neighbour estimate puts the NaN pattern 40x more often at the holes than elsewhere. This change: a store whose four channels are the same value assembled from bit fields (`v_or_b32`, `v_or3_b32`, `v_lshl_or_b32`, `v_and_or_b32`, `v_bfi_b32`, `v_perm_b32`, `v_alignbit_b32`, followed through `v_mov_b32` copies) is lowered as `textureStore.i32` through a 4xU32 handle (`0x405`), as the counter store already is. Other stores keep the float path. 144 of 25,693 programs translate differently: the TAA resolves, the screen-probe temporal resolves, water (transmission volumetrics, underwater mask, tessellation), voxelization and the terrain indirection remap. ## How it was tested - GPU and profile: RTX 3060 12 GB, Linux (Proton Experimental + vkd3d-proton), Series S, 720p, DLSS off, frame generation off, ray tracing off. - Before: black splotches on the hoodie in the first seconds of the police-car cutscene (screenshots 1-2 s in). - After: the hoodie is clean in the same shots, depth of field intact. - New test `emit::size_tests::a_packed_word_is_stored_bit_for_bit`: stores `0x7F800001` built with `v_or_b32` to all four channels of a uint texture and reads it back. Passes on the RTX 3060; with the change disabled it fails (`0x7FC00001`). The WARP run is skipped here (no SM 6.6 WARP device under Wine). - For shader changes, the wave sizes tested: the game's programs are wave64 on a 32-lane host; the new test is wave32. - `cargo test` passed for the crates it touches: `victory-shader --lib` under Wine on the RTX 3060: 458 passed, 5 failed, 9 ignored. The 5 failures do not involve image stores and so cannot reach this change (`filter3d_tests::by_hand_and_by_the_card_agree`, `opt::hw_tests::split_lds_wave32_read_after_read_barrier_coalescing_and_parity`, `intersect_tests::flat_global_stores_and_atomics_fence_uavs_at_group_barriers_across_waves`, `tests::stub_pipeline_is_created` (vkd3d accepts the altered digest), `valu_tests::whole_wave_sections_keep_rounding_mode_changes`); they look specific to Wine/vkd3d on this card. `cargo clippy -p victory-shader` reports four errors that are already on `main` (`lower/analysis.rs`, `lower.rs` unused import, `native.rs` argument count), none in this change. - Not checked in game: the other changed programs' scenes (water, screen probes indoors). ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #1730 and #1826 (R32 <-> R9G9B9E5 alias copies, which this does not touch); no open PR changes image store typing. AI use: Claude Code (Claude Opus 5.5) found the cause, wrote the change and the test, ran the checks and wrote this text. Label: [pr-fix]. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 14:25:29 +00:00
Author
Owner

@⁠dyshay on GitHub · 2026-11-30 14:53 UTC · original

Merged for testing into our integration branch dyshay/VIctory-NVIDIA janus-prs. Builds and the targeted CPU tests pass; a run on an RTX 4090 (Series S, hardware RT) is queued and I'll post the result here.

**@⁠dyshay** on GitHub · 2026-11-30 14:53 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4003#issuecomment-7282095956) Merged for testing into our integration branch [dyshay/VIctory-NVIDIA `janus-prs`](https://github.com/dyshay/VIctory-NVIDIA/tree/janus-prs). Builds and the targeted CPU tests pass; a run on an RTX 4090 (Series S, hardware RT) is queued and I'll post the result here.
github-bot referenced this pull request from a commit 2026-11-30 16:33:21 +00:00
github-bot changed target branch from main to gh-pr/4003/base 2026-11-30 16:33:36 +00:00
github manually merged commit 033c372cbb into gh-pr/4003/base 2026-11-30 16:33:38 +00:00
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/trustno1-coder--VIctory-NVIDIA!4003
No description provided.