Skip to content

shader: image stores of some channels, and image_store_mip to level 0 (port of Marvisak/VIctory#1955) - #248

Merged
pragyaangaur merged 3 commits into
pragyaangaur:mainfrom
earpjonathan:shader/partial-image-stores
Nov 26, 2026
Merged

pragyaangaur merged 3 commits into
pragyaangaur:mainfrom
earpjonathan:shader/partial-image-stores

Conversation

@earpjonathan

@earpjonathan earpjonathan commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

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 every image_store whose dmask wasn't 0xF and dropped the program's pipelines.

What it does (from upstream's commits)

  • Stores of some channels. The data VGPRs hold only the enabled channels, in channel order (with d16, two per VGPR). Each dword now goes to its channel, and the channels left out are written as 0, as the ISA guides describe DMASK. The host store still writes all four channels with a 0xF mask, because dxil.dll refuses narrower masks on typed UAV stores.
  • image_store_mip at 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 in emit/host.rs was between main's separate TextureUav arm 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.
  • With each data dword read from its channel's register instead of its index's, 4 of the 5 fail on D3DMetal, so the tests catch a wrong mapping there.
  • On this branch, rebased onto main b680692:
    • Wine: 1046 passed, 1 failed, 21 ignored. The failure is xmem::low_guards::tests::a_released_guard_is_guarded_again_around_what_took_it in victory-hle, which this branch doesn't touch. It passed 10 of 10 when run alone.
    • Native: 524 passed, 0 failed.
    • Clippy on the Windows target, with and without --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

RaghavVijayanand and others added 3 commits November 26, 2026 09:57
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>
@pragyaangaur
pragyaangaur merged commit 197314f into pragyaangaur:main Nov 26, 2026
1 check passed
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.

3 participants