Direct DXIL: reject invalid stage exports and graphics LDS ops #2102
No reviewers
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!2102
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2102"
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?
@Decodere on GitHub · 2026-11-25 04:13 UTC · original
Decodere:fix-1269-dxil-stage-guards→main· +132 −0 · 1 files · 1 commits · openWhat is in it
Matches the HLSL recompiler's stage guards (
recomp/emit.rs) in the direct DXIL translator'sLw::export()andLw::ds()(crates/xcl/src/gpu/dxil/lower_mem.rs):Lw::export(): after dispatchingEntry::Mesh(self.mesh.is_some()) andEntry::Vertex/Entry::Pixel(self.gfx.is_some()), rejectsEntry::Compute(self.res.is_none()) andEntry::Geometry(self.geom.is_some()) witherr(d, "export target")before reaching the kernel-modeKERNEL_EXPORTSstore path. Previously,ENC_EXPinEntry::Computepanicked onself.res.expect("res")whenEN != 0and silently returnedOk(())whenEN == 0, whileENC_EXPinEntry::Geometrysilently wrote kernel-export offsets into the geometry mesh-record UAV (u1).Lw::ds(): after handling wave-levelds_swizzle_b32andds_bpermute_b32(withds_nopalready skipped inNOOPS), rejects LDSENC_DSoperations inEntry::VertexandEntry::Pixel(self.gfx.is_some()) witherr(d, "LDS outside compute")beforeGDS/ LDS lowering. Previously, direct DXIL emitted invalidaddrspace(3)TGSM ops in graphics stages and returnedOk.gpu::dxil::lower_mem::stage_guard_testscovering computeEXP(EN = 0xFandEN = 0, wave32 and wave64), geometryEXP(EN = 0xFandEN = 0, ES-only and GS-only, native and split), VS/PS LDS ops (DS_READ_B32,DS_WRITE_B32, andGDS = 1), and positivedxil.dllvalidation controls for kernelEXP, compute LDS, and VS/PSDS_SWIZZLE_B32/DS_BPERMUTE_B32/DS_NOP+ validEXP.Part of #1269
Tested
Environment: Windows 11 Home 26200, Intel Core i5-11400F, 32 GB RAM, NVIDIA GeForce RTX 4060 8 GB (driver 621.14, wave32), Rust 1.100.0, DXC
1.9.2609.5(01b62ad4).cargo test -j 4 -p xcl --lib gpu::dxil::lower_mem::stage_guard_tests -- --nocapture): 1 passed, 3 failed (compute_export_rejectedpanicked atlower_mem.rs:2511:28: res->"the direct DXIL translator panicked: res";geometry_export_rejectedandgraphics_lds_rejectedunexpectedly succeeded;valid_stage_ops_still_translate_and_validatepassed).cargo test --release -p xcl --lib gpu::dxil::lower_mem::stage_guard_tests -- --nocapture): 4 passed, 0 failed (includingdxil 1.9.2609.5validation of positive controls).cargo build --release --workspaceandcargo test --release --workspace -- --test-threads=4 --nocapture): 1,158 passed, 0 failed, 46 ignored across 21 test binaries (1102inxcllib,56across the remaining 20 binaries), with 27SKIPPEDlines on this RTX 4060:no wave64(RTX 4060 is wave32-only)per-lane form: refused(wave32 f16 arithmetic, f16 packed, f32 conversions)no d3d12SDKLayers.dll/no D3D12 debug layercannot disable the driver cache(Windows Developer Mode not enabled)no heap windowsRegression run
Paired 60 s runs via
scripts/smoke.ps1on cleanorigin/main(cbc296ab) and clean PR head (00b5eef7):Main (
cbc296ab65a2661a61e3e2da109134bcd5319f60):PR (
00b5eef722359d70fd2549a12a5f87edb9b154f5):Not tested
no wave64skips on RTX 4060), D3D12 debug layer tests (2 skips withoutd3d12SDKLayers.dll), driver cache disable toggle (1 skip without Windows Developer Mode), and heap-window OOM fallback (1 skip withoutXCL_HEAP_WINDOWS).title: 29640639(and runtime title execution specifically exercising malformed compute/geometryEXPor graphics LDS shaders underXCL_DIRECT_DXIL).AI use
Google Antigravity (Gemini 4 Neon) wrote the stage guards, unit tests, and this PR description. All pre-fix/post-fix unit tests, full release workspace tests, paired 60 s smoke runs, and
scripts/pr_check.py --localvalidation were run locally on this machine.Match the HLSL recompiler's stage guards in Lw::export and Lw::ds: - Reject ENC_EXP in compute (res is None) and geometry (geom is Some) entries with "export target" instead of panicking on self.res.expect("res") (compute, en != 0), silently returning Ok (en == 0), or writing kernel-export offsets into the geometry mesh record buffer. - Reject LDS ENC_DS operations in vertex and pixel entries (gfx is Some) with "LDS outside compute" after allowing wave-level ds_swizzle_b32 and ds_bpermute_b32 (and ds_nop), instead of emitting invalid addrspace(3) TGSM ops in graphics DXIL. Part of #1269 Assisted-by: Google Antigravity (Gemini 4 Neon)@futurepro62 on GitHub · 2026-11-25 05:16 UTC · original · edited 2026-11-25 05:25 UTC
Full-suite run, since this PR has no test report yet. Tested exact head
00b5eef(on its basecbc296a).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::recomp::lower_dxil::tests::mask_ff0_and_flbit_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 1146 passed, 0 failed, 44 ignored. SKIPPED (no wave64):a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu,a_per_lane_2d_or_3d_group_runs_on_the_gpu,coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu,cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu,gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware,the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.compute_export_rejected,geometry_export_rejected,graphics_lds_rejected,valid_stage_ops_still_translate_and_validate.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 1157 passed, 0 failed, 46 ignored. SKIPPED:f16_programs_on_the_gpu(f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).--skipleaves out tests that fail on main6020a33too, not because of this PR. On NVIDIA:heap_window_out_of_memory_falls_back_to_the_switch_form(#1651), the fourgpu::recomp::lower_dxil::tests::*_programs_on_the_gputests,const_and_null_mask_operands_agree_with_hlsl_on_the_gpuandmask_ff0_and_flbit_agree_with_hlsl_on_the_gpu(follow-up on #1651) fail becauserunner::skip_testturns their skips into failures underXCL_REQUIRE_GPU=mesh, andgpu::dxil::fuzz_testsseeds 70, 545, 1019 and 1507 failCreateComputePipelineStatewithE_OUTOFMEMORYon this card (drivers 616.64 and 621.40). On AMD:fuzz_validate_and_gpu_1fails on seed 540 (res[833]0x7 vs CPU 0x6). The AMD run does not setXCL_REQUIRE_GPU.Not tested
AI use
@DavidM1911 on GitHub · 2026-11-25 06:02 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
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.