Skip to content

Translator: pack D16 explicit-LOD gather results - #1017

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

ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
Vonsek:codex/d16-gather-clean

Conversation

@Vonsek

@Vonsek Vonsek commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Replaces #928 following the maintainer's request to drop the removed README commits. Original coordination claim.

What and why

This is one commit directly on 43d4703. The range changes five files and contains zero README changes. The existing 2D image_gather4_l and image_gather4_l_o paths already fetch the four taps individually. The assembler accepts two destination VGPRs with d16, but the translator rejects both forms. The four results now use the same binary16 writeback as image_gather4_lz, two taps per VGPR, leaving the following register intact. The sampler bounds from merged #973 remain in the mip-selection path.

Tested

  • On unmodified 43d4703, the new ps_gather_wrap fixture fails translation with image_gather4_l form. Its neighboring ps_gather_sampler_lod translates and passes SPIR-V validation.
  • On this replacement branch, I rebuilt the Vulkan test programs from source and ran scripts/run_gpu_tests.py --filter gather from empty work directories on RTX 5080 (616.92) and Radeon Graphics (26.10.1). Each GPU passed the D16 case with 4096/4096 exact pixels and the sampler case with two exact 4096-pixel passes. The focused translator and D16 tests passed all 286 cases.
  • Negative controls on the identical source tree: forcing the offset to zero changed only G on all 4096 pixels. Changing the first untouched-register sentinel changed only R on all 4096. In a separate two-mip D16 draw, requests for LOD 0 and 1 yielded (1,1,0,0) at every pixel, a sampler maximum of 0.25 yielded (1,1,1,1), and a minimum of 0.75 yielded (0,0,0,0), on both GPUs.
  • On the identical integrated tree, the full RTX runner passed 78 of 105 with 27 skips; the standalone checker passed 68 of 97 with 29 skips. With wave64 emulation enabled, I reran the full RTX suite from the replacement branch and all 105/105 cases passed. The semantic suite passed 1062 tests; all 47 enabled CTest cases passed (GameInput disabled). Independent GPU reports for the earlier implementation are on Translator: pack d16 results for explicit-LOD 2D gathers #928.

Checklist

  • All shaders, textures and controls were built from source. No game data, keys or decryption.
  • docs/design.md records the packing order and the hardware check.

AI-assisted with Codex.

Route both four-tap gather paths through the existing binary16 conversion so explicit LOD and offsets keep the two-word result and the following register intact.
@kapitche

Copy link
Copy Markdown
Contributor

Tested 773891b 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_translate.py: 283 passed. With main's tools/rdna2spirv.py, 3 fail.
  • run_gpu_tests.py --filter gather: ps_gather_sampler_lod (two passes, 4096 RGBA32F pixels each exact) and ps_gather_wrap (4096/4096) pass on both the RTX 4080 SUPER and the Intel UHD 770.
  • ctest: 47/47 on NVIDIA. The two Intel failures (d3d12_vulkan_device, and d3d12_descriptor's minimum LOD view) also fail on main and aren't related to this translator change.

Same note as on #973: ps_gather_sampler_lod needs a current vk_texture_test, so rebuild runtime/ before running it.

@Vonsek

Vonsek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

The Windows job on this head compiled all six descriptor shaders, then failed in the workflow check for the retired cs_sample.spv filename. Main 43d4703 fails at the same step. The independent workflow fix is #1029. Thanks for the RTX 4080 SUPER and Intel results on this replacement head. AI-assisted.

@BACONMANXDGOD

Copy link
Copy Markdown
Contributor

Tested 773891b on an Intel Arrow Lake Xe-LPG iGPU (Core Ultra 9 275HX, Windows 32.0.101.8132, subgroup 8..32) and an RTX 5070 Ti Laptop (617.42): pass. Windows 11 26200, MSVC 19.44, llvm-mc 23.1.6, Vulkan SDK 1.4.363, runtime built from 43d4703 (this PR changes no C++).

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

@Bushyon

Bushyon commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested 773891b on AMD Radeon RX 7800 XT (RDNA3), RADV Mesa 26.2.6 (ACO), Vulkan 1.4.354, subgroup 32..64, Fedora 44; llvm-mc 22.1.8, GCC 16.2.1. First AMD run: pass.

  • scripts/run_gpu_tests.py: 105/105 native, 105/105 with LEONIDA_W64_EMULATE=1. ps_gather_wrap: 4096/4096 pixels exact; ps_gather_sampler_lod: pass.
  • runtime/test/shaders/check.py: 94/97 native and emulated, 3 mesh skips (build.py doesn't build them).
  • main's rdna2spirv.py on the same build: ps_gather_wrap is not translated (image_gather4_l form unsupported), so no .spv.
  • unittest discover -s tests/semantic, tests/test_shader_checks.py, tests/test_run_gpu_tests.py: OK. Not run: tests/test_translate.py (no pytest here).
  • The new taps are at LOD 0, so the nearest-mip tie in SHADER-152 is not exercised.

@Vonsek

Vonsek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Tested the combination with #1045 on main 43d4703: #1017 773891bd + #1045 a4728898 merge without conflicts (tree 09463420e9121f0e7ce05e4c755b373dbd7af946), and all 284 translator tests pass. A synthetic shader used the same descriptor-fed sampler for a D16 red gather and a D16 alpha gather offset by +1 texel in X. The CPU reference packed the four taps into two binary16 pairs for each gather.

Requested LOD and S# bound Packed red words Packed alpha words
LOD 0, min 0.75 → mip 1 0, 0 3c003c00, 3c003c00
LOD 1, max 0.25 → mip 0 3c000000, 3c000000 0, 3c003c00

The merged shader matched these hex words at all 4,096 pixels per draw on RTX 5080 and Radeon Graphics (RDNA2). Bypassing the active bound in validated SPIR-V selected the other row at every pixel in both draws. #1017 alone matched the same words on these two GPUs; #1045 alone rejected the two-register D16 form. The combined D16 case still lacks RX 7900 XTX verification. AI-assisted.

@quackottu quackottu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested 773891b on NVIDIA GeForce RTX 5070, driver 621.24, Windows 11 Pro (26300), VS 2022 Build Tools, Vulkan SDK 1.4.363.0, with LEONIDA_VK_VALIDATION=1 and LEONIDA_D3D12=vulkan: pass

  • ctest -C RelWithDebInfo: 100% tests passed, 0 tests failed out of 47
  • every test program in the build passes. d3d12_vulkan_device_test and d3d12_fence_timing_test each report 3 validation errors (VUID-vkCreateDevice-ppEnabledExtensionNames-01387), but main 43d4703 shows the same: the standalone instance drops VK_KHR_surface, which #1027 fixes. Not from this PR.
  • d3d12_clear_test differs from WARP exactly as on main (#521).

Implicit Vulkan layers (overlays) were off through an empty VK_IMPLICIT_LAYER_PATH.

@ItsNotRexed
ItsNotRexed merged commit 3d15db4 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.

6 participants