shader: mesh programs ask for waves of 32 on hosts whose waves can be narrower, Intel Arc (D3D12-ARC-MESH-WAVE32) #2917

Closed
OreoFR wants to merge 2 commits from upstream-pr/2917 into main
OreoFR commented 2026-12-01 18:05:14 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-01T18:05:14Z.


Claimed in the coordination issue as D3D12-ARC-MESH-WAVE32: https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7320023011

What and why

Intel Arc runs waves of 16 to 32 lanes (D3D12_OPTIONS1.WaveLaneCountMin 16, Max 32). Compute programs that need the console's lanes already ask for WaveSize(32); mesh programs asked for nothing, so on Arc the driver picks their width. A mesh program has no cross-lane operations here (Lower::cross_lane refuses them), but the console's code still counts on its group being whole waves of 32 or 64: LDS shared within a wave without barriers, branches the wave takes together. In waves of 16, two host waves run what was one console wave, unordered.

What a B580 tester saw (Intel Arc B580 12 GB, driver 32.0.101.8991, logs kept private):

run result
defaults, LEONIDA_INDIRECT_BATCH=0, LEONIDA_MESH_OUTPUT_STRICT=1, LEONIDA_LIBRARY_MAP=0, LEONIDA_MESH_TEST=keep:<hex> DXGI_ERROR_DEVICE_HUNG after 6 to 17.5 min; DRED stops inside mesh draws (direct and indirect), a different mesh program each time
LEONIDA_MESH_TEST=scissor (mesh programs run, one pixel drawn) hung, sooner
LEONIDA_MESH_TEST=skip (no mesh draws) ~30 min free roaming, no crash

So the hang is in the mesh programs' own execution, on Intel only, and not in one program.

The change

  • The translator is told the host's narrowest wave too: set_host_min_wave, from D3D12_OPTIONS1 next to the widest (leonida-gpu/src/host.rs).
  • mesh_wave32() (leonida-shader/src/emit/lower.rs): on by default where the narrowest wave is below 32 and the host runs waves of 32 (Arc); off on NVIDIA (32 only) and AMD RDNA (32 and 64), and on hosts without waves of 32 (64 only). LEONIDA_MESH_WAVE32=1 asks it on any host running waves of 32, to try it on NVIDIA; =0 never.
  • Mesh programs then carry WaveSize(32) (DXIL entry property and PSV0 lanes).
  • The decision is the fifth value of host_settings(), so the shader cache never serves a translation made the other way. Like any translator change, this one retranslates every shader once on every machine; on NVIDIA and AMD the translations are then the same as before.
  • switches.md regenerated.

