Shaders: lower image_store with any non-zero channel mask (including sparse) #146
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/146"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from fxceless/victory-fork. Originally posted by davi713albano-coder on 2026-11-24T21:50:48Z.
Summary
Lowers
image_storefor all non-zero channel masks (0x1..=0xF, including sparse masks such as0x5,0x9,0xD, both 32-bit float andd16packed f16) and treatsdmask == 0as a no-op (without normalizing it to0x1as loads/samples do).In RDNA2,
image_storepacks only the channels enabled bydmaskinto consecutive VGPRs (or 16-bit halves whend16is set) and writes0.0to disabled channels. DXIL typed UAVdx.op.textureStore.f32requires a full0xFwrite mask on 4-component declarations (the host format drops channels past its width), so disabled channels are zero-padded with0.0f32.Changes
crates/victory-shader/src/emit/lower.rs:dmask == 0intact forimage_store(returningOk(())as a no-op instead of normalizing to&1).d16halves for each enabled bit indmask(0x1..=0xF), zero-padding unselected channels with0.0f32, and emitdx.op.textureStore.f32(..., 0xF).crates/victory-shader/src/emit/valu_tests.rs:image_store_partial_dmask_writes_expected_channelstesting 10 cases (0x0,0x1,0x3,0x7, sparse0x5,0x9, andd160x1,0x3,0x7,0xD) againstdxil.dllvalidation and live D3D12 WARP 4-channel RGBA readback.Verification
windows-latest): https://github.com/davi713albano-coder/victory-fork/actions/runs/45494029704cargo clippy --workspace --all-targets --locked -- -D warnings: passedcargo clippy --workspace --all-targets --all-features --locked -- -D warnings: passedcargo test --workspace --locked(includingxtaskasset-policy check,dxil.dllvalidation, 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.)
Imported from fxceless/victory-fork. Originally posted by HAL9000RELOADED on 2026-11-25T19:29:47Z.
RX 7900 XTX (RDNA3), Windows 10 + #402 for SM 6.6, main
d510ee4: the new testimage_store_partial_dmask_writes_expected_channelspasses on the card with this PR, and fails with the test alone on the base. No other test changed. Run table: #129 (https://github.com/fxceless/victory-fork/pull/129#issuecomment-7172358511).Imported from fxceless/victory-fork. Originally posted by Castyan on 2026-11-26T14:20:10Z.
Thanks for this change. It is ported to DexNom/VIctory#64 as
90580ec(authorship kept), with one adaptation: the test'sHostShadergets two fields that tree adds (written_root_uavs,writes_guest_memory).How it does on real code there: the compute programs a title passes to device method 0x218 use partial
image_storemasks a lot. Of 200 such descriptions captured in game, 60 were refused as "an image store of some channels". With this change all of them get past image stores, and your 10-case test passes on an RTX 5060 and on WARP.The same rule (given channels first, the others written as 0) was applied to typed buffer stores of fewer than four channels (
buffer_store_format_x/xy/xyz/d16_x), with a readback test on a typed RGBA16F buffer. If you find a hardware reference that contradicts the zeroed channels, it would affect both.Details: https://github.com/DexNom/VIctory/pull/64#issuecomment-7194648018
🤖 Generated with Claude Code
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.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.