Skip to content

Fetch explicit 2D mips with the image view's numeric type - #1276

Merged
ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
evilclanker9000:codex/typed-image-load-mip
Nov 22, 2026
Merged

ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
evilclanker9000:codex/typed-image-load-mip

Conversation

@evilclanker9000

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: #1218 (comment)

What and why

On main after #1153, ordinary image_load selects a sampled image type from the T# FORMAT field. The 2D image_load_mip path still did every fetch through a float image. Drawing with a UINT or SINT image view raised VUID-vkCmdDraw-format-07753 on both tested adapters. SPIR-V validation alone passed on the original shader.

Use the same numeric-type selection for the 2D explicit-mip instruction and supply its third address VGPR as the mip operand on each fetch. The regression shader checks binding 0, all three sampled types, and that each fetch reads the mip from v6. On main it fails because the integer fetches are missing. This change covers 2D; 3D partial-volume work in #773 is separate.

Tested

Windows 11, RTX 5080 (616.92, Vulkan 1.4.351) and AMD Radeon Graphics (32.0.21045.16010, Vulkan 1.4.315). The synthetic fragment shader used 2D image_load_mip and exported all four channels to RGBA32F. Integer shaders converted the returned words with v_cvt_f32_u32 or v_cvt_f32_i32. Six pixel shader inputs (three formats × two mip operands) translated and passed spirv-val before and after. Full game-corpus counts were not measured.

I ran a two-level version of vk_image_fuzz with no sampler, an 8×8 zero base level and a 4×4 second level. Level 1 at (x,y) contained bytes (128+x, 240+y, 80+x+4y, 200+2x+y). The reference selected a texel for every output pixel and decoded all four channels for the view format.

R8G8B8A8 view, explicit mip 1 GPU-assisted validation before, each GPU After, each GPU
UINT VUID 07753, exit 1 4096/4096 pixels match, exit 0
SINT VUID 07753, exit 1 4096/4096 pixels match, exit 0
UNORM 4096/4096 match, exit 0 4096/4096 pixels match, exit 0

The first UINT pixel was (128,240,80,200); SINT was (-128,-16,80,-56). Forcing mip 0 changed every one of the 4,096 pixels for each format on each adapter. With GPU-assisted validation disabled, both drivers already happened to return the expected numbers on main.

The typed-load and image-fuzzer Python tests passed (50 tests, 12 subtests), as did the gfx10_descriptors CTest.

Checklist

  • No game data, keys or decryption, including in logs or reports quoted here.
  • The translator rule and its hardware verification are in the existing typed image loads row of docs/design.md.

AI-assisted implementation and testing.

Fetching an integer view through a float OpTypeImage violates the Vulkan draw contract even on drivers that return the expected bits. Reuse the typed fetch selection and pass the guest mip register to each branch.
@kapitche

Copy link
Copy Markdown
Contributor

Tested on Windows 11 with two GPUs on one machine (runtime built from this PR's head, MSVC 14.51, llvm-mc 23.1.6): pass.

  • pytest tests/test_image_load_typed.py tests/test_translate.py: 339 passed. With main's tools/rdna2spirv.py, 1 fails. ctest: 59/59.
  • GPU results:
RTX 4080 SUPER Intel UHD 770
--filter cs_img (cs_imgload, cs_imgload_d16, cs_imgstore) 3/3 3/3
image_fuzz.py --self-test + --programs 30 --seed 1 ok, 30/30 match ok, 30/30 match

On the Intel iGPU (no shaderStorageImageReadWithoutFormat), cs_imgload_d16 now passes, where it used to exit 77. So the typed path from #1153 holds for the explicit-mip and d16 loads too.

@evilclanker9000

Copy link
Copy Markdown
Contributor Author

Thanks for the Intel regression check. One detail for the hardware record: cs_imgload/cs_imgload_d16 and the stock image fuzzer execute image_load at level 0. They cover the shared typed path. The explicit image_load_mip level-1 pixel check in this PR was run on the RTX 5080 and Radeon Graphics; UHD 770 explicit-mip pixels are still unmeasured.

@ItsNotRexed
ItsNotRexed merged commit e7854c9 into ItsNotRexed:main Nov 22, 2026
11 checks passed
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.

3 participants