rdna2spirv: keep DATA0 for equal paired LDS write offsets (SHADER-LDS-EQUAL-WRITES) #966

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

@⁠akimfomin on GitHub · 2026-11-24 15:59 UTC · original
akimfomin:portbridge/paired-lds-data0 → main · +85 −8 · 4 files · 1 commits · open

Claimed in the coordination issue as: SHADER-LDS-EQUAL-WRITES

What and why

For compute-shader ds_write2 and ds_write2st64 (b32 and b64), equal offsets now emit only the DATA0 store. Both operands are still validated. Distinct offsets store both values, and paired reads are unchanged. AMD RDNA 2 ISA §10.4.3, printed p. 96

PortBridge linked THE-PRO-GAME’s finding in VIctory #1088 to the same lowering here. The XCL result uses the same rule.

Tested

  • Base a2892784: the hand-written fixture returned DATA1 in all five equal-offset cases, including the implicit zero-offset case. Existing paired read/write controls passed.
  • At 9ae6f12, all 379 LDS semantic tests passed without skips, including the five address cases and three malformed-operand controls. The no-game-data guard passed.
  • One synthetic shader translated and passed SPIR-V validation for Vulkan 1.3 on each tree. The baseline read DATA1 in all eight output words. The patch read all eight expected DATA0 words and emitted 8 instead of 16 volatile LDS stores.
  • A wider semantic sweep before the input-validation adjustment ran 6,109 tests. The only failing file with SPIR-V Tools enabled hit a Windows LLVM_MC path issue. All nine tests in that file passed after normalizing the path. The final head was retested with the LDS suite and Vulkan fixture.

GPUs tested: NVIDIA RTX 4070 Ti SUPER, driver 617.14, Windows 11 build 28000. All inputs are synthetic. AMD, retail inputs and the separate legacy geometry path were outside this check.

AI-assisted: yes, Codex assisted implementation and ran the checks.

Checklist

  • Based on main (a2892784 for the baseline comparison). GitHub reports a clean merge with current main.
  • One topic.
  • No game data, keys or decryption.
  • The translator rule and verification are in the existing docs/design.md contract row.
