Skip to content

dxil: refuse wave64 VS/PS with upper-lane reads in 32-lane mode (#1895) - #2252

Open
zondy1i wants to merge 1 commit into
xcl-dev:mainfrom
zondy1i:dxil/graphics-upper-lanes-guard
Open

zondy1i wants to merge 1 commit into
xcl-dev:mainfrom
zondy1i:dxil/graphics-upper-lanes-guard

Conversation

@zondy1i

@zondy1i zondy1i commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

What is in it
Fixes the remaining item (item 1) of #1895 (item 2, XCL_DXIL_NO_OPT, was already merged in #2013):

  • crates/xcl/src/gpu/dxil/kernel.rs: in translate_on_this_thread, when lowering a Vertex or Pixel entry with o.wave64 && o.split (32-lane hardware waves such as NVIDIA), run upper_lanes::analyze(&cfg.insts) and refuse the shader ("wave64 VS / PS in 32-lane waves: a read of lanes 32–63") if any read is non-Native (matching recomp::lower::lower_graphics).
  • crates/xcl/src/gpu/recomp/pso.rs: pass split_wave64 from compile_console_shader into direct_graphics and set split: wave64 && split_wave64 in KernelOptions instead of hardcoding split: false, so XCL_DIRECT_DXIL=all falls back to the HLSL upper_lanes path instead of caching broken wave64-only DXIL under the split=1 disk cache key. Modifying kernel.rs also advances XCL_DIRECT_DXIL_SOURCE_ID automatically so stale XCL_DIRECT_DXIL=all cache entries are invalidated.
  • crates/xcl/src/gpu/dxil/coverage.rs: stop overriding split: false for Mode::Vertex / Mode::Pixel in translate_mode so --direct --split 1 accurately reports 32-lane graphics refusals.
  • crates/xcl/src/gpu/dxil/core_tests.rs: add wave64_graphics_with_upper_lane_reads_refused_in_32_lane_mode covering translate_vertex, translate_pixel, and coverage::translate_mode for both split: true and split: false, with and without upper-lane reads.

Impact on a 2,000-program sample (--direct --sample 2000 --max-bytes 0, seed 1):

  • --split 1 (32-lane waves): 50 of 874 pixel shaders (5.7%) that read lanes 32–63 are now cleanly refused (wave64 VS / PS in 32-lane waves: a read of lanes 32–63) instead of silently emitting broken wave64-only DXIL; the remaining 824 PS and 178/178 VS still translate directly (1950 / 2000 total, 0 panics).
  • --split 0 (native wave64): 2000 / 2000 (100.0%) still translate directly (no change on native wave64).

Fixes #1895.

Tested

  • Hardware: NVIDIA GeForce RTX 3060 Ti (driver 621.01), AMD Ryzen 5 7500F, rustc 1.100.0, DXC / dxil.dll 1.9.2602.17, debug & release builds.
  • cargo test -p xcl --lib gpu::dxil::core_tests: 16 passed, 0 failed, 1 ignored (including new wave64_graphics_with_upper_lane_reads_refused_in_32_lane_mode).
  • cargo test -p xcl --lib gpu::dxil::coverage: 5 passed, 0 failed.
  • xcl shaders <pack> --direct --split 1 --sample 2000 --max-bytes 0: 1950 / 2000 translated, 50 PS refused for lanes 32–63, 0 panics.
  • xcl shaders <pack> --direct --split 0 --sample 2000 --max-bytes 0: 2000 / 2000 translated, 0 panics.

Regression run
Baseline (main 568e7db):

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: NVIDIA GeForce RTX 3060 Ti
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1580 (PresentX 1580)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15495 MB

PR (2a6d713):

xcl-smoke v1
commit: 2a6d71336ad89de71dad83f125344dcf60bb740e
gpu: NVIDIA GeForce RTX 3060 Ti
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1541 (PresentX 1541)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15459 MB

Not tested

  • Native wave64 GPU execution (AMD RDNA2/RDNA3 hardware; only --split 0 translation coverage verified locally on NVIDIA).
  • Full cargo test --workspace on f087b99 (current main has 2 pre-existing unrelated unit-test failures in device_x.rs — tracked by Tests: align device_x UAV strip and pso cache marker tests with main #2233 — and pso::shader_cache_tests::rerouted_disk_entries_follow_the_direct_translator).

AI use

  • Antigravity (Gemini 4 Neon) assisted with implementing the upper_lanes guard in kernel.rs, threading split_wave64 through pso.rs and coverage.rs, writing the unit test, and running the sweeps and smoke test.

@DarkPanda69

Copy link
Copy Markdown

The AMD native wave64 run listed as untested, plus an RTX 3060, paired against main with the direct translator on for the whole GPU suite. On native wave64 hardware the new refusal must not kick in, and nothing that ran before is refused now.

Head 2a6d713 applied on main 426a5a7, debug, Windows 11 Pro 26200, XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- gpu:: --test-threads=4, on main and on this PR for each card:

main this PR
RX 9070 XT (RDNA4, 32.0.32029.2010, native wave64) 626 passed, 3 failed, 22 ignored, 6 SKIPPED 627 passed, 3 failed, 22 ignored, 6 SKIPPED
RTX 3060 (32.0.16.1088, wave32, split wave64) 629 passed, 0 failed, 22 ignored, 23 SKIPPED 630 passed, 0 failed, 22 ignored, 23 SKIPPED

Per-test comparison: on both cards the only difference is the new wave64_graphics_with_upper_lane_reads_refused_in_32_lane_mode (ok). No existing test changes result, and the SKIPPED lines are identical, so no graphics program that ran before is refused now on either card. The RX 9070 XT failures are on main too: gpu_image_get_resinfo_past_last_level (reported on #2054) and the fuzz seeds tracked in #2115.

Not tested: a title with XCL_DIRECT_DXIL=1, RDNA2/RDNA3.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

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.

Shaders: XCL_DIRECT_DXIL=all ignores split_wave64 / upper_lanes for wave64 VS/PS (poisoning split=1 cache), and XCL_DXIL_NO_OPT bypasses cache_allowed()

2 participants