Repository navigation
rdna2spirv: image_store packs a 1_5_5_5_UNORM texel for #7604's R16_UINT storage view - #7878
tibzejoker wants to merge 2 commits into
Conversation
…B5 has no storage
A B5G5R5A1_UNORM texture with ALLOW_UNORDERED_ACCESS was refused on a GPU whose
VK_FORMAT_A1R5G5B5_UNORM_PACK16 has no STORAGE_IMAGE (NVIDIA): GetResourceAllocationInfo answered
UINT64_MAX and creation failed. A title's boot creates a 2560x1440 render-target + UAV one and
asserts on that size.
The R9G9B9E5 route generalizes: Format::r9g9b9e5_as_r32_uint becomes Format::uint_backed, the format
a UAV texture stored as a mutable unsigned image is viewed in (E5B9G9R9 for R32_UINT, A1R5G5B5 for
R16_UINT). For B5G5R5A1 the image is R16_UINT with {R16_UINT, A1R5G5B5} listed; its storage view is
R16_UINT in the uint class, SRVs are A1R5G5B5 sampled views, and RTVs and clears go through an
A1R5G5B5 attachment view (ResourceBinding::uint_backed lets replay's color_view_format take it). The
SRV and UAV T#s keep the 1_5_5_5_UNORM format. A shader store still needs the translator to pack
the bits for that view, so CheckFeatureSupport does not advertise the typed UAV yet.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…storage view Where VK_FORMAT_A1R5G5B5_UNORM_PACK16 has no storage support the D3D12 layer backs a B5G5R5A1_UNORM UAV texture with a mutable R16_UINT image whose storage view is in the uint class, and its T# keeps FORMAT 134 (ItsNotRexed#7604). A translated image_store picked the float view for that format, which is then the fallback, so the store was lost. The T# does not say which image is behind it, so an image_store whose FORMAT is 134 at run time now stores twice at the same index: the float texel through the float view as before (the image itself on a GPU that stores A1R5G5B5), then the texel packed through the uint view. The view the runtime did not bind is the 1x1 fallback, as on a lookup miss. The word has the A1R5G5B5 layout (component 0 in bits 14:10, 1 in 9:5, 2 in 4:0, 3 in bit 15), each channel clamped to [0, 1] with NMax/NMin (a NaN is 0) and rounded to nearest. Other formats keep their single store. - tests/semantic/test_image_store_1555.py runs the fixture image_store_1555.asm in spirv_mini_interp, which gains OpImageWrite on bound storage images. 8 of its 9 tests fail on the translator before this change. - test_image_coherent, test_image_cube_store_glc and test_image_store_dmask count the writes of an image_store and now expect the packed one. - runtime/test/d3d12_b5g5r5a1_store_test dispatches cs_b5g5r5a1_store.asm through the layer and reads 256 texels back as packed 16-bit values (RTX 4090, validation layer, 0 errors; 248 texels differ with the translator before this change). - docs/design.md: contract row "Packed 1_5_5_5 image stores". Depends on: ItsNotRexed#7604 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested ef3eca6 on Arch Linux, Python 3.14.10, CPU only: pass — new tests/semantic/test_image_store_1555.py 9/9 OK. Negative control: merge-base translator → 142 failures; restored, green again. GPU note: the cs_b5g5r5a1_store fixture translates + passes spirv-val here, but run_gpu_tests skips it by design (SKIP: run by d3d12_b5g5r5a1_store_test) — that D3D12 test needs a Windows runner, still open for one. No game files. AI-assisted. |
|
Tested Tools: llvm-mc 23.1.6 (conda-forge
AI-assisted (Hermes agent). No game files used. |
|
Additional native-path check: on AMD RX 6600 XT (Windows, driver 32.0.21045.16010), d3d12_b5g5r5a1_store_test passed 256/256 synthetic texels with Vulkan validation enabled and zero errors. Full report: #166 (comment). This GPU supports native A1R5G5B5 storage, so this run does not exercise the R16_UINT fallback. No game files; AI-assisted (Codex). |
gut0to
left a comment
There was a problem hiding this comment.
The format-specific pack path runs only for T# format 134, keeps the existing float store, and adds the packed uint store for the mutable R16_UINT fallback. The packer clamps before scaling, rounds with +0.5 then truncates, places alpha in bit 15, and the final SPIR-V pass decorates float arithmetic with NoContraction. Ran est_image_store_1555.py (9 passed) and est_image_store_dmask.py (13 passed) on this PR head.
|
Same-build native/fallback storage check at
Zero validation errors on either path. The shipped synthetic shader also passed |
Claimed in the coordination issue: #7599 (comment) (@NiiRoZz's open item, the translator half of #7604).
Depends on: #7604 (this branch is one commit on top of it).
What and why
With #7604, a
B5G5R5A1_UNORMUAV texture on a GPU with noA1R5G5B5storage (NVIDIA) is a mutableR16_UINTimage, and its storage view isR16_UINT. The translator still stored float texels through the float view, so shader writes to that UAV never reached the image: 248 of 256 texels were wrong in the new GPU test.image_storealready reads T# word 1 FORMAT [28:20] to pick the float, uint or sint view.1_5_5_5_UNORM), the store also packs the texel to 5-5-5-1 UNORM and writes(word, 0, 0, 0)through the uint view at the same coordinates (Gen.pack_1555_unormintools/rdna2spirv.py). The bit layout is component 0 in bits 14:10, 1 in 9:5, 2 in 4:0 and 3 in bit 15, matching d3d12: B5G5R5A1 UAV textures are mutable R16_UINT images where A1R5G5B5 has no storage #7604's readback (red clear0xFC00, green0x03E0). The conversion istrunc(clamp(x, 0, 1) * max + 0.5), with the clamp done byNMax/NMin, so a NaN stores 0. dmask andd16are covered. Other formats keep their single store,5_5_5_1_UNORM(135) included.docs/design.md("Packed 1_5_5_5 image stores"), plus a note indocs/d3d12_vulkan.md.A compromise to review
The T# can't tell whether the image behind a format-134 descriptor is a native
A1R5G5B5image (float view) or #7604'sR16_UINTbacking (uint view only). So the store is written twice: the unchanged float store and the packed uint store. Whichever view the runtime didn't bind is the 1x1 fallback, as on a lookup miss, so a GPU with native storage keeps working with no layer change. The cost is one extra store to a fallback image for format-134 T#s. The alternative is a contract where a format-134 storage image is alwaysR16_UINTin the uint class, which would mean changing #7604's layer to back B5G5R5A1 UAVs that way on every GPU. I'd rather the reviewers pick.Open points, not done here:
glc)image_loadfrom anR16_UINT-backed 1_5_5_5 image reads the float fallback. This is noted in the design row and left as a follow-up.CheckFeatureSupportstill doesn't advertise the typed UAV. Only the doc sentence is updated.Tested
RTX 4090, driver 617.42, Windows 11 26200, MSVC 2022 RelWithDebInfo:
LEONIDA_VK_VALIDATION=1: newd3d12_b5g5r5a1_store_test(a hand-writtencs_b5g5r5a1_store.asmtranslated and dispatched through the D3D12 layer). All 256 texels stored to aB5G5R5A1_UNORMUAV through theR16_UINTview match the CPU reference, with 0 validation errors. The inputs cover every level of every channel, quarter-step offsets, out-of-range values, infinities and NaN. Without this change: 248 of 256 wrong.d3d12_b5g5r5a1_uav_testandd3d12_m4_compute_teststill pass.vk_store_testoncs_imgstore/cs_imgload(rgba8, r32 uint, r32 sint) gives 0 bad texels.test_image_store_1555(9 tests; 8 fail before this change).spirv_mini_interp.pygainsOpImageWriteon bound storage images. Three existing tests that counted animage_store's writes now expect the packed one. 447 files, 5,960 tests, 2 files failing:test_image_atomics_guardandtest_image_store_d16, which fail identically onpr-7604without this change.No game data: the fixtures are hand-written. AI-assisted: yes (Claude Code).
🤖 Generated with Claude Code