Shader sample c l forms #1479

Open
github-bot wants to merge 2 commits from github-bot/gh-1479 into main AGit
Owner

@⁠vsking2000 on GitHub · 2026-11-25 01:12 UTC · original
vsking2000:shader-sample-c-l-forms → main · +378 −12 · 5 files · 2 commits · open

Claimed in the coordination issue as:

Depends on:

Fixes:

What and why

Tested

GPUs tested:

AI-assisted:

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.
**@⁠vsking2000** on GitHub · 2026-11-25 01:12 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1479) `vsking2000:shader-sample-c-l-forms` → `main` · +378 −12 · 5 files · 2 commits · open Claimed in the coordination issue as: <!-- the item ID from the open "Coordinating who works on what" issue, for example TEST-17, or a link to your claim --> Depends on: <!-- #N for every pull request this one builds on or conflicts with (the coordination issue's Commands section, AGENTS.md); delete the line if it builds on none and conflicts with none --> Fixes: <!-- #N for each issue this closes (GitHub closes it on merge); delete the line if it closes none --> ### What and why <!-- What this changes and the problem it solves. --> ### Tested <!-- What you ran and on which GPU and driver (CONTRIBUTING.md). For the shader translator: how many shaders translate and pass spirv-val, before and after. --> GPUs tested: <!-- vendor, model, driver and OS of each GPU the GPU tests ran on, or n/a --> AI-assisted: <!-- yes or no (AGENTS.md asks a coding agent to say so) --> ### Checklist - [ ] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [ ] One topic; follow-up work goes in a new pull request. - [ ] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed.
image_sample_c_l_o was refused by name and image_sample_c_l outside scalar 2D
with a single mask/dimension message. Both are now the explicit-LOD compare
path of image_sample_c_lz with the LOD read from the address:
OpImageSampleDrefExplicitLod with Lod, plus Offset for _o, in 1D, 2D, 2D array
and cube images, in every stage, with a16 (the offset and the compare keep a
dword each, the coordinates and the LOD pack in pairs) and d16.

The address order (offset, z-compare, coordinates, LOD) is LLVM's
AMDGPUSampleVariant and lowerImage and Mesa ACO's visit_tex; llvm-mc checks the
widths. --texel-offset-fallback folds the offset at the mip level of the
explicit LOD, as for image_sample_l_o, not at level 0.

Still refused: a 3D image (Vulkan has no Dref form for it), dmask other than
0x1, tfe/lwe, glc and any other modifier, and an address of another width.

Not GPU-checked. tests/semantic/test_sample_c_l_forms.py follows every operand
of every form to its VGPR and f16 half, validates each module with spirv-val
and checks the refusals and the fallback level; tests/test_texel_offsets.py has
the offset fields and the folded level of the new form.

AI-assisted.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y7fbZYVY7EtLknWBZUfSLf
- An unsupported modifier on image_sample_c_l(_o) now has its own message
  ("<op> modifier <m>"); the dmask / tfe / lwe message stays for those.
- test_texel_offsets.py's c_l_o fallback test also checks that the
  level chain's Floor reads the LOD register (v14), so a fold that read a
  constant or another word no longer passes it.
- docs/design.md: llvm-mc accepts these widths and the 8-register rounding
  of the 5- and 6-dword forms and rejects one register fewer; the
  disassembler prints the exact width.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y7fbZYVY7EtLknWBZUfSLf
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:53:25 +00:00
Author
Owner

@⁠GeorgiyDemo on GitHub · 2026-11-25 01:51 UTC · original

