rdna2spirv: write out a carry-out subtract of a register from itself (AMD Windows driver crash) #739

Closed
abnalstlll-byte wants to merge 1 commit from upstream-pr/739 into main
abnalstlll-byte commented 2026-11-24 13:13:49 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T13:13:49Z.


### Summary
Restores and updates work from draft PR #324 (old-pr/10058 / item OLD-10058).
Original commit by @wail-arch (183d63f55).

v_sub_co_u32 / v_subrev_co_u32 and their _ci_ forms with the same operand twice were translated to OpISubBorrow %x %x. AMD's Windows driver dies with an access violation (0xC0000005 in amdvlk64.dll, 32.0.21037.1004 and 32.0.21045.29003, gfx1036) creating a native wave64 compute pipeline in which that borrow predicates the value operand of an OpGroupNonUniformShuffle.

x - x is 0 with no borrow, so these forms now emit D = 0 - carry in and borrow out = carry in, with no OpISubBorrow. Values are unchanged; other operand pairs are translated as before.

Verification

  • python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/semantic/test_sub_co_same_operand.py docs/design.md -> Clean (no game data)
  • python -m unittest discover -s tests/semantic -p test_sub_co_same_operand.py -> 6/6 PASS in 2.07s
  • Clean rebase onto latest ubi/main (21625bca8).

AI-assisted verification and rebase by Antigravity (Autonomous Direct Mode).

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5472831384 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/739). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T13:13:49Z. --- ### Summary Restores and updates work from draft PR #324 (`old-pr/10058` / item `OLD-10058`). Original commit by @wail-arch (`183d63f55`). `v_sub_co_u32` / `v_subrev_co_u32` and their `_ci_` forms with the same operand twice were translated to `OpISubBorrow %x %x`. AMD's Windows driver dies with an access violation (`0xC0000005` in `amdvlk64.dll`, 32.0.21037.1004 and 32.0.21045.29003, gfx1036) creating a native wave64 compute pipeline in which that borrow predicates the value operand of an `OpGroupNonUniformShuffle`. `x - x` is 0 with no borrow, so these forms now emit `D = 0 - carry in` and `borrow out = carry in`, with no `OpISubBorrow`. Values are unchanged; other operand pairs are translated as before. ### Verification - `python -I scripts/check_no_game_data.py tools/rdna2spirv.py tests/semantic/test_sub_co_same_operand.py docs/design.md` -> Clean (no game data) - `python -m unittest discover -s tests/semantic -p test_sub_co_same_operand.py` -> 6/6 PASS in 2.07s - Clean rebase onto latest `ubi/main` (`21625bca8`). AI-assisted verification and rebase by Antigravity (Autonomous Direct Mode).
GeorgiyDemo commented 2026-11-24 13:26:27 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by GeorgiyDemo on 2026-11-24T13:26:27Z.


Tested b7de4d80 on Apple M5 Pro, macOS 26.7.3 (25G342), Python 3.15.2, against main d42773d07:

  • tests/semantic/test_sub_co_same_operand.py: 6 tests OK at this head.
  • The same file against main's translator fails 24 times, so the carry-out subtract of a register from itself is covered by the new cases.

No GPU leg and no way to reproduce the reported crash here: AMD's Windows driver is not available on this machine, and no runtime/test/shaders fixture uses v_sub_co_u32/v_subrev_co_u32 with the same operand twice. AI-assisted; synthetic fixtures only, no game data.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7132832224 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/739#issuecomment-7132832224). Originally posted by [GeorgiyDemo](https://github.com/GeorgiyDemo) on 2026-11-24T13:26:27Z. --- Tested `b7de4d80` on Apple M5 Pro, macOS 26.7.3 (25G342), Python 3.15.2, against `main` `d42773d07`: - `tests/semantic/test_sub_co_same_operand.py`: 6 tests OK at this head. - The same file against `main`'s translator fails 24 times, so the carry-out subtract of a register from itself is covered by the new cases. No GPU leg and no way to reproduce the reported crash here: AMD's Windows driver is not available on this machine, and no `runtime/test/shaders` fixture uses `v_sub_co_u32`/`v_subrev_co_u32` with the same operand twice. AI-assisted; synthetic fixtures only, no game data.
snain0511 commented 2026-11-24 14:28:57 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by snain0511 on 2026-11-24T14:28:57Z.


Tested b7de4d80 on AMD Windows hardware, including the driver build named in the description.

