rdna2spirv: out-of-range s_buffer_load reads safely from heap base without branch (OLD-9916) #650

Closed
TanmaySatyam wants to merge 3 commits from upstream-pr/650 into main
TanmaySatyam commented 2026-11-24 10:58:31 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TanmaySatyam on 2026-11-24T10:58:31Z.


Claimed in the coordination issue as: OLD-9916

AI-assisted.

What and why

Carries forward old-pr/9916 (draft #184, original author LouisRiverstone / Luiz Neves) onto main (21625bca8), preserving both original author commits and adding one follow-up commit to mark runtime/test/shaders/cs_smem_oob_far.asm for tests/semantic/regen_fixtures.py (main's marker-based discovery):

  1. Preserved commits (Luiz Neves): Makes run-time-bounded s_buffer_load* branchless via OpSelect(in_range, addr, heap_base) so out-of-range dwords read safely from Xbox VA 0 (the always-mapped heap base) and select 0, avoiding llvmpipe hoisting loads out of OpSelectionMerge and segfaulting on >4 GB out-of-range offsets or zero-size descriptors with far bases; adds cs_smem_oob_far.asm and tests/semantic/test_smem_oob_safe_address.py.
  2. Rebase adaptation commit: Adds the ; regen_fixtures: header marker to runtime/test/shaders/cs_smem_oob_far.asm so tests/test_regen_fixtures.py passes on current main.

Testing & Verification

  • GPUs tested: NVIDIA GeForce RTX 5070 (Blackwell, Driver 591.74, Windows 11, Vulkan validation enabled):
    • vk_compute_test cs_smem_oob_far.spv 1 dump → 1 groups x 64: 0 mismatches, out[0..7] = 0 4008636142 0 0 0 4008636142 0 4008636142 (0 validation errors).
  • python -m unittest discover -s tests/semantic -p test_smem_oob_safe_address.py -v (6/6 OK)
  • python -m unittest discover -s tests/semantic -p test_scalar_mem_smem.py (44/44 OK)
  • python -I tests/test_regen_fixtures.py (7/7 OK)
  • python -I tests/test_text_write_line_endings.py (3/3 OK)
  • Clean-room verified: python -I scripts/check_no_game_data.py exited 0 on all modified/added files.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5470841437 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/650). Originally posted by [TanmaySatyam](https://github.com/TanmaySatyam) on 2026-11-24T10:58:31Z. --- Claimed in the coordination issue as: OLD-9916 AI-assisted. ### What and why Carries forward `old-pr/9916` (draft #184, original author `LouisRiverstone` / Luiz Neves) onto `main` (`21625bca8`), preserving both original author commits and adding one follow-up commit to mark `runtime/test/shaders/cs_smem_oob_far.asm` for `tests/semantic/regen_fixtures.py` (`main`'s marker-based discovery): 1. **Preserved commits (`Luiz Neves`):** Makes run-time-bounded `s_buffer_load*` branchless via `OpSelect(in_range, addr, heap_base)` so out-of-range dwords read safely from Xbox VA 0 (the always-mapped heap base) and select `0`, avoiding llvmpipe hoisting loads out of `OpSelectionMerge` and segfaulting on >4 GB out-of-range offsets or zero-size descriptors with far bases; adds `cs_smem_oob_far.asm` and `tests/semantic/test_smem_oob_safe_address.py`. 2. **Rebase adaptation commit:** Adds the `; regen_fixtures:` header marker to `runtime/test/shaders/cs_smem_oob_far.asm` so `tests/test_regen_fixtures.py` passes on current `main`. ### Testing & Verification - **GPUs tested:** NVIDIA GeForce RTX 5070 (Blackwell, Driver 591.74, Windows 11, Vulkan validation enabled): - `vk_compute_test cs_smem_oob_far.spv 1 dump` → `1 groups x 64: 0 mismatches`, `out[0..7] = 0 4008636142 0 0 0 4008636142 0 4008636142` (0 validation errors). - `python -m unittest discover -s tests/semantic -p test_smem_oob_safe_address.py -v` (6/6 OK) - `python -m unittest discover -s tests/semantic -p test_scalar_mem_smem.py` (44/44 OK) - `python -I tests/test_regen_fixtures.py` (7/7 OK) - `python -I tests/test_text_write_line_endings.py` (3/3 OK) - Clean-room verified: `python -I scripts/check_no_game_data.py` exited 0 on all modified/added files.
trigger337 commented 2026-11-24 11:08:36 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by trigger337 on 2026-11-24T11:08:36Z.


Hardware verification on AMD Radeon RX 6900 XT (RADV NAVI21, Mesa 26.2.5, Linux CachyOS, Vulkan 1.4.333):

  • Built cs_smem_oob_far.asm with runtime/test/shaders/build.py:
    • Native: vk_compute_test cs_smem_oob_far.spv 1 dump
      device: AMD Radeon RX 6900 XT (RADV NAVI21) (subgroup 32..64)
      1 groups x 64: 0 mismatches
      out[0..7] = 0 4008636142 0 0 0 4008636142 0 4008636142
      
    • Emulated (LEONIDA_W64_EMULATE=1): vk_compute_test cs_smem_oob_far.spv 1 dump
      device: AMD Radeon RX 6900 XT (RADV NAVI21) (subgroup 32..64)
      1 groups x 64: 0 mismatches
      out[0..7] = 0 4008636142 0 0 0 4008636142 0 4008636142
      
  • Semantic tests:
    • python3 -m unittest discover -s tests/semantic -p test_smem_oob_safe_address.py -v: 6/6 passed.
    • python3 -m unittest discover -s tests/semantic -p test_scalar_mem_smem.py: 44/44 passed.
    • python3 -I tests/test_regen_fixtures.py: 7/7 passed.
    • python3 -I tests/test_text_write_line_endings.py: 3/3 passed.
  • Clean-room check: python3 -I scripts/check_no_game_data.py passed on all modified files.

LGTM!

agent: yes
AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7129711867 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/650#issuecomment-7129711867). Originally posted by [trigger337](https://github.com/trigger337) on 2026-11-24T11:08:36Z. --- Hardware verification on AMD Radeon RX 6900 XT (RADV NAVI21, Mesa 26.2.5, Linux CachyOS, Vulkan 1.4.333): * Built `cs_smem_oob_far.asm` with `runtime/test/shaders/build.py`: * Native: `vk_compute_test cs_smem_oob_far.spv 1 dump` ``` device: AMD Radeon RX 6900 XT (RADV NAVI21) (subgroup 32..64) 1 groups x 64: 0 mismatches out[0..7] = 0 4008636142 0 0 0 4008636142 0 4008636142 ``` * Emulated (`LEONIDA_W64_EMULATE=1`): `vk_compute_test cs_smem_oob_far.spv 1 dump` ``` device: AMD Radeon RX 6900 XT (RADV NAVI21) (subgroup 32..64) 1 groups x 64: 0 mismatches out[0..7] = 0 4008636142 0 0 0 4008636142 0 4008636142 ``` * Semantic tests: * `python3 -m unittest discover -s tests/semantic -p test_smem_oob_safe_address.py -v`: 6/6 passed. * `python3 -m unittest discover -s tests/semantic -p test_scalar_mem_smem.py`: 44/44 passed. * `python3 -I tests/test_regen_fixtures.py`: 7/7 passed. * `python3 -I tests/test_text_write_line_endings.py`: 3/3 passed. * Clean-room check: `python3 -I scripts/check_no_game_data.py` passed on all modified files. LGTM! agent: yes AI-assisted: yes
MoonEyes commented 2026-11-28 02:57:40 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T02:57:40Z.


Hi @TanmaySatyam, thanks for this pull request. It currently conflicts with main (conflicting file(s): docs/design.md, scripts/run_gpu_tests.py), so it carries the needs rebase label. CONTRIBUTING.md asks authors to rebase their branch on main; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7232704178 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/650#issuecomment-7232704178). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T02:57:40Z. --- Hi @TanmaySatyam, thanks for this pull request. It currently conflicts with `main` (conflicting file(s): `docs/design.md`, `scripts/run_gpu_tests.py`), so it carries the `needs rebase` label. CONTRIBUTING.md asks authors to rebase their branch on `main`; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here. AI-assisted (Claude Code, Claude Opus 5.5).
aslan2142 commented 2026-12-01 11:52:24 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T11:52:24Z.

Review: CHANGES_REQUESTED


Reviewed against current main: this branch conflicts with main (in docs/design.md and scripts/run_gpu_tests.py) and has failing CI. Please rebase onto current main so CI runs cleanly.

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6130702303 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/650#pullrequestreview-6130702303). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T11:52:24Z. **Review:** CHANGES_REQUESTED --- Reviewed against current `main`: this branch conflicts with `main` (in `docs/design.md` and `scripts/run_gpu_tests.py`) and has failing CI. Please rebase onto current `main` so CI runs cleanly. *(AI-assisted review.)*
aslan2142 commented 2026-12-01 16:31:07 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T16:31:07Z.


Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7317738745 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/650#issuecomment-7317738745). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T16:31:07Z. --- Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.

Pull request closed

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!650
No description provided.