**@⁠akimfomin** on GitHub · 2026-11-24 15:59 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/966) `akimfomin:portbridge/paired-lds-data0` → `main` · +85 −8 · 4 files · 1 commits · open Claimed in the coordination issue as: [SHADER-LDS-EQUAL-WRITES](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ### What and why For compute-shader `ds_write2` and `ds_write2st64` (b32 and b64), equal offsets now emit only the DATA0 store. Both operands are still validated. Distinct offsets store both values, and paired reads are unchanged. [AMD RDNA 2 ISA §10.4.3, printed p. 96](https://docs.amd.com/api/khub/documents/Et~wpu9g~Ffl7d9q0QZ~Og/content#page=104) [PortBridge](https://github.com/akimfomin/PortBridge) linked [THE-PRO-GAME’s finding in VIctory #1088](https://github.com/Marvisak/VIctory/pull/1088) to the same lowering here. The [XCL result](https://github.com/ivall/xcl/issues/42#issuecomment-7136754354) uses the same rule. ### Tested - Base `a2892784`: the hand-written fixture returned DATA1 in all five equal-offset cases, including the implicit zero-offset case. Existing paired read/write controls passed. - At `9ae6f12`, all **379 LDS semantic tests passed** without skips, including the five address cases and three malformed-operand controls. The no-game-data guard passed. - One synthetic shader translated and passed SPIR-V validation for Vulkan 1.3 on each tree. The baseline read DATA1 in all eight output words. The patch read all eight expected DATA0 words and emitted 8 instead of 16 volatile LDS stores. - A wider semantic sweep before the input-validation adjustment ran 6,109 tests. The only failing file with SPIR-V Tools enabled hit a Windows `LLVM_MC` path issue. All nine tests in that file passed after normalizing the path. The final head was retested with the LDS suite and Vulkan fixture. GPUs tested: NVIDIA RTX 4070 Ti SUPER, driver 617.14, Windows 11 build 28000. All inputs are synthetic. AMD, retail inputs and the separate legacy geometry path were outside this check. AI-assisted: yes, Codex assisted implementation and ran the checks. ### Checklist - [x] Based on `main` (`a2892784` for the baseline comparison). GitHub reports a clean merge with current `main`. - [x] One topic. - [x] No game data, keys or decryption. - [x] The translator rule and verification are in the existing `docs/design.md` contract row.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:30:51 +00:00
Author
Owner

@⁠KernelSmoker on GitHub · 2026-11-24 16:02 UTC · original · approved these changes

Verified the submitted head 9ae6f1253ffc45cc1ebf774dcaa630959111ccb0. The equal-offset regression passes 2/2 and the existing paired LDS b64 suite passes 6/6 on Linux. The new test covers b32/b64, st64, implicit zero offsets and malformed second operands; it confirms the DATA0 result without relying on paired reads. check_no_game_data.py and git diff --check pass. I did not run a GPU test locally.

**@⁠KernelSmoker** on GitHub · 2026-11-24 16:02 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/966#pullrequestreview-6042837366) · **approved these changes** Verified the submitted head `9ae6f1253ffc45cc1ebf774dcaa630959111ccb0`. The equal-offset regression passes 2/2 and the existing paired LDS b64 suite passes 6/6 on Linux. The new test covers b32/b64, st64, implicit zero offsets and malformed second operands; it confirms the DATA0 result without relying on paired reads. `check_no_game_data.py` and `git diff --check` pass. I did not run a GPU test locally.
Author
Owner

@⁠akimfomin on GitHub · 2026-11-24 16:27 UTC · original

One additional result for the upstream fixture: nullmarsh ran all four paired LDS checks successfully at VIctory 59ab6b7 on an AMD Steam Deck through vkd3d-proton. This adds a translated RDNA2 check for the VIctory side of the comparison. Original report · PortBridge case

I also tried the PortBridge prior-work summary with this PR’s URL. The GitHub Actions summary surfaced the original VIctory change and the exact XCL test result in one place.

For a future shader review, would anyone on Continued like to try the same lookup on one PR they already care about? You can paste a PR URL into the public catalog to try it immediately. If it helps, maintainers can opt into the manual job-summary workflow, which adds an optional read-only summary. A link to a test you actually reused would help assess the trial.

**@⁠akimfomin** on GitHub · 2026-11-24 16:27 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/966#issuecomment-7137694786) One additional result for the upstream fixture: nullmarsh ran all four paired LDS checks successfully at VIctory `59ab6b7` on an AMD Steam Deck through vkd3d-proton. This adds a translated RDNA2 check for the VIctory side of the comparison. [Original report](https://github.com/Marvisak/VIctory/pull/1088#issuecomment-7137333841) · [PortBridge case](https://akimfomin.github.io/PortBridge/cases/pb-0018.html) I also tried the [PortBridge](https://github.com/akimfomin/PortBridge) prior-work summary with this PR’s URL. The [GitHub Actions summary](https://github.com/akimfomin/PortBridge/actions/runs/45436942552#summary-138597213073) surfaced the original VIctory change and the exact XCL test result in one place. For a future shader review, would anyone on Continued like to try the same lookup on one PR they already care about? You can [paste a PR URL into the public catalog](https://akimfomin.github.io/PortBridge/#/problems) to try it immediately. If it helps, maintainers can opt into the [manual job-summary workflow](https://github.com/akimfomin/PortBridge/blob/main/docs/GITHUB-ACTION.md#try-it-on-one-pull-request), which adds an optional read-only summary. A link to a test you actually reused would help assess the trial.
Author
Owner

@⁠Poussistar on GitHub · 2026-11-24 16:52 UTC · original

Checked this diff on today main (3ed8e50b7, Linux, CPython 3.14.7): it applies except one hunk, docs/design.md:423. That table moved since the PR opened, so git apply stops there and leaves everything after it unapplied.

With git apply --exclude=docs/design.md the rest applies, and the new test passes:

$ python tests/semantic/test_lds_write2_equal_offsets.py
Ran 2 tests in 0.021s
OK

Negative control, so the fixture is not vacuous: keeping the new test and reverting tools/rdna2spirv.py to main gives FAILED (failures=5, errors=1) with - (858993459, 1145324612) / + (286331153, 572662306).

So the translator change and its fixture are sound on current main; rebasing the docs/design.md hunk is what is left. I ran this one file, not the whole translator suite. AI-assisted. No game files.

**@⁠Poussistar** on GitHub · 2026-11-24 16:52 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/966#issuecomment-7138331703) Checked this diff on today main (`3ed8e50b7`, Linux, CPython 3.14.7): it applies **except one hunk**, `docs/design.md:423`. That table moved since the PR opened, so `git apply` stops there and leaves everything after it unapplied. With `git apply --exclude=docs/design.md` the rest applies, and the new test passes: ``` $ python tests/semantic/test_lds_write2_equal_offsets.py Ran 2 tests in 0.021s OK ``` Negative control, so the fixture is not vacuous: keeping the new test and reverting `tools/rdna2spirv.py` to main gives `FAILED (failures=5, errors=1)` with `- (858993459, 1145324612)` / `+ (286331153, 572662306)`. So the translator change and its fixture are sound on current main; rebasing the `docs/design.md` hunk is what is left. I ran this one file, not the whole translator suite. AI-assisted. No game files.
Author
Owner

@⁠akimfomin on GitHub · 2026-11-24 17:04 UTC · original

Thanks for checking this and including the negative control. I reproduced the plain git apply --check failure at docs/design.md:423. The neighboring Typed image stores row changed after the branch opened, so the old patch context no longer matches.

On both 3ed8e50b and fce586c6, git apply --check --3way succeeded with the patch’s base blobs available. I also ran a three-way merge check on fce586c6 against this PR’s 9ae6f125 head and confirmed the result contains both documentation rows and all four changed files. Your 2/2 Linux test result is linked in the PortBridge coordination log. The PR head is unchanged.

**@⁠akimfomin** on GitHub · 2026-11-24 17:04 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/966#issuecomment-7138641803) Thanks for checking this and including the negative control. I reproduced the plain `git apply --check` failure at `docs/design.md:423`. The neighboring Typed image stores row changed after the branch opened, so the old patch context no longer matches. On both `3ed8e50b` and `fce586c6`, `git apply --check --3way` succeeded with the patch’s base blobs available. I also ran a three-way merge check on `fce586c6` against this PR’s `9ae6f125` head and confirmed the result contains both documentation rows and all four changed files. Your 2/2 Linux test result is [linked in the PortBridge coordination log](https://github.com/akimfomin/PortBridge/pull/32). The PR head is unchanged.
Author
Owner

@⁠thesubtleties on GitHub · 2026-11-24 20:07 UTC · original

CPU check of 9ae6f1253 merged onto main 3aa97542 (CachyOS, Python 3.14).

  • test_lds_write2_equal_offsets.py: 2 pass; 5 failures and 1 error with main's rdna2spirv.py.
  • run_semantic_tests.py tests/semantic: 471 files / 6,170 tests, 0 failed.
  • wave_diff.py (600 programs) is clean on both.

Not tested: GPU, hardware, game corpus. AI-assisted (Claude Code)

**@⁠thesubtleties** on GitHub · 2026-11-24 20:07 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/966#issuecomment-7143076710) CPU check of `9ae6f1253` merged onto main `3aa97542` (CachyOS, Python 3.14). - `test_lds_write2_equal_offsets.py`: 2 pass; 5 failures and 1 error with main's `rdna2spirv.py`. - `run_semantic_tests.py tests/semantic`: 471 files / 6,170 tests, 0 failed. - `wave_diff.py` (600 programs) is clean on both. Not tested: GPU, hardware, game corpus. AI-assisted (Claude Code)
Author
Owner

@⁠thesubtleties on GitHub · 2026-11-24 23:33 UTC · original

Native RDNA2 result that contradicts this PR, and a follow-up to my CPU check above.

On gfx1036 (Ryzen 7 7800X3D iGPU, tools/hw_oracle through libdrm, CachyOS), equal offsets keep DATA1: ds_write2_b32, ds_write2st64_b32, ds_write2_b64 and ds_write2st64_b64, offset0 = offset1 = 3, both data orders, wave32 (1 and 32 threads, lane 0 on) and wave64, 10 runs each: 240 of 240. Control: distinct offsets store both values. I read back with ds_read_b32.

Main's behavior matches this, so I think the change should wait until someone explains the difference from ISA §10.4.3. My CPU check only showed that the code does what its test says.

One chip only; the console is a custom RDNA2. AI-assisted (Claude Code)

**@⁠thesubtleties** on GitHub · 2026-11-24 23:33 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/966#issuecomment-7147542598) Native RDNA2 result that contradicts this PR, and a follow-up to my CPU check above. On gfx1036 (Ryzen 7 7800X3D iGPU, `tools/hw_oracle` through libdrm, CachyOS), equal offsets keep **DATA1**: `ds_write2_b32`, `ds_write2st64_b32`, `ds_write2_b64` and `ds_write2st64_b64`, offset0 = offset1 = 3, both data orders, wave32 (1 and 32 threads, lane 0 on) and wave64, 10 runs each: 240 of 240. Control: distinct offsets store both values. I read back with `ds_read_b32`. Main's behavior matches this, so I think the change should wait until someone explains the difference from ISA §10.4.3. My CPU check only showed that the code does what its test says. One chip only; the console is a custom RDNA2. AI-assisted (Claude Code)
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-25 02:47 UTC · original

Thanks. Holding this for now, because a hardware measurement in this thread points the other way.

  • The measurement: thesubtleties' raw gfx1036 run above (tools/hw_oracle) keeps DATA1 for equal paired offsets in 240 of 240 runs, which is what main already does. The rule here keeps DATA0, backed by the ISA text and other projects' code, but not yet by a hardware run.
  • What would settle it: a hardware run of your own, or an explanation of how the ISA's wording and that measurement fit together (for example a difference in the instruction form, the offsets or the EXEC pattern between your case and theirs).
  • Everything else checks out: the claim is valid, the branch merges cleanly with main, and the new tests fail on main and pass with the change.
  • For scale: on the maintainer's own shader corpus (counts only), 555 shaders use ds_write2, 5 listings have equal offsets, and none of their translated modules changes either way.

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

**@⁠aslan2142** on GitHub · 2026-11-25 02:47 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/966#issuecomment-7151199761) Thanks. Holding this for now, because a hardware measurement in this thread points the other way. - **The measurement:** thesubtleties' raw gfx1036 run above (`tools/hw_oracle`) keeps DATA1 for equal paired offsets in 240 of 240 runs, which is what `main` already does. The rule here keeps DATA0, backed by the ISA text and other projects' code, but not yet by a hardware run. - **What would settle it:** a hardware run of your own, or an explanation of how the ISA's wording and that measurement fit together (for example a difference in the instruction form, the offsets or the EXEC pattern between your case and theirs). - **Everything else checks out:** the claim is valid, the branch merges cleanly with `main`, and the new tests fail on `main` and pass with the change. - **For scale:** on the maintainer's own shader corpus (counts only), 555 shaders use `ds_write2`, 5 listings have equal offsets, and none of their translated modules changes either way. AI-assisted (Claude Code, Claude Opus 5.5).
Author
Owner

@⁠tiguan26 on GitHub · 2026-11-25 19:06 UTC · original · approved these changes

Approving. Merged into current main (9f9a7c5) with no conflicts. test_lds_write2_equal_offsets.py passes, and the full translator suite gives 491 files / 6,294 tests with only test_int32_to_f64 failing, the same baseline failure as main here (Linux, Python 3.13).

I checked the cited rule in the RDNA 2 ISA (the LDS addressing section, p. 104 of the PDF): "Specify only one address by setting both offsets to the same value. This causes only one read or write to occur and uses only the first DATA0." The change follows it for all four write2 forms: the second store is skipped when its offset equals the first, and the operand checks now run before that skip, so a bad operand is still refused.

AI-assisted (Claude).

**@⁠tiguan26** on GitHub · 2026-11-25 19:06 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/966#pullrequestreview-6063402581) · **approved these changes** Approving. Merged into current main (9f9a7c5) with no conflicts. `test_lds_write2_equal_offsets.py` passes, and the full translator suite gives 491 files / 6,294 tests with only `test_int32_to_f64` failing, the same baseline failure as main here (Linux, Python 3.13). I checked the cited rule in the RDNA 2 ISA (the LDS addressing section, p. 104 of the PDF): "Specify only one address by setting both offsets to the same value. This causes only one read or write to occur and uses only the first DATA0." The change follows it for all four write2 forms: the second store is skipped when its offset equals the first, and the operand checks now run before that skip, so a bad operand is still refused. AI-assisted (Claude).
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/966/head:github-bot/gh-966'
git switch 'github-bot/gh-966'

Merge

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