You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
dxil: fix alloca align=0, live double/TGSM metadata, and heap raw buffer flag (#1894) - #2227
What is in it
Fixes the four remaining Direct DXIL bitcode and metadata bugs from #1894 (item 1, TG_SIZEdiv_ceil, is already fixed on main):
Op::Alloca with align == 0 (crates/xcl/src/gpu/dxil/module.rs): encode alignment 0 as 0 instead of 0u32.trailing_zeros() + 1 == 33, which silently set the LLVM 3.7 inalloca flag (bit 5) and align 1 (matching Op::Load, Op::Store, and MODULE_CODE_GLOBALVAR).
Dead / unreachable shader-flag scans (crates/xcl/src/gpu/dxil/module.rs): scan only reachable live blocks (block_layout()) in Module::uses_double_extensions() (and insts_use_type() / has_rov_handle()) instead of scanning dead instructions in self.insts, preventing mismatched DoubleExtensions shader flags after Module::optimize().
Stripped TGSM globals in mesh PSV0 (crates/xcl/src/gpu/dxil/module.rs, graphics.rs): factor out Module::live_decls() from bitcode emission and add Module::live_global_bytes_layout(), called by try_finish_graphics() so mesh PSV0groupshared_bytes counts only TGSM globals actually emitted into bitcode.
Spurious Feature::RawAndStructuredBuffers on Shader::heap_raw_buffer_uav() (crates/xcl/src/gpu/dxil/shader.rs): dxil.dll 1.9 validation confirms that SM 6.6 ResourceDescriptorHeap raw buffers (createHandleFromHeap + annotateHandle) do not set the bound RawAndStructuredBuffers bit (0x10); removing the spurious self.require(Feature::RawAndStructuredBuffers) from heap_raw_buffer_uav() makes shaders whose only raw buffers come from the descriptor heap pass validation (correcting the direction noted in 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 item 5).
Tests (crates/xcl/src/gpu/dxil/tests.rs, graphics_tests.rs): four new dxil.dll-validated tests covering each fix (dead_double_extension_does_not_set_feature_flag, alloca_with_default_align_zero_validates_without_inalloca, heap_raw_buffer_uav_does_not_set_spurious_raw_buffer_flag, and mesh_psv0_excludes_stripped_groupshared_globals).
Antigravity (Gemini 4 Neon) assisted with implementing the four fixes, validating the heap raw-buffer flag behavior against dxil.dll 1.9, adding the four validator tests, and running the test and smoke sweeps.
The AMD native wave64 run the PR and the review above ask for, plus an RTX 3060, paired against main with the direct translator on for the whole GPU suite.
Head f296ca8 applied on mainf087b99, 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:
Per-test comparison: on both cards the only differences are the 4 new tests (all ok): alloca_with_default_align_zero_validates_without_inalloca, dead_double_extension_does_not_set_feature_flag, heap_raw_buffer_uav_does_not_set_spurious_raw_buffer_flag, mesh_psv0_excludes_stripped_groupshared_globals. No existing test changes result or skip state. The failures are all on current main without this PR: rerouted_disk_entries_follow_the_direct_translator on both cards (reported on #2120), and on the RX 9070 XT gpu_image_get_resinfo_past_last_level (reported on #2054) plus the fuzz seeds tracked in #2115.
Not tested: Intel Arc, a title with XCL_DIRECT_DXIL=1.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is in it
Fixes the four remaining Direct DXIL bitcode and metadata bugs from #1894 (item 1,
TG_SIZEdiv_ceil, is already fixed onmain):Op::Allocawithalign == 0(crates/xcl/src/gpu/dxil/module.rs): encode alignment0as0instead of0u32.trailing_zeros() + 1 == 33, which silently set the LLVM 3.7inallocaflag (bit 5) andalign 1(matchingOp::Load,Op::Store, andMODULE_CODE_GLOBALVAR).crates/xcl/src/gpu/dxil/module.rs): scan only reachable live blocks (block_layout()) inModule::uses_double_extensions()(andinsts_use_type()/has_rov_handle()) instead of scanning dead instructions inself.insts, preventing mismatchedDoubleExtensionsshader flags afterModule::optimize().PSV0(crates/xcl/src/gpu/dxil/module.rs,graphics.rs): factor outModule::live_decls()from bitcode emission and addModule::live_global_bytes_layout(), called bytry_finish_graphics()so meshPSV0groupshared_bytescounts only TGSM globals actually emitted into bitcode.Feature::RawAndStructuredBuffersonShader::heap_raw_buffer_uav()(crates/xcl/src/gpu/dxil/shader.rs):dxil.dll 1.9validation confirms that SM 6.6ResourceDescriptorHeapraw buffers (createHandleFromHeap+annotateHandle) do not set the boundRawAndStructuredBuffersbit (0x10); removing the spuriousself.require(Feature::RawAndStructuredBuffers)fromheap_raw_buffer_uav()makes shaders whose only raw buffers come from the descriptor heap pass validation (correcting the direction noted in 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 item 5).crates/xcl/src/gpu/dxil/tests.rs,graphics_tests.rs): four newdxil.dll-validated tests covering each fix (dead_double_extension_does_not_set_feature_flag,alloca_with_default_align_zero_validates_without_inalloca,heap_raw_buffer_uav_does_not_set_spurious_raw_buffer_flag, andmesh_psv0_excludes_stripped_groupshared_globals).Fixes #1894.
Tested
rustc 1.100.0, DXC /dxil.dll1.9.2602.17, debug & release builds.cargo test --workspace -- --test-threads=4: 1158 passed, 0 failed, 46 ignored (SKIPPED GPU tests: 20 native wave64 tests on 32-lane NVIDIA GPU, 3 pre-existing f16/f32-to-f16 per-lane refusals, 1 driver-cache test without Windows Developer Mode, 1 heap-window test).xcl shaders <pack> --direct --validate --sample 1000(release build): 837 / 837 translated and validated bydxil.dll 1.9(CS 63, GS 18, MS 328, PS 339, VS 89), 0 validator errors, 0 panics.Regression run
Baseline (
main568e7db):PR (
f296ca8):Not tested
AI use
dxil.dll 1.9, adding the four validator tests, and running the test and smoke sweeps.