Skip to content

leonida-shader: guard 32-lane host tests by the adapter's wave width - #2920

Closed
aznohonza wants to merge 4 commits into
ProjectLeonida:mainfrom
aznohonza:gpu/warp-wave-guards
Closed

aznohonza wants to merge 4 commits into
ProjectLeonida:mainfrom
aznohonza:gpu/warp-wave-guards

Conversation

@aznohonza

@aznohonza aznohonza commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

LEONIDA_WARP=1 makes Host::new(false) return the software adapter, so tests that ask for "hardware only" still run on it. The software adapter takes 4-lane waves, while the translator lowers these programs for 32-lane host waves, so eight of the leonida-shader tests fail with that switch.

Host::takes_waves_of(lanes) asks the adapter (D3D12_OPTIONS1) which program wave widths it accepts, and the tests that assume 32 skip a device that does not:

  • valu_tests: run_cases_on takes the required width (None keeps the old behaviour). The quadmask and the two cross-wave LDS tests use a 32-lane path, and the whole-wave f64 test checks its own loop.
  • pack_tests: the five host sites guard for 32 and print SKIP: the adapter does not run 32-lane waves.
  • wave64_tests: host_32() is the hardware lookup plus the width check; all 14 sites use it, and the two manual D3D12_OPTIONS1 queries now use the helper.

Verification:

  • cargo xwin check --target x86_64-pc-windows-msvc --workspace --all-targets --locked passes, and -p leonida-shader --tests --features host passes too.
  • This box has no D3D12 device, so the runs themselves were not repeated. A 32-lane adapter runs every test as before; a 4-lane one now skips them with a named reason.
  • No test changes its assertions when it runs; no game data; no new switch.

Claimed in #2570 (RS-WARP-TEST-WAVES). AI-assisted.

