Repository navigation
Shader: preserve the trailing VGPR high half on odd-component d16 image loads - #1336
freemanovec wants to merge 1 commit into
Conversation
|
Ran independent RGBA32F readbacks on 6fc4588 with RTX 5080 and Radeon Graphics on Windows. R8G8B8A8 UINT, SINT and UNORM each used distinguishable per-texel values. The shader seeded v4=0x5a5aaaaa and v5=0xa5a5bbbb, then exported all four halfwords numerically. Dmask 0x8 (A into v4.lo) and 0xd (R/B/A into v4 and v5.lo) passed all 4096 pixels on both GPUs for each format. Replacing the preserved half in the CPU oracle by zero disagreed at all 4096 pixels in every odd-mask case. Dmask 0x3 also passed with v5 entirely unchanged. At this head image_load_mip D16 still does not produce a fragment module: the PR is based on c0ac5fd before #1308, and GitHub reports a conflict. Please merge current main so the released explicit-mip path uses the same odd-mask handling. I have a two-mip fixture ready for the revised SHA. Related #1340 handles integer saturation independently. |
|
I also exercised explicit mip on a local integration of the executable changes from 6fc4588 onto f85582e (translator blob 9ea4cea5e0ab648c612e1f5272fbd1793726cd6a). The two code/test files applied without conflict; the conflict was in the design table. The two mip levels have distinct channel patterns. On RTX 5080 and Radeon gfx1036, image_load_mip d16 at mip 1 reproduced the expected packed VGPR contents at all 4096 pixels for each of UINT, SINT and UNORM with masks 0x8, 0xd and 0x3. Zeroing the trailing high half in the reference disagreed at all 4096 pixels in all 12 odd-mask cases. The plain image_load cases still matched at mip 0. This result is for the local combination; the PR head itself still predates D16 explicit mip. |
6fc4588 to
be4620e
Compare
|
Rebased onto |
# Conflicts: # docs/design.md
|
Already merged into |
|
Tested be4620e on RTX 5070 (Blackwell, subgroup 32..32), NVIDIA 616.56, Windows 11 Pro 26200: pass. (It conflicts with current main (c2967a5), so this is the PR head.)
Tools: llvm-mc 21.1.8 (WSL), MSVC 19.50, Vulkan SDK 1.4.363.0, Python 3.13. |
Claimed in #1218 (#1218 (comment)) from @Vonsek's finding (#1218 (comment)).
Why
On native RDNA2 (
gfx1036), a 1-component D16image_load/image_load_mippreserves the unused high 16 bits of the destination VGPR (a seeded0x5a5ahigh half survived all four UINT/SINT cases).Gen.image_load_typedpadded odd component counts (1 or 3 indmask) with0, zeroing the trailing VGPR's high half.What changed
Gen.image_load_typed(write()) intools/rdna2spirv.pyto write the trailing odd component throughself.write_lo16(dest, lo)(matching Shader: preserve the last VGPR high half on packed D16 buffer loads #1275's buffer-load rule):self.f16_bits(self.tof(xs[i]))for the float branch andxs[i] & 0xFFFFfor the integer branches. Even component counts continue to write the full packed VGPR.spirv-valtests intests/test_image_load_typed.pyverifying high-half preservation fordmask:0x1anddmask:0x7across all three typed branches, and full writes fordmask:0x3anddmask:0xf.Typed image loadsrow indocs/design.md.Testing
python3 -m compileall -q tools testspython3 -I tests/test_image_load_typed.py -v: 9/9 OK (includingspirv-valv2026.4 ond16dmask:0x1anddmask:0x7)scripts/run_gpu_tests.py --filter imgloadon Intel(R) HD Graphics 530 SKL GT2, Mesa26.2.7-arch1.1ANV, Vulkan1.4.354, Arch Linux,llvm-mc23.1.5):cs_imgloadandcs_imgload_d162/2 pass.