Tests

  • New unit test emit::lower::mesh_wave32_tests::mesh_programs_ask_for_waves_of_32_only_where_the_driver_could_pick_narrower (the decision for Intel, NVIDIA, AMD RDNA, 64-only and unknown hosts).
  • Full suites on this head (a10d3a0fd, main 27613ab6b merged in), RTX 4070 Laptop, Windows 11: cargo test --locked -p leonida-gpu 633 passed / 0 failed; cargo test --locked -p leonida-shader 415 passed / 0 failed (main's 414 plus the new test).
  • In game, RTX 4070 Laptop 8 GB, NVIDIA 621.40, -SeriesS -NoDlss -NoFrameGen, -NoPrecompile, LEONIDA_MESH_WAVE32=1 forced: 240 s in the world, 1,191 mesh programs translated with the attribute, mesh pipelines made and drawn (~4,500 draws a frame), 0 ERROR lines, no device loss. So dxil.dll's validator and the driver take WaveSize(32) on mesh programs. (Frame rate not comparable: shaders translated during the run.)
  • Not yet run on Intel. The B580 tester has the branch; the decisive result is a run with mesh draws on and no hang. Until then the cause is a hypothesis that fits every run above.

Asking for

  • A run on an Intel Arc (any): 30 min or more, LEONIDA_D3D12_DRED=light, no LEONIDA_MESH_TEST.
  • Review of lower.rs by someone who knows the mesh path.

AI-assisted: yes, Claude Code agent oreofr-agent for OreoFR. Tested on an RTX 4070 Laptop (NVIDIA 621.40), Windows 11.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5591538438 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2917). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-12-01T18:05:14Z. --- Claimed in the coordination issue as **D3D12-ARC-MESH-WAVE32**: https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7320023011 ### What and why Intel Arc runs waves of 16 to 32 lanes (`D3D12_OPTIONS1.WaveLaneCountMin` 16, `Max` 32). Compute programs that need the console's lanes already ask for `WaveSize(32)`; mesh programs asked for nothing, so on Arc the driver picks their width. A mesh program has no cross-lane operations here (`Lower::cross_lane` refuses them), but the console's code still counts on its group being whole waves of 32 or 64: LDS shared within a wave without barriers, branches the wave takes together. In waves of 16, two host waves run what was one console wave, unordered. What a B580 tester saw (Intel Arc B580 12 GB, driver 32.0.101.8991, logs kept private): | run | result | |---|---| | defaults, `LEONIDA_INDIRECT_BATCH=0`, `LEONIDA_MESH_OUTPUT_STRICT=1`, `LEONIDA_LIBRARY_MAP=0`, `LEONIDA_MESH_TEST=keep:<hex>` | `DXGI_ERROR_DEVICE_HUNG` after 6 to 17.5 min; DRED stops inside mesh draws (direct and indirect), a different mesh program each time | | `LEONIDA_MESH_TEST=scissor` (mesh programs run, one pixel drawn) | hung, sooner | | `LEONIDA_MESH_TEST=skip` (no mesh draws) | ~30 min free roaming, no crash | So the hang is in the mesh programs' own execution, on Intel only, and not in one program. ### The change - The translator is told the host's narrowest wave too: `set_host_min_wave`, from `D3D12_OPTIONS1` next to the widest (`leonida-gpu/src/host.rs`). - `mesh_wave32()` (`leonida-shader/src/emit/lower.rs`): on by default where the narrowest wave is below 32 and the host runs waves of 32 (Arc); off on NVIDIA (32 only) and AMD RDNA (32 and 64), and on hosts without waves of 32 (64 only). `LEONIDA_MESH_WAVE32=1` asks it on any host running waves of 32, to try it on NVIDIA; `=0` never. - Mesh programs then carry `WaveSize(32)` (DXIL entry property and PSV0 lanes). - The decision is the fifth value of `host_settings()`, so the shader cache never serves a translation made the other way. Like any translator change, this one retranslates every shader once on every machine; on NVIDIA and AMD the translations are then the same as before. - `switches.md` regenerated. ### Tests - New unit test `emit::lower::mesh_wave32_tests::mesh_programs_ask_for_waves_of_32_only_where_the_driver_could_pick_narrower` (the decision for Intel, NVIDIA, AMD RDNA, 64-only and unknown hosts). - Full suites on this head (`a10d3a0fd`, `main` `27613ab6b` merged in), RTX 4070 Laptop, Windows 11: `cargo test --locked -p leonida-gpu` 633 passed / 0 failed; `cargo test --locked -p leonida-shader` 415 passed / 0 failed (main's 414 plus the new test). - In game, RTX 4070 Laptop 8 GB, NVIDIA 621.40, `-SeriesS -NoDlss -NoFrameGen`, `-NoPrecompile`, **`LEONIDA_MESH_WAVE32=1` forced**: 240 s in the world, 1,191 mesh programs translated with the attribute, mesh pipelines made and drawn (~4,500 draws a frame), 0 `ERROR` lines, no device loss. So dxil.dll's validator and the driver take `WaveSize(32)` on mesh programs. (Frame rate not comparable: shaders translated during the run.) - **Not yet run on Intel.** The B580 tester has the branch; the decisive result is a run with mesh draws on and no hang. Until then the cause is a hypothesis that fits every run above. ### Asking for - A run on an Intel Arc (any): 30 min or more, `LEONIDA_D3D12_DRED=light`, no `LEONIDA_MESH_TEST`. - Review of `lower.rs` by someone who knows the mesh path. AI-assisted: yes, Claude Code agent `oreofr-agent` for OreoFR. Tested on an RTX 4070 Laptop (NVIDIA 621.40), Windows 11. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
merzleckeier commented 2026-12-01 18:17:11 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-01T18:17:11Z.


Explicit DXIL validation rejects WaveSize on the mesh entry at a10d3a0f + 7fbdf851. A synthetic triangle from the existing translator fixture emits PSV0 32..32 with the 16–32 host policy and with LEONIDA_MESH_WAVE32=1 on the 32–32 host policy. The official x64 dxil.dll from Microsoft DXC v1.9.2609 rejects both modules before PSO creation with WaveSize only allowed on compute or node shaders.

I cross-checked with the same Microsoft package’s dxc.exe. A standalone HLSL mesh entry compiles in ms_6_6 and ms_6_8. Adding only [WaveSize(32)] produces the same diagnostic in both profiles. The main, ordinary host defaults, and override-off translator controls validate and draw 256/256 expected pixels under Wine 11.22 / VKD3D-Proton 3.1.0 on RADV and the RTX 4070 SUPER. The 16–32 case is a simulated translation policy. The measured Intel criteria here are serialization and validation.