The full leonida-shader suite on the software adapter still has four failures on barycentric/rect; they are the DXIL validator refusing the shader (#2864), not wave width. With #2864's commit on this head the crate is 415 passed, 0 failed, 5 ignored on WARP.

The software adapter runs 4-lane waves, so the tests that lower for the
card's 32 fail under LEONIDA_WARP=1 even when they ask for "hardware":
that switch makes Host::new(false) return WARP too. Ask the made host
whether it takes waves of 32 and skip it otherwise.

`run_cases_on` takes the required width; the quadmask and the two
cross-wave LDS tests use a 32-lane path, and the whole-wave f64 test
checks its own loop. The pack tests and the wave64 helpers guard their
host; the two manual OPTIONS1 queries now use `takes_waves_of`.

Verified by compiling the crate and the workspace for
x86_64-pc-windows-msvc; this box has no D3D12 device, so the runs
themselves were not repeated.

AI-assisted: yes
@merzleckeier

Copy link
Copy Markdown
Contributor

Wave-width guard check on Radeon and RTX 4070 SUPER at 00e56f41 on main 7fbdf851 (Win64, Wine 11.22 / VKD3D-Proton 3.1.0, RADV 26.3.1 and NVIDIA 620.73.4 as reported by Wine). Six selected pack, VALU/LDS and wave64 tests returned success on each GPU for each build. On RADV, both_host_waves_observe_the_lds_flag_after_the_join logged a skip on main because its old check required the maximum width to equal 32. The PR admitted the adapter and the dispatch assertions passed.

For the negative control, an instrumented run logged the RTX device’s real Options1 range of 32–32 and supplied a 4–4 range to the PR’s predicate. All six selected cases guarded out their 32-lane hardware sections. An explicit LEONIDA_WARP=1 run logged that DXVK returned the first hardware adapter, so native Microsoft WARP remains unmeasured here.

MEASURED with the repository’s synthetic fixtures. AI-assisted (Codex).

@Neutron-0

Copy link
Copy Markdown

Verified on Windows 11, Rust 1.98.1, with the software adapter. The pull request says "this box has no D3D12 device, so the runs themselves were not repeated" - this box has one, and LEONIDA_WARP=1 reaches the software adapter, so the runs were repeated.

The change does what it says. cargo test -p leonida-shader --tests --features host --locked with LEONIDA_WARP=1:

result
the base 7fbdf8511 402 passed, 12 failed, 5 ignored
the head 00e56f41b 410 passed, 4 failed, 5 ignored

The eight failures that are gone on the head are exactly the eight the pull request names - pack_tests::a_packed_program_keeps_each_console_groups_memory_to_itself, pack_tests::a_packed_program_reads_the_lanes_of_its_own_console_group, valu_tests::ds_min_max_f32_order_floats_and_return_the_old_value, valu_tests::lds_subtracts_return_the_old_value_and_subtract, valu_tests::v_permlane16_and_x16_read_the_lanes_their_selectors_pick, valu_tests::whole_wave_f64_sum_and_cvt_f32_f64, wave64_tests::a_lane_mask_joined_with_a_number_is_read_as_the_number_it_is and wave64_tests::partial_dispatch_with_a_cross_half_wave_op_runs_in_32_lane_waves - so the count of eight is right, and on the head they skip with a named reason instead of failing.

The four failures that are left are not about wave width, and they are not this pull request's to fix. They are:

emit::barycentric_tests::a_masked_pixel_program_reads_the_position_where_the_vertex_program_writes_it
emit::barycentric_tests::first_half_values_render_on_hardware_and_warp
emit::rect::tests::rectangles_are_drawn_whole
emit::rect::tests::the_rectangle_stage_is_a_geometry_shader

and all four panic at the same place, crates/leonida-shader/src/emit/mod.rs:3840:50, which is the .unwrap() on the DXIL validator's verdict inside the test helper validate() - the validator refuses the shader. That has nothing to do with the adapter: they fail the same way with LEONIDA_WARP unset, on this box's own card. The cause is the PSV0 part's name table, and #2864 is the pull request that fixes it. Put #2864's commit on top of this head and the whole crate on the software adapter is green:

on 00e56f41b plus #2864's commit, LEONIDA_WARP=1 result
cargo test -p leonida-shader --tests --features host --locked 415 passed, 0 failed, 5 ignored

So the pull request's own claim is complete once #2864 is in, and the four leftovers are worth saying out loud - otherwise the next person to run the suite on a machine with a dxil.dll will read them as this pull request's doing.

One note on the helper, not blocking. Host::takes_waves_of(lanes) reads D3D12_OPTIONS1 and asks whether the adapter's range contains the width, which is the better question than the two it replaces: one of them asked WaveLaneCountMax != 32 (so an adapter that took 16 to 64 lanes was refused) and the other asked contains(&32) (so it was accepted). A device that reports WaveLaneCountMin = 0 because it does not support wave operations at all would answer contains(&32) as true, and the tests would run on it; WaveOps is what says whether the adapter has wave operations at all, and the old code's first version checked it. It costs one field to ask WaveOps as well.

Not checked: a 4-lane adapter as such (the software adapter here reports a wave width outside 32, which is the same branch the guard takes); the tests' behaviour on an adapter that takes 32 lanes but not 64; the xwin cross-build (only the native Windows build was run).

@KelboLive KelboLive left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The guard shape is right: D3D12_OPTIONS1 is 32/32 on this card, 4/4 on WARP, and Arc's 16..32 still runs — so Intel's mixed widths are not hidden, and on a 32-lane host every test still executes (414/0/5 here, 500 s). The f64 guard is genuinely load-bearing: removing it under WARP fails at pipeline creation (valu_tests.rs:2349, "The parameter is incorrect"), while the run_cases_32 mutation is inert at 4 lanes — which is fine, but means that one is only exercised on a host that is neither 32-wide nor WARP.

Two nits before merge:

  1. Two sites still skip silently: wave64_tests.rs:1358 and :1954 use a bare else { return }, so a 4-lane or 64-only host reports a pass with no reason. The other 12 print. That contradicts the "named reason" claim, and it is exactly the failure mode this PR is meant to fix.
  2. takes_waves_of drops the WaveOps check the old both_host_waves block had. A device that reports the width range but not wave ops would be treated as runnable and fail at pipeline creation instead of skipping.

Not blocking on either. Merge is clean against current main, and there is no file overlap with #2917 — conceptually they are adjacent and agree: this guard correctly lets Arc run the tests that #2917 would make it request 32-lane waves for.

KelboLive's review of #2920: two `host_32()` sites still returned
silently, and `takes_waves_of` no longer asked whether the adapter has
wave operations at all (the old manual check did). Both now say their
reason, and the query includes `WaveOps`.

AI-assisted: yes
@aznohonza

Copy link
Copy Markdown
Contributor Author

Both nits fixed in a06018f3e:

  1. partial_dispatch_with_a_cross_half_wave_op_runs_in_32_lane_waves and one_d_wave64_group_skips_entry_ticket_barrier_and_keeps_thread_ids now print no SM 6.6 device that runs 32-lane waves; not run before returning, like the other 12.
  2. takes_waves_of now requires WaveOps as well as the width range, so an adapter that reports the range but no wave operations skips instead of failing at pipeline creation.

Thanks for the WARP run and the #2864 pointer — I added a line to the description so the four remaining validator failures are not read as wave-width ones. This box has no D3D12 device, so only the cross-build was repeated.

AI-assisted.

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.

4 participants