Skip to content

feat(rdna2spirv): implement image_sample_c_l_o - #3492

Open
klarnet2009 wants to merge 1 commit into
ItsNotRexed:mainfrom
klarnet2009:feat/rdna2spirv-image-sample-c-l
Open

klarnet2009 wants to merge 1 commit into
ItsNotRexed:mainfrom
klarnet2009:feat/rdna2spirv-image-sample-c-l

Conversation

@klarnet2009

Copy link
Copy Markdown
Contributor

Implements image_sample_c_l_o (explicit-LOD depth-compare sample with packed signed 6-bit texel offsets) in tools/rdna2spirv.py.

Changes

  • Added "image_sample_c_l_o" to MIMG dispatch and scalar 2D depth comparison address-length validation (want_addr = 4 under a16, 5 without a16).
  • Allowed texel offset (off) and explicit LOD extraction (lod) for kind == "_c_l", emitting OpImageSampleDrefExplicitLod %float with Lod|Offset {lod} {off} in valid SPIR-V ImageOperands bit order (Lod = 0x2, Offset = 0x10).
  • Updated docs/design.md with image_sample_c_l_o documentation (CPU/assembler-verified; not yet GPU-measured).
  • Added tests/semantic/test_image_sample_c_l_o.py covering Lod|Offset, signed 6-bit offset extraction, d16, a16, Unsupported rejections, and spirv_asm.assemble() verification on every emitted module.

Verification

  • py -3.12 -I tests/semantic/test_image_sample_c_l_o.py -v: 3/3 OK (0.086s)
  • py -3.12 -I tests/test_isa_coverage.py -v: 18 tests OK (3 skipped: LEONIDA_RDNA2_ISA_XML unset)
  • py -3.12 -I tests/test_ctest_registration.py -v: 4/4 OK
  • py -3.12 -I -m compileall -q tools/rdna2spirv.py tests/semantic/test_image_sample_c_l_o.py: OK

@kotorvr

kotorvr commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested ccf30b5 on NVIDIA GeForce RTX 4090 (Ada, subgroup 32..32), 621.14, Windows 11 (26200): pass, no change against main f847748 (the branch's base). The GPU suite has no image_sample_c_l_o fixture, so on hardware this is a no-regression check; the new op itself is only covered by the PR's CPU test.

Test programs: MSVC 19.44 RelWithDebInfo build of main f847748 (the PR changes nothing under runtime/). llvm-mc 21.1.8, Vulkan SDK 1.4.363.0, Python 3.13.7.

main f847748 ccf30b5
python -I scripts/run_gpu_tests.py 153/199 passed, 46 skipped, 0 failed 153/199 passed, 46 skipped, 0 failed
the same with LEONIDA_W64_EMULATE=1 184/199 passed, 15 skipped 184/199 passed, 15 skipped

On the branch:

  • python -m unittest discover -s tests/semantic -p test_image_sample_c_l_o.py: 3 tests OK
  • python -I tests/test_isa_coverage.py: 18 OK (3 skipped)
  • python -I -m compileall -q make_game.py tools tests: exit 0

Not run: the full tests/semantic suite. No game files. AI-assisted check (Claude Code).

@ttd0x

ttd0x commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested ccf30b5b on NVIDIA GeForce RTX 2080 Ti (Turing, subgroup 32..32, driver 610.88), Windows 11: pass, no regression.

  • tests/semantic/test_image_sample_c_l_o.py: 3 tests OK.
  • scripts/run_gpu_tests.py (default, no emulation), 204 shaders translated, all pass spirv-val: 152/199 passed, 46 skipped (native wave64, expected on a 32-wide device), 1 failed. Main f847748c gives the same result lines; the one failure (ps_sdwa_f16_const) also fails on main.
  • Limit: no GPU fixture uses image_sample_c_l_o, so the GPU run shows only that nothing else broke.

Synthetic fixtures only, no game data. AI-assisted (Claude Code).

@sperm

sperm commented Nov 22, 2026

Copy link
Copy Markdown

Tested ccf30b5 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.

  • Full python -I scripts/run_gpu_tests.py (Linux build of this branch's runtime/, LEONIDA_VK_DEVICE per GPU): 185/199 passed, 14 skipped, 0 failed on both GPUs. Compared with the same suite at the merge base f847748 on the same machine, every test has the same result.
  • python -m unittest discover -s tests/semantic: 7325 run, OK (expected failures=1)

No game files. AI-assisted.

@whattheflop whattheflop 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.

AI-assisted verification at ccf30b5b. Both LLVM-assembled forms validated with the maintenance8 option. The RTX 3080 readback checked this opcode directly: all 4,096 pixels chose the expected mip and texel. The scratch run used #3045 for the sampled-array dynamic indexing declaration and #3347 for feature chaining in the test device. The exact head omits the declaration even though both descriptor indices are runtime lookups. Standalone spirv-val did not catch that omission.

The new depth-compare form also inherits an issue in the shared --texel-offset-fallback. With nearest mip filtering and explicit LOD 0.75, the sample uses mip 1, while texel_offset_fold() floors that LOD and uses mip 0 to scale the offset. On an 8x8 base mip and 4x4 mip 1, UV (0.6875,0.5625) with offset (-1,+1) computes mip-1 texel (2,2) instead of (1,3). I checked the emitted size-query chain and confirmed the CPU coordinate calculation. The native run covers integer LODs with maintenance8. Vulkan mip selection

@javdc

javdc commented Nov 22, 2026

Copy link
Copy Markdown

Tested ccf30b5 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

  • python3 -m pytest tests/semantic/test_image_sample_c_l_o.py -q -> 3 passed, 7 subtests passed
  • python3 -I scripts/run_gpu_tests.py --build <build> -> 184/199 passed, 14 skipped, 0 failed (expected D3D12-owned skips)

No runtime C++ changes; GPU suite run from the PR worktree against the existing main runtime build.

AI-assisted (OpenCode).

@im-a-cat

Copy link
Copy Markdown

Tested ccf30b5 on Windows 11 Pro 10.0.26300, Python 3.12.10 (CPU checks; this PR has no GPU fixture):

  • python -I tests/semantic/test_image_sample_c_l_o.py -v: 3/3 OK
  • python -I tests/test_isa_coverage.py: 18 tests OK (3 skipped: LEONIDA_RDNA2_ISA_XML unset)
  • python -I tests/test_ctest_registration.py: 4/4 OK
  • Full tests/semantic at the PR head, one file per process: 333/333 files clean, 7,325 tests, no failures

Run in a temporary worktree at the PR head. Not GPU-checked: the PR adds no fixture for image_sample_c_l_o, so this does not confirm the Lod|Offset result on hardware.

AI-assisted.

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