[PR #2018] shader_meta: handle short v_*_co_ci_u32, SMEM atomics, buffer_load lds, and VGPR swap/rel vscale (SHADER-META-OPERANDS-AND-LDS) #2025

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

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2018
Author: @ShotTechOp
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: fix/shader-meta-operands-lds


📝 Commits (1)

  • 92c174d shader_meta: fix short v_*_co_ci_u32, SMEM atomics, buffer_load lds, and VGPR swap/rel vscale

📊 Changes

2 files changed (+148 additions, -13 deletions)

View changed files

➕ tests/test_shader_meta_split_and_lds.py (+109 -0)
📝 tools/shader_meta.py (+39 -13)

📄 Description

Claimed in #1608 as SHADER-META-OPERANDS-AND-LDS.

What and why

Fixes four static-analysis bugs in tools/shader_meta.py:

  1. 3-operand v_*_co_ci_u32 short forms (v_add_co_ci_u32 vD, src0, src1 and sub/subrev variants with implicit VCC): _split_operands previously treated a[1] as a written carry-out SGPR regardless of arity, dropping a user SGPR in src0 from reads and marking it written. Carry-out a[1] is now treated as a write only when len(a) >= 4.
  2. SMEM atomics (s_atomic_*, s_buffer_atomic_*): _split_operands previously placed a[0] in writes only, missing it as a read-before-write operand and falsely clobbering it when glc is absent. _step_state now also classifies a[1] as ptr64/ptr32_lo (s_atomic_*) or vsharp (s_buffer_atomic_*).
  3. LDS DMA buffer loads (buffer_load* / tbuffer_load* with lds): these omit vdata, placing srsrc (V#) at a[1] instead of a[2]. _step_state now inspects a[1] when lds is present so user-SGPR V#s are classified as vsharp.
  4. VGPR vscale tracking across v_swap_b32 and v_movreld_b32/v_movrelsd_b32/v_movrelsd_2_b32/v_swaprel_b32: v_swap_b32 now swaps vscale between both operands instead of only clearing a[0], and relative VGPR writes clear vscale entries at or above the base VGPR.

Testing

  • AI-assisted: yes.
  • Environment: Windows 11, Python 3.12 (no GPU / LLVM / SPIRV-Tools installed locally).
  • New test suite: tests/test_shader_meta_split_and_lds.py.
  • RED control on origin/main: tests/test_shader_meta_split_and_lds.py fails with FAILED (failures=9) across all 4 test methods on origin/main.
  • GREEN checks on branch:
    • python -I tests/test_shader_meta_split_and_lds.py -v (4/4 OK)
    • python -I tests/test_shader_meta.py (28/28 OK)
    • python -I tests/test_shader_meta_operands.py (5/5 OK)
    • python -I tests/test_text_write_line_endings.py (3/3 OK)
    • python -m compileall -q tools/shader_meta.py tests/test_shader_meta_split_and_lds.py
    • python -I scripts/check_no_game_data.py tools/shader_meta.py tests/test_shader_meta_split_and_lds.py
    • git diff --check

🔄 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/2018 **Author:** [@ShotTechOp](https://github.com/ShotTechOp) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/shader-meta-operands-lds` --- ### 📝 Commits (1) - [`92c174d`](https://github.com/ubiquitarianism/leonida/commit/92c174d7b28fa501c6cb622761dd47932301fd97) shader_meta: fix short v_*_co_ci_u32, SMEM atomics, buffer_load lds, and VGPR swap/rel vscale ### 📊 Changes **2 files changed** (+148 additions, -13 deletions) <details> <summary>View changed files</summary> ➕ `tests/test_shader_meta_split_and_lds.py` (+109 -0) 📝 `tools/shader_meta.py` (+39 -13) </details> ### 📄 Description Claimed in #1608 as `SHADER-META-OPERANDS-AND-LDS`. ## What and why Fixes four static-analysis bugs in `tools/shader_meta.py`: 1. **3-operand `v_*_co_ci_u32` short forms** (`v_add_co_ci_u32 vD, src0, src1` and `sub`/`subrev` variants with implicit VCC): `_split_operands` previously treated `a[1]` as a written carry-out SGPR regardless of arity, dropping a user SGPR in `src0` from `reads` and marking it written. Carry-out `a[1]` is now treated as a write only when `len(a) >= 4`. 2. **SMEM atomics (`s_atomic_*`, `s_buffer_atomic_*`)**: `_split_operands` previously placed `a[0]` in `writes` only, missing it as a read-before-write operand and falsely clobbering it when `glc` is absent. `_step_state` now also classifies `a[1]` as `ptr64`/`ptr32_lo` (`s_atomic_*`) or `vsharp` (`s_buffer_atomic_*`). 3. **LDS DMA buffer loads (`buffer_load*` / `tbuffer_load*` with `lds`)**: these omit `vdata`, placing `srsrc` (V#) at `a[1]` instead of `a[2]`. `_step_state` now inspects `a[1]` when `lds` is present so user-SGPR V#s are classified as `vsharp`. 4. **VGPR `vscale` tracking across `v_swap_b32` and `v_movreld_b32`/`v_movrelsd_b32`/`v_movrelsd_2_b32`/`v_swaprel_b32`**: `v_swap_b32` now swaps `vscale` between both operands instead of only clearing `a[0]`, and relative VGPR writes clear `vscale` entries at or above the base VGPR. ## Testing - **AI-assisted**: yes. - **Environment**: Windows 11, Python 3.12 (no GPU / LLVM / SPIRV-Tools installed locally). - **New test suite**: `tests/test_shader_meta_split_and_lds.py`. - **RED control on `origin/main`**: `tests/test_shader_meta_split_and_lds.py` fails with `FAILED (failures=9)` across all 4 test methods on `origin/main`. - **GREEN checks on branch**: - `python -I tests/test_shader_meta_split_and_lds.py -v` (4/4 OK) - `python -I tests/test_shader_meta.py` (28/28 OK) - `python -I tests/test_shader_meta_operands.py` (5/5 OK) - `python -I tests/test_text_write_line_endings.py` (3/3 OK) - `python -m compileall -q tools/shader_meta.py tests/test_shader_meta_split_and_lds.py` - `python -I scripts/check_no_game_data.py tools/shader_meta.py tests/test_shader_meta_split_and_lds.py` - `git diff --check` --- <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#2025
No description provided.