Skip to content

make_game: --wave64-emulate auto leaves emulation off on RDNA2 under the AMD Windows driver (#857) - #1697

Merged
ItsNotRexed merged 3 commits into
ItsNotRexed:mainfrom
BetterJdue:wave64-rdna2-guard
Nov 22, 2026
Merged

ItsNotRexed merged 3 commits into
ItsNotRexed:mainfrom
BetterJdue:wave64-rdna2-guard

Conversation

@BetterJdue

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: #1548 (#857 follow-up: --wave64-emulate auto guard for RDNA2 on the AMD Windows driver)

What and why

#857 shows that the AMD Windows driver (32.0.21030 through at least 32.0.21045.29003) crashes in amdvlk64.dll when it compiles emulated-wave64 compute shaders on RDNA2. It's been seen on the RX 6700, the RX 6800 and the 0x13C0/0x164E iGPUs. RDNA3, RDNA4, RADV, NVIDIA and the older 23.20.44 driver are fine. No translator workaround is known yet.

auto alone can't cause this on an RDNA2-only machine, since the card is 64-wide and emulation stays off. The real exposure is a PC with a 32-wide device next to an RX 6000 card, for example an Intel iGPU. auto sees the 32-wide device and turns emulation on, but the runtime then picks the RX 6000, and the build crashes the driver.

This change:

Notes for review:

  • A work folder that already has emulated shaders keeps them under auto, as it does today. Running --wave64-emulate off once clears them.
  • The device-ID list will need upkeep. A simpler rule would be any AMD proprietary-driver device with native wave64 that isn't RDNA3+, but that's harder to state without a list. I'm happy to switch if you prefer that. Once AMD ships a fixed driver, a version bound can be added.

Tested

  • tests/test_vk_subgroup_info.py (34), tests/test_make_game_wave64.py (32), tests/test_make_game_argparse.py (36) and tests/test_make_game_translator_flags.py (14) all pass, and compileall is clean. These ran on Windows 11 with Python 3.15.2 on top of a0acd33.
  • The new tests cover device classification (RX 6700, RX 6800, Navi 24, 0x13C0 and 0x164E are true; 7900 XTX, 9070 XT, 780M, RADV and NVIDIA are false). They also check that the report describes the runtime's GPU (Intel iGPU + RX 6700 in both orders), that auto is off only in that case, and that old or broken tool output falls back to the previous behaviour.
  • On real hardware, an RX 6700 (0x73DF) with driver 32.0.21045.29003 reports "rdna2_amd_windows": true, and auto still gives "wave64 emulation off".
  • I couldn't test a real iGPU + RX 6000 machine; that path is covered by the unit tests only.

Checklist

  • 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: no translator rule; make_game and tools/ only)

AI-assisted change and verification using synthetic inputs.

…the AMD Windows driver (ItsNotRexed#857)

AMD's Windows shader compiler for RDNA2 crashes (access violation in
vkCreateComputePipelines) on many --wave64-emulate compute shaders with LDS
(ItsNotRexed#857). auto turns emulation on when any device is 32-wide, so an Intel iGPU
next to an RX 6000 card gets emulated modules, and the runtime then runs them on
the RX 6000.

tools/vk_subgroup_info.py now reports vendor_id, device_id, driver_id and
rdna2_amd_windows for the runtime's GPU (RDNA2 by PCI device ID, AMD proprietary
driver). auto leaves emulation off when that GPU is one and runs wave64
natively; on and off are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Rossrocha

Copy link
Copy Markdown

Tested 95a89a7 on AMD Radeon RX 6600 (RDNA2, Navi 23, PCI 0x73FF), Adrenalin 26.11.2 (Vulkan 1.4.315, amdvlk64.dll 32.0.21045.29003), Windows 11 Pro 10.0.26300: pass, and #857 reproduces on this card.

Detection. python -I tools/vk_subgroup_info.py:

{"device": "AMD Radeon RX 6600", ..., "native64": true, ..., "vendor_id": 4098, "device_id": 29695, "driver_id": 1, "rdna2_amd_windows": true}

Navi 23 (0x73FF) is matched.

