Skip to content

Shaders: lower image_store with any non-zero channel mask (including sparse) - #146

Open
davi713albano-coder wants to merge 1 commit into
fxceless:mainfrom
davi713albano-coder:shader/image-store-partial-dmask
Open

davi713albano-coder wants to merge 1 commit into
fxceless:mainfrom
davi713albano-coder:shader/image-store-partial-dmask

Conversation

@davi713albano-coder

Copy link
Copy Markdown

Summary

Lowers image_store for all non-zero channel masks (0x1..=0xF, including sparse masks such as 0x5, 0x9, 0xD, both 32-bit float and d16 packed f16) and treats dmask == 0 as a no-op (without normalizing it to 0x1 as loads/samples do).

In RDNA2, image_store packs only the channels enabled by dmask into consecutive VGPRs (or 16-bit halves when d16 is set) and writes 0.0 to disabled channels. DXIL typed UAV dx.op.textureStore.f32 requires a full 0xF write mask on 4-component declarations (the host format drops channels past its width), so disabled channels are zero-padded with 0.0f32.

Changes

  • crates/victory-shader/src/emit/lower.rs:
    • Keep dmask == 0 intact for image_store (returning Ok(()) as a no-op instead of normalizing to &1).
    • Unpack consecutive VGPRs / d16 halves for each enabled bit in dmask (0x1..=0xF), zero-padding unselected channels with 0.0f32, and emit dx.op.textureStore.f32(..., 0xF).
  • crates/victory-shader/src/emit/valu_tests.rs:
    • Add synthetic compute test image_store_partial_dmask_writes_expected_channels testing 10 cases (0x0, 0x1, 0x3, 0x7, sparse 0x5, 0x9, and d16 0x1, 0x3, 0x7, 0xD) against dxil.dll validation and live D3D12 WARP 4-channel RGBA readback.

Verification

  • Fork CI (windows-latest): https://github.com/davi713albano-coder/victory-fork/actions/runs/45494029704
    • cargo clippy --workspace --all-targets --locked -- -D warnings: passed
    • cargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passed
    • cargo test --workspace --locked (including xtask asset-policy check, dxil.dll validation, and D3D12 WARP readback): 497 passed, 0 failed (emit::valu_tests::image_store_partial_dmask_writes_expected_channels ... ok)

(No title data used. AI-assisted.)

JustDownTV pushed a commit to JustDownTV/victory-gta6 that referenced this pull request Nov 24, 2026
@HAL9000RELOADED

Copy link
Copy Markdown

RX 7900 XTX (RDNA3), Windows 10 + #402 for SM 6.6, main d510ee4: the new test image_store_partial_dmask_writes_expected_channels passes on the card with this PR, and fails with the test alone on the base. No other test changed. Run table: #129 (#129 (comment)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants