Repository navigation
Shaders: image stores of some channels, to mip 0, and to integer views - #1955
RaghavVijayanand wants to merge 4 commits into
Conversation
|
Automated triage for the maintainers. This pull request no longer merges cleanly into Generated by Claude Code |
3c5df8e to
6abd8ff
Compare
catminou4
left a comment
There was a problem hiding this comment.
Tested locally: macOS arm64, rustc 1.98.1, PR head merged into main 940d32f, cargo test -p victory-shader --locked.
144 passed / 0 failed / 2 ignored. Image stores of some channels, to mip 0, and to integer views — partial-channel store lowering.
|
Test report: RTX 5060 Ti (Blackwell), Windows 11 Pro 26200, driver 621.24. Branch at |
Offline measurement on a retail dumpResult: no count change against I merged head 6abd8ff onto No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right. No shader names or data are included, per the asset policy. AI-assisted (Claude Code). |
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.
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.
Every image store went to DXIL's textureStore.f32 on a handle of four F32 channels, whatever the view's format; the console converts by the format, which is in the descriptor the program reads when it runs, so the translator cannot see it. One thing does tell: an image atomic in the same program on the same descriptor (the same source, or another load of the same table entry), as the host's typed atomics take only R32_UINT and R32_SINT views (and R32G32_UINT for main's 64-bit image atomics). Stores to such a view now go to textureStore.i32 on a handle of four U32 channels, with the data VGPRs as integers and, with d16, each 16-bit half zero-extended rather than converted as an f16 (a shortcut for signed formats wider than 16 bits, noted at the store). Every other store stays a float store, a shortcut noted at the store: D3D leaves a float store to an integer view undefined. On the default hardware adapter and WARP, the tests show such stores writing their dwords to RGBA32_UINT and R32_UINT views unchanged, denormal and NaN patterns included; d16 data there is still converted as f16. Handles were cached per block by descriptor and resource kind only, so an atomic's U32 handle and a float access's F32 handle of the same descriptor in one block shared whichever came first (main's atomics annotate (kind | UAV, 0x105), a store (kind | UAV, 0x409): the same first dword); the cache key now holds both annotated property dwords. Tests: in emit/image_store_tests.rs, a program first adds 0 to the texel with image_atomic_add through a second load of the descriptor, then stores to an R32_UINT view: dwords with denormal and NaN patterns, and d16 halves (5 and 0xFFFF), which as f16 would land as 0x34a00000 and a NaN. Validated with dxil.dll and run on the default hardware adapter and WARP. With the integer path turned off, or with only the same-source match kept (not the same table entry), the test fails on the d16 case.
6abd8ff to
43229cd
Compare
|
Rebased onto |
lower.rs grew past the repository's 512 KiB file limit with this branch on top of main; the descriptor check moves to lower/images.rs unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Three image-store refusals in the translator. Each is its own commit, and each builds and passes tests.
image_store_mip: a level that is a constant 0 stores to the view's own level. A non-zero or computed level is still refused, because it would need a view per level.textureStore.i32. Integer views with no atomic still get a float store; that is documented.Tests: the new
emit/image_store_tests.rs(6 tests) covers:Each program is validated with dxil.dll and run on the default hardware adapter and WARP. Each fix was broken on purpose to confirm a test fails. The test host gains
View::Uint4TextureUav(RGBA32_UINT) beside main'sUint2TextureUav. The integer-store detection also treats main's 64-bit atomics (R32G32_UINT) as proof of an integer view.This PR and #1956 (cube/MSAA) both touch
image()inemit/lower.rs, so merging both needs a small manual merge.Rebased onto current main (940d32f). On this machine, 5 tests fail on main itself, with or without this change:
descriptor::host::tests::dynamic_slots_are_held_until_released,memory::tests::lists_share_a_table_and_copies_keep_their_views, the twostride_tests::a_heap_buffer_read_*tests, andsynthetic_tests::gathers_at_a_level_match_the_hardware. Everything else passes, and clippy passes with-D warnings, with and without--all-features.