rdna2spirv: guard image_bvh PhysicalStorageBuffer loads on active EXEC lanes #95

Open
github-bot wants to merge 1 commit from github-bot/gh-95 into main AGit
Owner

@⁠Andretuta on GitHub · 2026-11-24 02:16 UTC · original
ubiquitarianism:old-pr/9827 → main · +51 −1 · 2 files · 1 commits · draft

Carried over from old PR 9827 by Lewandox in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9827, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
Lewandox: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

Gen.image_bvh() in tools/rdna2spirv.py only predicated the final vgpr writes (out(k, ...)) on EXEC, never the PhysicalStorageBuffer loads (OpConvertUToPtr / OpLoad). In a divergent BVH traversal loop where finished lanes are masked off in EXEC and hold stale or null node pointers, inactive lanes still entered the triangle/box branches and issued 10-40 PSB loads from invalid addresses (risking VK_ERROR_DEVICE_LOST), unlike global_mem, global_sub, buffer_load, buffer_load_sub, and global_atomic which all guard their loads with self.active_b().

Wrap the PSB pointer conversion and node-type dispatch in an outer OpSelectionMerge / OpBranchConditional on self.active_b() so inactive lanes skip all PSB loads and leave v[vd:vd+3] untouched.

Added an inactive-lane (EXEC == 0) regression test in tests/semantic/test_image_bvh_box.py covering triangle (type=0) and box (type=4, 5) nodes with a read-tracking memory map (fails with 10 / 40 PSB reads before the fix, passes with 0 reads and preserved vdst after).

Claimed in #9065. AI-assisted; tested on Windows 11 / Python 3.12.10 with python -I -m unittest discover -s tests/semantic -p "*bvh*.py" -v, python -m compileall -q tools/rdna2spirv.py tests/semantic/test_image_bvh_box.py, and python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/semantic/test_image_bvh_box.py (no game files).

Reopened after mass PR cleanup (previously #9170).

**@⁠Andretuta** on GitHub · 2026-11-24 02:16 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/95) `ubiquitarianism:old-pr/9827` → `main` · +51 −1 · 2 files · 1 commits · draft > Carried over from **old PR 9827** by `Lewandox` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/9827`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > `Lewandox`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): `Gen.image_bvh()` in `tools/rdna2spirv.py` only predicated the final `vgpr` writes (`out(k, ...)`) on `EXEC`, never the `PhysicalStorageBuffer` loads (`OpConvertUToPtr` / `OpLoad`). In a divergent BVH traversal loop where finished lanes are masked off in `EXEC` and hold stale or null node pointers, inactive lanes still entered the triangle/box branches and issued 10-40 PSB loads from invalid addresses (risking `VK_ERROR_DEVICE_LOST`), unlike `global_mem`, `global_sub`, `buffer_load`, `buffer_load_sub`, and `global_atomic` which all guard their loads with `self.active_b()`. Wrap the PSB pointer conversion and node-type dispatch in an outer `OpSelectionMerge` / `OpBranchConditional` on `self.active_b()` so inactive lanes skip all PSB loads and leave `v[vd:vd+3]` untouched. Added an inactive-lane (`EXEC == 0`) regression test in `tests/semantic/test_image_bvh_box.py` covering triangle (`type=0`) and box (`type=4, 5`) nodes with a read-tracking memory map (fails with 10 / 40 PSB reads before the fix, passes with 0 reads and preserved `vdst` after). Claimed in `#9065`. AI-assisted; tested on Windows 11 / Python 3.12.10 with `python -I -m unittest discover -s tests/semantic -p "*bvh*.py" -v`, `python -m compileall -q tools/rdna2spirv.py tests/semantic/test_image_bvh_box.py`, and `python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/semantic/test_image_bvh_box.py` (no game files). Reopened after mass PR cleanup (previously `#9170`).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:44:12 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/95/head:github-bot/gh-95'
git switch 'github-bot/gh-95'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-95'
git switch 'github-bot/gh-95'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-95'
git switch 'github-bot/gh-95'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-95'
git switch 'main'
git merge --squash 'github-bot/gh-95'
git switch 'main'
git merge --ff-only 'github-bot/gh-95'
git switch 'main'
git merge 'github-bot/gh-95'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.