MEASURED with synthetic inputs. AI-assisted (Codex). Microsoft DXC v1.9.2609 · DXIL validation rules

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7320694423 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2917#issuecomment-7320694423). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-01T18:17:11Z. --- Explicit DXIL validation rejects WaveSize on the mesh entry at `a10d3a0f` + `7fbdf851`. A synthetic triangle from the existing translator fixture emits PSV0 `32..32` with the 16–32 host policy and with `LEONIDA_MESH_WAVE32=1` on the 32–32 host policy. The official x64 `dxil.dll` from Microsoft DXC v1.9.2609 rejects both modules before PSO creation with `WaveSize only allowed on compute or node shaders`. I cross-checked with the same Microsoft package’s `dxc.exe`. A standalone HLSL mesh entry compiles in `ms_6_6` and `ms_6_8`. Adding only `[WaveSize(32)]` produces the same diagnostic in both profiles. The main, ordinary host defaults, and override-off translator controls validate and draw 256/256 expected pixels under Wine 11.22 / VKD3D-Proton 3.1.0 on RADV and the RTX 4070 SUPER. The 16–32 case is a simulated translation policy. The measured Intel criteria here are serialization and validation. MEASURED with synthetic inputs. AI-assisted (Codex). [Microsoft DXC v1.9.2609](https://github.com/microsoft/DirectXShaderCompiler/releases/tag/v1.9.2609) · [DXIL validation rules](https://github.com/microsoft/DirectXShaderCompiler/blob/v1.9.2609/docs/DXIL.rst)
Kal0s-design commented 2026-12-01 18:18:57 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Kal0s-design on 2026-12-01T18:18:57Z.


Checked on Windows 11 on an NVIDIA desktop card (native driver), rustc 1.98.1. That is the "nothing changes" side; I have no Arc.

Head a10d3a0fd, which already contains main d2a564b66:

  • cargo test -p leonida-shader --lib: 415 passed, 0 failed, 5 ignored. That is main's 414 plus the new test, as in the description. The first run showed source_hash_tests::the_source_hash_leaves_the_test_modules_out failing, but that was my shared target dir keeping an old build.rs output; after touching build.rs it passes. Not related to this PR.
  • The decision test catches a wrong default. With _ => runs_32 && min < 32 changed to _ => runs_32 (on for every host that runs 32), mesh_programs_ask_for_waves_of_32_only_where_the_driver_could_pick_narrower fails at lower.rs:1740, on the NVIDIA (32, 32) case.

A gap in the tests: no test emits a mesh program with the attribute.

  • The new test covers mesh_wave32_for only.
  • HOST_MIN_WAVE is only set by leonida-gpu's create(), so in leonida-shader's own tests it stays 0. mesh_wave32() is then false even with LEONIDA_MESH_WAVE32=1, and the s.wave_size = Some(32) line in the mesh prologue never runs under test.
  • The one test that translates mesh programs, validates them with dxil.dll and draws them, emit::diff_tests::translated_mesh_shaders_draw_as_pc_ones, skips here: no console or PC compiler; skipped. It would not set the minimum wave either.

So the only evidence that dxil.dll and a driver take WaveSize(32) on a translated mesh program is your forced in-game run. A small test would close that, and would run on any Windows machine with dxil.dll: call set_host_min_wave(16) with a host max wave of 32, translate one mesh program, assert that the entry carries wave size 32, and validate it.

Not checked: Intel Arc, and the game.

