fix(rdna2spirv): order image_sample, image_gather4, image_bvh and ignore ds_nop in --wave64-emulate #282

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

@⁠Andretuta on GitHub · 2026-11-24 02:58 UTC · original
ubiquitarianism:old-pr/10011 → main · +80 −5 · 3 files · 1 commits · draft

Carried over from old PR 10011 by totonicpu in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/10011, 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.
totonicpu: 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):

Summary

Fixes two memory-ordering gaps in --wave64-emulate (tools/rdna2spirv.py and its mirror tools/wave64_emulate_opt.py):

  1. Order image_sample*, image_gather4*, and image_bvh* as "mem" reads: Both Gen.x_memory_order() (tools/rdna2spirv.py:5717) and _x_memory_order_access() (tools/wave64_emulate_opt.py:777) tracked image_load, image_store, and image_atomic, but omitted image_sample, image_gather4, and image_bvh. Under --wave64-emulate, an image_store/buffer_store followed by image_sample*/image_gather4*/image_bvh* (or vice versa) stayed in the same round without a barrier between the two 32-lane halves.
  2. Sync ds_nop parity: Adds "ds_nop" to Gen.x_memory_order()'s ignore tuple (tools/rdna2spirv.py:5713), matching _x_memory_order_access() (tools/wave64_emulate_opt.py:773) so ds_nop no longer marks LDS read+write dirty.

Testing

  • Fail-first proof: Added RAW (image_store -> image_sample_lz), WAR (image_sample_lz -> image_store), and mirror-parity (image_sample*, image_gather4*, image_bvh*, ds_nop) tests in tests/semantic/test_w64x_scalar_load_order.py. Before the fix, both image_store and image_sample_lz landed in the same round (%blk0) with no separating barrier and _x_memory_order_access("image_sample") returned None.
  • Semantic tests (-W default -W error::ResourceWarning):
    • python -I -W default -W error::ResourceWarning tests/semantic/test_w64x_scalar_load_order.py: 8/8 OK
    • python -I -W default -W error::ResourceWarning tests/semantic/test_wave64_emulate_opt.py: 30/30 OK
  • SPIR-V validation: Assembled and validated both emitted RAW and WAR shaders with spirv-as --target-env vulkan1.2 + spirv-val --target-env vulkan1.2 (0 errors).
**@⁠Andretuta** on GitHub · 2026-11-24 02:58 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/282) `ubiquitarianism:old-pr/10011` → `main` · +80 −5 · 3 files · 1 commits · draft > Carried over from **old PR 10011** by `totonicpu` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/10011`, 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. > `totonicpu`: 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): ## Summary Fixes two memory-ordering gaps in `--wave64-emulate` (`tools/rdna2spirv.py` and its mirror `tools/wave64_emulate_opt.py`): 1. **Order `image_sample*`, `image_gather4*`, and `image_bvh*` as `"mem"` reads:** Both `Gen.x_memory_order()` (`tools/rdna2spirv.py:5717`) and `_x_memory_order_access()` (`tools/wave64_emulate_opt.py:777`) tracked `image_load`, `image_store`, and `image_atomic`, but omitted `image_sample`, `image_gather4`, and `image_bvh`. Under `--wave64-emulate`, an `image_store`/`buffer_store` followed by `image_sample*`/`image_gather4*`/`image_bvh*` (or vice versa) stayed in the same round without a barrier between the two 32-lane halves. 2. **Sync `ds_nop` parity:** Adds `"ds_nop"` to `Gen.x_memory_order()`'s ignore tuple (`tools/rdna2spirv.py:5713`), matching `_x_memory_order_access()` (`tools/wave64_emulate_opt.py:773`) so `ds_nop` no longer marks LDS read+write dirty. ## Testing - **Fail-first proof:** Added RAW (`image_store -> image_sample_lz`), WAR (`image_sample_lz -> image_store`), and mirror-parity (`image_sample*`, `image_gather4*`, `image_bvh*`, `ds_nop`) tests in `tests/semantic/test_w64x_scalar_load_order.py`. Before the fix, both `image_store` and `image_sample_lz` landed in the same round (`%blk0`) with no separating barrier and `_x_memory_order_access("image_sample")` returned `None`. - **Semantic tests (`-W default -W error::ResourceWarning`):** - `python -I -W default -W error::ResourceWarning tests/semantic/test_w64x_scalar_load_order.py`: **8/8 OK** - `python -I -W default -W error::ResourceWarning tests/semantic/test_wave64_emulate_opt.py`: **30/30 OK** - **SPIR-V validation:** Assembled and validated both emitted RAW and WAR shaders with `spirv-as --target-env vulkan1.2` + `spirv-val --target-env vulkan1.2` (0 errors).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 08:51:54 +00:00
Author
Owner

@⁠GeorgiyDemo on GitHub · 2026-11-24 07:32 UTC · original

Checked 1826e888 on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), against main d42773d07:

  • Regression tests are real: tests/semantic/test_w64x_scalar_load_order.py has 8 tests at this head and all pass; the same file applied to main's translator fails 3 of 8 with AssertionError: None != ('mem', True, False) : image_sample.
  • GPU, LEONIDA_W64_EMULATE=1, MoltenVK 1.4.2: ps_sample* 6/6, gather 4/4, cs_bvh/cs_bvh32 2/2, identical to main on the same filters — no regression. To be explicit, these fixtures pass before and after here, so on this driver they do not by themselves distinguish the revisions; the semantic tests are what show the fix.

Note: the PR currently shows CONFLICTING against main; this check is on the head as-is. Binaries from main. llvm-mc 23.1.6. Synthetic fixtures only, no game data. AI-assisted.

**@⁠GeorgiyDemo** on GitHub · 2026-11-24 07:32 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/282#issuecomment-7125104160) Checked `1826e888` on Apple M5 Pro (16-core GPU), macOS 26.7.3 (25G342), against `main` `d42773d07`: - **Regression tests are real:** `tests/semantic/test_w64x_scalar_load_order.py` has 8 tests at this head and all pass; the same file applied to `main`'s translator fails 3 of 8 with `AssertionError: None != ('mem', True, False) : image_sample`. - **GPU, `LEONIDA_W64_EMULATE=1`, MoltenVK 1.4.2:** `ps_sample*` 6/6, gather 4/4, `cs_bvh`/`cs_bvh32` 2/2, identical to `main` on the same filters — no regression. To be explicit, these fixtures pass before and after here, so on this driver they do not by themselves distinguish the revisions; the semantic tests are what show the fix. Note: the PR currently shows CONFLICTING against `main`; this check is on the head as-is. Binaries from `main`. llvm-mc 23.1.6. Synthetic fixtures only, no game data. AI-assisted.
This pull request has changes conflicting with the target branch.
  • tools/rdna2spirv.py
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

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

Merge

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