Setup: Windows 11 10.0.26200.9974, AMD 26.11.2. Ryzen 5 7600X iGPU (gfx1036) on driver version 32.0.21045.29003, one of the two this PR reports crashing; RX 9070 (GFX1201) on 32.0.32029.2010. vk_compute_test built from main d0da7dade (MSVC 19.44), llvm-mc 21.1.8.

CPU: tests/semantic/test_sub_co_same_operand.py: 6/6 OK at this head. With tools/rdna2spirv.py swapped back to the base 21625bca8, the same file fails (24 failures), so the test does detect the old translation.

GPU: I wrote a local wave64 compute shader (not committed) with the pattern the description gives: v_sub_co_u32 v8, vcc, v2, v2, then v_cndmask_b32 v9, v2, 0, vcc, and v9 as the data of ds_bpermute_b32. In the base translator's SPIR-V the borrow of OpISubBorrow %x %x reaches the value operand of OpGroupNonUniformShuffle through VCC and an OpSelect (2 OpISubBorrow); with this PR there are none. Both pass spirv-val. vk_compute_test ... 1 dump --require-wave64 (subgroup 64):

GPU, driver base 21625bca8 this PR
7600X iGPU, 32.0.21045.29003 pipeline created, exit 0, 36 316 253 0 (expected) exit 0, 36 316 253 0
RX 9070, 32.0.32029.2010 exit 0, 36 316 253 0 exit 0, 36 316 253 0

So this minimal form of the pattern does not crash amdvlk64.dll 32.0.21045.29003 on gfx1036 here, and the PR gives the same correct values. That doesn't rule out the crash: the shader that hit it may need more around the shuffle than this one has. If you can say which fixture or shape crashed (counts or a hand-written repro, no game shader), I'll run it on this iGPU, without and with the PR. No game files used.

AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7134445796 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/739#issuecomment-7134445796). Originally posted by [snain0511](https://github.com/snain0511) on 2026-11-24T14:28:57Z. --- Tested `b7de4d80` on AMD Windows hardware, including the driver build named in the description. **Setup:** Windows 11 10.0.26200.9974, AMD 26.11.2. Ryzen 5 7600X iGPU (gfx1036) on driver version **32.0.21045.29003**, one of the two this PR reports crashing; RX 9070 (GFX1201) on 32.0.32029.2010. `vk_compute_test` built from `main` `d0da7dade` (MSVC 19.44), llvm-mc 21.1.8. **CPU:** `tests/semantic/test_sub_co_same_operand.py`: 6/6 OK at this head. With `tools/rdna2spirv.py` swapped back to the base `21625bca8`, the same file fails (24 failures), so the test does detect the old translation. **GPU:** I wrote a local wave64 compute shader (not committed) with the pattern the description gives: `v_sub_co_u32 v8, vcc, v2, v2`, then `v_cndmask_b32 v9, v2, 0, vcc`, and `v9` as the data of `ds_bpermute_b32`. In the base translator's SPIR-V the borrow of `OpISubBorrow %x %x` reaches the value operand of `OpGroupNonUniformShuffle` through VCC and an `OpSelect` (2 `OpISubBorrow`); with this PR there are none. Both pass spirv-val. `vk_compute_test ... 1 dump --require-wave64` (subgroup 64): | GPU, driver | base `21625bca8` | this PR | |---|---|---| | 7600X iGPU, 32.0.21045.29003 | pipeline created, exit 0, `36 316 253 0` (expected) | exit 0, `36 316 253 0` | | RX 9070, 32.0.32029.2010 | exit 0, `36 316 253 0` | exit 0, `36 316 253 0` | So this minimal form of the pattern does **not** crash `amdvlk64.dll` 32.0.21045.29003 on gfx1036 here, and the PR gives the same correct values. That doesn't rule out the crash: the shader that hit it may need more around the shuffle than this one has. If you can say which fixture or shape crashed (counts or a hand-written repro, no game shader), I'll run it on this iGPU, without and with the PR. No game files used. AI-assisted: yes
Sangonapou commented 2026-11-24 14:54:11 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Sangonapou on 2026-11-24T14:54:11Z.


Tested b7de4d80 on NVIDIA GeForce RTX 3080 Ti Laptop (Ampere, subgroup 32..32, mesh shaders), NVIDIA 621.24, Vulkan 1.4.357, Windows 11 Pro (build 26300), native Windows: pass, regression check (NVIDIA side; the AMD driver case is covered above)

