Skip to content

rdna2spirv: d16 image_load reads integer images through their uint/sint views - #1136

Merged
ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
quackottu:image-load-d16-typed
Nov 22, 2026
Merged

ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
quackottu:image-load-d16-typed

Conversation

@quackottu

Copy link
Copy Markdown
Contributor

A d16 image_load on 1D/2D/2D_ARRAY/3D skipped the T# FORMAT branch that the 32-bit image_load uses (if dim in self.STORE_DIMS and not d16 in tools/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 a Texture2D<min16uint> / min16int Load returned garbage.

d16 loads now go through image_load_typed, which packs the dmask components two per VGPR, low half first (RDNA2 ISA, MIMG D16):

RTX 5070, cs_imgload_d16 (cs_imgload with a d16 read-back) main this PR
r32 uint (uint view) 0 bad 0 bad
r32 sint (sint view) 64 bad, texel(5,3) = 14774 0 bad, texel(5,3) = 129
rgba8 unorm (float view) ok ok

Tests:

  • tests/test_image_load_d16_typed.py (llvm-mc + spirv-val; dmask 0x1/0x3/0x7) checks that the uint/sint OpImageReads are emitted, that there is no PackHalf2x16, and that the module validates. All 3 fail on main and pass here.
  • runtime/test/shaders/cs_imgload_d16.asm is registered in check.py and scripts/run_gpu_tests.py next to cs_imgload. check.py on the RTX 5070 (621.24): 74 of 103 pass, 29 skipped (wave64 on NVIDIA). On main the count is 73, and the only difference is cs_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.

…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.
@LocranKing

Copy link
Copy Markdown
Contributor

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:

  • python scripts/run_gpu_tests.py --filter imgload: 2/2 passed (cs_imgload and this PR's new cs_imgload_d16 PASS on RTX 3060 Ti).
  • Negative control: with ools/rdna2spirv.py from main, cs_imgload_d16 fails (FAIL cs_imgload_d16).
  • git diff --check: clean.

No game files. AI-assisted.

@kapitche

Copy link
Copy Markdown
Contributor

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):

  • pytest tests/test_image_load_d16_typed.py: 3 passed. With main's tools/rdna2spirv.py, all 3 fail. ctest: 54/54 on NVIDIA.

  • RTX 4080 SUPER: cs_imgload_d16 passes:

    • rgba8 unorm (float view), r32 uint (uint view) and r32 sint (sint view) all have 0 bad texels;
    • texel(5,3) = 182 109 127 255 / 129 / 129.
  • Intel UHD 770: cs_imgload_d16 is reported as FAIL, but it's really unsupported. vk_store_test prints unsupported: shaderStorageImageReadWithoutFormat and returns 77. The ("cs_imgload", "cs_imgload_d16") branch in run_gpu_tests.py judges rc == 0 only, so 77 counts as a failure.

    This isn't new: the existing cs_imgload fails the same way on this GPU on main. Since this PR adds a case to that branch, mapping rc == UNSUPPORTED to unsupported_skip(msg) (as the ps_tex and gather branches do) would turn both into proper skips on devices without read-without-format.

@BACONMANXDGOD

Copy link
Copy Markdown
Contributor

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 main c63773d; applied to c63773d (merges cleanly). GPUs: Intel Arrow Lake Xe-LPG iGPU (Windows 32.0.101.8132, subgroup 8..32) and RTX 5070 Ti Laptop (617.42), picked with VK_LOADER_DRIVERS_SELECT.

No game files. AI-assisted (Claude Code).

@ItsNotRexed
ItsNotRexed merged commit fcdf2b3 into ItsNotRexed:main Nov 22, 2026
10 of 11 checks passed
ItsNotRexed added a commit that referenced this pull request Nov 22, 2026
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>
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.

5 participants