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

Open
github-bot wants to merge 2 commits from github-bot/gh-3403 into main AGit
Owner

@⁠Texbirds on GitHub · 2026-11-26 22:29 UTC · original
Texbirds:feat/shader-partial-image-stores → main · +606 −69 · 6 files · 2 commits · open

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.

**@⁠Texbirds** on GitHub · 2026-11-26 22:29 UTC · [original](https://github.com/Marvisak/VIctory/pull/3403) `Texbirds:feat/shader-partial-image-stores` → `main` · +606 −69 · 6 files · 2 commits · open ### 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 01:06:45 +00:00
Author
Owner

@⁠Dukestar69 on GitHub · 2026-11-26 22:49 UTC · original · approved these changes

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).

**@⁠Dukestar69** on GitHub · 2026-11-26 22:49 UTC · [original](https://github.com/Marvisak/VIctory/pull/3403#pullrequestreview-6081251736) · **approved these changes** 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).
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 23:03 UTC · original · requested changes

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.
**@⁠fuzeofficlal** on GitHub · 2026-11-26 23:03 UTC · [original](https://github.com/Marvisak/VIctory/pull/3403#pullrequestreview-6081331104) · **requested changes** 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.
Author
Owner

@⁠Jackster on GitHub · 2026-11-26 23:08 UTC · original

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.

**@⁠Jackster** on GitHub · 2026-11-26 23:08 UTC · [original](https://github.com/Marvisak/VIctory/pull/3403#issuecomment-7205284070) 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.
Author
Owner

@⁠Texbirds on GitHub · 2026-11-26 23:25 UTC · original

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!

**@⁠Texbirds** on GitHub · 2026-11-26 23:25 UTC · [original](https://github.com/Marvisak/VIctory/pull/3403#issuecomment-7205536444) 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!
Author
Owner

@⁠andrewpozdnakov7-jpg on GitHub · 2026-11-26 23:33 UTC · original

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]>.

**@⁠andrewpozdnakov7-jpg** on GitHub · 2026-11-26 23:33 UTC · [original](https://github.com/Marvisak/VIctory/pull/3403#issuecomment-7205639886) 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]>`.
Author
Owner

@⁠Texbirds on GitHub · 2026-11-26 23:38 UTC · original

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** on GitHub · 2026-11-26 23:38 UTC · [original](https://github.com/Marvisak/VIctory/pull/3403#issuecomment-7205718968) 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!)
Author
Owner

@⁠Texbirds on GitHub · 2026-11-26 23:45 UTC · original

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).

**@⁠Texbirds** on GitHub · 2026-11-26 23:45 UTC · [original](https://github.com/Marvisak/VIctory/pull/3403#issuecomment-7205823586) 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).
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-27 00:16 UTC · original · requested changes

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).

**@⁠fuzeofficlal** on GitHub · 2026-11-27 00:16 UTC · [original](https://github.com/Marvisak/VIctory/pull/3403#pullrequestreview-6081899375) · **requested changes** 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`).
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3403/head:github-bot/gh-3403'
git switch 'github-bot/gh-3403'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3403'
git switch 'github-bot/gh-3403'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3403'
git switch 'github-bot/gh-3403'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3403'
git switch 'main'
git merge --squash 'github-bot/gh-3403'
git switch 'main'
git merge --ff-only 'github-bot/gh-3403'
git switch 'main'
git merge 'github-bot/gh-3403'
git push origin 'main'
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/Marvisak--VIctory!3403
No description provided.