Shaders: lower image_store with contiguous partial channel masks (dmask 0x1, 0x3, 0x7) #920
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory#920
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@davi713albano-coder on GitHub · 2026-11-24 14:10 UTC · original
### Summary
Lowers
image_storewith contiguous partial channel masks (dmask=0x1,0x3,0x7, and no-op0x0, both 32-bit float andd16packed 16-bit) incrates/victory-shader/src/emit/lower.rs, unlocking shaders that store to 1-, 2-, and 3-channel float/unorm/snorm UAVs (RWTexture*<float>,float2,float3) instead of failing withan image store of some channels.Because external PR creation is restricted (
collaborators_only), the CI-green branch is ready on my fork:f1c423f(based onmainffe310e, 2 files, +218/-9)Changes
crates/victory-shader/src/emit/lower.rs:dmask == 0forimage_store(emitting a no-op instead of defaulting to channel 0 as loads/samples do).0x1,0x3,0x7,0xF(rejecting sparse/non-contiguous masks such as0x5because DXIL typed UAV stores cannot perform partial read-modify-write stores without clobbering lower channels).dmask.count_ones()packed VGPRs (or half-VGPRs ford16), zero-pads trailing channels with0.0f32, and emitsdx.op.textureStore.f32with write mask0xFas required by the DXIL validator (store on typed uav must write to all four components of the UAV); host D3D12 drops extra components according to the bound UAV format.crates/victory-shader/src/emit/valu_tests.rs: addsimage_store_partial_dmask_writes_expected_channels.Tests & Verification
image_store_partial_dmask_writes_expected_channelsexercises:dmask = 0x5withUnsupported("an image store of some channels").dxil.dll) and live D3D12 UAV readback acrossdmask=0x0,0x1,0x3,0x7(32-bit float) and0x1,0x3,0x7(d16packed f16).Verified on GitHub Actions (
windows-latest) using upstreamci.yml(cargo clippy --workspace --all-targets --locked -- -D warnings,--all-features, andcargo test --workspace --lockedincludingxtaskasset-policy check):victory-shader: 121 passed, 0 failed (full workspace: 343 passed, 0 failed, 6 ignored)Not tested: live title execution.
No game data used. AI-assisted.
@fuzeofficlal on GitHub · 2026-11-24 14:20 UTC · original
RDNA 2 defines sparse
image_storemasks such as0x9. The selected components are packed into consecutive VGPRs and unselected components are written as zero. AMD RDNA 2 ISA, Table 41 and section 8.2.5#332 already implements this for sparse masks while emitting the full
0xFwrite required by DXIL. I verified its current head (a5b0dcb) with0x9f32 and0xbd16 against an initialized RGBA32F UAV. Windows hardware and WARP both overwrote the disabled channels with zero, and both shaders passed DXIL validation. The test and results cover nonzero masks.@MichaelSmithAI on GitHub · 2026-11-24 14:25 UTC · original
Independent four-channel readback on RTX 4090 under Wine/vkd3d-proton 3.2: exact f1c423f refuses sparse mask
0x5. With sparse lowering added to that branch, the f32 case returned[1.5, 0, -2.25, 0], and packed d16 mask0xdreturned[1.5, 0, -2, 4]. All eleven fixture cases matched their complete expected texels. For the zero-mask control, the shader first stored four distinct nonzero values and all four survived the second store. That checks the branch’s no-op behavior independently of the texture’s initial contents.The existing #332 Windows hardware and WARP result already verifies nonzero sparse masks against an initialized UAV. These Wine results add different masks and the seeded zero-mask control. We have no title shader or rendered frame attributed to this change.
@davi713albano-coder on GitHub · 2026-11-24 17:22 UTC · original
Thanks @fuzeofficlal and @MichaelSmithAI for the RDNA 2 ISA reference and the RTX 4090 check!
Updated the branch (
0c5a47d) to lower all non-zeroimage_storechannel masks (0x1..=0xF), including sparse masks:d16) and fills disabled channels with0.0f32before emittingtextureStore.f32(..., 0xF).image_store_partial_dmask_writes_expected_channelsto assert full 4-channel RGBA readback across0x0,0x1,0x3,0x7, sparse0x5([1.5, 0, -2.25, 0]), sparse0x9([1.5, 0, 0, 4.0]), andd160x1,0x3,0x7, sparse0xD([1.5, 0, -2.0, 4.0]).Verified on GitHub Actions (
windows-latest, upstreamci.yml— clippy-D warningswith and without--all-features,cargo test --workspace --locked, asset-policy check):victory-shader: 121 passed, 0 failed (full workspace: 343 passed, 0 failed, 6 ignored)@Marvisak on GitHub · 2026-11-25 06:57 UTC · original
Automated triage for the maintainers.
On
main,image_storewith any mask other than all four channels is still refused with "an image store of some channels" (crates/victory-shader/src/emit/lower.rs). Open PR #332 ("Shaders: lower partial-channel image_store") already lowers these masks, sparse ones included, and has Windows hardware and WARP results, so review can continue there. Your updated branch (0c5a47d) now does the same, so it can be compared with #332; please bring any test it has that #332 lacks to that PR.Generated by Claude Code