[PR #2168] rdna2spirv: MUBUF loads to LDS, buffer_load_{dword,ubyte,sbyte,ushort,sshort} ... lds (SHADER-MUBUF-LDS-DMA) #2173

Open
opened 2026-11-26 21:20:17 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2168
Author: @vinceychu
Created: 11/26/2026
Status: 🔄 Open

Base: main ← Head: shader-mubuf-lds-dma


📝 Commits (1)

  • 5e7ab21 rdna2spirv: MUBUF loads to LDS, buffer_load_{dword,ubyte,sbyte,ushort,sshort} ... lds (SHADER-MUBUF-LDS-DMA)

📊 Changes

7 files changed (+357 additions, -10 deletions)

View changed files

📝 docs/design.md (+1 -0)
📝 runtime/test/shaders/check.py (+8 -3)
➕ runtime/test/shaders/cs_buf_lds.asm (+53 -0)
📝 scripts/run_gpu_tests.py (+6 -2)
➕ tests/semantic/test_buffer_load_lds.py (+215 -0)
📝 tests/semantic/test_buffer_load_sub.py (+1 -2)
📝 tools/rdna2spirv.py (+73 -3)

📄 Description

Claimed in the coordination issue as: SHADER-MUBUF-LDS-DMA (#1608)

What and why

The translator refused the lds modifier on MUBUF loads (raise Unsupported(op + " form")). With it, RDNA2 loads go
straight to LDS ("Memory Buffer Load to LDS", RDNA2 ISA 8.1.9), the way compilers stage data into shared memory.

  • Forms: buffer_load_dword, buffer_load_ubyte, buffer_load_sbyte, buffer_load_ushort, buffer_load_sshort
    with lds, in compute and mesh shaders.
  • The value goes to LDS, not a VGPR, at LDS_BASE + M0[15:0] + inst_offset + TIDinWave*4 (the ISA figure; TIDinWave
    is added on the LDS path whatever the V#'s ADD_TID_ENABLE says). The VDATA field names the M# and is ignored; the
    llvm-mc spelling omits it, so a three-operand listing is accepted too.
  • The memory read is buffer_address's, bounds-checked exactly like the VGPR forms; an out-of-range read supplies 0,
    which is what the lane writes. Sub-dword values are zero- or sign-extended to the stored dword (the byte/short read
    is shared with buffer_load_sub through a new buffer_sub_value helper).
  • The LDS write runs in active lanes only and goes through lds_access, so it is dropped outside the wave's LDS
    allocation (RSRC2 LDS_SIZE for compute), like the ds_* stores.
  • Still refused, rather than guessed: buffer_load_dwordxN ... lds (not in the ISA's lds subset),
    buffer_load_format_* ... lds, tfe with lds, and other stages.
  • design.md: new contract-table row next to "Sub-dword MUBUF loads".

Tested

  • New GPU fixture runtime/test/shaders/cs_buf_lds.asm (registered in check.py and run_gpu_tests.py): 32 lanes
    load a dword, a ubyte and an sbyte into three M0-based LDS regions, s_waitcnt + s_barrier, then read back
    their own and their neighbour's (t^1) slots. run_gpu_tests.py --filter cs_buf_lds: PASS on an RTX 5090
    (NVIDIA 595.99.02, Ubuntu 26.04) and on the Ryzen 9 9950X's Radeon iGPU (RADV, Mesa 26.0.8)
    .
  • New tests/semantic/test_buffer_load_lds.py (10 tests through spirv_mini_interp): per-lane slots, offset: and
    M0[15:0], the three-operand form, u/s byte/short extension, out of range -> 0, inactive lanes write nothing, the
    out-of-allocation drop, the refused forms.
  • python -I scripts/run_semantic_tests.py tests/semantic: 496 files, 6,343 tests, 0 failed.
  • pytest tests/test_translate.py: 714 passed; the 2 failures are cs_dpp_cmp.asm with LLVM 21, failing on main too
    (#1375).
  • python -m compileall, tests/test_ci_registration.py: clean.
  • Not run: the native hardware oracle (tools/hw_oracle) — the only RDNA2 GPU here drives a display.

GPUs tested: NVIDIA GeForce RTX 5090 (595.99.02, Ubuntu 26.04.1); AMD Radeon iGPU of the Ryzen 9 9950X (RADV, Mesa 26.0.8)

AI-assisted: yes (Claude Code, with a Devin draft reviewed against the ISA, rebased and GPU-tested)

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

https://claude.ai/code/session_01RAL8MMXUuNpQAVa1iiyAMP


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/2168 **Author:** [@vinceychu](https://github.com/vinceychu) **Created:** 11/26/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `shader-mubuf-lds-dma` --- ### 📝 Commits (1) - [`5e7ab21`](https://github.com/ubiquitarianism/leonida/commit/5e7ab21e0b479e363150ff95a0a8efd4d2fe9975) rdna2spirv: MUBUF loads to LDS, buffer_load_{dword,ubyte,sbyte,ushort,sshort} ... lds (SHADER-MUBUF-LDS-DMA) ### 📊 Changes **7 files changed** (+357 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+1 -0) 📝 `runtime/test/shaders/check.py` (+8 -3) ➕ `runtime/test/shaders/cs_buf_lds.asm` (+53 -0) 📝 `scripts/run_gpu_tests.py` (+6 -2) ➕ `tests/semantic/test_buffer_load_lds.py` (+215 -0) 📝 `tests/semantic/test_buffer_load_sub.py` (+1 -2) 📝 `tools/rdna2spirv.py` (+73 -3) </details> ### 📄 Description Claimed in the coordination issue as: SHADER-MUBUF-LDS-DMA (#1608) ### What and why The translator refused the `lds` modifier on MUBUF loads (`raise Unsupported(op + " form")`). With it, RDNA2 loads go straight to LDS ("Memory Buffer Load to LDS", RDNA2 ISA 8.1.9), the way compilers stage data into shared memory. - Forms: `buffer_load_dword`, `buffer_load_ubyte`, `buffer_load_sbyte`, `buffer_load_ushort`, `buffer_load_sshort` with `lds`, in compute and mesh shaders. - The value goes to LDS, not a VGPR, at `LDS_BASE + M0[15:0] + inst_offset + TIDinWave*4` (the ISA figure; TIDinWave is added on the LDS path whatever the V#'s ADD_TID_ENABLE says). The VDATA field names the M# and is ignored; the llvm-mc spelling omits it, so a three-operand listing is accepted too. - The memory read is `buffer_address`'s, bounds-checked exactly like the VGPR forms; an out-of-range read supplies 0, which is what the lane writes. Sub-dword values are zero- or sign-extended to the stored dword (the byte/short read is shared with `buffer_load_sub` through a new `buffer_sub_value` helper). - The LDS write runs in active lanes only and goes through `lds_access`, so it is dropped outside the wave's LDS allocation (RSRC2 LDS_SIZE for compute), like the `ds_*` stores. - Still refused, rather than guessed: `buffer_load_dwordxN ... lds` (not in the ISA's lds subset), `buffer_load_format_* ... lds`, `tfe` with `lds`, and other stages. - design.md: new contract-table row next to "Sub-dword MUBUF loads". ### Tested - New GPU fixture `runtime/test/shaders/cs_buf_lds.asm` (registered in `check.py` and `run_gpu_tests.py`): 32 lanes load a dword, a ubyte and an sbyte into three M0-based LDS regions, `s_waitcnt` + `s_barrier`, then read back their own and their neighbour's (`t^1`) slots. `run_gpu_tests.py --filter cs_buf_lds`: **PASS on an RTX 5090 (NVIDIA 595.99.02, Ubuntu 26.04) and on the Ryzen 9 9950X's Radeon iGPU (RADV, Mesa 26.0.8)**. - New `tests/semantic/test_buffer_load_lds.py` (10 tests through `spirv_mini_interp`): per-lane slots, `offset:` and `M0[15:0]`, the three-operand form, u/s byte/short extension, out of range -> 0, inactive lanes write nothing, the out-of-allocation drop, the refused forms. - `python -I scripts/run_semantic_tests.py tests/semantic`: 496 files, 6,343 tests, 0 failed. - `pytest tests/test_translate.py`: 714 passed; the 2 failures are `cs_dpp_cmp.asm` with LLVM 21, failing on main too (#1375). - `python -m compileall`, `tests/test_ci_registration.py`: clean. - Not run: the native hardware oracle (`tools/hw_oracle`) — the only RDNA2 GPU here drives a display. GPUs tested: NVIDIA GeForce RTX 5090 (595.99.02, Ubuntu 26.04.1); AMD Radeon iGPU of the Ryzen 9 9950X (RADV, Mesa 26.0.8) AI-assisted: yes (Claude Code, with a Devin draft reviewed against the ISA, rebased and GPU-tested) ### 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) https://claude.ai/code/session_01RAL8MMXUuNpQAVa1iiyAMP --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#2173
No description provided.