rdna2spirv: guard image_bvh PhysicalStorageBuffer loads on active EXEC lanes (OLD-9827) #1258

Closed
ambroseautomation wants to merge 1 commit from upstream-pr/1258 into main
ambroseautomation commented 2026-11-24 21:00:01 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ambroseautomation on 2026-11-24T21:00:01Z.


Claimed in the coordination issue as: OLD-9827 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7144109503)

What and why

Carries forward old-pr/9827 (draft #95, original commit author Lewandox preserved; indexed in #17), rebased cleanly onto current main.

Guards image_bvh*_intersect_ray PhysicalStorageBuffer loads on active EXEC lanes in tools/rdna2spirv.py:

  • Wraps the BVH node pointer dereference and triangle/box intersection body inside an OpSelectionMerge / OpBranchConditional gated on self.active_b(), so inactive lanes (EXEC == 0) in divergent traversal loops never dereference stale or null node pointers and leave vdst untouched.
  • Adds test_inactive_lane_skips_memory_reads_and_preserves_dst in tests/semantic/test_image_bvh_box.py.

Tested

  • python -m unittest discover -s tests/semantic -p test_image_bvh_box.py -v: 5 tests, OK.
  • python -m unittest discover -s tests/semantic -p test_image_bvh_tri.py -v: 7 tests, OK.
  • python -I scripts/run_semantic_tests.py tests/semantic: 470 files, 6,169 tests, 0 files failed.
  • python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/semantic/test_image_bvh_box.py: exit 0 (no game data).

GPUs tested: n/a (CPU SPIR-V interpreter semantic suite on Windows 11 Pro 64-bit, Python 3.12.10)

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. (n/a — EXEC guard on existing image_bvh PSB loads)
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5480242443 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1258). Originally posted by [ambroseautomation](https://github.com/ambroseautomation) on 2026-11-24T21:00:01Z. --- Claimed in the coordination issue as: OLD-9827 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7144109503) ### What and why Carries forward `old-pr/9827` (draft #95, original commit author `Lewandox` preserved; indexed in #17), rebased cleanly onto current `main`. Guards `image_bvh*_intersect_ray` `PhysicalStorageBuffer` loads on active `EXEC` lanes in `tools/rdna2spirv.py`: - Wraps the BVH node pointer dereference and triangle/box intersection body inside an `OpSelectionMerge` / `OpBranchConditional` gated on `self.active_b()`, so inactive lanes (`EXEC == 0`) in divergent traversal loops never dereference stale or null node pointers and leave `vdst` untouched. - Adds `test_inactive_lane_skips_memory_reads_and_preserves_dst` in `tests/semantic/test_image_bvh_box.py`. ### Tested - `python -m unittest discover -s tests/semantic -p test_image_bvh_box.py -v`: 5 tests, OK. - `python -m unittest discover -s tests/semantic -p test_image_bvh_tri.py -v`: 7 tests, OK. - `python -I scripts/run_semantic_tests.py tests/semantic`: 470 files, 6,169 tests, 0 files failed. - `python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/semantic/test_image_bvh_box.py`: exit 0 (no game data). GPUs tested: n/a (CPU SPIR-V interpreter semantic suite on Windows 11 Pro 64-bit, Python 3.12.10) 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. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a — EXEC guard on existing `image_bvh` PSB loads)
tiguan26 commented 2026-11-25 06:32:57 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-25T06:32:57Z.

Review: APPROVED


Approving. Merged into current main (42537e7) with no conflicts. The full translator suite, including this PR's test, gives 487 files / 6,280 tests with only test_int32_to_f64 failing, as on main here (Linux, Python 3.13).

The structure is sound. The whole node read, from the pointer conversion through every end1/end2 arm, now sits inside one OpSelectionMerge act_end region taken only by active lanes. Nothing after end1 used a value from inside it, so the new merge block doesn't need a phi, and inactive lanes keep vdst because nothing in the skipped region stores to it.

AI-assisted (Claude).

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6052887252 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1258#pullrequestreview-6052887252). Originally posted by [tiguan26](https://github.com/tiguan26) on 2026-11-25T06:32:57Z. **Review:** APPROVED --- Approving. Merged into current main (42537e7) with no conflicts. The full translator suite, including this PR's test, gives 487 files / 6,280 tests with only `test_int32_to_f64` failing, as on main here (Linux, Python 3.13). The structure is sound. The whole node read, from the pointer conversion through every `end1`/`end2` arm, now sits inside one `OpSelectionMerge act_end` region taken only by active lanes. Nothing after `end1` used a value from inside it, so the new merge block doesn't need a phi, and inactive lanes keep vdst because nothing in the skipped region stores to it. AI-assisted (Claude).
PierreEbele commented 2026-11-25 14:38:49 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by PierreEbele on 2026-11-25T14:38:49Z.


Reviewed 85ea3e7: ran test_image_bvh_box/tri/box_hw/tri_hw (17 tests) plus the census, tri-probe and decode unit tests - all pass on the PR tree; on main only the new inactive-lane test fails. An 8-lane mixed-EXEC probe (even lanes active at a valid node, odd lanes masked off with a garbage node id) reproduces the bug on main (160 PSB loads through the garbage pointer per wave) and shows it fixed on the PR tree with active-lane results and read counts unchanged and inactive lanes' vdst preserved. No findings. Not run: full semantic suite, spirv-val (not installed), GPU tests. AI-assisted review.

Recommendation: Merge

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7165600967 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1258#issuecomment-7165600967). Originally posted by [PierreEbele](https://github.com/PierreEbele) on 2026-11-25T14:38:49Z. --- Reviewed 85ea3e7: ran test_image_bvh_box/tri/box_hw/tri_hw (17 tests) plus the census, tri-probe and decode unit tests - all pass on the PR tree; on main only the new inactive-lane test fails. An 8-lane mixed-EXEC probe (even lanes active at a valid node, odd lanes masked off with a garbage node id) reproduces the bug on main (160 PSB loads through the garbage pointer per wave) and shows it fixed on the PR tree with active-lane results and read counts unchanged and inactive lanes' vdst preserved. No findings. Not run: full semantic suite, spirv-val (not installed), GPU tests. AI-assisted review. **Recommendation:** Merge

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