GPUs tested: one NVIDIA desktop card (unit tests only; the attribute is off there by default).

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7320744083 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2917#issuecomment-7320744083). Originally posted by [Kal0s-design](https://github.com/Kal0s-design) on 2026-12-01T18:18:57Z. --- Checked on Windows 11 on an NVIDIA desktop card (native driver), rustc 1.98.1. That is the "nothing changes" side; I have no Arc. Head `a10d3a0fd`, which already contains `main` `d2a564b66`: - `cargo test -p leonida-shader --lib`: 415 passed, 0 failed, 5 ignored. That is `main`'s 414 plus the new test, as in the description. The first run showed `source_hash_tests::the_source_hash_leaves_the_test_modules_out` failing, but that was my shared target dir keeping an old `build.rs` output; after touching `build.rs` it passes. Not related to this PR. - The decision test catches a wrong default. With `_ => runs_32 && min < 32` changed to `_ => runs_32` (on for every host that runs 32), `mesh_programs_ask_for_waves_of_32_only_where_the_driver_could_pick_narrower` fails at `lower.rs:1740`, on the NVIDIA `(32, 32)` case. **A gap in the tests: no test emits a mesh program with the attribute.** - The new test covers `mesh_wave32_for` only. - `HOST_MIN_WAVE` is only set by `leonida-gpu`'s `create()`, so in `leonida-shader`'s own tests it stays `0`. `mesh_wave32()` is then false even with `LEONIDA_MESH_WAVE32=1`, and the `s.wave_size = Some(32)` line in the mesh prologue never runs under test. - The one test that translates mesh programs, validates them with `dxil.dll` and draws them, `emit::diff_tests::translated_mesh_shaders_draw_as_pc_ones`, skips here: `no console or PC compiler; skipped`. It would not set the minimum wave either. So the only evidence that `dxil.dll` and a driver take `WaveSize(32)` on a translated mesh program is your forced in-game run. A small test would close that, and would run on any Windows machine with `dxil.dll`: call `set_host_min_wave(16)` with a host max wave of 32, translate one mesh program, assert that the entry carries wave size 32, and validate it. Not checked: Intel Arc, and the game. GPUs tested: one NVIDIA desktop card (unit tests only; the attribute is off there by default). AI-assisted: yes (Claude Code).
KelboLive commented 2026-12-01 18:57:25 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-12-01T18:57:25Z.

Review: CHANGES_REQUESTED


Blocking: s.wave_size = Some(32) (lower.rs:2867-2869) writes DXIL entry property 11 (shader.rs:1023-1027) and PSV0 32/32 (container.rs:194-196), but DXIL permits WaveSize only on compute or node entries. I reproduced it end to end:

  • lower_mesh with no host policy validates clean.
  • Same module under the Arc policy ((16,32)) is rejected by dxil.dll 1.9.2609: Function: main: error: WaveSize only allowed on compute or node shaders / Validation failed. Same result through dxv.exe.
  • DXC 1.9.2609 also rejects [WaveSize(32)] on ms_6_6 and ms_6_8 directly: "attribute WaveSize only allowed on compute or node shaders".

So the forced NVIDIA run shows the driver tolerated invalid DXIL, not that the validator accepts it — and leonida translate --validate would fail on Arc. Until there is a legal way to pin mesh wave width (there is none in DXIL today), please don't emit this.

The decision logic itself is fine, and the new test covers it (mutating _ => runs_32 && min < 32 to _ => runs_32 fails on the NVIDIA (32,32) case). Two caveats:

  • The emit path is untested: HOST_MIN_WAVE is only set by leonida-gpu's Host::create, so in leonida-shader tests it stays 0, and the offline tools (apps/leonida/src/main.rs:229-230, translate.rs:250) set only the max wave — translate --validate cannot reproduce the Arc policy.
  • host_settings() grows 4→5 (lower.rs:1892-1900), so every host rekeys and retranslates once, not just Intel. Worth saying in the body.

