Skip to content

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() #1895

In review

Description

@microwave805

Static audit on main @ 689f2db found two shader-routing / cache-correctness bugs in crates/xcl/src/gpu/recomp/pso.rs and crates/xcl/src/gpu/dxil/coverage.rs:

1. XCL_DIRECT_DXIL=all ignores split_wave64 / upper_lanes for wave64 VS/PS and caches broken DXIL under the split=1 cache key

  • Where:
    • crates/xcl/src/gpu/recomp/pso.rs:365-373 (compile_console_shader does not pass split_wave64 to direct_graphics)
    • crates/xcl/src/gpu/recomp/pso.rs:651-666 (direct_graphics hardcodes split: false)
    • crates/xcl/src/gpu/recomp/pso.rs:258-263, 324-331 (disk cache stores the result under {hash}_{stage}_{sampler_base}_{windows}_{split as u8}.bin)
    • crates/xcl/src/gpu/dxil/kernel.rs:390 (let split = split && !gfx;)
    • crates/xcl/src/gpu/dxil/coverage.rs:254-255 (translate_mode also forces split: false for VS/PS)
  • Root cause: Unlike the HLSL path (recomp/emit.rs:4267) and the per-lane path (recomp/lower.rs:1100), Direct DXIL (gpu/dxil) has no upper_lanes handling for wave64 vertex/pixel shaders running on 32-lane hardware (NVIDIA, or AMD in wave32 graphics mode). When XCL_DIRECT_DXIL=all is set on a wave32 GPU (split_wave64 == true):
    1. direct_graphics() silently translates wave64 VS/PS with split: false even when upper_lanes::analyze(&insts) finds cross-lane reads of lanes 32..63 (which WaveReadLaneAt / WaveActiveBallot cannot provide in a 32-lane graphics wave), instead of falling back to the HLSL upper_lanes path.
    2. The resulting wave64-only DXIL is persisted into the translated disk cache under the split=1 filename (..._1.bin), poisoning the cache for wave32 GPUs.
  • Fix direction: Pass split_wave64 into direct_graphics() (and translate_mode()), and when wave64 && split_wave64 check upper_lanes::analyze and return Err(...) to fall back to the HLSL upper_lanes path whenever any read is non-Native (matching recomp/lower.rs:1100).

2. XCL_DXIL_NO_OPT is omitted from cache_allowed(), poisoning the translated disk cache

  • Where:
    • crates/xcl/src/gpu/recomp/pso.rs:560-573 (cache_allowed)
    • crates/xcl/src/gpu/dxil/module/opt.rs:352 (std::env::var("XCL_DXIL_NO_OPT"))
  • Root cause: Module::optimize() reads XCL_DXIL_NO_OPT (phi, cse, dce, or all) to skip optimization passes for bisecting, but cache_allowed() does not check XCL_DXIL_NO_OPT (and identity() does not include it). Running once with XCL_DXIL_NO_OPT=all writes unoptimized DXIL into the persistent disk cache under the normal identity, silently serving unoptimized shaders on all subsequent normal runs. (Same class of bug as #1409 for XCL_SAFE_BARRIER=0.)
  • Fix direction: Add "XCL_DXIL_NO_OPT" to the list of env vars in cache_allowed() (pso.rs:561), and add a unit test in pso.rs verifying cache_allowed returns false when XCL_DXIL_NO_OPT is set.

AI use

  • Antigravity (Gemini 4 Neon): static code audit on main @ 689f2db and issue drafting.

Activity

  1. added a commit that references this issue on Nov 24, 2026
    d09f1ee
  2. oni-swr commented on Nov 25, 2026

    @oni-swr
    Contributor

    Taking #1895: respect split_wave64 / upper_lanes under XCL_DIRECT_DXIL=all for wave64 VS/PS and enforce cache_allowed() when XCL_DXIL_NO_OPT is set, with cache/translator regression tests.

  3. oni-swr commented on Nov 25, 2026

    @oni-swr
    Contributor

    Releasing our claim on #1895: PR #1913 / #2252 and merged PR #2013 already cover both items.

  4. YaBulochka commented on Nov 25, 2026

    @YaBulochka

    Status check on current main (568e7db), in case it saves someone a re-audit:

    • crates/xcl/src/gpu/recomp/pso.rs:760 fn direct_graphics(blob, stage, sampler_base, windows) still takes no split_wave64, and line 767 still builds KernelOptions { wave64: ..., split: false, ... }.
    • the cache key does carry split, so the "poisoning" half is unchanged until that is passed through.

    So as of 568e7db the split half of #1895 is still present in the tree; #1913/#2252 are the fix and are still open. The cache half is covered by #2013, as @oni-swr said.

    No action wanted from this comment - just recording the exact line and the state, so the next person reading the issue does not have to grep it again. I will re-check after #2252 lands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions