[PR #1908] rdna2spirv: model atomic VGPR reads and writes in liveness analyses (SHADER-RBW-ATOMIC-DATA) #1918

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

📋 Pull Request Information

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

Base: main ← Head: contrib/rbw-atomic-data


📝 Commits (1)

  • e0f7d8a rdna2spirv: model atomic VGPR reads and writes in liveness analyses (SHADER-RBW-ATOMIC-DATA)

📊 Changes

3 files changed (+198 additions, -14 deletions)

View changed files

📝 docs/design.md (+1 -0)
➕ tests/semantic/test_rbw_atomic_data.py (+157 -0)
📝 tools/rdna2spirv.py (+40 -14)

📄 Description

Claimed in the coordination issue as: SHADER-RBW-ATOMIC-DATA

What and why

read_before_write_vgprs(), interp_ij_analysis(), and reg_reads_writes() in tools/rdna2spirv.py previously treated only VGPR_READ_ONLY_PREFIXES (plus global_atomic_ without glc in read_before_write_vgprs() only) as read-only on a[0]:

  • Non-returning buffer_atomic_*, image_atomic_*, flat_atomic_*, non-_rtn DS atomics, and ds_store* were treated as overwriting a[0] without reading it, causing pixel shaders whose first touch of entry barycentrics (v0/v1) is e.g. buffer_atomic_add v0, ... to omit loading %bary (sending 0 to the atomic and downstream exports) and falsely triggering computed-I/J PerVertexKHR lowering in interp_ij_analysis().
  • Returning buffer_atomic_* and image_atomic_* (glc) also read a[0] (including multi-VGPR cmpswap / _x2 data pairs) before overwriting a[0] with the prior value.
  • interp_ij_analysis() and reg_reads_writes() also lacked global_atomic_ non-glc handling.

Changes:

  1. Added "ds_store" to VGPR_READ_ONLY_PREFIXES and introduced shared helpers _vgpr_reads_all(op, mods) and _vgpr_dst_also_read(op, mods) in tools/rdna2spirv.py, applied uniformly across read_before_write_vgprs(), interp_ij_analysis(), and reg_reads_writes() (including full a[0] multi-register range range(a[0]["r"], a[0]["r"] + a[0].get("n", 1)) when returning buffer_atomic_*/image_atomic_* or DST_ALSO_READ reads a[0]).
  2. Added tests/semantic/test_rbw_atomic_data.py with CPU fragment execution (spirv_mini_interp) for non-glc and glc PS barycentric buffer_atomic_add, interp_ij_analysis PerVertexKHR discrimination, and unit coverage across buffer_atomic_*, cmpswap, _x2, image_atomic_* (vector & NSA vlist), global_atomic_*, flat_atomic_*, ds_store*, and non-_rtn/_rtn DS atomics.
  3. Added the Atomic VGPR operand liveness (SHADER-RBW-ATOMIC-DATA) row to docs/design.md.

Tested

  • git diff --cached --check -> exit 0
  • python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/semantic/test_rbw_atomic_data.py docs/design.md -> exit 0
  • python -I tests/semantic/test_rbw_atomic_data.py -> Ran 5 tests in 0.039s OK
  • python -I -m unittest discover -s tests/semantic -p "test_store_liveins.py" -> Ran 4 tests in 0.061s OK
  • python -I -m unittest discover -s tests/semantic -p "test_interp_computed_ij.py" -> Ran 22 tests in 0.420s OK
  • python -I -m compileall -q make_game.py tools tests -> exit 0
  • python -I make_game.py --help -> exit 0
  • python -I tests/test_text_write_line_endings.py (3 OK), tests/test_report_paths.py (22 tests, 1 skipped, OK), tests/test_docs_design_rows.py (5 OK), tests/test_docs_repo_paths.py (3 OK), tests/test_docs_repeated_lines.py (2 OK), tests/test_ci_registration.py (16 OK)
  • python -I scripts/run_semantic_tests.py tests/semantic -> 490 files, 6293 tests, 0 files failed in 196 s with 16 jobs

GPUs tested: n/a

AI-assisted: yes

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.

🔄 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/1908 **Author:** [@JordanWebDev](https://github.com/JordanWebDev) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `contrib/rbw-atomic-data` --- ### 📝 Commits (1) - [`e0f7d8a`](https://github.com/ubiquitarianism/leonida/commit/e0f7d8a6cd14ab11bee032356f69dea9d6a2ee37) rdna2spirv: model atomic VGPR reads and writes in liveness analyses (SHADER-RBW-ATOMIC-DATA) ### 📊 Changes **3 files changed** (+198 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `docs/design.md` (+1 -0) ➕ `tests/semantic/test_rbw_atomic_data.py` (+157 -0) 📝 `tools/rdna2spirv.py` (+40 -14) </details> ### 📄 Description Claimed in the coordination issue as: SHADER-RBW-ATOMIC-DATA ### What and why `read_before_write_vgprs()`, `interp_ij_analysis()`, and `reg_reads_writes()` in `tools/rdna2spirv.py` previously treated only `VGPR_READ_ONLY_PREFIXES` (plus `global_atomic_` without `glc` in `read_before_write_vgprs()` only) as read-only on `a[0]`: - Non-returning `buffer_atomic_*`, `image_atomic_*`, `flat_atomic_*`, non-`_rtn` DS atomics, and `ds_store*` were treated as overwriting `a[0]` without reading it, causing pixel shaders whose first touch of entry barycentrics (`v0`/`v1`) is e.g. `buffer_atomic_add v0, ...` to omit loading `%bary` (sending 0 to the atomic and downstream exports) and falsely triggering computed-I/J `PerVertexKHR` lowering in `interp_ij_analysis()`. - Returning `buffer_atomic_*` and `image_atomic_*` (`glc`) also read `a[0]` (including multi-VGPR `cmpswap` / `_x2` data pairs) before overwriting `a[0]` with the prior value. - `interp_ij_analysis()` and `reg_reads_writes()` also lacked `global_atomic_` non-`glc` handling. Changes: 1. Added `"ds_store"` to `VGPR_READ_ONLY_PREFIXES` and introduced shared helpers `_vgpr_reads_all(op, mods)` and `_vgpr_dst_also_read(op, mods)` in `tools/rdna2spirv.py`, applied uniformly across `read_before_write_vgprs()`, `interp_ij_analysis()`, and `reg_reads_writes()` (including full `a[0]` multi-register range `range(a[0]["r"], a[0]["r"] + a[0].get("n", 1))` when returning `buffer_atomic_*`/`image_atomic_*` or `DST_ALSO_READ` reads `a[0]`). 2. Added `tests/semantic/test_rbw_atomic_data.py` with CPU fragment execution (`spirv_mini_interp`) for non-`glc` and `glc` PS barycentric `buffer_atomic_add`, `interp_ij_analysis` `PerVertexKHR` discrimination, and unit coverage across `buffer_atomic_*`, `cmpswap`, `_x2`, `image_atomic_*` (vector & NSA `vlist`), `global_atomic_*`, `flat_atomic_*`, `ds_store*`, and non-`_rtn`/`_rtn` DS atomics. 3. Added the `Atomic VGPR operand liveness (SHADER-RBW-ATOMIC-DATA)` row to `docs/design.md`. ### Tested - `git diff --cached --check` -> exit 0 - `python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/semantic/test_rbw_atomic_data.py docs/design.md` -> exit 0 - `python -I tests/semantic/test_rbw_atomic_data.py` -> Ran 5 tests in 0.039s OK - `python -I -m unittest discover -s tests/semantic -p "test_store_liveins.py"` -> Ran 4 tests in 0.061s OK - `python -I -m unittest discover -s tests/semantic -p "test_interp_computed_ij.py"` -> Ran 22 tests in 0.420s OK - `python -I -m compileall -q make_game.py tools tests` -> exit 0 - `python -I make_game.py --help` -> exit 0 - `python -I tests/test_text_write_line_endings.py` (3 OK), `tests/test_report_paths.py` (22 tests, 1 skipped, OK), `tests/test_docs_design_rows.py` (5 OK), `tests/test_docs_repo_paths.py` (3 OK), `tests/test_docs_repeated_lines.py` (2 OK), `tests/test_ci_registration.py` (16 OK) - `python -I scripts/run_semantic_tests.py tests/semantic` -> 490 files, 6293 tests, 0 files failed in 196 s with 16 jobs GPUs tested: n/a AI-assisted: yes ### 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. --- <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#1918
No description provided.