Runtime built at this head with scripts\build_runtime.ps1 (MSVC 19.51, VS Build Tools 2026, Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0). No game files.

  • Full run_gpu_tests.py: 257 shaders, 257 translated, 257 pass spirv-val; native 197/248 passed, 49 skipped; LEONIDA_W64_EMULATE=1 229/248 passed, 17 skipped. The only failures are cs_imgload_tfe and cs_imgload_d16_tfe, which fail identically on main 2d73c242 on this card (#31 / #336).
  • CPU: tests/semantic/test_sub_co_same_operand.py 6 OK.
<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7135135790 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/739#issuecomment-7135135790). Originally posted by [Sangonapou](https://github.com/Sangonapou) on 2026-11-24T14:54:11Z. --- Tested b7de4d80 on NVIDIA GeForce RTX 3080 Ti Laptop (Ampere, subgroup 32..32, mesh shaders), NVIDIA 621.24, Vulkan 1.4.357, Windows 11 Pro (build 26300), native Windows: pass, regression check (NVIDIA side; the AMD driver case is covered above) Runtime built at this head with `scripts\build_runtime.ps1` (MSVC 19.51, VS Build Tools 2026, Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0). No game files. - Full `run_gpu_tests.py`: 257 shaders, 257 translated, 257 pass spirv-val; native 197/248 passed, 49 skipped; `LEONIDA_W64_EMULATE=1` 229/248 passed, 17 skipped. The only failures are `cs_imgload_tfe` and `cs_imgload_d16_tfe`, which fail identically on `main` `2d73c242` on this card (#31 / #336). - CPU: `tests/semantic/test_sub_co_same_operand.py` 6 OK.
thesubtleties commented 2026-11-24 17:12:47 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by thesubtleties on 2026-11-24T17:12:47Z.


For whoever merges: #324, #739 and #930 change exactly the same lines in tools/ and tests/ (heads 183d63f55, b7de4d802, 474dbe2be). #324 conflicts with main in docs/design.md; #739 and #930 merge cleanly, so one of them is enough. On main 98a977b4 the shared test file has 24 failures without the change and passes with it. I could not check the AMD Windows driver crash (Linux here). No game files. AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7138855104 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/739#issuecomment-7138855104). Originally posted by [thesubtleties](https://github.com/thesubtleties) on 2026-11-24T17:12:47Z. --- For whoever merges: #324, #739 and #930 change exactly the same lines in `tools/` and `tests/` (heads `183d63f55`, `b7de4d802`, `474dbe2be`). #324 conflicts with `main` in `docs/design.md`; #739 and #930 merge cleanly, so one of them is enough. On `main` `98a977b4` the shared test file has 24 failures without the change and passes with it. I could not check the AMD Windows driver crash (Linux here). No game files. AI-assisted (Claude Code).
aslan2142 commented 2026-11-24 22:09:10 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-24T22:09:10Z.


Thanks for carrying this forward, and thanks to everyone who tested it. I'm closing this as a duplicate of #930.

  • Merged onto main, #739, #930 and #1093 are the same patch (git patch-id --stable matches) and give the same tree.
  • When patches are identical, the earliest valid claim in #14 decides. #930's claim (SHADER-SUB-CO-SAME, 15:02 UTC) is the only one posted before its pull request; #14 has no claiming: line for this item from this account. This PR was opened first, at 13:13 UTC, but without a claim.
  • For future restorations, please post claiming: <item> in #14 before opening the pull request.
  • The test reports here (macOS, gfx1036 on 32.0.21045.29003 and an RX 9070, an RTX 3080 Ti) apply to #930 as well, because the change is the same. The open question from snain0511 about the exact shape that crashes the driver can move there.

AI-assisted (Claude Code, Claude Fable 5.2 and Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7145871122 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/739#issuecomment-7145871122). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-11-24T22:09:10Z. --- Thanks for carrying this forward, and thanks to everyone who tested it. I'm closing this as a duplicate of #930. - Merged onto `main`, #739, #930 and #1093 are the same patch (`git patch-id --stable` matches) and give the same tree. - When patches are identical, the earliest valid claim in #14 decides. #930's claim (`SHADER-SUB-CO-SAME`, 15:02 UTC) is the only one posted before its pull request; #14 has no `claiming:` line for this item from this account. This PR was opened first, at 13:13 UTC, but without a claim. - For future restorations, please post `claiming: <item>` in #14 before opening the pull request. - The test reports here (macOS, gfx1036 on 32.0.21045.29003 and an RX 9070, an RTX 3080 Ti) apply to #930 as well, because the change is the same. The open question from `snain0511` about the exact shape that crashes the driver can move there. AI-assisted (Claude Code, Claude Fable 5.2 and Claude Opus 5.5).

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