Repository navigation
feat(rdna2spirv): implement image_sample_cd, image_sample_c_d, and image_sample_c_cd variants - #3300
klarnet2009 wants to merge 2 commits into
Conversation
8569d1b to
382f0ee
Compare
|
At LLVM accepts the instruction (gfx1030): Translating it with the semantic-test helpers, on the head and on its merge with main: The equivalent AI-assisted (Devin); Linux, Python 3.12, llvm-mc 15, CPU translation only, no GPU or game files. |
|
Thank you @ray3242 for catching that! Fixed in
Verified with
|
|
Tested
Synthetic fixtures only, no game data. AI-assisted (Claude Code). |
|
Tested 5497f4c on AMD Radeon RX 9070 XT (RADV GFX1201) and the Ryzen 7 9800X3D iGPU (RADV RAPHAEL_MENDOCINO, gfx1036), Mesa 26.2.6, Linux 7.3.4: pass, no regressions.
No game files. AI-assisted. |
|
Rechecked at |
|
Tested on Windows 11 with two GPUs on one machine (head merged with main f847748, MSVC 14.51, Python 3.13.1):
So nothing regresses, but |
|
Tested 5497f4c on Steam Deck LCD (Jupiter), AMD Custom GPU 0405 "Van Gogh", RADV Mesa 26.2.0-devel (git-5c65d4fc31), Vulkan 1.4.350, SteamOS 3.9.5 (holo), kernel 7.2.7-valve2-2-neptune-72-g31504582a073: pass
No runtime C++ changes; GPU suite run from the PR worktree against the existing main runtime build. AI-assisted (OpenCode). |
|
Tested
The new AI-assisted (Claude Code). No game files. |
jeremygold02
left a comment
There was a problem hiding this comment.
Direct GPU execution at 5497f4ce1c082b163f794ce79569987838103d98: image_sample_cd, image_sample_c_d, and image_sample_c_cd selected the expected mip on an RTX 5070 with both A32 and packed A16 coordinates. This includes the corrected A16 color form from the last commit. The corresponding A16 and A32 RGBA32F frames were byte-identical for both color and depth.
Five synthetic 16×16 draws used an 8×8 base mip, a 4×4 second mip, nearest filtering, and sampler LOD range [0,1]. UV was constant at (0.6875, 0.5625), so the mip change had to come from the supplied gradients. I held dUV/dx at (1/16,0) and changed dUV/dy from (0,1/8) to (0,1/4), selecting mip 0 and mip 1 respectively.
| Input and instructions | Expected and observed result | Pixels |
|---|---|---|
RGBA8 UNORM, image_sample_cd, A32 and A16 |
Mip 0 texel (5,4), mip 1 texel (2,2). R/G encoded both coordinates and mip, yielding byte codes (5,4,18,34). | 256/256 each |
D32, image_sample_c_d then image_sample_c_cd, A32 and A16 |
Mip depths 0.25 and 0.75, reference 0.5, LESS_OR_EQUAL. Both instructions returned (0,1) across the gradient change, giving RGBA (0,1,0,1). | 256/256 each |
| Same A16 depth shader with the two mip values exchanged | RGBA reversed to (1,0,1,0). | 256/256 |
LLVM assembled each of the three opcodes in both address widths for gfx1013 and gfx1030. The draw shaders used the gfx1013 listings. All five original translated modules passed Vulkan 1.2 spirv-val. For execution I added the sampled-array dynamic-indexing capability from #3045 to the four pixel modules and enabled the matching device feature. Removing that one declaration reproduces each head-generated SPIR-V text exactly. The scratch vk_texture_test kept DrawParameters in the device feature chain as in #3347 and supplied the synthetic color/depth mips. The checks cover the three 2D gradient forms with f32 results. The offset, MinLod and d16 variants remain outside this run.
GPU execution used NVIDIA GeForce RTX 5070, driver 621.01 (32.0.16.2101), with Intel Core Ultra 7 265K on Windows 11 Home 25H2 build 26200.9974.
AI-assisted by GPT-6.2 Astra.
|
Tested
No GPU, no game data. AI-assisted. |
5497f4c to
0d11b47
Compare
|
Verified at the PR head against main 3faac55. All five tests in tests/semantic/test_image_sample_cd.py pass under python -I, compileall is clean, and the nearest existing suites on the sample dispatch (test_cube_sample 18/18, test_desc_cache, test_shader_meta) stay green. Main's rewritten sample-name grammar (kind.endswith(_cl) plus an allowed set — verified) has no _cd/_c_d/_c_cd form, so nothing here is superseded — but the PR and main now edit the same name-dispatch code with different shapes, so this needs a rebase onto main's current grammar before it can land. CI currently fails linux-gpu-tools and windows. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run). |
|
Found a rendering difference on head
Counts are per instruction. Both the f32 result and the widened d16 result show the same split. All three runs used the same integrated Radeon, RADV RAPHAEL_MENDOCINO, Mesa 26.3.1, CachyOS kernel 7.3.5-2. The fallback was forced on this driver to compare both paths on identical hardware. The explicit gradient selects mip 1 of a 128-wide image. A two-texel offset should therefore shift U by 2/64. At this head, Synthetic reproducerUse the two-mip v_interp_p1_f32_e32 v2, v0, attr0.x
v_interp_p2_f32_e32 v2, v1, attr0.x
s_load_dwordx8 s[8:15], s[0:1], 0x0
s_waitcnt lgkmcnt(0)
s_mov_b32 s16, 0x3092
s_mov_b32 s17, 0xc00000
s_mov_b32 s18, 0x14500000
s_mov_b32 s19, 0
v_cmp_le_f32_e32 vcc_lo, 0.5, v2
v_mov_b32_e32 v4, 2
v_cndmask_b32_e64 v4, 0, v4, vcc_lo
v_mov_b32_e32 v5, 0.5
v_mov_b32_e32 v6, 0x3c800000
v_mov_b32_e32 v7, 0
v_mov_b32_e32 v8, 0
v_mov_b32_e32 v9, 0
v_mov_b32_e32 v10, 0x3ef40000
v_mov_b32_e32 v11, 0.25
image_sample_c_d_o v14, v[4:11], s[8:15], s[16:19] dmask:0x1 dim:SQ_RSRC_IMG_2D
image_sample_c_d_o v15, v[4:11], s[8:15], s[16:19] dmask:0x1 dim:SQ_RSRC_IMG_2D d16
s_waitcnt vmcnt(0)
v_cvt_f32_f16_e32 v15, v15
exp mrt0 v14, v15, v2, v4 done vm
s_endpgmThe no-offset controls passed on all three runtimes. Explicit shadow gradients and their min-LOD-clamped forms selected the expected mip at all 4,096 pixels with both ordinary and packed Hand-written shaders only. AI-assisted. |
|
The RADV shadow-offset difference also reproduces on native Windows at 0d11b473. Windows 11 x64, RTX 3080 Ti / 621.35, MSVC 19.44, LLVM MC 23.1.6, Vulkan SDK 1.4.363.0. Using the same synthetic two-mip texture and hand-written shaders, both All five fragment variants and the vertex shader passed |
What and why
Implements the 12 derivative and depth-compare
image_sample*variants intools/rdna2spirv.py:image_sample_cd,image_sample_cd_o,image_sample_cd_cl,image_sample_cd_cl_o->OpImageSampleExplicitLod %v4floatimage_sample_c_d,image_sample_c_d_o,image_sample_c_d_cl,image_sample_c_d_cl_o,image_sample_c_cd,image_sample_c_cd_o,image_sample_c_cd_cl,image_sample_c_cd_cl_o->OpImageSampleDrefExplicitLod %floatGrad,Grad|Offset,Grad|MinLod, andGrad|Offset|MinLodin exact SPIR-VImageOperandsorder,a16(keeping offset, z-compare, and gradients 32-bit while unpacking f16 coords/minlod), andd16packing.docs/design.md(CPU/structural verification only; unmeasured on GPU) and adds tests intests/semantic/test_image_sample_cd.py(5 tests, assembling every emitted SPIR-V module viaspirv_asm).Claim: #3232 (comment)
Tested
spirv_asm)py -3.12 -I -m compileall -q tools/rdna2spirv.py tests/semantic/test_image_sample_cd.py: passed (exit 0)py -3.12 -I tests/semantic/test_image_sample_cd.py -v: Ran 5 tests in 0.232s, OKpy -3.12 -I tests/test_isa_coverage.py -v: Ran 13 tests in 3.652s, OK (skipped=3 forLEONIDA_RDNA2_ISA_XML)py -3.12 -I tests/test_ctest_registration.py -v: Ran 4 tests in 0.048s, OKtools/rdna2spirv.pytoHEADand confirmedtest_image_sample_cd.pyfailed (15Unsupportederrors), then restored and re-ran 5/5 passing.Checklist
python -Icompatible)