OLD-9996: rdna2spirv: lower wide and strided geometry shader LDS accesses #1761

Open
github-bot wants to merge 1 commit from github-bot/gh-1761 into main AGit
Owner

@⁠potatoe0100 on GitHub · 2026-11-25 11:37 UTC · original
potatoe0100:carry/old-9996 → main · +138 −18 · 4 files · 1 commits · open

Claimed in the coordination issue as: OLD-9996 (#1608)

What and why

Carries on old PR 9996 by @⁠tedin7 (draft #267, branch old-pr/9996, listed in #17), rebased on current main with the author's commit kept.

The legacy (merged ES/GS) geometry shader path in Gen.gs_ds only knew ds_read_b32/b64/b96/b128, ds_read2_b32, ds_write_b32/b64 and ds_write2_b32. A GS that stages its output with ds_write_b96/ds_write_b128, or walks ES input vertices / output slots with the 64-dword stride forms ds_read2st64_b32/ds_write2st64_b32, raised Unsupported. This adds them: wide writes stage 3 or 4 consecutive output dwords from consecutive VGPRs; st64 offsets count 64-dword units, so on reads one unit advances one synthetic ES input vertex and on writes they address the flat staged output slots. The byte-offset arithmetic for read2/write2 is shared with the compute LDS path through a small lds_pair_byte_offsets helper (no behaviour change there). The rule is added to the contract table in docs/design.md.

Rebase note: one conflict in tools/rdna2spirv.py, where main added ds_append next to the new helper; both are kept unchanged.

Tested

  • python -m pytest tests/test_gs_ds_ring.py: 4 passed (translation + spirv-val of each new form), 1 skipped (the Vulkan readback needs LEONIDA_VK_HARNESS). With main's tools/rdna2spirv.py the same 4 tests fail with Unsupported, so they cover the change.
  • Translator suite python -I scripts/run_semantic_tests.py tests/semantic: 488 files, 6,287 tests; 6,286 pass on this branch and on main alike. The one failure, test_int32_to_f64.test_constant_folded_mrt_words, is the distro spirv-opt (SPIRV-Tools 2025.1) crashing with SIGSEGV, identical on main.
  • llvm-mc 18.1.3 (amdgcn, gfx1030), SPIRV-Tools 2025.1, Python 3.13, Linux. No shader corpus count (no game files here).

GPUs tested: n/a (the test_geometry_lds_rasterization readback is not run yet; a GPU result can follow)

AI-assisted: yes (Claude rebased and tested; the change is tedin7's)

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.

🤖 Generated with Claude Code

**@⁠potatoe0100** on GitHub · 2026-11-25 11:37 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1761) `potatoe0100:carry/old-9996` → `main` · +138 −18 · 4 files · 1 commits · open Claimed in the coordination issue as: OLD-9996 (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/1608) ### What and why Carries on old PR 9996 by @⁠tedin7 (draft #267, branch `old-pr/9996`, listed in #17), rebased on current `main` with the author's commit kept. The legacy (merged ES/GS) geometry shader path in `Gen.gs_ds` only knew `ds_read_b32/b64/b96/b128`, `ds_read2_b32`, `ds_write_b32/b64` and `ds_write2_b32`. A GS that stages its output with `ds_write_b96`/`ds_write_b128`, or walks ES input vertices / output slots with the 64-dword stride forms `ds_read2st64_b32`/`ds_write2st64_b32`, raised `Unsupported`. This adds them: wide writes stage 3 or 4 consecutive output dwords from consecutive VGPRs; st64 offsets count 64-dword units, so on reads one unit advances one synthetic ES input vertex and on writes they address the flat staged output slots. The byte-offset arithmetic for read2/write2 is shared with the compute LDS path through a small `lds_pair_byte_offsets` helper (no behaviour change there). The rule is added to the contract table in `docs/design.md`. Rebase note: one conflict in `tools/rdna2spirv.py`, where `main` added `ds_append` next to the new helper; both are kept unchanged. ### Tested - `python -m pytest tests/test_gs_ds_ring.py`: 4 passed (translation + spirv-val of each new form), 1 skipped (the Vulkan readback needs `LEONIDA_VK_HARNESS`). With `main`'s `tools/rdna2spirv.py` the same 4 tests fail with `Unsupported`, so they cover the change. - Translator suite `python -I scripts/run_semantic_tests.py tests/semantic`: 488 files, 6,287 tests; 6,286 pass on this branch and on `main` alike. The one failure, `test_int32_to_f64.test_constant_folded_mrt_words`, is the distro `spirv-opt` (SPIRV-Tools 2025.1) crashing with SIGSEGV, identical on `main`. - llvm-mc 18.1.3 (amdgcn, gfx1030), SPIRV-Tools 2025.1, Python 3.13, Linux. No shader corpus count (no game files here). GPUs tested: n/a (the `test_geometry_lds_rasterization` readback is not run yet; a GPU result can follow) AI-assisted: yes (Claude rebased and tested; the change is tedin7's) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:04:02 +00:00
Author
Owner

@⁠Tyrannys on GitHub · 2026-11-25 14:44 UTC · original

Independent verification of head ed9459619 (Windows 11 Pro 26300, Python 3.14.4, native llvm-mc 21.1.8, Vulkan SDK 1.4.341.0, NVIDIA GeForce RTX 4070 SUPER driver 621.01).

  • tests/test_gs_ds_ring.py (pytest, with LEONIDA_VK_HARNESS set to a local vk_harness build so the readback runs too): 5/5 pass at this head, including test_geometry_lds_rasterization (control -1, reference and wide/strided 1 on all 64 pixels).
  • The same test file against main's tools/rdna2spirv.py: 5/5 fail (Unsupported: ds_read2st64_b32 in gs, ds_write_b96 in gs, and so on), so the test shows what the PR adds.
  • Full suite at this head, python -I scripts/run_semantic_tests.py -j 4 tests/semantic: 488 files, 6287 tests, 0 files failed.

One note from reading the diff, not blocking: in gs_ds reads, the vertex_delta from divmod(dw, GS_VTX_DW) is only used for ds_read2st64_b32. ds_read2_b32 ... offset1:64 and ds_read_b32 ... offset:256 address the same bytes as ds_read2st64_b32 ... offset1:1 under the "vertex i at dword 64·i" layout, but still wrap to the base vertex (as they did on main). If a corpus GS ever reaches the next vertex that way it would read the wrong vertex silently; applying the delta to every read form (or refusing a nonzero delta outside st64) would keep the three spellings consistent.

No game files. AI-assisted (Claude Code).

**@⁠Tyrannys** on GitHub · 2026-11-25 14:44 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1761#issuecomment-7165734950) **Independent verification** of head `ed9459619` (Windows 11 Pro 26300, Python 3.14.4, native llvm-mc 21.1.8, Vulkan SDK 1.4.341.0, NVIDIA GeForce RTX 4070 SUPER driver 621.01). - `tests/test_gs_ds_ring.py` (pytest, with `LEONIDA_VK_HARNESS` set to a local `vk_harness` build so the readback runs too): **5/5 pass** at this head, including `test_geometry_lds_rasterization` (control `-1`, reference and wide/strided `1` on all 64 pixels). - The same test file against `main`'s `tools/rdna2spirv.py`: **5/5 fail** (`Unsupported: ds_read2st64_b32 in gs`, `ds_write_b96 in gs`, and so on), so the test shows what the PR adds. - Full suite at this head, `python -I scripts/run_semantic_tests.py -j 4 tests/semantic`: **488 files, 6287 tests, 0 files failed**. One note from reading the diff, not blocking: in `gs_ds` reads, the `vertex_delta` from `divmod(dw, GS_VTX_DW)` is only used for `ds_read2st64_b32`. `ds_read2_b32 ... offset1:64` and `ds_read_b32 ... offset:256` address the same bytes as `ds_read2st64_b32 ... offset1:1` under the "vertex i at dword 64·i" layout, but still wrap to the base vertex (as they did on `main`). If a corpus GS ever reaches the next vertex that way it would read the wrong vertex silently; applying the delta to every read form (or refusing a nonzero delta outside st64) would keep the three spellings consistent. No game files. AI-assisted (Claude Code).
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/1761/head:github-bot/gh-1761'
git switch 'github-bot/gh-1761'

Merge

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