Decision, calling make_game.wave64_emulate() on this one-GPU machine:

  • auto: "smallest maximum subgroup size is 64: wave64 emulation off" (the normal path; the exception isn't needed here)
  • auto with smallest_max_subgroup patched to return 32, standing in for a 32-wide second device; the runtime GPU query stays real: "...but the runtime's GPU (AMD Radeon RX 6600) is RDNA2 on the AMD Windows driver, whose shader compiler crashes on emulated wave64 code (AMD Windows driver crashes creating lds_fuzz wave64 programs translated with --wave64-emulate #857), and runs wave64 natively: wave64 emulation off (--wave64-emulate on to force it)" -> False
  • on -> True, off -> False

Unit tests: test_vk_subgroup_info.py 34 OK, test_make_game_wave64.py 32 OK, test_make_game_argparse.py 36 OK, test_make_game_translator_flags.py 14 OK.

#857 on this card, on main 99f9989: python -I tools/lds_fuzz.py --seed 1 --programs 100 --wave 64 --emulate gives 42/42 programs that ran match, and 58 harness errors: vk_compute_test exits 0xC0000005. The Windows event log puts all 58 in amdvlk64.dll 32.0.21045.29003 at the same offset, 0x7e4613. That is close to the RX 6700's 59 of 100 in SHADER-104.

Adrenalin 26.11.2 ships that 32.0.21045.29003 Vulkan driver for RDNA2, so the version range in your description still covers the current Adrenalin release on RDNA2.

AI-assisted (Claude Code): it ran the checks and the fuzzer, read the event log and wrote this comment.

@UlteriorMotive00

Copy link
Copy Markdown
Contributor

Tested 95a89a7 on a real RDNA2 iGPU + 32-wide dGPU PC: Ryzen 7 9800X3D iGPU (0x13C0, AMD Windows driver 32.0.21042.62, one of the #857 crash GPUs) plus an RTX 5070 (617.42). Windows 11 Home 10.0.26300, Python 3.14.7, Vulkan SDK 1.4.363.0, VK_LOADER_LAYERS_DISABLE=~implicit~.

what Vulkan sees / asks for vk_subgroup_info.py reports wave64_emulate('auto')
both GPUs (default) RTX 5070, native64: false, rdna2_amd_windows: false on (right: the runtime takes the 5070)
only the iGPU (VK_LOADER_DRIVERS_SELECT=*amd*) AMD Radeon(TM) Graphics, device_id 5056 (0x13C0), driver_id 1, native64: true, rdna2_amd_windows: true off
both GPUs, LEONIDA_VK_DEVICE=Radeon RTX 5070, rdna2_amd_windows: false on

The 0x13C0 classification is right. But the last row is a gap. LEONIDA_VK_DEVICE makes the runtime take the iGPU (runtime/src/vulkan_device_filter.h), while vk_subgroup_info.py still picks the discrete GPU (it prefers DEVICE_TYPE_DISCRETE_GPU, line 217, and doesn't read LEONIDA_VK_DEVICE). So with the iGPU selected, auto builds emulated shaders for exactly the GPU whose driver crashes on them. That's the #857 crash, and I reproduced it on this iGPU. Making the tool apply the same name filter as the runtime would close it. It was the same on main before this PR, but this PR now depends on the tool naming the right GPU.

AI-assisted (Claude Code). No game files.

@adrbn

adrbn commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested 95a89a7 on Apple M1 (16 GB), Homebrew MoltenVK 1.4.2, macOS 27.0.1, Python 3.14.7: pass on a 32-wide non-AMD GPU.

  • tests/test_vk_subgroup_info.py, test_make_game_wave64.py, test_make_game_argparse.py, test_make_game_translator_flags.py: 115 passed, 1 skipped.
  • Real tools/vk_subgroup_info.py on the M1: subgroup_size 32, native64 false, vendor_id 4203 (0x106B), driver_id 14 (MoltenVK), rdna2_amd_windows false.
  • wave64_emulate: on -> True, off -> False. auto -> True. Note: on this branch, auto on macOS takes the "couldn't read the GPU's subgroup size from vulkaninfo" path, because MoltenVK 1.4's vulkaninfo prints a second, nested deviceName (make_game.py: a layered driver's nested deviceName is not another GPU #1708). With smallest_max_subgroup forced to 32, auto reaches the new check, runtime_gpu_info() reports the M1 with rdna2_amd_windows false, and it logs smallest maximum subgroup size is 32: wave64 emulation on. So the guard leaves non-AMD 32-wide GPUs alone.

@Impre-visible

Copy link
Copy Markdown

Tested 95a89a7 on NVIDIA GeForce GTX 1660 (Turing, TU116, subgroup 32..32), driver 620.73.04 (proprietary, Vulkan 1.4.357), Arch Linux (kernel 6.18): pass. This is the "32-wide GPU that is not AMD stays emulated" side of the change, on a single-GPU NVIDIA Linux PC.

  • tools/vk_subgroup_info.py on this device: vendor_id 4318, device_id 8580, driver_id 4, native64 false, rdna2_amd_windows false
  • make_game.wave64_emulate("auto"): logs "smallest maximum subgroup size is 32: wave64 emulation on" and returns True, the same decision as main
  • tests/test_make_game_wave64.py + tests/test_vk_subgroup_info.py (pytest): 66 passed
  • tests/semantic: 1398 OK; compileall OK
  • Native build of runtime/ from this head; build.py: 175 translated, 175 pass spirv-val; check.py: 114 of 147 pass, 33 skipped
  • run_gpu_tests.py: 168/168 translated and pass spirv-val; 125/163 passed, 38 skipped, 0 failed; with LEONIDA_W64_EMULATE=1: 155/163 passed, 8 skipped (fixtures run by the d3d12 tests), 0 failed

Not covered here: any AMD device, and the full make_game.py build (no game files on this machine yet).

AI-assisted run (Claude). Counts only, no game files involved.

…r the runtime

The runtime and its tests keep only the Vulkan devices whose name contains LEONIDA_VK_DEVICE
(runtime/src/vulkan_device_filter.h), but vk_subgroup_info.py ignored it. On a Ryzen 9800X3D iGPU (0x13C0, one of
the ItsNotRexed#857 GPUs) next to an RTX 5070 with LEONIDA_VK_DEVICE=Radeon, the runtime takes the iGPU while the answer was
the 5070, so --wave64-emulate auto turned emulation on for the GPU whose compiler crashes on it (ItsNotRexed#1697 review).

The filter is applied before the runtime's own choice, without case, and a value that matches no usable device is
an error (exit 1, so make_game falls back to its "can't tell" path), not another GPU.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@BetterJdue

Copy link
Copy Markdown
Contributor Author

Thanks @UlteriorMotive00, good catch. I pushed cfee276, so tools/vk_subgroup_info.py now applies LEONIDA_VK_DEVICE the way runtime/src/vulkan_device_filter.h does. It keeps only the devices whose name contains the value, without case, and filters before the runtime's own choice. A value that matches no usable device is an error (exit 1) instead of falling back to another GPU.

New tests cover an iGPU + RTX 5070 with radeon, RADEON, 5070 and the variable unset, and a filter that matches nothing. The existing tests now clear a tester's own LEONIDA_VK_DEVICE. test_vk_subgroup_info (36) and test_make_game_wave64 (32) pass, also with LEONIDA_VK_DEVICE set in the environment. Your third row should now report the iGPU with rdna2_amd_windows: true and auto off; could you rerun it? And thanks to everyone who tested.

AI-assisted change and verification using synthetic inputs.

… does for the runtime"

This reverts commit cfee276. The same fix is TEST-258, claimed first and opened as ItsNotRexed#1755, so it lands there instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@XFlawless1

Copy link
Copy Markdown
Contributor

Tested 0effeca on a Ryzen 7 9800X3D iGPU (RDNA2, 0x13C0, AMD Windows 32.0.21042.62) plus an RTX 5080 (NVIDIA 621.14), Windows 11 Pro 10.0.26300, Python 3.12.10: pass. #857 reproduces on this iGPU at c2967a5e: lds_fuzz --emulate --seed 1 --programs 200 crashes 126 of the 200 wave64 programs (exit 0xC0000005). The w32 programs and every native run pass.

AI-assisted (Claude Code).

@ItsNotRexed
ItsNotRexed merged commit 2419f4c into ItsNotRexed:main Nov 22, 2026
2 of 4 checks passed
DiazE117 added a commit to DiazE117/Leonida that referenced this pull request Nov 22, 2026
…wide compute path (BUILD-629)

With --mesh-compute every mesh shader is a compute shader, but auto still
asked vk_subgroup_info.py's native64, which needs the mesh stage. An RX 5000
(RDNA1) has no mesh stage, so auto turned emulation on there, and the AMD
Windows driver crashed creating the emulated pipelines (ItsNotRexed#857, RX 5700).

vk_subgroup_info.py reports compute_native64 (the same test for compute
alone). wave64_emulate() takes mesh_compute and uses it for the native
check and for ItsNotRexed#1697's RDNA2 exemption; an older tool without the key falls
back to native64. Without --mesh-compute the decision is unchanged.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants