Skip to content

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

Open
OreoFR wants to merge 2 commits into
ProjectLeonida:mainfrom
OreoFR:fix/arc-mesh-wave32
Open

OreoFR wants to merge 2 commits into
ProjectLeonida:mainfrom
OreoFR:fix/arc-mesh-wave32

Conversation

@OreoFR

@OreoFR OreoFR commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

Claimed in the coordination issue as D3D12-ARC-MESH-WAVE32: #2570 (comment)

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

OreoFR and others added 2 commits December 1, 2026 18:37
… narrower (LEONIDA_MESH_WAVE32)

Intel Arc runs waves of 16 to 32 lanes (`WaveLaneCountMin` 16). Compute programs that need the
console's lanes already ask for `WaveSize(32)`; mesh programs asked for nothing, so 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.

On a B580 (driver 32.0.101.8991) every crash was a device hang inside mesh programs, also with
each mesh draw cut to one pixel (LEONIDA_MESH_TEST=scissor), and none in ~30 min with mesh draws
skipped (LEONIDA_MESH_TEST=skip). The hung program changed from run to run.

- The translator is told the host's narrowest wave too (`set_host_min_wave`, from
  D3D12_OPTIONS1 next to the widest).
- `mesh_wave32()`: on by default where the narrowest wave is below 32 and the host runs waves of
  32; `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)`.
- It is part of `host_settings()`, the shader cache key, so no translation made the other way is
  served.
- switches.md regenerated.

Not yet confirmed on Intel hardware: a test branch for the B580 tester.

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

Copy link
Copy Markdown
Contributor

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

@Kal0s-design

Copy link
Copy Markdown
Contributor

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).

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.

3 participants