Tested cce1f4181 on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), against main c266c269e (translator-only PR; binaries from the build at 66d4f5aa3):

  • python3 -m unittest test_sample_c_l_forms (from tests/semantic): OK (1 skipped) at this head. The same file on main fails 14 + 57 errors (1 skipped) — the new _c_l forms are refused there.
  • tests/test_texel_offsets.py + tests/test_translate.py (pytest 9.2.0 from tests/requirements.txt in a venv): 755 passed, 2 failed. Both failures are cs_dpp_cmp.asm (test_gpu_samples_translate_and_validate, test_wave64_emulate_uses_no_subgroup_ops): Homebrew LLVM 23 llvm-mc rejects v_cmp_gt_f32_dpp … dpp8:[…] with "dpp variant of this instruction is not supported". The same 2 fail on main with the same command, so it is a pre-existing local toolchain issue, not this PR.
  • GPU regression, --filter ps_sample_c on MoltenVK 1.4.2: 4/4 PASS (ps_sample_c, _b, _lz, _lz_a16).
  • Not run: GPU execution of the new _c_l forms — no .asm fixture; semantic evidence only.

AI-assisted; synthetic fixtures only, no game data.

**@⁠GeorgiyDemo** on GitHub · 2026-11-25 01:51 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1479#issuecomment-7150029427) Tested `cce1f4181` on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), against `main` `c266c269e` (translator-only PR; binaries from the build at `66d4f5aa3`): - `python3 -m unittest test_sample_c_l_forms` (from `tests/semantic`): **OK** (1 skipped) at this head. The same file on `main` fails **14 + 57 errors** (1 skipped) — the new `_c_l` forms are refused there. - `tests/test_texel_offsets.py` + `tests/test_translate.py` (pytest 9.2.0 from `tests/requirements.txt` in a venv): **755 passed, 2 failed**. Both failures are `cs_dpp_cmp.asm` (`test_gpu_samples_translate_and_validate`, `test_wave64_emulate_uses_no_subgroup_ops`): Homebrew LLVM 23 `llvm-mc` rejects `v_cmp_gt_f32_dpp … dpp8:[…]` with "dpp variant of this instruction is not supported". The same 2 fail on `main` with the same command, so it is a pre-existing local toolchain issue, not this PR. - GPU regression, `--filter ps_sample_c` on **MoltenVK 1.4.2**: **4/4 PASS** (`ps_sample_c`, `_b`, `_lz`, `_lz_a16`). - Not run: GPU execution of the new `_c_l` forms — no `.asm` fixture; semantic evidence only. AI-assisted; synthetic fixtures only, no game data.
Author
Owner

@⁠tiguan26 on GitHub · 2026-11-25 06:07 UTC · original · approved these changes

Approving. Merged into current main (42537e7) with no conflicts; the PR's tests pass and the full translator suite gives 488 files / 6,291 tests with only test_int32_to_f64 failing, as on main here (Linux, Python 3.13). The address width now follows LLVM's order ([offset,] z-compare, coordinates, LOD): under a16 the offset and compare keep a dword each and coordinates plus LOD pack in pairs, so fixed + (ncoord + 2) // 2; the LOD of the fold comes from the c_l address too; and a 3D view, dmask other than 0x1, tfe/lwe or another modifier is refused with its own message.

AI-assisted (Claude).

**@⁠tiguan26** on GitHub · 2026-11-25 06:07 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1479#pullrequestreview-6052639080) · **approved these changes** Approving. Merged into current main (42537e7) with no conflicts; the PR's tests pass and the full translator suite gives 488 files / 6,291 tests with only `test_int32_to_f64` failing, as on main here (Linux, Python 3.13). The address width now follows LLVM's order ([offset,] z-compare, coordinates, LOD): under a16 the offset and compare keep a dword each and coordinates plus LOD pack in pairs, so fixed + (ncoord + 2) // 2; the LOD of the fold comes from the c_l address too; and a 3D view, dmask other than 0x1, tfe/lwe or another modifier is refused with its own message. AI-assisted (Claude).
This pull request has changes conflicting with the target branch.
  • tools/rdna2spirv.py
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1479/head:github-bot/gh-1479'
git switch 'github-bot/gh-1479'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1479'
git switch 'github-bot/gh-1479'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1479'
git switch 'github-bot/gh-1479'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1479'
git switch 'main'
git merge --squash 'github-bot/gh-1479'
git switch 'main'
git merge --ff-only 'github-bot/gh-1479'
git switch 'main'
git merge 'github-bot/gh-1479'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.