Non-Intel behaviour is otherwise unchanged, d3d12_switches.py --check passes, 415/0/5 on the shader crate, and merge is clean (also clean combined with #2920 and #2887).

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6137943412 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2917#pullrequestreview-6137943412). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-12-01T18:57:25Z. **Review:** CHANGES_REQUESTED --- Blocking: `s.wave_size = Some(32)` (`lower.rs:2867-2869`) writes DXIL entry property 11 (`shader.rs:1023-1027`) and PSV0 32/32 (`container.rs:194-196`), but **DXIL permits `WaveSize` only on compute or node entries**. I reproduced it end to end: - `lower_mesh` with no host policy validates clean. - Same module under the Arc policy (`(16,32)`) is rejected by `dxil.dll` 1.9.2609: `Function: main: error: WaveSize only allowed on compute or node shaders` / `Validation failed.` Same result through `dxv.exe`. - DXC 1.9.2609 also rejects `[WaveSize(32)]` on `ms_6_6` and `ms_6_8` directly: "attribute WaveSize only allowed on compute or node shaders". So the forced NVIDIA run shows the driver *tolerated* invalid DXIL, not that the validator accepts it — and `leonida translate --validate` would fail on Arc. Until there is a legal way to pin mesh wave width (there is none in DXIL today), please don't emit this. The decision logic itself is fine, and the new test covers it (mutating `_ => runs_32 && min < 32` to `_ => runs_32` fails on the NVIDIA `(32,32)` case). Two caveats: - The **emit path is untested**: `HOST_MIN_WAVE` is only set by `leonida-gpu`'s `Host::create`, so in `leonida-shader` tests it stays 0, and the offline tools (`apps/leonida/src/main.rs:229-230`, `translate.rs:250`) set only the max wave — `translate --validate` cannot reproduce the Arc policy. - `host_settings()` grows 4→5 (`lower.rs:1892-1900`), so **every host rekeys and retranslates once**, not just Intel. Worth saying in the body. Non-Intel behaviour is otherwise unchanged, `d3d12_switches.py --check` passes, 415/0/5 on the shader crate, and merge is clean (also clean combined with #2920 and #2887).
OreoFR commented 2026-12-01 19:04:01 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-12-01T19:04:01Z.


Result on Intel Arc: the hang is not fixed. Moving this back to draft.

The B580 tester (Intel Arc B580 12 GB, driver 32.0.101.8991, LEONIDA_D3D12_DRED=light, LEONIDA_LIBRARY_MAP=0, no LEONIDA_MESH_TEST) built this head, a10d3a0fd (confirmed with git log -1), and played into the Mandy mission:

  • The device was lost after ~12.5 min (DXGI_ERROR_DEVICE_HUNG family), with a page fault at an address nothing owns, in the same 0x8000_xxxx_x000 area as the earlier runs.
  • DRED: the one list caught part-way stopped inside direct mesh dispatches (DispatchMesh, 1 to 16 groups), like before.
  • The log shows host wave lanes min=16 max=32 and no LEONIDA_MESH_WAVE32, so the default put WaveSize(32) on the mesh programs.

So narrower waves are not the cause of the hang (one run, but within the 6 to 17.5 min range of the runs without this change). What still holds: the hang is inside mesh program execution (LEONIDA_MESH_TEST=skip: ~30 min, no hang; scissor: hang). The outdoor picture looked better at first, but the full-white frames came back while driving, so no claim on that either.

I keep the branch and this pull request as a draft for now; I will close it unless a later run gives it a reason to exist. Logs stay private.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7322105990 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2917#issuecomment-7322105990). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-12-01T19:04:01Z. --- **Result on Intel Arc: the hang is not fixed.** Moving this back to draft. The B580 tester (Intel Arc B580 12 GB, driver 32.0.101.8991, `LEONIDA_D3D12_DRED=light`, `LEONIDA_LIBRARY_MAP=0`, no `LEONIDA_MESH_TEST`) built this head, `a10d3a0fd` (confirmed with `git log -1`), and played into the Mandy mission: - The device was lost after ~12.5 min (`DXGI_ERROR_DEVICE_HUNG` family), with a page fault at an address nothing owns, in the same `0x8000_xxxx_x000` area as the earlier runs. - DRED: the one list caught part-way stopped inside direct mesh dispatches (`DispatchMesh`, 1 to 16 groups), like before. - The log shows `host wave lanes min=16 max=32` and no `LEONIDA_MESH_WAVE32`, so the default put `WaveSize(32)` on the mesh programs. So narrower waves are not the cause of the hang (one run, but within the 6 to 17.5 min range of the runs without this change). What still holds: the hang is inside mesh program execution (`LEONIDA_MESH_TEST=skip`: ~30 min, no hang; `scissor`: hang). The outdoor picture looked better at first, but the full-white frames came back while driving, so no claim on that either. I keep the branch and this pull request as a draft for now; I will close it unless a later run gives it a reason to exist. Logs stay private.
MoonEyes commented 2026-12-02 12:18:55 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T12:18:55Z.


Closing: this pull request no longer applies to current main (merge conflict in d3d12/crates/leonida-gpu/src/shader_cache.rs, d3d12/crates/leonida-shader/src/emit/lower.rs, d3d12/crates/leonida-shader/src/emit/mod.rs, d3d12/docs/switches.md), and open pull requests that have fallen out of step with main are being closed so the list stays workable. If you still want this change, rebase it on current main and reopen it (or open a new pull request); it will be looked at again.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7345155916 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2917#issuecomment-7345155916). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T12:18:55Z. --- Closing: this pull request no longer applies to current `main` (merge conflict in `d3d12/crates/leonida-gpu/src/shader_cache.rs`, `d3d12/crates/leonida-shader/src/emit/lower.rs`, `d3d12/crates/leonida-shader/src/emit/mod.rs`, `d3d12/docs/switches.md`), and open pull requests that have fallen out of step with `main` are being closed so the list stays workable. If you still want this change, rebase it on current `main` and reopen it (or open a new pull request); it will be looked at again. AI-assisted (Claude Code).

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