Shaders: lower partial-channel and dmask=0 image_store #3403

Open
Texbirds wants to merge 4 commits from upstream-pr/3403 into main
Texbirds commented 2026-11-26 22:29:35 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Texbirds on 2026-11-26T22:29:35Z.


Problem

In crates/victory-shader/src/emit/lower.rs (Lower::image), image_store currently refuses any instruction with dmask != 0xF ("an image store of some channels"), preventing translation of compute and pixel shaders that write 1-, 2-, or 3-channel RWTexture UAVs (R32_FLOAT, R32_UINT, R16_FLOAT, R16G16_FLOAT, R32G32_FLOAT, etc.). In addition, dmask == 0 was normalized to dmask = 1 before checking store, even though RDNA2 IMAGE_STORE with dmask = 0 is a no-op.

Root cause

Lower::image assumed every image_store supplied all four channels (dmask == 0xF) and indexed vdata by output channel k (0..4) rather than by the packed index of enabled dmask bits.

Solution

  • In Lower::image (crates/victory-shader/src/emit/lower.rs):
    • Preserve raw_dmask before the load/sample 0 -> 1 adjustment, and treat image_store with raw_dmask == 0 as a no-op (Ok(())) while continuing to refuse image_store_mip / _pck.
    • Pack only the raw_dmask-enabled channels from vdata in ascending bit order (with d16 reading two 16-bit halves per VGPR, low half first, in dmask bit order), fill disabled channels with 0.0f, and emit dx.op.textureStore.f32 with write mask 0xF.
  • In crates/victory-shader/src/emit/host.rs:
    • Add #[cfg(test)] View::TypedTextureUav(DXGI_FORMAT, u32, u32, u32) and pass r.GetDesc().Format to footprint_as so CopyTextureRegion zeroing and readback match the texture's DXGI format.

Correctness

  • DXIL validation: Satisfies WRITEMASKFORTYPEDUAVSTORE (write mask 0xF) and WRITEMASKMATCHVALUEFORUAVSTORE (non-undef 0.0f values for disabled channels).
  • RDNA2 / D3D12 semantics: IMAGE_STORE is a whole-texel store (not a partial-channel RMW); D3D12 hardware drops channels past the bound UAV format's channel count, and dmask = 0 leaves memory untouched.
  • Guards & dimensions: Preserves existing begin_guarded(guard) EXEC/helper-lane guarding and supports all existing UAV dimensions (1D, 2D, 3D, 1DArray, 2DArray).

Testing

All synthetic GFX10 compute shaders (no game data):

  • emit::lower::image_store_tests::partial_dmask_and_d16_image_stores_lower_and_validate: lowers and validates (dxil.dll) all 15 non-zero dmask values in 32-bit and d16 modes on 2D UAVs, plus 1D, 3D, 1DArray, and 2DArray dimensions.
  • emit::lower::image_store_tests::image_store_with_zero_dmask_is_noop: verifies dmask = 0 lowers and validates cleanly.
  • emit::lower::image_store_tests::image_store_mip_is_still_refused: verifies image_store_mip remains refused.
  • emit::stride_tests::partial_dmask_image_stores_write_typed_texture_uavs: hardware GPU + WARP execution readback covering R32_FLOAT (0x1), R32_UINT (0x1), R32G32_FLOAT (0x3), R16G16_FLOAT (0x3 d16), R16G16B16A16_FLOAT (sparse 0x5 d16), and R32_FLOAT (0x0 no-op).

Verification status: Not run locally (no Rust toolchain on this machine); intended for verification via CI (cargo clippy --workspace --all-targets --locked -- -D warnings, --all-features, cargo test --workspace --locked, and xtask policy check) and hardware/WARP runs.

Limitations

  • d16 stores to integer texture UAVs (R16_UINT, R16G16_UINT) still widen via legacyF16ToF32 (same as existing dmask = 0xF d16 image_store), pending texture integer-format metadata in VIEW_STRIDES (#2125).
  • image_store_mip and _pck variants remain refused.

Prior work

Follows the same DXIL typed-UAV write-mask and test pattern as #3377 (partial-channel typed buffer stores). AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5518016816 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3403). Originally posted by [Texbirds](https://github.com/Texbirds) on 2026-11-26T22:29:35Z. --- ### Problem In `crates/victory-shader/src/emit/lower.rs` (`Lower::image`), `image_store` currently refuses any instruction with `dmask != 0xF` (`"an image store of some channels"`), preventing translation of compute and pixel shaders that write 1-, 2-, or 3-channel `RWTexture` UAVs (`R32_FLOAT`, `R32_UINT`, `R16_FLOAT`, `R16G16_FLOAT`, `R32G32_FLOAT`, etc.). In addition, `dmask == 0` was normalized to `dmask = 1` before checking `store`, even though RDNA2 `IMAGE_STORE` with `dmask = 0` is a no-op. ### Root cause `Lower::image` assumed every `image_store` supplied all four channels (`dmask == 0xF`) and indexed `vdata` by output channel `k` (`0..4`) rather than by the packed index of enabled `dmask` bits. ### Solution - In `Lower::image` (`crates/victory-shader/src/emit/lower.rs`): - Preserve `raw_dmask` before the load/sample `0 -> 1` adjustment, and treat `image_store` with `raw_dmask == 0` as a no-op (`Ok(())`) while continuing to refuse `image_store_mip` / `_pck`. - Pack only the `raw_dmask`-enabled channels from `vdata` in ascending bit order (with `d16` reading two 16-bit halves per VGPR, low half first, in `dmask` bit order), fill disabled channels with `0.0f`, and emit `dx.op.textureStore.f32` with write mask `0xF`. - In `crates/victory-shader/src/emit/host.rs`: - Add `#[cfg(test)] View::TypedTextureUav(DXGI_FORMAT, u32, u32, u32)` and pass `r.GetDesc().Format` to `footprint_as` so `CopyTextureRegion` zeroing and readback match the texture's DXGI format. ### Correctness - **DXIL validation:** Satisfies `WRITEMASKFORTYPEDUAVSTORE` (write mask `0xF`) and `WRITEMASKMATCHVALUEFORUAVSTORE` (non-`undef` `0.0f` values for disabled channels). - **RDNA2 / D3D12 semantics:** `IMAGE_STORE` is a whole-texel store (not a partial-channel RMW); D3D12 hardware drops channels past the bound UAV format's channel count, and `dmask = 0` leaves memory untouched. - **Guards & dimensions:** Preserves existing `begin_guarded(guard)` EXEC/helper-lane guarding and supports all existing UAV dimensions (`1D`, `2D`, `3D`, `1DArray`, `2DArray`). ### Testing All synthetic GFX10 compute shaders (no game data): - `emit::lower::image_store_tests::partial_dmask_and_d16_image_stores_lower_and_validate`: lowers and validates (`dxil.dll`) all 15 non-zero `dmask` values in 32-bit and `d16` modes on 2D UAVs, plus 1D, 3D, 1DArray, and 2DArray dimensions. - `emit::lower::image_store_tests::image_store_with_zero_dmask_is_noop`: verifies `dmask = 0` lowers and validates cleanly. - `emit::lower::image_store_tests::image_store_mip_is_still_refused`: verifies `image_store_mip` remains refused. - `emit::stride_tests::partial_dmask_image_stores_write_typed_texture_uavs`: hardware GPU + WARP execution readback covering `R32_FLOAT` (`0x1`), `R32_UINT` (`0x1`), `R32G32_FLOAT` (`0x3`), `R16G16_FLOAT` (`0x3` `d16`), `R16G16B16A16_FLOAT` (sparse `0x5` `d16`), and `R32_FLOAT` (`0x0` no-op). **Verification status:** Not run locally (no Rust toolchain on this machine); intended for verification via CI (`cargo clippy --workspace --all-targets --locked -- -D warnings`, `--all-features`, `cargo test --workspace --locked`, and `xtask` policy check) and hardware/WARP runs. ### Limitations - `d16` stores to integer texture UAVs (`R16_UINT`, `R16G16_UINT`) still widen via `legacyF16ToF32` (same as existing `dmask = 0xF` `d16` `image_store`), pending texture integer-format metadata in `VIEW_STRIDES` (#2125). - `image_store_mip` and `_pck` variants remain refused. ### Prior work Follows the same DXIL typed-UAV write-mask and test pattern as #3377 (partial-channel typed buffer stores). AI-assisted.
Dukestar69 commented 2026-11-26 22:49:44 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T22:49:44Z.

Review: APPROVED


LGTM — verified on RTX 5090 and VICTORY_WARP=1 (Windows / D3D12) against origin/main (63bcca4).

  • Lowering partial-channel and dmask=0 image_store (including d16 variants while continuing to reject image_store_mip) validates cleanly and executes accurately on both RTX 5090 and WARP.
  • cargo test -p victory-shader --lib image_store_tests:: -- --test-threads=1: 3 passed, 0 failed.
  • cargo test -p victory-shader --lib emit::stride_tests::image_store -- --test-threads=1: passed on RTX 5090 and VICTORY_WARP=1.
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.
  • cargo xtask policy: 192 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6081251736 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3403#pullrequestreview-6081251736). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T22:49:44Z. **Review:** APPROVED --- LGTM — verified on RTX 5090 and `VICTORY_WARP=1` (Windows / D3D12) against `origin/main` (`63bcca4`). - Lowering partial-channel and `dmask=0` `image_store` (including `d16` variants while continuing to reject `image_store_mip`) validates cleanly and executes accurately on both RTX 5090 and WARP. - `cargo test -p victory-shader --lib image_store_tests:: -- --test-threads=1`: 3 passed, 0 failed. - `cargo test -p victory-shader --lib emit::stride_tests::image_store -- --test-threads=1`: passed on RTX 5090 and `VICTORY_WARP=1`. - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 192 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
fuzeofficlal commented 2026-11-26 23:03:54 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-26T23:03:54Z.

Review: CHANGES_REQUESTED


Unpacking packed VDATA slots (including d16 half-word unpacking) in ascending dmask bit order with 0.0 for missing channels matches RDNA2 IMAGE_STORE float-UAV semantics, lower.rs stays under 512 KiB (521,053 bytes), policy and clippy pass, and all new image_store_tests and stride_tests tests pass on RTX 5090 and WARP.

Two blocking items need fixing before merge:

  1. rustfmt --edition 2024 --check fails on PR-modified lines:
    crates/victory-shader/src/emit/host.rs:1693 and crates/victory-shader/src/emit/stride_tests.rs (814, 863, 943) fail rustfmt check.
  2. P1 — d16 integer texture stores run legacyF16ToF32 unconditionally (crates/victory-shader/src/emit/lower.rs:8618-8626, 8641):
    While 32-bit R32_UINT stores in stride_tests.rs work by raw bit-copy through float_of + textureStore.f32, the d16 branch unconditionally converts every 16-bit halfword with legacyF16ToF32 and emits an F32 (0x409) handle + textureStore.f32. On 16-bit integer UAVs (R16_UINT, R16G16_UINT, etc.), this silently corrupts integer payloads (e.g., 0x3C00 / 15360 becomes 1.0f instead of 15360).

Non-blocking P2 notes:

  • image_store_pck currently falls into the "an image store to a mip level" error message at lower.rs:8590-8592.
  • The synthetic tests in image_store_tests.rs leave UNRM (bit 12) clear in the MIMG encoding.
<!-- greyfinch-sync:Marvisak/VIctory:review:6081331104 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3403#pullrequestreview-6081331104). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-26T23:03:54Z. **Review:** CHANGES_REQUESTED --- Unpacking packed `VDATA` slots (including `d16` half-word unpacking) in ascending `dmask` bit order with `0.0` for missing channels matches RDNA2 `IMAGE_STORE` float-UAV semantics, `lower.rs` stays under 512 KiB (`521,053` bytes), `policy` and `clippy` pass, and all new `image_store_tests` and `stride_tests` tests pass on RTX 5090 and WARP. Two blocking items need fixing before merge: 1. **`rustfmt --edition 2024 --check` fails on PR-modified lines:** `crates/victory-shader/src/emit/host.rs:1693` and `crates/victory-shader/src/emit/stride_tests.rs` (`814, 863, 943`) fail `rustfmt` check. 2. **P1 — `d16` integer texture stores run `legacyF16ToF32` unconditionally (`crates/victory-shader/src/emit/lower.rs:8618-8626, 8641`):** While 32-bit `R32_UINT` stores in `stride_tests.rs` work by raw bit-copy through `float_of` + `textureStore.f32`, the `d16` branch unconditionally converts every 16-bit halfword with `legacyF16ToF32` and emits an `F32` (`0x409`) handle + `textureStore.f32`. On 16-bit integer UAVs (`R16_UINT`, `R16G16_UINT`, etc.), this silently corrupts integer payloads (e.g., `0x3C00` / `15360` becomes `1.0f` instead of `15360`). Non-blocking P2 notes: - `image_store_pck` currently falls into the `"an image store to a mip level"` error message at `lower.rs:8590-8592`. - The synthetic tests in `image_store_tests.rs` leave `UNRM` (bit 12) clear in the MIMG encoding.
Jackster commented 2026-11-26 23:08:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Jackster on 2026-11-26T23:08:08Z.


Windows 11, 63bcca4 + this PR, Radeon RX 7900 XTX:

  • cargo test -p victory-shader --lib --features host emit::: 208 passed / 0 failed / 2 ignored (143 s).
  • cargo clippy -p victory-shader --all-targets -- -D warnings: clean.

The new tests are in that run: emit::lower::image_store_tests::partial_dmask_and_d16_image_stores_lower_and_validate, image_store_with_zero_dmask_is_noop, image_store_mip_is_still_refused and partial_dmask_image_stores_write_typed_texture_uavs, plus the two table_image_uav_* ones. Synthetic only. AI-assisted.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7205284070 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3403#issuecomment-7205284070). Originally posted by [Jackster](https://github.com/Jackster) on 2026-11-26T23:08:08Z. --- Windows 11, `63bcca4` + this PR, Radeon RX 7900 XTX: - `cargo test -p victory-shader --lib --features host emit::`: **208 passed / 0 failed / 2 ignored** (143 s). - `cargo clippy -p victory-shader --all-targets -- -D warnings`: clean. The new tests are in that run: `emit::lower::image_store_tests::partial_dmask_and_d16_image_stores_lower_and_validate`, `image_store_with_zero_dmask_is_noop`, `image_store_mip_is_still_refused` and `partial_dmask_image_stores_write_typed_texture_uavs`, plus the two `table_image_uav_*` ones. Synthetic only. AI-assisted.
Texbirds commented 2026-11-26 23:25:58 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Texbirds on 2026-11-26T23:25:58Z.


Thanks @Dukestar69, @Jackster, and @fuzeofficlal for the RTX 5090, RX 7900 XTX, and WARP testing and review!

Pushed 7652064 addressing both blocking items and both P2 notes (lower.rs is 523,845 bytes, and CI / check is green):

  • d16 integer texture stores (shader.rs, lower.rs, stride_tests.rs):
    • Recorded texture UAV heap indices in Shader::texture_uav_index (separate from view_index buffer write marks and texture_index SRV read marks) and updated Lower::integer_view to check it.
    • In Lower::image, d16 stores now branch on VIEW_INTEGER from the view-stride table: integer texture UAVs emit dx.op.textureStore.i32 through an integer-typed handle (kind | 0x1000, 0x405) with zero-/sign-extended 16-bit integer channels, while float/normalized texture UAVs emit dx.op.textureStore.f32 through (kind | 0x1000, 0x409) with legacyF16ToF32.
    • Added DXGI_FORMAT_R16G16_UINT (including 0x3C00 = 15360) with VIEW_INTEGER to partial_dmask_image_stores_write_typed_texture_uavs.
  • rustfmt --edition 2024: Fixed formatting in stride_tests.rs.
  • image_store_pck error message: Split "an image store to a mip level" (_mip) from "a packed image store" (image_store_pck) and pinned both in image_store_mip_and_pck_are_still_refused.
  • UNRM bit: Set UNRM (bit 12) on the synthetic image_store encodings in image_store_tests.rs and stride_tests.rs.

Ready for re-review!

<!-- greyfinch-sync:Marvisak/VIctory:comment:7205536444 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3403#issuecomment-7205536444). Originally posted by [Texbirds](https://github.com/Texbirds) on 2026-11-26T23:25:58Z. --- Thanks @Dukestar69, @Jackster, and @fuzeofficlal for the RTX 5090, RX 7900 XTX, and WARP testing and review! Pushed `7652064` addressing both blocking items and both P2 notes (`lower.rs` is 523,845 bytes, and `CI / check` is green): - **`d16` integer texture stores (`shader.rs`, `lower.rs`, `stride_tests.rs`):** - Recorded texture UAV heap indices in `Shader::texture_uav_index` (separate from `view_index` buffer write marks and `texture_index` SRV read marks) and updated `Lower::integer_view` to check it. - In `Lower::image`, `d16` stores now branch on `VIEW_INTEGER` from the view-stride table: integer texture UAVs emit `dx.op.textureStore.i32` through an integer-typed handle `(kind | 0x1000, 0x405)` with zero-/sign-extended 16-bit integer channels, while float/normalized texture UAVs emit `dx.op.textureStore.f32` through `(kind | 0x1000, 0x409)` with `legacyF16ToF32`. - Added `DXGI_FORMAT_R16G16_UINT` (including `0x3C00` = `15360`) with `VIEW_INTEGER` to `partial_dmask_image_stores_write_typed_texture_uavs`. - **`rustfmt --edition 2024`:** Fixed formatting in `stride_tests.rs`. - **`image_store_pck` error message:** Split `"an image store to a mip level"` (`_mip`) from `"a packed image store"` (`image_store_pck`) and pinned both in `image_store_mip_and_pck_are_still_refused`. - **`UNRM` bit:** Set `UNRM` (bit 12) on the synthetic `image_store` encodings in `image_store_tests.rs` and `stride_tests.rs`. Ready for re-review!
andrewpozdnakov7-jpg commented 2026-11-26 23:33:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-26T23:33:23Z.


I reproduced the original Windows CI failure on 04fc2d0: all 32 R16G16_UINT texels read back 0xffffffff on app-local WARP. I verified that the updated 7652064 passes the existing WARP readback and validator tests.

The shader now consults the format-kind bits, which the test supplies in its root table. The production heap still supplies those bits only for typed buffers. Follow-up 188df5b adds the bits for explicit typed texture UAV descriptions, including placed textures, while keeping their buffer stride at zero.

The expanded test passed three WARP runs. All 32 texels matched in each signed and unsigned 16-bit case. A seeded dmask=0x9 store also replaced every RGBA32F texel with [16, 0, 0, 32], and every RG32F texel with [16, 0]. This follows the RDNA 2 whole-texel store rule. The affected shader tests passed 45/45, the four GPU integer tests passed, and strict Clippy in both configurations and asset policy passed.

@Texbirds, could you take the production format metadata change and repeat the two integer formats on your card? If you fold in the changes, please retain the Git author or add Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7205639886 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3403#issuecomment-7205639886). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-26T23:33:23Z. --- I reproduced the [original Windows CI failure](https://github.com/Marvisak/VIctory/actions/runs/45909725583/job/140214889230) on `04fc2d0`: all 32 `R16G16_UINT` texels read back `0xffffffff` on app-local WARP. I verified that the updated `7652064` passes the existing WARP readback and validator tests. The shader now consults the format-kind bits, which the test supplies in its root table. The production heap still supplies those bits only for typed buffers. [Follow-up `188df5b`](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/188df5b599ccf72c447bfae563b4c70ecb8d71b7) adds the bits for explicit typed texture UAV descriptions, including placed textures, while keeping their buffer stride at zero. The expanded test passed three WARP runs. All 32 texels matched in each signed and unsigned 16-bit case. A seeded `dmask=0x9` store also replaced every RGBA32F texel with `[16, 0, 0, 32]`, and every RG32F texel with `[16, 0]`. This follows the [RDNA 2 whole-texel store rule](https://www.amd.com/content/dam/amd/en/documents/radeon-tech-docs/instruction-set-architectures/rdna2-shader-instruction-set-architecture.pdf#page=74). The affected shader tests passed 45/45, the four GPU integer tests passed, and strict Clippy in both configurations and asset policy passed. @Texbirds, could you take the production format metadata change and repeat the two integer formats on your card? If you fold in the changes, please retain the Git author or add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`.
Texbirds commented 2026-11-26 23:38:28 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Texbirds on 2026-11-26T23:38:28Z.


Thanks @andrewpozdnakov7-jpg! That cleanly closes the production VIEW_STRIDES metadata gap for texture UAVs and adds great coverage for R16G16_SINT and seeded dmask=0x9 whole-texel writes.

Cherry-picked 188df5b onto this branch as 1ac4502 with your original Git authorship preserved, and CI (check) is running now. (I don't have a local Rust toolchain on this machine to run hardware tests directly, so if anyone on NVIDIA/AMD can re-run partial_dmask_image_stores_write_typed_texture_uavs on 1ac4502 to confirm the R16G16_UINT/R16G16_SINT cases on physical hardware, that would be huge!)

<!-- greyfinch-sync:Marvisak/VIctory:comment:7205718968 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3403#issuecomment-7205718968). Originally posted by [Texbirds](https://github.com/Texbirds) on 2026-11-26T23:38:28Z. --- Thanks @andrewpozdnakov7-jpg! That cleanly closes the production `VIEW_STRIDES` metadata gap for texture UAVs and adds great coverage for `R16G16_SINT` and seeded `dmask=0x9` whole-texel writes. Cherry-picked `188df5b` onto this branch as `1ac4502` with your original Git authorship preserved, and CI (`check`) is running now. (I don't have a local Rust toolchain on this machine to run hardware tests directly, so if anyone on NVIDIA/AMD can re-run `partial_dmask_image_stores_write_typed_texture_uavs` on `1ac4502` to confirm the `R16G16_UINT`/`R16G16_SINT` cases on physical hardware, that would be huge!)
Texbirds commented 2026-11-26 23:45:07 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Texbirds on 2026-11-26T23:45:07Z.


Verified 1ac4502 locally on NVIDIA GeForce RTX 3080 Ti (driver 32.0.16.1088, Windows 11, Rust 1.98.1) and WARP:

  • cargo test -p victory-shader --lib --locked -- --test-threads=1 partial_dmask_image_stores_write_typed_texture_uavs image_store_tests::: 4 passed, 0 failed (both hardware RTX 3080 Ti and WARP — including R16G16_UINT, R16G16_SINT, and seeded dmask=0x9 whole-texel writes).
  • cargo test -p victory-gpu --lib --locked explicit_integer_texture_uavs_have_kind_bits_without_a_buffer_stride: 1 passed, 0 failed.

Synthetic tests only (no game files).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7205823586 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3403#issuecomment-7205823586). Originally posted by [Texbirds](https://github.com/Texbirds) on 2026-11-26T23:45:07Z. --- Verified `1ac4502` locally on **NVIDIA GeForce RTX 3080 Ti** (driver `32.0.16.1088`, Windows 11, Rust 1.98.1) and **WARP**: - `cargo test -p victory-shader --lib --locked -- --test-threads=1 partial_dmask_image_stores_write_typed_texture_uavs image_store_tests::`: **4 passed, 0 failed** (both hardware RTX 3080 Ti and WARP — including `R16G16_UINT`, `R16G16_SINT`, and seeded `dmask=0x9` whole-texel writes). - `cargo test -p victory-gpu --lib --locked explicit_integer_texture_uavs_have_kind_bits_without_a_buffer_stride`: **1 passed, 0 failed**. Synthetic tests only (no game files).
fuzeofficlal commented 2026-11-27 00:16:01 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-27T00:16:01Z.

Review: CHANGES_REQUESTED


Tested 1ac4502b2db0da7815f6e675b370392171e949aa with cargo xtask policy, cargo clippy --tests (default and --features diagnostics), dxil.dll validation, dxc.exe -dumpbin, and live D3D12 runs on both RTX 5090 and WARP (VICTORY_D3D12_DEBUG=1).

The new tests pass (image_store_tests 3/3, stride_tests::partial_dmask_image_stores_write_typed_texture_uavs on both hardware and WARP, descriptor::host::tests 16/16 on WARP and 15/15 on RTX 5090, and lower.rs stays under the 512 KiB limit at 523,845 bytes). However, two functional issues remain before this is ready to merge:

  1. Handle caches still drop props.1, so textureStore.i32 still receives the F32-annotated handle (crates/victory-shader/src/emit/lower.rs:219, 224, 227, 5377, 5390, 5499, 8658)

    • lower.rs:8612 requests props = (kind | 0x1000, 0x409) (RWTexture2D<4xF32>), and lower.rs:8658 requests (kind | 0x1000, 0x405) (RWTexture2D<4xI32>).
    • Because handles (line 219 / 5390), entry_handles (line 224 / 5377), and join_handles (line 227 / 5499) still key only on props.0, the second self.handle(...) call hits the cache and returns the exact same F32-annotated handle for Source::Loaded and Source::Phi.
    • Disassembling the emitted d16 2D image_store DXIL with dxc.exe -dumpbin confirms no 0x405 (4xI32) annotation is emitted at all:
      %11 = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle %10, %dx.types.ResourceProperties { i32 4098, i32 1033 }) ; resource: RWTexture2D<4xF32>
      ...
      call void @dx.op.textureStore.i32(i32 67, %dx.types.Handle %11, ...)
      
    • Including the full props: (u32, u32) tuple in handles, entry_handles, and join_handles keys fixes all three caches cleanly.
  2. view_kind misses default (desc = None) and format-inheriting (Format = DXGI_FORMAT_UNKNOWN) integer texture UAVs (crates/victory-gpu/src/descriptor/host.rs:1013-1045)

    • Host UAV creation in descriptor/host.rs:1547-1556 and 1642-1658 explicitly supports both View::Unordered(resource, _, None) (default UAV inheriting the texture's format) and desc.Format == 0 (DXGI_FORMAT_UNKNOWN, resolved via crate::resource::view_format(resource) for View::Unordered and the resource's format for placed textures).
    • In view_kind(), View::Unordered(_, _, None) falls through to _ => return 0 (line 1022), and words[0] == 0 maps through integer_format(pc_format(0)) to 0 (line 1040) for both View::Unordered(r, _, Some([0, dim, ...])) and View::Placed(true, resource, [0, dim, ...]).
    • When an integer texture UAV is created that way, the stride table carries neither VIEW_INTEGER nor VIEW_SIGNED, causing d16 image_store to take the float branch (legacyF16ToF32 + textureStore.f32) and silently corrupt the stored integer texels.
    • Please fall back to the texture resource's format when desc is None (on texture resources) or words[0] == 0 (for both View::Unordered and placed texture UAVs).

Minor note: a few newly added lines in crates/victory-shader/src/emit/stride_tests.rs (lines 785–989) still have formatting diffs under rustfmt --edition 2024 --check (max_width = 100).

<!-- greyfinch-sync:Marvisak/VIctory:review:6081899375 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3403#pullrequestreview-6081899375). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-27T00:16:01Z. **Review:** CHANGES_REQUESTED --- Tested `1ac4502b2db0da7815f6e675b370392171e949aa` with `cargo xtask policy`, `cargo clippy --tests` (default and `--features diagnostics`), `dxil.dll` validation, `dxc.exe -dumpbin`, and live D3D12 runs on both RTX 5090 and WARP (`VICTORY_D3D12_DEBUG=1`). The new tests pass (`image_store_tests` 3/3, `stride_tests::partial_dmask_image_stores_write_typed_texture_uavs` on both hardware and WARP, `descriptor::host::tests` 16/16 on WARP and 15/15 on RTX 5090, and `lower.rs` stays under the 512 KiB limit at 523,845 bytes). However, two functional issues remain before this is ready to merge: 1. **Handle caches still drop `props.1`, so `textureStore.i32` still receives the `F32`-annotated handle (`crates/victory-shader/src/emit/lower.rs:219, 224, 227, 5377, 5390, 5499, 8658`)** - `lower.rs:8612` requests `props = (kind | 0x1000, 0x409)` (`RWTexture2D<4xF32>`), and `lower.rs:8658` requests `(kind | 0x1000, 0x405)` (`RWTexture2D<4xI32>`). - Because `handles` (`line 219 / 5390`), `entry_handles` (`line 224 / 5377`), and `join_handles` (`line 227 / 5499`) still key only on `props.0`, the second `self.handle(...)` call hits the cache and returns the exact same `F32`-annotated handle for `Source::Loaded` and `Source::Phi`. - Disassembling the emitted `d16` 2D `image_store` DXIL with `dxc.exe -dumpbin` confirms no `0x405` (`4xI32`) annotation is emitted at all: ```llvm %11 = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle %10, %dx.types.ResourceProperties { i32 4098, i32 1033 }) ; resource: RWTexture2D<4xF32> ... call void @dx.op.textureStore.i32(i32 67, %dx.types.Handle %11, ...) ``` - Including the full `props: (u32, u32)` tuple in `handles`, `entry_handles`, and `join_handles` keys fixes all three caches cleanly. 2. **`view_kind` misses default (`desc = None`) and format-inheriting (`Format = DXGI_FORMAT_UNKNOWN`) integer texture UAVs (`crates/victory-gpu/src/descriptor/host.rs:1013-1045`)** - Host UAV creation in `descriptor/host.rs:1547-1556` and `1642-1658` explicitly supports both `View::Unordered(resource, _, None)` (default UAV inheriting the texture's format) and `desc.Format == 0` (`DXGI_FORMAT_UNKNOWN`, resolved via `crate::resource::view_format(resource)` for `View::Unordered` and the resource's format for placed textures). - In `view_kind()`, `View::Unordered(_, _, None)` falls through to `_ => return 0` (`line 1022`), and `words[0] == 0` maps through `integer_format(pc_format(0))` to `0` (`line 1040`) for both `View::Unordered(r, _, Some([0, dim, ...]))` and `View::Placed(true, resource, [0, dim, ...])`. - When an integer texture UAV is created that way, the stride table carries neither `VIEW_INTEGER` nor `VIEW_SIGNED`, causing `d16` `image_store` to take the float branch (`legacyF16ToF32` + `textureStore.f32`) and silently corrupt the stored integer texels. - Please fall back to the texture resource's format when `desc` is `None` (on texture resources) or `words[0] == 0` (for both `View::Unordered` and placed texture UAVs). Minor note: a few newly added lines in `crates/victory-shader/src/emit/stride_tests.rs` (lines 785–989) still have formatting diffs under `rustfmt --edition 2024 --check` (`max_width = 100`).
zzm1234560621-prog commented 2026-11-27 04:01:16 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by zzm1234560621-prog on 2026-11-27T04:01:16Z.


Verification on Intel (Arc, Xe-LPG, driver 32.0.101.6127), 1ac4502 on top of 63bcca4:

cargo test -p victory-shader --lib -- image_store
test result: ok. 4 passed; 0 failed; 0 ignored

cargo test -p victory-shader --lib
299 passed, 7 failed, 3 ignored

The seven failures are this adapter's standing set on unmodified 63bcca4 (#3196): three BVH tests one ULP off from this driver's reassociation, arithmetic_matches_the_hardware and the MAD signed zero (fixed by #3212), image_atomics_of_64_bits (gated by #3203) and the view-heap test (#3191/#3178), and fspx_…dot_products. So no new failure here, and the 299 over the 295 baseline is your four image_store tests.

cargo clippy -p victory-shader --all-targets --locked -- -D warnings: clean.

One note for whoever runs this next: I built the head from a zip (git fetch to github is being reset on this network today), so the run was a cold build — 72 minutes for the suite. Nothing about the code, just why the timings in this comment are not comparable with the others I have posted.

No game files. AI-assisted (Claude).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7209454451 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3403#issuecomment-7209454451). Originally posted by [zzm1234560621-prog](https://github.com/zzm1234560621-prog) on 2026-11-27T04:01:16Z. --- Verification on Intel (Arc, Xe-LPG, driver 32.0.101.6127), `1ac4502` on top of `63bcca4`: ``` cargo test -p victory-shader --lib -- image_store test result: ok. 4 passed; 0 failed; 0 ignored cargo test -p victory-shader --lib 299 passed, 7 failed, 3 ignored ``` The seven failures are this adapter's standing set on unmodified `63bcca4` (#3196): three BVH tests one ULP off from this driver's reassociation, `arithmetic_matches_the_hardware` and the MAD signed zero (fixed by #3212), `image_atomics_of_64_bits` (gated by #3203) and the view-heap test (#3191/#3178), and `fspx_…dot_products`. So **no new failure** here, and the 299 over the 295 baseline is your four `image_store` tests. `cargo clippy -p victory-shader --all-targets --locked -- -D warnings`: clean. One note for whoever runs this next: I built the head from a zip (git fetch to github is being reset on this network today), so the run was a cold build — 72 minutes for the suite. Nothing about the code, just why the timings in this comment are not comparable with the others I have posted. _No game files. AI-assisted (Claude)._
andrewpozdnakov7-jpg commented 2026-11-27 07:13:39 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by andrewpozdnakov7-jpg on 2026-11-27T07:13:39Z.


@Texbirds 1c0acc5 is a follow-up on 1ac4502 for the two format observations.

The three handle caches now keep both resource-property words. Before the fix, the DXIL test found the float annotation but no integer annotation for the d16 case. Both annotations are present after the fix and the four image-store tests passed.

The stride table now uses the texture UAV format actually chosen at host view creation. This covers a default UAV and an explicit texture descriptor with DXGI_FORMAT_UNKNOWN. The placed-resource description supplies the format for an inherited placed texture before the host view is made. The added format test and the full descriptor host group passed on app-local WARP (17/17), and a separate native WARP fixture checked an actual default and an inheriting UAV. Strict all-features GPU and shader Clippy passed.

If you take the patch, please retain Git authorship when cherry-picking or rebasing. If folded into another commit, please add Co-authored-by: andrewpozdnakov7-jpg <[email protected]>.

AI-assisted with Codex. Synthetic tests only.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7212266625 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3403#issuecomment-7212266625). Originally posted by [andrewpozdnakov7-jpg](https://github.com/andrewpozdnakov7-jpg) on 2026-11-27T07:13:39Z. --- @Texbirds [1c0acc5](https://github.com/andrewpozdnakov7-jpg/VIctory/commit/1c0acc536bd2288a9d0c6d9ef6cbc04457881d8f) is a follow-up on `1ac4502` for the two format observations. The three handle caches now keep both resource-property words. Before the fix, the DXIL test found the float annotation but no integer annotation for the d16 case. Both annotations are present after the fix and the four image-store tests passed. The stride table now uses the texture UAV format actually chosen at host view creation. This covers a default UAV and an explicit texture descriptor with `DXGI_FORMAT_UNKNOWN`. The placed-resource description supplies the format for an inherited placed texture before the host view is made. The added format test and the full descriptor host group passed on app-local WARP (17/17), and a separate native WARP fixture checked an actual default and an inheriting UAV. Strict all-features GPU and shader Clippy passed. If you take the patch, please retain Git authorship when cherry-picking or rebasing. If folded into another commit, please add `Co-authored-by: andrewpozdnakov7-jpg <[email protected]>`. AI-assisted with Codex. Synthetic tests only.
Texbirds commented 2026-11-27 07:31:03 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Texbirds on 2026-11-27T07:31:03Z.


Thanks @fuzeofficlal for the dxc -dumpbin audit, @zzm1234560621-prog for the Intel Arc verification, and @andrewpozdnakov7-jpg for the 1c0acc5 follow-up!

Cherry-picked 1c0acc5 onto this branch as 8531c85 (preserving @andrewpozdnakov7-jpg's Git authorship) and pushed b0a959e fixing the remaining rustfmt --edition 2024 diffs in stride_tests.rs:

  • Handle cache keys (lower.rs): handles, entry_handles, and join_handles now key on the full props: (u32, u32) tuple so d16 image_store emits both the 0x409 (4xF32) and 0x405 (4xU32) handle annotations (verified in image_store_tests).
  • Default & DXGI_FORMAT_UNKNOWN texture UAV format metadata (victory-gpu/src/descriptor/host.rs): view_kind now resolves inherited texture UAV formats for both View::Unordered(..., None) / Format == 0 and placed texture UAVs (inherited_integer_texture_uavs_have_kind_bits).
  • Formatting (stride_tests.rs): rustfmt --edition 2024 --check is clean across all PR-added lines.

Local verification on b0a959e (NVIDIA GeForce RTX 3080 Ti 32.0.16.1088 + WARP, Windows 11, Rust 1.98.1, synthetic tests only):

  • cargo clippy -p victory-shader -p victory-gpu --all-targets --locked -- -D warnings (default & --all-features): clean
  • cargo xtask policy: 192 files ok (lower.rs = 524,074 bytes)
  • cargo test -p victory-shader --lib --locked -- --test-threads=1 image_store_tests:: partial_dmask_image_stores_write_typed_texture_uavs: 4 passed, 0 failed (2.52s)
  • cargo test -p victory-gpu --lib --locked descriptor::host::tests::: 16/17 passed (both new integer texture UAV tests pass; only the pre-existing NVIDIA 1M view-heap cap failure in dynamic_slots_are_held_until_released)

Ready for re-review!

<!-- greyfinch-sync:Marvisak/VIctory:comment:7212548730 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3403#issuecomment-7212548730). Originally posted by [Texbirds](https://github.com/Texbirds) on 2026-11-27T07:31:03Z. --- Thanks @fuzeofficlal for the `dxc -dumpbin` audit, @zzm1234560621-prog for the Intel Arc verification, and @andrewpozdnakov7-jpg for the `1c0acc5` follow-up! Cherry-picked `1c0acc5` onto this branch as `8531c85` (preserving @andrewpozdnakov7-jpg's Git authorship) and pushed `b0a959e` fixing the remaining `rustfmt --edition 2024` diffs in `stride_tests.rs`: - **Handle cache keys (`lower.rs`):** `handles`, `entry_handles`, and `join_handles` now key on the full `props: (u32, u32)` tuple so `d16` `image_store` emits both the `0x409` (`4xF32`) and `0x405` (`4xU32`) handle annotations (verified in `image_store_tests`). - **Default & `DXGI_FORMAT_UNKNOWN` texture UAV format metadata (`victory-gpu/src/descriptor/host.rs`):** `view_kind` now resolves inherited texture UAV formats for both `View::Unordered(..., None)` / `Format == 0` and placed texture UAVs (`inherited_integer_texture_uavs_have_kind_bits`). - **Formatting (`stride_tests.rs`):** `rustfmt --edition 2024 --check` is clean across all PR-added lines. **Local verification on `b0a959e` (NVIDIA GeForce RTX 3080 Ti `32.0.16.1088` + WARP, Windows 11, Rust 1.98.1, synthetic tests only):** - `cargo clippy -p victory-shader -p victory-gpu --all-targets --locked -- -D warnings` (default & `--all-features`): clean - `cargo xtask policy`: `192 files ok` (`lower.rs` = 524,074 bytes) - `cargo test -p victory-shader --lib --locked -- --test-threads=1 image_store_tests:: partial_dmask_image_stores_write_typed_texture_uavs`: **4 passed, 0 failed** (2.52s) - `cargo test -p victory-gpu --lib --locked descriptor::host::tests::`: **16/17 passed** (both new integer texture UAV tests pass; only the pre-existing NVIDIA 1M view-heap cap failure in `dynamic_slots_are_held_until_released`) Ready for re-review!
passerbyyhx commented 2026-11-27 09:36:32 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by passerbyyhx on 2026-11-27T09:36:32Z.


I verified b0a959edd8d40f8be181164307cdc0c898f2f54d on a GeForce RTX 4090 Laptop GPU (621.14) and Microsoft WARP. The unmodified head passed all four selected image_store tests. I then used three matched synthetic dispatches per adapter to read back the result of a d16 store on a pre-filled R16G16B16A16_FLOAT texture. All 32 texels per dispatch were checked.

Second store after seeding RGBA = (0.5, 1, 2, 4) Readback RGBA Packed dwords (hex)
None (seed control) (0.5, 1, 2, 4) 3c003800 44004000
dmask=0, with new values in the source register (0.5, 1, 2, 4) 3c003800 44004000
dmask=5, packed R=5 and B=12 (5, 0, 12, 0) 00004500 00004a00

Both adapters matched all 96 texels each. The zero mask preserved the nonzero green and alpha channels, whereas the sparse whole-texel store cleared them and placed the upper source half in blue. This is a Windows D3D12 host readback. Synthetic fixture. AI-assisted with Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7214881491 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3403#issuecomment-7214881491). Originally posted by [passerbyyhx](https://github.com/passerbyyhx) on 2026-11-27T09:36:32Z. --- I verified `b0a959edd8d40f8be181164307cdc0c898f2f54d` on a GeForce RTX 4090 Laptop GPU (621.14) and Microsoft WARP. The unmodified head passed all four selected `image_store` tests. I then used three matched synthetic dispatches per adapter to read back the result of a `d16` store on a pre-filled `R16G16B16A16_FLOAT` texture. All 32 texels per dispatch were checked. | Second store after seeding RGBA = (0.5, 1, 2, 4) | Readback RGBA | Packed dwords (hex) | | --- | --- | --- | | None (seed control) | (0.5, 1, 2, 4) | `3c003800 44004000` | | `dmask=0`, with new values in the source register | (0.5, 1, 2, 4) | `3c003800 44004000` | | `dmask=5`, packed R=5 and B=12 | (5, 0, 12, 0) | `00004500 00004a00` | Both adapters matched all 96 texels each. The zero mask preserved the nonzero green and alpha channels, whereas the sparse whole-texel store cleared them and placed the upper source half in blue. This is a Windows D3D12 host readback. [Synthetic fixture](https://github.com/passerbyyhx/VIctory/commit/e9c16d386daae2ae58982ae89445b89d230aa161). AI-assisted with Codex.
pablogonz12 commented 2026-11-27 17:05:32 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by pablogonz12 on 2026-11-27T17:05:32Z.


I tested the current head b0a959edd8d40f8be181164307cdc0c898f2f54d on RX 9070 XT (RDNA4), RADV, Mesa 26.3.1-arch3.5, GE-Proton11-14 (Wine 11.0), Rust/Cargo 1.100.0. This was one run per tree.

I built the Windows test binary with cargo xwin test --no-run -p victory-shader --lib --target x86_64-pc-windows-msvc, then ran it under Wine with --test-threads=1 image_store, using the hardware adapter rather than WARP.

Tree Result
main 63bcca43c6a00a758510398fa43096ce7e4f7df0 0 matching tests; 0 failed (305 filtered out)
PR head b0a959edd8d40f8be181164307cdc0c898f2f54d 4 passed, 0 failed (305 filtered out), including partial_dmask_image_stores_write_typed_texture_uavs hardware readback

The main tree does not contain these new tests, so its zero-test result is not a readback control. Unit tests only, not a game run. Not tested on NVIDIA hardware.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7224016357 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3403#issuecomment-7224016357). Originally posted by [pablogonz12](https://github.com/pablogonz12) on 2026-11-27T17:05:32Z. --- I tested the current head `b0a959edd8d40f8be181164307cdc0c898f2f54d` on RX 9070 XT (RDNA4), RADV, Mesa 26.3.1-arch3.5, GE-Proton11-14 (Wine 11.0), Rust/Cargo 1.100.0. This was one run per tree. I built the Windows test binary with `cargo xwin test --no-run -p victory-shader --lib --target x86_64-pc-windows-msvc`, then ran it under Wine with `--test-threads=1 image_store`, using the hardware adapter rather than WARP. | Tree | Result | |---|---| | main `63bcca43c6a00a758510398fa43096ce7e4f7df0` | 0 matching tests; 0 failed (305 filtered out) | | PR head `b0a959edd8d40f8be181164307cdc0c898f2f54d` | 4 passed, 0 failed (305 filtered out), including `partial_dmask_image_stores_write_typed_texture_uavs` hardware readback | The main tree does not contain these new tests, so its zero-test result is not a readback control. Unit tests only, not a game run. Not tested on NVIDIA hardware.
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/3403:upstream-pr/3403'
git switch 'upstream-pr/3403'

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