Shader gather4 c lz #1482

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

@⁠vsking2000 on GitHub · 2026-11-25 01:13 UTC · original
vsking2000:shader-gather4-c-lz → main · +302 −0 · 3 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:13 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1482) `vsking2000:shader-gather4-c-lz` → `main` · +302 −0 · 3 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.
Both were refused by name. Each is now one OpImageDrefGather at the base level on
the sampled image and comparison sampler image_sample_c_lz uses (the compare
function is the sampler's, built from S# DEPTH_COMPARE_FUNC):

- address order after the optional offset dword: z-compare (f32, also under a16),
  s, t, and the slice of an array or cube (LLVM AMDGPUSampleVariant "{offset}
  {bias} {z-compare}" then the coordinates, no LOD for _lz; llvm-mc dword counts:
  2D 3, array and cube 4, +1 for _o, 2/3/+1 under a16);
- _lz is the base level (LLVM rewrites image_gather4_c_l with LOD <= 0 to
  IMAGE_GATHER4_C_LZ);
- four comparisons (0.0 or 1.0) in the gather order image_gather4_lz uses, two
  VGPRs for d16;
- _o: the signed 6-bit x [5:0], y [13:8] offset dword as image_gather4_lz_o reads
  it, an Offset operand (shaderImageGatherExtended).

Refused with a message: 1D and 3D, dmask other than 0x1, tfe, lwe, unorm, glc and
any other modifier. Mesa ACO and the RDNA2 ISA text were not readable; the row in
docs/design.md says so. Not GPU-checked.

tests/semantic/test_gather4_c_lz.py (16 tests): every operand of the emitted
OpImageDrefGather traced back to its VGPR and half, for 2D, array and cube, _o and
a16; result order; d16; stages; --texel-offset-fallback; the refusals; spirv-val
on every form.

AI-assisted.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Y7fbZYVY7EtLknWBZUfSLf
Mesa's ACO visit_tex for nir_texop_tg4 (read in two copies from a Mesa mirror,
about 2021 and a recent one) selects exactly image_gather4_c_lz and
image_gather4_c_lz_o for a shadow gather at level zero, pushes the address as
offset, bias, compare, derivatives, coordinates (no LOD word at level zero),
builds the offset dword as (offset & 0x3F) << (8 * i), keeps the compare whole
under a16, and sets dmask 1 for every shadow gather, which is the sourced reason
for refusing other dmask bits. Its half-texel integer workaround is GFX8-and-older
integer results only and does not touch a compare gather.

docs/design.md row, the emit_gather4_c_lz docstring and the test file header now
cite it; no behaviour change and no new case.

AI-assisted.

Co-Authored-By: Claude Sonnet 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:31 +00:00
Author
Owner

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

Tested 12677c341 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_gather4_c_lz (from tests/semantic): OK at this head. The same file on main fails 7 + 52 errors — the _lz compare-gather form is refused there.
  • GPU regression, --filter ps_gather on MoltenVK 1.4.2: 4/4 PASS (ps_gather4_c_l, ps_gather_border, ps_gather_sampler_lod, ps_gather_wrap).
  • Not run: GPU execution of the new image_gather4_c_lz form itself — no .asm fixture for it; the semantic suite is the evidence here.

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

**@⁠GeorgiyDemo** on GitHub · 2026-11-25 01:51 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1482#issuecomment-7150029013) Tested `12677c341` 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_gather4_c_lz` (from `tests/semantic`): **OK** at this head. The same file on `main` fails **7 + 52 errors** — the `_lz` compare-gather form is refused there. - GPU regression, `--filter ps_gather` on **MoltenVK 1.4.2**: **4/4 PASS** (`ps_gather4_c_l`, `ps_gather_border`, `ps_gather_sampler_lod`, `ps_gather_wrap`). - Not run: GPU execution of the new `image_gather4_c_lz` form itself — no `.asm` fixture for it; the semantic suite is the evidence here. AI-assisted; synthetic fixtures only, no game data.
Author
Owner

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

Approving. Merged into current main (42537e7) with no conflicts; the PR's test passes and the full translator suite gives 488 files / 6,295 tests with only test_int32_to_f64 failing, as on main here (Linux, Python 3.13). The address order after the optional offset dword is z-compare then coordinates, the _o offset reads signed 6-bit x/y at [5:0] and [13:8] as for image_gather4_lz_o, and a dmask other than 0x1, a 3D view or an untranslated modifier is refused rather than guessed.

AI-assisted (Claude).

**@⁠tiguan26** on GitHub · 2026-11-25 05:56 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1482#pullrequestreview-6052548506) · **approved these changes** Approving. Merged into current main (42537e7) with no conflicts; the PR's test passes and the full translator suite gives 488 files / 6,295 tests with only `test_int32_to_f64` failing, as on main here (Linux, Python 3.13). The address order after the optional offset dword is z-compare then coordinates, the _o offset reads signed 6-bit x/y at [5:0] and [13:8] as for image_gather4_lz_o, and a dmask other than 0x1, a 3D view or an untranslated modifier is refused rather than guessed. AI-assisted (Claude).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

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