Repository navigation
rdna2spirv: implement 14 image_gather4_{c_l,cl,c_cl,b,b_cl,c_b,c_b_cl}[_o] variants - #5206
Conversation
|
Tested 86e0bc0 on AMD Radeon 610M (RADV, subgroup 32..64), Linux: tests/semantic test_image_gather4_variants passes (11 tests), and run_gpu_tests.py --filter gather passes 4/4 (ps_gather4_c_l, ps_gather_border, ps_gather_sampler_lod, ps_gather_wrap, each 4096/4096 pixels exact), identical with and without LEONIDA_VK_DEVICE=RADV. A nonexistent device name does not make these ps_ rows fail (the cs_ rows do fail with "no Vulkan physical device matches"), so their attribution to this GPU rests on the device setting. The PR's RTX 5090 run with LEONIDA_W64_EMULATE=1 was not reproduced. AI-assisted. |
|
Tested 86e0bc0 on Windows 11 with NVIDIA GeForce RTX 4090 (32.0.16.2101) and AMD Radeon Graphics (32.0.21043.5001): pass. AI-assisted. I selected each driver separately with VK_DRIVER_FILES. In each run, vulkaninfo --summary listed only the selected GPU. I set LEONIDA_W64_EMULATE=1.
All 11 new semantic tests passed. All 71 existing gather tests in tests/test_translate.py passed. All three line-ending tests passed. With the implementation from parent 3faac55, the new semantic suite reported 93 errors across its tests and subtests. The parent translator rejected image_gather4_c_l. |
|
Tested 86e0bc0 on Intel UHD 630 (CFL GT2, subgroup 8..32), Mesa 25.2.8 ANV, Ubuntu 24.04: tests/semantic test_image_gather4_variants passes (11 tests), test_translate.py -k gather gives 71 passed, and run_gpu_tests.py --filter gather with LEONIDA_VK_DEVICE=Intel LEONIDA_W64_EMULATE=1 passes 4/4 (ps_gather4_c_l, ps_gather_border, ps_gather_sampler_lod, ps_gather_wrap, 4096 pixels exact each). With a nonexistent device name all 4 fail with "no Vulkan physical device matches", so the Intel run is attributed to this GPU. The RTX 5090 Windows run was not reproduced, and the "5/5 shaders passed spirv-val" count in the PR body was not checked. AI-assisted. |
Kam471
left a comment
There was a problem hiding this comment.
Built and ran at 86e0bc05e on Windows 11, RTX 5070 Ti.
tests/semantic/test_image_gather4_variants.py-> 11 tests, OK.- GPU:
run_gpu_tests.py --filter ps_gather4_c_l-> 1/1 passed,ps_gather4_c_l->4096/4096 pixels exact; translator 1/1 +spirv-val. git diff --checkclean.
The 14 image_gather4_{c_l,cl,c_cl,b,b_cl,c_b,c_b_cl}[_o] variants are now implemented with their component/bias/compare selectors and offsets; the semantic suite covers the operand forms and the GPU fixture checks the sampled/compared result across the frame. No blocking issue.
|
Independent Windows 11 CPU + GPU check at exact head \86e0bc05e97a56838532e18fe804d87172ef7873\ (GPU: NVIDIA GeForce RTX 4060 Laptop GPU, driver \32.0.16.1714; claim: #5156 (comment)):
Synthetic fixtures only, no game data. AI-assisted. |
|
Independent check — PASS (Windows 11, NVIDIA RTX 5090, driver 617.42, Vulkan SDK 1.4.363.0).
AI-assisted (Devin); no game files. |
|
Focused review of exact head 86e0bc0: the G case in runtime/test/shaders/ps_gather4_c_l.asm is labelled ‘run-time S#’, but |
kacper-serewis
left a comment
There was a problem hiding this comment.
The clean integration of 86e0bc0 with #4321 a255d1b selects different mips for ordinary and explicit depth-compare gathers. At LOD bits 0x3eff0000 and 0x3eff0001, ordinary gather selected mip 1 and compare gather selected mip 0. Both zero-offset forms reproduced this on all four taps at all 4,096 pixels on a Windows RTX 5070, driver 616.56. One step below the boundary and at 0.5, both paths agreed. Please share #4321’s mip-selection arithmetic with emit_gather4_lod and cover both compare forms at this boundary. All 17 synthetic modules validated. The test used software depth comparison over a two-mip color texture.
AI-assisted independent review.
|
Tested
AI-assisted (Claude Code). Hand-written fixture only, no game files. |
… runtime S# in ps_gather4_c_l
|
Addressed both review findings in 9dd3db2:
|
|
Tested
|
|
Re-tested the current head
AI-assisted (Claude Code). |
kacper-serewis
left a comment
There was a problem hiding this comment.
AI-assisted review. RTX 5070 recheck at 9dd3db2, Windows driver 616.56. The explicit depth-compare path now selects mip 1 at 0x3eff0000 and 0x3eff0001. Standalone ordinary gather still selected mip 0 at both. With #4321 and this fix together, all four ordinary/compare and zero-offset forms selected mip 1. All agreed one float below (mip 0) and at 0.5 (mip 1), for every tap at all 4,096 pixels. The original compare finding is resolved in the combination; please keep the #4321 integration requirement visible.
|
Tested
Hand-written fixtures only, no game files. AI-assisted (Claude Code). |
|
Tested Test programs built from
AI-assisted (Claude Code). |
shayderrr
left a comment
There was a problem hiding this comment.
Summary
tools/rdna2spirv.py adds GATHER4_LOD_OPS (14 variants) and emit_gather4_lod(): 2x2 OpImageFetch gathers with offset/bias/clamp/LOD decoding, literal or runtime DEPTH_COMPARE_FUNC [14:12] comparisons, #4321's 8-fraction-bit mip rounding, a16/d16 and border modes; biased forms stay Unsupported in compute. New tests/semantic/test_image_gather4_variants.py validates all variants via spirv-as/spirv-val, and ps_gather4_c_l.asm plus check.py provide a GPU fixture.
Why merge
Fills a 14-opcode translator gap with structural validation and a hardware test covering depth compare, offsets and d16.
Verdict: Approve
Summary
Why mergeFills a 14-opcode translator gap with structural validation and a hardware test covering depth compare, offsets and d16. Verdict: Approve |
Summary
Implements the 14 remaining unclaimed AMD RDNA2
image_gather4_*MIMG instructions intools/rdna2spirv.py:image_gather4_c_l,image_gather4_c_l_oOpImageQueryLod+ bias /min_lodclamp, plus compute-stage_clwith LOD 0 base):image_gather4_cl,image_gather4_cl_oimage_gather4_c_cl,image_gather4_c_cl_oimage_gather4_b,image_gather4_b_oimage_gather4_b_cl,image_gather4_b_cl_oimage_gather4_c_b,image_gather4_c_b_oimage_gather4_c_b_cl,image_gather4_c_b_cl_oClaim: #5032 (comment)
Zero overlap with #3201 (
image_gather4,image_gather4_o,image_gather4_c,image_gather4_c_o,image_gather4_c_lz,image_gather4_c_lz_oare untouched).Implementation Details
OpImageFetchfootprint,gather_addr_modes,gather_addr,gather_border_one,clamp_gather_lod,image_read_typed, andstore_gather_tapshelpers intools/rdna2spirv.py.2Dand2D_ARRAY,dmasksingle-channel selection (channel 0 always compared for_c),d16f16/i16/u16 packing,a16address unpacking (_o,_b,_c,_l,_cl), andunorm.SQ_IMG_SAMP_WORD0.DEPTH_COMPARE_FUNC([14:12], codes 0..7) for both literal and run-timeS#descriptors and comparesref <op> texel(after border substitution) to select1.0/0.0per tap.OpImageQueryLodcomponent 1 (unclamped relative LODlambda') before applying shaderbias,min_lodclamp (FMax), andS#MIN_LOD/MAX_LODclamping.Verification
spirv-val(Vulkan 1.2):python -m unittest discover -s tests/semantic -p test_image_gather4_variants.py -v— 11/11 passed (all 14 ops in 2D, 2D_ARRAY,d16,a162D & 2D_ARRAY, compute stage, all 8DEPTH_COMPARE_FUNCliteral & runtime,unorm,dmask, border modes).python -m pytest -W ignore -k gather tests/test_translate.py -q— 71/71 passed.python -I tests/test_text_write_line_endings.py— 3/3 passed;git diff --checkclean.LEONIDA_W64_EMULATE=1):python -I scripts/run_gpu_tests.py --build H:\leonida\Leonida\runtime\build --filter gatherPASS ps_gather4_c_l 4096/4096 pixels exact(testsimage_gather4_c_l,image_gather4_c_l_oruntimeS#,image_gather4_clG channel,image_gather4_c_b_cl_o d16)PASS ps_gather_border 4096/4096 pixels exactPASS ps_gather_sampler_lod two passes, 4096 RGBA32F pixels each exact; wrong mip and UV rejectedPASS ps_gather_wrap 4096/4096 pixels exactspirv-val).AI-assisted (Gemini 4 Neon).