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
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl#1894
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@microwave805 on GitHub · 2026-11-24 22:37 UTC · original
Static audit on
main @ 689f2dbfound five small, self-contained correctness bugs across Direct DXIL's compute init, bitcode encoder, and shader-flag metadata:1. Compute
TG_SIZE[5:0]truncatestotal / lanesinstead of rounding upcrates/xcl/src/gpu/dxil/kernel.rs:568-578(compute_init)TG_SIZE[5:0]holds the number of waves in the threadgroup (ceil(total / lanes)). For any non-multiple threadgroup size (e.g.total = 16or32withwave64, or[8, 1, 1]withwave32),total / lanesevaluates to0instead of1(and e.g.total = 96in wave64 gives1instead of2).total.div_ceil(lanes)(comparelw.waves = t.div_ceil(64).max(1)atkernel.rs:486).2.
Module::uses_double_extensions()scans deadself.instsinstead of liveself.blockscrates/xcl/src/gpu/dxil/module.rs:1394-1402uses_double_extensions()iteratesself.insts.iter()instead ofself.blocks.iter().flatten()(contrastinsts_use_type()directly below it atmodule.rs:1403-1419, which iteratesself.blocks.iter().flatten()). Any dead/DCE'd/unreachable-block f64fdivor f64↔int cast remains inself.instsand leavesFeature::DoubleExtensionsset in shader flags even though the instruction is not emitted in bitcode (DXIL validator rejects mismatched shader feature flags).self.blocks.iter().flatten().map(|&i| &self.insts[i as usize]).3.
Op::Allocabitcode encoding corruptsalign == 0intoinallocaflag (bit 5)crates/xcl/src/gpu/dxil/module.rs:1227-1232Allocaalignment is encoded in bits[4:0]as0(default alignment) orlog2(align) + 1(1..31), while bit5(1 << 5 = 32) isinallocaand bit6(1 << 6) isexplicit type. Whenalign == 0,0u32.trailing_zeros() + 1 == 33 == (1 << 5) | 1, silently setting theinallocaflag bit and encodingalign 1!let a = if *align == 0 { 0 } else { align.trailing_zeros() as u64 + 1 };(and assert power-of-two /align.is_power_of_two()).4.
Module::global_bytes_layout()counts stripped unused TGSM globals inPSV0crates/xcl/src/gpu/dxil/module.rs:1501-1503global_bytes_layout()sumsself.globals.iter()unfiltered, whereas the bitcode writer strips unreferenced globals (e.g. TGSM arrays whose uses were eliminated byModule::optimize()). For mesh shaders / compute metadata usingglobal_bytes_layout(3, ...),PSV0reports non-zero TGSM size for globals absent from the emitted bitcode.self.blocks(matching the bitcode writer's liveness filter).5.
Shader::heap_raw_buffer()omitsself.require(Feature::RawAndStructuredBuffers)crates/xcl/src/gpu/dxil/shader.rs:289-293Shader::heap_raw_buffer()callshandle_from_heap+annotate(RAW_BUFFER)without callingself.require(Feature::RawAndStructuredBuffers)(contrastShader::heap_raw_buffer_uav()directly below atshader.rs:297-303, which callsself.require(Feature::RawAndStructuredBuffers)). A shader whose only raw buffers come throughheap_raw_buffer()will miss the required shader flag in DXIL validation.self.require(Feature::RawAndStructuredBuffers);inShader::heap_raw_buffer().AI use
main @ 689f2dband issue drafting.github-bot referenced this issue2026-11-26 05:23:50 +00:00
github-bot referenced this issue2026-11-26 06:18:30 +00:00