Repository navigation
shader: image stores of some channels, and image_store_mip to level 0 (port of Marvisak/VIctory#1955) - #248
Merged
pragyaangaur merged 3 commits intoNov 26, 2026
Conversation
An image_store whose dmask left out a channel stopped the program ("an
image store of some channels"). Its data VGPRs hold the enabled channels
only, in channel order (d16: two per VGPR, low half first), and the
console writes the channels left out as 0 (the ISA guides' DMASK
description; LLVM trims zero channels from image stores on the same
grounds). The store now maps each data dword to its channel and writes 0
to the others. The host's store still writes all four channels with a
0xF mask: dxil.dll refuses a typed UAV store with a narrower mask ("store
on typed uav must write to all four components of the UAV"), which was
checked by emitting the dmask as the mask.
Tests: emit/image_store_tests.rs hand-assembles a compute program that
fills texel (1, 1) of a 2x2 texture UAV with a four-channel store, then
stores to it with the dmask under test; the program is validated by
dxil.dll and run on the default hardware adapter and WARP, and the whole
texture is read back. They cover all fifteen dmasks on RGBA32_FLOAT,
seven d16 dmasks, and RGBA32_UINT and R32_UINT views with denormal, NaN
and negative-zero bit patterns (which reach the integer views unchanged
through the float store on both). The host harness gains an RGBA32_UINT
texture UAV, and texture readback takes each view's format. With each
data dword put in the channel of its index rather than its channel's,
all three tests fail.
(cherry picked from commit 98e806f41528c7cd4d81195cbd688b4153b75e7a)
image_store_mip stopped the program ("an image store to a mip level").
Its level, the address after the coordinates, counts from the
descriptor's base level, and DXIL's textureStore has no level: a UAV
views a single level. Taking the host's view to be the one the title
made for that base level, a store to level 0 is a store to the view, and
now lowers as image_store does (the level read as a constant, either half
with 16-bit addresses). Another level would need a view per level, which
the title's heap does not hold; it, and a level the program computes,
still stop the program, now with "an image store to a mip level other
than 0 or unknown". The packed stores (image_store_pck, _mip_pck), which
also stopped it under the old message, now stop it with their names.
Tests: in emit/image_store_tests.rs, image_store_mip with an inline 0
level is validated by dxil.dll and run on the default hardware adapter
and WARP (RGBA32_FLOAT dmasks 0xF and 0x9, R32_UINT dmask 0x1), and
levels 1 and a root constant are checked to stop the program. With the
check loosened to accept any constant level, the second test fails.
(cherry picked from commit 6e76ec3e18f2b6471dae563b41310b13b870ec0b)
The ported tests' lowering options gain the four fields main added (atomic_locks, bias_as_gradients, host_wave32, narrow_waves), and main's zeroing helper in the test host takes each texture's format, which the port's footprint now needs. Under CrossOver 26.3's Wine with D3DMetal 4.0 beta 3 on an M5 Pro, the five tests pass on the hardware adapter (WARP and dxil.dll are not there). With each data dword read from its channel's register instead of its index's, four of them fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A port of the first two commits of RaghavVijayanand's open upstream PR Marvisak/VIctory#1955, cherry-picked with authorship kept (
-x). pedrofort's M5 run in #133 and #50 hit "partial-channel image stores": the translator refused everyimage_storewhose dmask wasn't 0xF and dropped the program's pipelines.What it does (from upstream's commits)
image_store_mipat a constant level 0 stores to the view's own level. Other levels, and levels computed at run time, are still refused, now with a clearer message.Left out: upstream's third commit, integer stores to views that an image atomic shows are integer. It also changes the handle-cache key, and this repository's main has reworked that code since (entry and join handle caches). It deserves its own port and its own check of those caches.
My commit adds the four lowering options main added since upstream's base (
atomic_locks,bias_as_gradients,host_wave32,narrow_waves) to the test's initializer. It also passes each texture's format to main's zeroing helper in the test host, which the port's footprint change needs. The conflict inemit/host.rswas between main's separateTextureUavarm and upstream's merged arm. I kept upstream's arm with main's copy-destination zeroing.Tested under CrossOver 26.3's Wine with D3DMetal 4.0 beta 3 on an M5 Pro:
emit::image_store_tests: 5 passed on the hardware adapter. These cover all 15 dmasks on RGBA32_FLOAT, 7 d16 dmasks, integer views, and mip level 0, and they check that levels 1 and computed levels are still refused. WARP and dxil.dll aren't available under Wine, so those parts are skipped.xmem::low_guards::tests::a_released_guard_is_guarded_again_around_what_took_itin victory-hle, which this branch doesn't touch. It passed 10 of 10 when run alone.--all-features: no warnings.Upstream's notes still apply: the zeros for missing channels follow the ISA guides and LLVM, and haven't been checked on console hardware. None of this ran in the game.
🤖 Generated with Claude Code