rdna2spirv: 16-bit gradients for image_sample_d_g16 and image_sample_… #1481
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!1481
Loading…
Reference in a new issue
No description provided.
Delete branch "shader-sample-g16"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull request successfully merged and closed
…d_cl_g16 (SHADER-SAMPLE-G16)
The two g16 forms whose f32-gradient sibling main translates are now the same sample as image_sample_d / image_sample_d_cl, with dP/dx and dP/dy read as f16 halves: two per VGPR, low half first, each axis padded to a whole VGPR (1D (dx, -) (dx, -); 2D/array/cube (x, y) (x, y); 3D (x, y) (z, -) (x, y) (z, -)). Coordinates and clamp follow, packed only under a16; g16 and a16 are independent. Gen.g16_gradients widens each half with UnpackHalf2x16 and drops the pad; the f32-gradient path does the rest. LLVM (SIISelLowering lowerImage, packImage16bitOpsToDwords) and Mesa ACO (aco_select_nir.cpp, emit_pack_v1) agree on every point.
The six compare/offset g16 forms stay refused until their f32 siblings are translated (SHADER-SAMPLE-GRAD-FORMS), and the eight _cd g16 forms stay refused. docs/design.md gets a row. Not run on a GPU.
Claude-Session: https://claude.ai/code/session_01Y7fbZYVY7EtLknWBZUfSLf
Claimed in the coordination issue as:
Depends on:
Fixes:
What and why
Tested
GPUs tested:
AI-assisted:
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.Tested
ece08d3b1on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), againstmainb4b7756e8(translator-only PR; binaries from the build at66d4f5aa3):python3 -m unittest test_sample_g16(fromtests/semantic): OK at this head. The same file onmainerrors 46 times — every g16 gradient form is refused there, so the coverage is real.--filter ps_sample_on MoltenVK 1.4.2: 6/6 PASS (ps_sample_c,ps_sample_c_b,ps_sample_c_lz,ps_sample_c_lz_a16,ps_sample_implicit_sint,ps_sample_implicit_uint)..asmfixture for them; the semantic suite is the evidence here.AI-assisted; synthetic fixtures only, no game data.
I ran both new opcodes through this PR’s own
rdna2spirv.pyandvk_texture_testatece08d3b1, on a desktop RTX 4060, driver 32.0.16.2114, Windows 11 Pro build 26300. All four 64×64 draws matched every expected RGBA pixel.image_sample_d_g16image_sample_d_cl_g16The ordinary G16 sample uses a larger horizontal gradient on the right half to select the cyan mip. The clamped form keeps both gradients small and raises the minimum LOD on that half. The left half retains the red/blue pattern of mip 0. The parent translator at
b4b7756e8rejected all four programs by opcode. The PR’s seventest_sample_g16.pytests also passed, includingspirv-val, with zero skips.To repeat on another Vulkan device, build this PR’s
vk_texture_test, putspirv-asandspirv-valon PATH, and runpython leonida_g16.py <leonida-checkout> <vk_texture_test.exe>. The fixture uses handwritten shader listings and the renderer’s own texture. AI-assisted (Codex, GPT-6). Runnable test and pixel referenceApproving. Merged into current main (42537e7) with no conflicts; the PR's test passes and the full translator suite gives 488 files / 6,286 tests with only
test_int32_to_f64failing, as on main here (Linux, Python 3.13). The G16 layout matches LLVM's packImage16bitOpsToDwords: dP/dx and dP/dy packed separately, two halves per VGPR, low half first, each axis padded to a whole VGPR (so 3D is (dx/dh, dy/dh), (dz/dh, -), (dx/dv, dy/dv), (dz/dv, -)); each half is widened with UnpackHalf2x16 and the pad half dropped, and only the gradient words change.AI-assisted (Claude).
Hi @vsking2000, thanks for this pull request.
CONTRIBUTING.md asks contributors to claim their work in the coordination issue ("Coordinating who works on what", currently #1608) before opening a pull request: post
claiming: <ID>there, or a one-line description if the item is not listed yet, and put the ID in the pull request. I could not find a claim from you for this one (the IDSHADER-SAMPLE-G16appears in the pull request, but there is noclaiming:line for it).The claim matters because "it is claimed in the coordination issue by the pull request's author" is the first item on the maintainers' checklist for a mergeable pull request, and because it lets others see that the work is taken before they write it a second time.
Could you post the claim in #1608 and add the ID to the pull request description? If you already claimed it in another form, a link to your comment is enough.
AI-assisted (Claude Code, Claude Opus 5.5).
#1481 | head
ece08d3b1e2c51af15c133ae95480ad27cfb522b|python3 -m unittest discover -s tests/semantic -p test_sample_g16.py -v| red: 7 run, 46 errors | green: 7 passed | Red → greenMain raised translation errors for the 16-bit gradient cases, including cube and dmask variants. All seven test methods passed after merge.
Captured 25 distinct complete SPIR-V module(s) emitted while rerunning test_sample_g16.py on the merged tree. All assembled and passed spirv-val for Vulkan 1.2 with --allow-offset-texture-operand.
Base
3bd936ecd98995bca3e1da83d5e28d2343001aefwas merged into the recorded PR head for the second run. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Counts include unittest subtest events where applicable. AI-assisted with OpenAI Codex. Batch claim.Merged, thank you @vsking2000! This translator PR (rdna2spirv: 16-bit gradients for image_sample_d_g16 and image_sample_…) passed its own tests with main merged in during sodove's verification of this batch, so it went in with the batch.
AI-assisted (Claude Code, Claude Opus 5.5), posted for the maintainers.