Shaders: lower partial-channel image_store #332
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/332"
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 Marvisak/VIctory. Originally posted by tarcisioads on 2026-11-24T02:21:27Z.
Support partial-channel
image_store(dmask != 0xF,dmask != 0) incrates/victory-shader/src/emit/lower.rs:v[reg..]registers (for both 32-bit andd16packed f16), pad missing channels with0.0f(self.s.m.f32(0)), and pass0xFas thewriteMaskargument ofdx.op.textureStore.f32(matching RDNA2MIMG DMASKsemantics and the DXIL validator's typed-UAV rule).image_storewithdmask == 0explicitly ("an image store with no channels").partial_channel_image_store_lowerscovering0x0refusal, 32-bit partial masks (0x1,0x3,0x5), andd16partial mask (0x7, encoded at word 1 bit 31) withunorm = 1(word 0 bit 12), verifyingSFI0RESOURCE_HEAPemission.Verification
cargo test -p victory-shader(119 passed, 0 failed, 1 ignored benchmark on macOS; Windowsdxil.dllvalidation not run)cargo xtask policy(ok)Imported from Marvisak/VIctory. Originally posted by r4tedx on 2026-11-24T03:14:29Z.
Review note: the partial mask is passed through to DXIL (
args.push(self.s.m.i8(*dmask))), and the DXIL validator rejects that for a typed UAV. Adding validation to this PR's own fixture (dxil.dll from the Windows SDK, RTX 5070 machine) fails on the first store, mask1, withThe console's rule for the channels left out is in the RDNA 2 ISA (MIMG
DMASK): "Writes: defines which components are written with data from VGPRs (missing components get 0). Enabled components come from consecutive VGPRs." So the DXIL store needs mask0xFwith zeros in the channels the dmask leaves out, and the data VGPRs are the enabled channels in order (fordmask = 0x5, red is in VGPRn and blue in VGPRn+1). #160 does it that way.D3D12 only checks the container hash, so a driver may still take the module; that is why the test passes without the validator.
From the documents and synthetic tests only; I have no copy of the title and have not run this on console hardware.
Imported from Marvisak/VIctory. Originally posted by tarcisioads on 2026-11-24T11:18:54Z.
Rebased onto
main(ffe310e) and addressed @r4tedx's DXIL validator feedback ina5b0dcb:dmaskwith0.0f(self.s.m.f32(0)) and pass0xFas thewriteMaskofdx.op.textureStore.f32.cargo test -p victory-shader(97 passed, 0 failed on macOS;dxil.dllvalidation still needs Windows).Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-24T14:20:04Z.
I retested
a5b0dcbon Windows with Microsoft’s DXIL validator and a 1×1 RGBA32F UAV initialized to[7, 8, 9, 10]. Both shaders validated and produced the same results on the default hardware adapter and explicit WARP.dmask=0x9, f32:[1.5, 0, 0, -2.25]dmask=0xb, d16:[1.5, -2, 0, 4]Test commit checks all channels against a nonzero starting texel to distinguish clearing from leaving a channel untouched. It also corrects the existing lowering test’s d16 selector to bit 31 of MIMG word 1. Bit 15 of word 0 controls R128. The changes are confined to tests and the test harness.
victory-shader --libpassed 122 tests with one ignored, and Clippy and the asset check passed.Imported from Marvisak/VIctory. Originally posted by DrDarkDK on 2026-11-24T15:01:23Z.
I extended the initialized RGBA32F readback from
a5541cdwithdmask=0x0and0x1, then ran the same inputs on this PR (a5b0dcb) and the #920 branch (f1c423f). The starting texel was[7, 8, 9, 10].0x0[1.5, 0, 0, 0][7, 8, 9, 10]0x1[1.5, 0, 0, 0][1.5, 0, 0, 0]The results were identical for f32 and packed d16 on native Windows, RTX 4070 Ti and WARP. All compared shaders passed DXIL validation.
On #332, the shared zero-mask normalization changes
0x0to0x1before store lowering. The #920 branch preserves zero for stores and emits no write. A native RDNA2 readback would settle which behavior to carry forward.AI-assisted with Codex.
Imported from Marvisak/VIctory. Originally posted by tarcisioads on 2026-11-24T15:43:07Z.
Updated
shader/image-store-partial-dmasksoimage_storewithdmask == 0is treated as a no-op (returnsOk(())without emittingdx.op.textureStore.f32, matching RDNA2IMAGE_STOREDMASK = 0semantics), instead of being normalized todmask = 1. Addeddmask = 0x0topartial_channel_image_store_lowers;cargo test -p victory-shader(97 passed, 0 failed on macOS).Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T00:28:25Z.
Automated triage for the maintainers.
Needs rebase.
mainhas moved since the last triage, and this PR no longer merges cleanly into it (conflict incrates/victory-shader/src/emit/lower.rs). It will be reviewed again once it is rebased onto currentmain.Previous verdict for this head: merge candidate.
Generated by Claude Code
Imported from Marvisak/VIctory. Originally posted by tarcisioads on 2026-11-25T00:35:12Z.
Addressed all three triage points:
0.0fpadding and0xFwriteMask.d16at word 1 bit 31,unormat word 0 bit 12) and added assertions on the emittedSFI0RESOURCE_HEAPflag anddmask == 0refusal.dmask == 0to refuse ("an image store with no channels") rather than no-op.cargo test -p victory-shader(119 passed, 0 failed on macOS).Imported from Marvisak/VIctory. Originally posted by Machad3x on 2026-11-25T22:02:06Z.
Hardware result: tested at head
0915bf5c. One host: RTX 3080 Ti, driver 621.24, Windows 11, a fork stacking open PRs, Series X mode. Cherry-picked together with #2816 and #2831: the shader tests pass apart from one failure the stack had before (a view heap cap test), and one 7-minute run in play had no device removal. Offline refused containers across the three went from 214 to 213 (not attributed to one PR). On the stack, the added test needed the stack's extraPartsfields.Ran with AI assistance (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.