dxil: fix alloca align=0, live double/TGSM metadata, and heap raw buffer flag (#1894) #2217
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2227"
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?
Imported from ivall/xcl. Originally posted by zondy1i on 2026-11-25T10:40:20Z.
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 #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.Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-25T10:46:46Z.
Full diff review on
f296ca8(graphics.rs,graphics_tests.rs,module.rs,shader.rs,tests.rs) looks clean, and CI is green.Only item remaining for dual-vendor coverage on
f296ca8is an independent AMD GPU (native wave64) test run.Imported from ivall/xcl. Originally posted by DarkPanda69 on 2026-11-25T11:09:11Z.
The AMD native wave64 run the PR and the review above ask for, plus an RTX 3060, paired against
mainwith the direct translator on for the whole GPU suite.Head
f296ca8applied onmainf087b99, debug, Windows 11 Pro 26200,XCL_DIRECT_DXIL=1 cargo test -p xcl --lib -- gpu:: --test-threads=4, onmainand on this PR for each card:mainPer-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 currentmainwithout this PR:rerouted_disk_entries_follow_the_direct_translatoron both cards (reported on #2120), and on the RX 9070 XTgpu_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.
Imported from ivall/xcl. Originally posted by throny on 2026-11-25T14:53:59Z.
Two contributors checked independently and found that #1952 #2255 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.
Imported from ivall/xcl. Originally posted by zondy1i on 2026-11-25T15:32:25Z.
Comparison for #1607 (group D73: #2227 vs #1952 and #2255):
MERGEABLE, green-CI diff already reviewed by @raylitebull and verified on both AMD RDNA4 (RX 9070 XT) and NVIDIA (RTX 3060 / 3060 Ti):Op::Allocaalign == 0encoded as0(no spuriousinallocabit 5).uses_double_extensions(),insts_use_type(), andhas_rov_handle()scan only reachable blocks viablock_layout()(excluding both dead instructions and unreachable blocks).PSV0groupshared_bytesuseslive_global_bytes_layout()sharinglive_decls()with bitcode emission.Feature::RawAndStructuredBuffersfromShader::heap_raw_buffer_uav()(verified withdxil.dll 1.9that heap-only raw buffers fail validation when bit0x10is set).uses_double_extensionsandheap_raw_buffer_uav), currently failsPR description, and has an unneededTRANSLATOR_VERSIONbump.blocks.iter().flatten()(still including unreachable blocks), and leaves the spuriousRawAndStructuredBuffersflag inheap_raw_buffer_uav().Only one PR is needed for #1894; #2227 is a strict superset of #1952 and #2255, has dual-vendor verification, and is ready to merge.
Imported from ivall/xcl. Originally posted by CalvyPZ on 2026-11-25T22:43:41Z.
This PR has been marked as a duplicate and closed after multiple agreeing checks in #1607. If you believe this is incorrect please re-open with why.
Imported from ivall/xcl. Originally posted by Decodere on 2026-11-27T10:22:23Z.
Independent desktop NVIDIA verification of PR #2227 at head
f296ca8ff351e425d084c312c7eef86c57878c0a(1commit; exact parent & merge-base:568e7db7729c8fa6c8f0f4b32d798faaf11462bb, pre-#2555ancestor ofmain).Environment
7956 MiBreported by D3D12, Wave32-only Ada), driver32.0.16.2114(NVIDIA621.14, WDDM 3.2)31.9 GiBusable), Windows 11 Home26200(Developer Mode off)rustc 1.100.0 (0ef1bc386 2026-11-09)MSVC, DXC1.9.2609.5,--releaseTargeted tests & build (
f296ca8f)cargo test --release -p xcl --lib -- --nocapture mesh_psv0_excludes_stripped_groupshared_globals 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(3 consecutive runs)4 passed; 0 failed; 0 ignored; 1124 filtered out× 3 (0.01s,0.01s,0.01s,0skipped; live DXIL1.9.2609.5SDK validator checks on all 4 new regressions for#1894)cargo test --release -p xcl --lib gpu::dxil:: -- --nocapture(3 consecutive runs)126 passed; 0 failed; 3 ignored; 999 filtered out× 3 (4.52s,4.53s,3.82s,0runtime skips;3pre-existing#[ignore]debug/seed tests; includes2000DXIL fuzz validation seeds and1232live RTX 4060 GPU comparisons per run)cargo build --release -p xcl1m 29s, exit0,0new warnings across the 5 modifiedgpu::dxilfiles)Paired quiet 60 s retail smoke (
title: 29640639)Exact parent & merge-base (
568e7db7729c8fa6c8f0f4b32d798faaf11462bb, cached baseline on the same machine):PR #2227 (
f296ca8ff351e425d084c312c7eef86c57878c0a):Limits of coverage
#1894DXIL metadata/validation tests (allocadefault align=0 withoutinalloca, live double-extension flag, stripped groupshared PSV0 sizing, and heap raw-buffer UAV flag) plus the fullgpu::dxil::suite (126tests +2000fuzz seeds /1232GPU comparisons) passed3/3withdxil.dll 1.9.2609.5on desktop RTX 4060 (Wave32-only Ada; native Wave64 paths are not exercised).0device removals,0crashes, steady 60 Hz); single-run frame/commit delta vs. the cached parent reflects normal startup variance rather than this PR.AI disclosure: test execution and report drafting assisted by Google Antigravity (Gemini 4 Neon).
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T07:37:21Z.
Triage (#1607) – head
f296ca8#2255 (open, same issue #1894) overlaps in part. Both encode an
align == 0alloca as 0 instead ofinalloca, factor out the live-globals scan and count only referenced TGSM in PSV0. They differ elsewhere. This PR scans only reachable blocks for double extensions and dropsRawAndStructuredBuffersfromheap_raw_buffer_uav(the flag is still set by the raw load/store ops inops.rs). #2255 adds a TG_SIZE test and a power-of-two assert. Main has neither alloca fix nor the live TGSM count yet.No problems found in the diff.
Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.