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 gpu::dxil::coverage on da82f10: 25 passed, 0 failed, 1 ignored (including new wave64_graphics_with_upper_lane_reads_refused_in_32_lane_mode).
  • cargo test --workspace -- --test-threads=4 on da82f10: 1436 passed, 0 failed, 47 ignored across 37 test binaries.
  • Translation sweeps below were run on the pre-rebase head 2a6d713; the rebase onto current main only resolved a conflict in pso.rs (split_wave64 is threaded through direct_graphics next to fssm_wave64).
  • 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 (da82f10):

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

Not tested

  • Native wave64 GPU execution (AMD RDNA2/RDNA3 hardware; only --split 0 translation coverage verified locally on NVIDIA).
  • Translation sweeps (--sample 2000) were not re-run on the rebased head da82f10; the numbers above are from 2a6d713.

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.

@jennydeth

Copy link
Copy Markdown

Full workspace run on this head (listed under Not tested). Two failures, both also on the PR's base, so not from this PR.

Setup: RTX 3060 12 GB (32-lane waves, driver 32.0.16.2101), Ryzen 5 5600X, 32 GB RAM, Windows 11 build 26300, Rust 1.100.0, DXC 1.9.2609.5, debug build. Head 2a6d713, base f087b99.

Result: cargo test --workspace -- --test-threads=4: 1173 passed, 2 failed, 26 ignored.

gpu::recomp::pso::shader_cache_tests::rerouted_disk_entries_follow_the_direct_translator (left 68, right 1)
hle::d3d12x::device_x::tests::pc_resource_desc_strips_uav_on_unsupported_formats_and_msaa (format 85 kept: left 28, right 85)
Both fail the same way on the base f087b99 alone, and pass on current main 1a0bbe3, so a rebase onto main should clear them. SKIPPED: 18 GPU tests for no wave64 (expected on this card).

AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this report.

@throny

throny commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Two contributors checked independently and found that #1913 solves the same problem (for #1895) in a different way: #1607, group D74. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.

This is a hint from the community triage in #1607, not a maintainer decision.

AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.

@S1m0ne1997

Copy link
Copy Markdown

Test report for 2a6d71336ad89de71dad83f125344dcf60bb740e (this PR's head), for #1607.

Tested

  • NVIDIA GeForce RTX 4090 24 GB (driver 621.40), AMD Ryzen 9 9950X3D, 47 GB RAM, Windows 11 Home 10.0.26300, rustc 1.100.0 (0ef1bc386 2026-11-09) x86_64-pc-windows-msvc, debug.
  • cargo build --workspace, then cargo test --workspace -- --test-threads=4 at the head: 1173 passed, 2 failed, 26 ignored.
  • SKIPPED (14): a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu (no wave64), coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu (no wave64), cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu (no wave64), the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu (no wave64), a_per_lane_2d_or_3d_group_runs_on_the_gpu (no wave64), const_and_null_mask_operands_agree_with_hlsl_on_the_gpu (const_mask, wave64: no wave64), f16_programs_on_the_gpu (f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 semantics differ from the console's)); f16 arithmetic, wave64: no wave64), f32_programs_on_the_gpu (f32 arithmetic, wave64: no wave64; f32 compares, wave64: no wave64), f64_programs_on_the_gpu (f64, wave64: no wave64), integer_programs_on_the_gpu (integer arithmetic, wave64: no wave64; integer carries, wave64: no wave64), mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu (mask_ff0_flbit, wave64: no wave64), gpu_geometry_wave32_prefix_count_over_a_mask (no wave64), gpu_wave32_program_in_wave64_hardware (no wave64), pso_measurement_compiles_an_exact_synthetic_record (cannot disable the driver cache (Windows Developer Mode is required): L'applicazione ha richiesto un'operazione che dipende da un componente SDK mancante o non corrispondente. (0x887A002D)).
  • Failed: gpu::recomp::pso::shader_cache_tests::rerouted_disk_entries_follow_the_direct_translator, hle::d3d12x::device_x::tests::pc_resource_desc_strips_uav_on_unsupported_formats_and_msaa

The 2 failures are in this PR's base, not in its change. Both fail the same way on its merge base f087b99 without this PR (rerouted_disk_entries_follow_the_direct_translator: left 68, right 1; pc_resource_desc_strips_uav_on_unsupported_formats_and_msaa: format 85 kept, 28 expected), and both pass on current main 06c9f55. They are the two tests of #2242 / #2248, fixed on main since (#2243 for the first). A rebase onto current main should clear them.

Regression run (retail title, scripts/smoke.ps1 -Seconds 60, release; main built from the commit in its block, this PR from its head with no changes to crates/, both run with the scripts/smoke.ps1 of main, which hashes the name of the game folder)

main:

xcl-smoke v1
commit: 06c9f5505f63f10c5ec49ef932d75b2c28177324
gpu: NVIDIA GeForce RTX 4090
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1599 (PresentX 1599)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16384 MB

this PR:

xcl-smoke v1
commit: 2a6d71336ad89de71dad83f125344dcf60bb740e
gpu: NVIDIA GeForce RTX 4090
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1608 (PresentX 1608)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 18229 MB

Not tested

  • AMD, other NVIDIA cards and drivers, Linux. I did not review the diff; this report is the build, the suite and the regression run only.

AI use: Claude Code with Claude Opus 5.5 ran the build, the suite and the regression run and wrote this report at my request.

@zondy1i

zondy1i commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

Comparison for #1607 (group D74: #2252 vs #1913):

Both PRs are MERGEABLE, CI-green, and fix the remaining #1895 item (wave64 VS/PS reading lanes 32-63 on 32-lane GPUs):

Only one of the two should be merged - if maintainers prefer #1913, I'm happy to close #2252 in its favour.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

@CalvyPZ CalvyPZ added the duplicate This issue or pull request already exists label Nov 25, 2026
@CalvyPZ CalvyPZ closed this Nov 25, 2026
@CalvyPZ CalvyPZ reopened this Nov 25, 2026
@CalvyPZ CalvyPZ removed the duplicate This issue or pull request already exists label Nov 25, 2026
@zondy1i
zondy1i force-pushed the dxil/graphics-upper-lanes-guard branch from 2a6d713 to da82f10 Compare November 26, 2026 02:47
@zondy1i

zondy1i commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (b49be183); the only conflict was in pso.rs (kept fssm_wave64 and threaded split_wave64 through direct_graphics). Re-ran the unit tests, the full workspace suite (1436 passed, 0 failed) and a 60 s smoke on the new head da82f10; description updated with the new smoke block.

rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 26, 2026
…pstream xcl-dev#2252)

Soundness gate reusing the shared recomp::upper_lanes analysis: a
wave64 vertex/pixel shader with any non-native lane-32..63 read is
refused when it may run in 32-lane waves (those console lanes do not
exist there). Direct graphics now honors split_wave64 so the gate is
live; translate-only test vector lands in core_tests.rs.
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()

7 participants