Skip to content

Direct DXIL: fix TG_SIZE wave rounding, alloca align=0, and shader fl… - #2255

Open
fixgep wants to merge 1 commit into
xcl-dev:mainfrom
fixgep:fix/dxil-encoder-and-flags
Open

fixgep wants to merge 1 commit into
xcl-dev:mainfrom
fixgep:fix/dxil-encoder-and-flags

Conversation

@fixgep

@fixgep fixgep commented Nov 25, 2026

Copy link
Copy Markdown

Fixes three remaining direct DXIL encoder/flag bugs from #1894 and adds synthetic DXIL-validator unit tests across all five items (note: item 1 TG_SIZE div_ceil was already fixed on main in 5b31ca7, and item 5 heap_raw_buffer keeps Feature::RawAndStructuredBuffers omitted because dxil.dll 1.9.2602.17 rejects that flag on heap-only raw buffers with Flags must match usage: declared=1073741840, actual=1073741824, matching dxc.exe).

Fixes #1894

What is in it

  • crates/xcl/src/gpu/dxil/module.rs: scan live self.blocks.iter().flatten() instead of self.insts.iter() in uses_double_extensions so dead or unreachable f64 ops do not trigger Feature::DoubleExtensions.
  • crates/xcl/src/gpu/dxil/module.rs: encode Op::Alloca alignment 0 as 0 instead of 33 ((1 << 5) | 1, which set inalloca bit 5), and assert align == 0 || align.is_power_of_two().
  • crates/xcl/src/gpu/dxil/module.rs: share used_globals_and_funcs between write_bitcode and global_bytes_layout so stripped/unreferenced TGSM globals are excluded from PSV0 NumBytesGroupSharedMemory.
  • crates/xcl/src/gpu/dxil/module.rs, crates/xcl/src/gpu/dxil/core_tests.rs, crates/xcl/src/gpu/dxil/graphics_tests.rs, crates/xcl/src/gpu/dxil/shader.rs: add synthetic unit and dxil.dll validation tests for all five Direct DXIL: TG_SIZE truncation, dead-inst double-extension scan, Alloca align=0 inalloca bit, stripped TGSM PSV0 size, and heap_raw_buffer feature flag #1894 items, and update groupshared_bytes_follow_the_16bit_layout so its test globals are referenced by live instructions.

Tested

  • Hardware & toolchain: NVIDIA GeForce RTX 3060 (driver 32.0.15.9144), AMD Ryzen 5 7500F, Windows 11 25H2 (build 26200), rustc 1.100.0 (0ef1bc386 2026-11-09), debug (cargo test) and release (cargo build --release -p xcl + scripts/smoke.ps1), Windows SDK dxcompiler 1.9.2602.17 / dxil 1.9.2602.17.
  • cargo test -p xcl --lib gpu::dxil -- --test-threads=4: 128 passed, 0 failed, 3 ignored, 0 SKIPPED.
  • cargo test -p xcl --lib -- --test-threads=4: 1102 passed, 2 failed (gpu::recomp::tests::gpu_clamp_and_omod_per_instruction, pre-existing HLSL/DXC path v_pk_add_i16 clamp failure on this adapter; hle::d3d12x::real::readback_routing_tests::coherent_buffer_sanitizes_console_flags_and_state, passed 1/1 when rerun standalone), 26 ignored; 24 SKIPPED GPU tests (20 no wave64, 3 refused #1426 f16/f32 semantics on wave32 per-lane, 1 cannot disable the driver cache without Windows Developer Mode).
  • cargo test -p xcl --test '*' -- --test-threads=4: 56 passed, 0 failed, 20 ignored, 1 SKIPPED (heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows).

Regression run

main:

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

PR:

xcl-smoke v1
commit: fb9e4011429462b0cd4fb50da2344514ee45c9ac
gpu: NVIDIA GeForce RTX 3060
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 884 (PresentX 885)
presents per 2 s (last 3): 60 59 60
device removals: 0
crashes: 0
peak commit: 15357 MB

Not tested

  • AMD or Intel GPUs, and native wave64 hardware (no wave64 on RTX 3060).
  • cargo test --workspace -- --test-threads=4 as a single invocation (ran cargo build --workspace plus cargo test -p xcl --lib and cargo test -p xcl --test '*').
  • The retail smoke title does not exercise every modified DXIL path (e.g. Alloca align=0, dead f64 extension ops, or Mesh shader stripped TGSM).

AI use

@throny

throny commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Two contributors checked independently and found that #1952 #2227 solves the same problem (for #1894) in a different way: #1607, group D73. 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.

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.

Direct DXIL: TG_SIZE truncation, dead-inst double-extension scan, Alloca align=0 inalloca bit, stripped TGSM PSV0 size, and heap_raw_buffer feature flag

2 participants