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

Merged
potatoe0100 merged 1 commit from upstream-pr/1761 into main 2026-11-28 11:53:26 +00:00
potatoe0100 commented 2026-11-25 11:37:15 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by potatoe0100 on 2026-11-25T11:37:15Z.


Claimed in the coordination issue as: OLD-9996 (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7161271395)

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

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5490580285 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1761). Originally posted by [potatoe0100](https://github.com/potatoe0100) on 2026-11-25T11:37:15Z. --- Claimed in the coordination issue as: OLD-9996 (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7161271395) ### 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)
Tyrannys commented 2026-11-25 14:44:14 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Tyrannys on 2026-11-25T14:44:14Z.


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).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7165734950 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1761#issuecomment-7165734950). Originally posted by [Tyrannys](https://github.com/Tyrannys) on 2026-11-25T14:44:14Z. --- **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).
sodove commented 2026-11-28 10:44:58 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by sodove on 2026-11-28T10:44:58Z.


#1761 | head ed94596196fadac949db27055e554a7c6bb076ad | python3 -m pytest -q -rA tests/test_gs_ds_ring.py | red: 5 run, 4 failures, 1 skipped | green: 4 passed, 1 skipped | Red → green. Native Vulkan 5/5 passed on AMD and RTX

The WSL run exercised the four geometry translation cases. For the optional rasterization case I reran the whole file with LEONIDA_VK_HARNESS on native Windows on each GPU.

Captured 2 distinct complete SPIR-V module(s) emitted while rerunning test_gs_ds_ring.py on the merged tree. All assembled and passed spirv-val for Vulkan 1.2 with --allow-offset-texture-operand.

With the native Vulkan harness, 5/5 failed on the baseline before rasterization because translation rejected the GS LDS accesses. After merging, 5/5 passed on each adapter, including the 8×8 control, reference and wide/strided readbacks. The initial RTX baseline timed out and the completed repeat gave the five translation failures.

Windows Vulkan adapters: AMD Radeon(TM) Graphics (26.11.2) and NVIDIA GeForce RTX 5070 Ti (610.74).

Additional commands

  • python -m pytest -q -rA tests/test_gs_ds_ring.py (Windows, LEONIDA_VK_HARNESS set)

Base 3bd936ecd98995bca3e1da83d5e28d2343001aef was merged into the recorded PR head for the second run. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Native runs used Windows 11, Python 3.12.10. Counts include unittest subtest events where applicable. AI-assisted with OpenAI Codex. Batch claim.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7238096910 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1761#issuecomment-7238096910). Originally posted by [sodove](https://github.com/sodove) on 2026-11-28T10:44:58Z. --- #1761 | head `ed94596196fadac949db27055e554a7c6bb076ad` | `python3 -m pytest -q -rA tests/test_gs_ds_ring.py` | red: 5 run, 4 failures, 1 skipped | green: 4 passed, 1 skipped | **Red → green. Native Vulkan 5/5 passed on AMD and RTX** The WSL run exercised the four geometry translation cases. For the optional rasterization case I reran the whole file with LEONIDA_VK_HARNESS on native Windows on each GPU. Captured 2 distinct complete SPIR-V module(s) emitted while rerunning test_gs_ds_ring.py on the merged tree. All assembled and passed spirv-val for Vulkan 1.2 with --allow-offset-texture-operand. With the native Vulkan harness, 5/5 failed on the baseline before rasterization because translation rejected the GS LDS accesses. After merging, 5/5 passed on each adapter, including the 8×8 control, reference and wide/strided readbacks. The initial RTX baseline timed out and the completed repeat gave the five translation failures. Windows Vulkan adapters: AMD Radeon(TM) Graphics (26.11.2) and NVIDIA GeForce RTX 5070 Ti (610.74). Additional commands - `python -m pytest -q -rA tests/test_gs_ds_ring.py (Windows, LEONIDA_VK_HARNESS set)` Base `3bd936ecd98995bca3e1da83d5e28d2343001aef` was merged into the recorded PR head for the second run. Ubuntu 26.04.1 (WSL2), Python 3.14.4. Native runs used Windows 11, Python 3.12.10. Counts include unittest subtest events where applicable. AI-assisted with OpenAI Codex. [Batch claim](https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7237873883).
DadaCap commented 2026-11-28 11:53:28 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by DadaCap on 2026-11-28T11:53:28Z.


Merged, thank you @potatoe0100! This translator PR (OLD-9996: rdna2spirv: lower wide and strided geometry shader LDS accesses) 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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7238850348 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1761#issuecomment-7238850348). Originally posted by [DadaCap](https://github.com/DadaCap) on 2026-11-28T11:53:28Z. --- Merged, thank you @potatoe0100! This translator PR (OLD-9996: rdna2spirv: lower wide and strided geometry shader LDS accesses) 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.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!1761
No description provided.