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

Merged
Andretuta merged 1 commit from upstream-pr/95 into main 2026-12-01 15:13:24 +00:00
Andretuta commented 2026-11-24 02:16:55 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Andretuta on 2026-11-24T02:16:55Z.


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).

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5464814766 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/95). Originally posted by [Andretuta](https://github.com/Andretuta) on 2026-11-24T02:16:55Z. --- > 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`).
MoonEyes commented 2026-11-30 18:36:08 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-30T18:36:08Z.


Maintainer review: not ready to merge. The active-lane guard is absent from current main, so this does not appear obsolete. This remains a draft and all current checks were cancelled; please promote it when ready, establish the claim in the current coordination issue, and rerun focused plus required CI against the integrated current-main tree. PR #137 also changes the image_bvh lowering in the same source file; please coordinate/recheck the combined result. The existing Ray tracing contract row does not state this inactive-lane load guarantee, so please document it there with its confirmation basis, or explain why no contract update is needed.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7288091339 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/95#issuecomment-7288091339). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-30T18:36:08Z. --- Maintainer review: not ready to merge. The active-lane guard is absent from current main, so this does not appear obsolete. This remains a draft and all current checks were cancelled; please promote it when ready, establish the claim in the current coordination issue, and rerun focused plus required CI against the integrated current-main tree. PR #137 also changes the image_bvh lowering in the same source file; please coordinate/recheck the combined result. The existing Ray tracing contract row does not state this inactive-lane load guarantee, so please document it there with its confirmation basis, or explain why no contract update is needed.
aslan2142 commented 2026-12-01 12:00:04 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T12:00:04Z.

Review: COMMENTED


Draft review against current main: the active-lane EXEC guard around image_bvh PhysicalStorageBuffer loads in tools/rdna2spirv.py:13905-13911 looks clean, clean-room verified, and still relevant, but CI checks are cancelled and the PR is still Draft. Please merge/rebase current main and mark Ready for Review so CI runs green.

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6130839577 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/95#pullrequestreview-6130839577). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T12:00:04Z. **Review:** COMMENTED --- Draft review against current `main`: the active-lane EXEC guard around `image_bvh` PhysicalStorageBuffer loads in `tools/rdna2spirv.py:13905-13911` looks clean, clean-room verified, and still relevant, but CI checks are cancelled and the PR is still Draft. Please merge/rebase current `main` and mark Ready for Review so CI runs green. *(AI-assisted review.)*
aslan2142 commented 2026-12-01 12:07:25 +00:00 (Migrated from github.com)

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


Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review.

(AI-assisted triage.)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7310682129 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/95#issuecomment-7310682129). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T12:07:25Z. --- Marking Ready for Review since no WIP/blocker reason for draft status is specified on this PR, so it can enter normal CI and review. *(AI-assisted triage.)*
aslan2142 commented 2026-12-01 13:02:20 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T13:02:20Z.

Review: APPROVED


Now ready for review and MERGEABLE. Clean-room verified: the active-lane EXEC guard on image_bvh PhysicalStorageBuffer loads in tools/rdna2spirv.py:13905-13911 with tests/semantic/test_image_bvh_box.py is clean and well-scoped. (Note: coordinate merge order with #137, which also touches image_bvh lowering.)

Approving — ready to merge once fresh CI runs green on current main (existing Nov 24 checks were cancelled).

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6131770472 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/95#pullrequestreview-6131770472). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T13:02:20Z. **Review:** APPROVED --- Now ready for review and `MERGEABLE`. Clean-room verified: the active-lane `EXEC` guard on `image_bvh` `PhysicalStorageBuffer` loads in `tools/rdna2spirv.py:13905-13911` with `tests/semantic/test_image_bvh_box.py` is clean and well-scoped. (Note: coordinate merge order with `#137`, which also touches `image_bvh` lowering.) Approving — ready to merge once fresh CI runs green on current `main` (existing Nov 24 checks were cancelled). *(AI-assisted review.)*
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!95
No description provided.