Repository navigation
rdna2spirv: d16 image_load reads integer images through their uint/sint views - #1136
Conversation
…nt views A d16 image_load skipped the T# FORMAT branch the 32-bit load uses and always read the float sampled view, which integer images are never bound to, so a min16uint/min16int Load returned garbage (sint texel 14774 for 129 on an RTX 5070). d16 loads now go through image_load_typed and pack the dmask components two per VGPR: f16 from the float view, the 16-bit integer (truncated) from the uint/sint views.
|
GPU check of 1979b94 on Windows 11 Build 26200 x64: NVIDIA GeForce RTX 3060 Ti (driver 621.01, Vulkan 1.4.357), AMD Ryzen 5 5500, llvm-mc 21.1.8, SPIRV-Tools v2026.4:
No game files. AI-assisted. |
|
Tested 1979b94 on Windows 11 with two GPUs on one machine (runtime built from this PR's head, MSVC 14.51, llvm-mc 23.1.6):
|
|
Tested 1979b94: pass on both GPUs. Windows 11 26200, MSVC 19.44, llvm-mc 23.1.6, Vulkan SDK 1.4.363, runtime built from
No game files. AI-assisted (Claude Code). |
test_carry_exec_mask (#1109) and test_wave64_vcc_half_write (#1125) stored through a V# with word3 = 0, which is OOB_SELECT 0 (structured with offset) with stride 0: since #1104 every store is out of range, as on RDNA2, and the tests read back nothing. They now use the raw-buffer V# (OOB_SELECT 3) the other semantic tests use. test_shader_checks counts the third vk_store_test check (#1136) and its fake harness answers it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A d16
image_loadon 1D/2D/2D_ARRAY/3D skipped the T# FORMAT branch that the 32-bitimage_loaduses (if dim in self.STORE_DIMS and not d16intools/rdna2spirv.py). It always read the float sampled view and packed f16 from it. The runtime binds UINT/SINT images only into the uint/sint storage arrays (docs/design.md, "Typed image loads"), and a float view of an integer image is undefined in Vulkan. So aTexture2D<min16uint>/min16intLoadreturned garbage.d16 loads now go through
image_load_typed, which packs the dmask components two per VGPR, low half first (RDNA2 ISA, MIMG D16):pack_f16_pair_int(integer ops, noPackHalf2x16, as Translator: pack d16 image sample/gather results with integer f32->f16 RTE #489);(x & 0xFFFF) | (y << 16), truncating. This is markedshortcut:because AMD may saturate instead (Mesa'sinteger_dest_saturates), which isn't measured.cs_imgload_d16(cs_imgload with a d16 read-back)mainTests:
tests/test_image_load_d16_typed.py(llvm-mc + spirv-val; dmask 0x1/0x3/0x7) checks that the uint/sintOpImageReads are emitted, that there is noPackHalf2x16, and that the module validates. All 3 fail onmainand pass here.runtime/test/shaders/cs_imgload_d16.asmis registered incheck.pyandscripts/run_gpu_tests.pynext tocs_imgload.check.pyon the RTX 5070 (621.24): 74 of 103 pass, 29 skipped (wave64 on NVIDIA). Onmainthe count is 73, and the only difference iscs_imgload_d16.test_translate,test_image_fuzz,test_cube_sample,test_texel_offsets: 382 passed.python -m unittest discover -s tests/semantic: 1101 OK.docs/design.md's "Typed image loads" row gets the d16 rule. Not verified: saturation versus truncation on AMD; d16 on 1D, 2D-array and 3D on a GPU; the high-half packing and the float d16 branch on a GPU (the fixture uses dmask 0x1).AI-assisted.