Skip to content

Translate packed D16 explicit 2D mip loads - #1308

Merged
ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
Vonsek:codex/typed-mip-d16
Nov 22, 2026
Merged

ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
Vonsek:codex/typed-mip-d16

Conversation

@Vonsek

@Vonsek Vonsek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: 2D packed explicit mip loads. Follows merged #1276.

What and why

An assembled 2D image_load_mip with D16 was rejected before the explicit mip or image view could be used. Route its result through the packed writer already used for image_load. UINT and SINT channels retain integer bits. Float channels convert to binary16. The added test uses a sparse red/alpha mask and verifies that each of the three numeric paths writes only the first destination VGPR.

Tested

  • Base c0ac5fd rejected the new fixture with Unsupported: image_load_mip 2D. At 78b1119 it translates. Two synthetic pixel programs with explicit mip 1/0 passed spirv-val (Vulkan 1.2) for all three format setups.
  • Windows, RTX 5080 driver 616.92/Vulkan 1.4.351 and AMD Radeon Graphics 32.0.21045.16010/Vulkan 1.4.315, GPU-assisted validation enabled. A local two-mip vk_image_fuzz variant uploaded an 8x8 zero base and a 4x4 level 1 with four distinguishable channels. The source-built pixel shader unpacked each of the four halves and exported an RGBA32F result. Each 64x64 render matched an independent CPU decode on both adapters for R8G8B8A8_UINT, _SINT and _UNORM. Forcing mip 0 produced 4096/4096 mismatches in all six runs. No sampler is used for image fetches.
  • 406 Python tests and 12 subtests passed, 2 skipped. CTest gfx10_descriptors passed. Corpus frequency and native RDNA2 conversion for out-of-range integers remain unmeasured.

Checklist

  • No game data, keys or decryption (including in logs or reports).
  • The translator contract table records the rule and its GPU check.

AI-assisted implementation and verification.

The explicit-mip fetch already selects the sampled view by numeric type. Pass its D16 modifier to the same result writer as image_load so integer components and floating halves retain their representation.
@kapitche

Copy link
Copy Markdown
Contributor

Tested 78b1119 on Linux (WSL2 Ubuntu), Python 3.12, CPU only (no llvm-mc, no GPU): pass.

@freemanovec

Copy link
Copy Markdown
Contributor

Tested 78b11199 on Intel(R) HD Graphics 530 (SKL GT2), Mesa 26.2.7-arch1.1 (ANV), Arch Linux: pass. AI-only review and run.

  • Code review: clean, minimal change — allows d16 on 2D image_load_mip and forwards d16="d16" in mods to image_load_typed; new unit test checks sparse dmask:0x9 across float/uint/sint views and confirms only v0 is written; docs/design.md contract row updated.
  • python3 -I tests/test_image_load_typed.py: 8/8 OK
  • python3 -m unittest discover -s tests/semantic: 1171/1171 OK
  • scripts/run_gpu_tests.py (llvm-mc 23.1.5, SPIRV-Tools v2026.4): cs_imgload + cs_imgload_d16 (2/2 pass), ps_texture_mip0 (1/1 pass), ps_texture_sample_d16 (1/1 pass).

No game files.

@Rainmaker33

Copy link
Copy Markdown

Tested 78b1119 on NVIDIA GeForce RTX 3090 (Ampere, subgroup 32..32), driver 610.88 (Vulkan 1.4.341), Windows 11 Pro 26300: pass, no change on the GPU.

The PR's diff applied cleanly to main c0ac5fd. VS 2022, Vulkan SDK 1.4.363.0, llvm-mc 21.1.8; harness programs from a CMake build of that main.

  • tests/semantic: 1171 run, OK (1 skipped). tests/test_image_load_typed.py: OK.
  • scripts/run_gpu_tests.py: 98/126 pass, 28 skipped (wave64), identical per test to main's translator.

No game files.

@danosovsky

Copy link
Copy Markdown

Tested 78b1119 on NVIDIA RTX 4070 SUPER, 621.24, Windows 11 (26300), MSVC BuildTools 2022, Vulkan SDK 1.4.363.0: pass

  • python -m unittest discover -s tests/semantic: 1171 tests OK (includes the new D16 image_load_mip fixture).
  • run_gpu_tests.py: 129 shaders, 129 translated, 129 pass spirv-val; 98/126 passed, 28 skipped (wave64, 32-wide subgroups), exit 0.
  • With LEONIDA_W64_EMULATE=1: 126/126 passed, exit 0.
    No regression in the existing GPU suite. I did not re-run the PR's local two-mip vk_image_fuzz variant.

AI-assisted run.

@tylerstraub

Copy link
Copy Markdown
Contributor

Tested 78b111992bdf3f918d466dee6d6c6b8599ab1a52 on NVIDIA GeForce RTX 5090, 595.99.02 (Linux).

Independent Linux check on RTX 5090, NVIDIA 595.99.02, Linux 7.0.0-43-generic, llvm-mc 21.1.8 and SPIRV-Tools 2026.1.

I assembled a synthetic pixel shader with image_load_mip, dmask:0x9 and d16. A two-mip variant of vk_image_fuzz uploaded an 8×8 zero base and a 4×4 mip with distinct, varying R/A values and distinguishable G/B values. The pixel shader exported both raw 16-bit halves as exactly representable floats and exported a sentinel from the following VGPR.

All six draws matched the CPU reference at all 4,096 pixels per draw. For R8G8B8A8_UINT, _SINT and _UNORM, mip 1 packed R in the low half and A in the high half. Selecting mip 0 returned two zero halves for each format. The sentinel stayed unchanged in every draw. All three shader modules passed spirv-val --target-env vulkan1.2.

The Vulkan validation layer was unavailable on this host. The integer input values fit in 16 bits, and the two-component mask fills both halves. AI-assisted verification.

AI-assisted verification.

@ItsNotRexed
ItsNotRexed merged commit baafd44 into ItsNotRexed:main Nov 22, 2026
9 of 10 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.

7 participants