Direct DXIL: reject invalid stage exports and graphics LDS ops #2092
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from ivall/xcl. Originally posted by Decodere on 2026-11-25T04:13:53Z.
What 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.Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-25T05:16:32Z.
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
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T06:02:37Z.
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!
upstream-sync referenced this pull request2026-11-25 12:04:57 +00:00
Imported from ivall/xcl. Originally posted by upipibi on 2026-11-26T23:18:33Z.
Tested head
00b5eef722359d70fd2549a12a5f87edb9b154f5, merge-basecbc296ab65a2661a61e3e2da109134bcd5319f60, RTX 3070 (Ampere) driver 616.56, Windows 11, rustc 1.100.0cargo test -p xcl --lib -- stage_guard_tests --test-threads=1 --nocapture, 3 runs on head: 4 passed, 0 failed (each run).stage_guard_testsmodule appended alone to the merge-base'slower_mem.rs(compiles, without the two guards): 1 passed, 3 failed (compute_export_rejected,geometry_export_rejected,graphics_lds_rejected; the compute export case panics in the translator onres).valid_stage_ops_still_translate_and_validatepasses there.cargo test -p xcl --lib -- --test-threads=4: head 1102 passed, 0 failed, 26 ignored; merge-base (unmodified) 1098 passed, 0 failed, 26 ignored.Not tested: retail title; AMD hardware.
AI-assisted (Claude Code, Claude Sonnet 5.5 ran the tests; Claude Opus 5.5 checked and posted).
Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-27T00:15:21Z.
Tested: Clean
00b5eef722359d70fd2549a12a5f87edb9b154f5, Windows 11 build 26200, Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175, Rust 1.100.0 MSVC, DXC/DXIL 1.9.2602.17, debug. Built withcargo test --locked -j 2 -p xcl --lib --no-runand ran the resulting executable with--exact --test-threads=1 --nocaptureunder the shared Arc lock. WithXCL_ADAPTER=A770andXCL_DIRECT_DXIL=1, 7 passed across graphics linking/branches, pixel survival, geometry records, mesh pass-through, compute LDS, and lane swizzle/bpermute. WithXCL_DIRECT_DXIL=0, 3 passed on the same mesh, compute LDS and lane-operation controls. Both runs had 0 failures, ignores or skips. The binary hash matched before and after each run.Not tested: Native wave64 execution, the full workspace suite, retail smoke, and on-device execution of the exact VS/PS wave-DS validator fixture.
AI use: T3 Code / Codex (
gpt-6.2-sol) ran and reran the GPU checks and wrote the report.Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-28T09:37:27Z.
merge-check
base:
e429936c10head:
00b5eef722merge: clean
build:
cargo build --offline --locked -j 4 --workspace-> oktests:
cargo test --offline --locked -j 4 --workspace --no-fail-fast -- --test-threads=4-> 2,129 passed, 10 failed, 48 ignored; 25 GPU skip notices. The 10 failures match my earlier untouched-main run at this base:dispatch_chain_oversized_loop_matches_whole,dispatch_chain_wave32_live_loops,dispatch_chain_wave64_live_loops_and_exchange,gpu_heap_flat_reads_match_guarded_and_root_output,console_mesh_caches_hlsl_compute_pass_in_memory_and_on_disk,gpu_compute_mode_dispatch_abi,gpu_float_cas_uses_ieee_equality, and the threetest_title_*e2e cases (test_title_runs_and_game_folder_is_untouched,test_title_runs_under_the_debug_layer_with_dred,test_title_draws_with_a_root_signature_under_the_debug_layer). The four newstage_guard_testspassed separately (4 passed, 0 failed, 0 ignored, 0 skipped) withcargo test --offline --locked -j 4 -p xcl --lib gpu::dxil::lower_mem::stage_guard_tests -- --nocapture.review: none. I read the full diff. The stage checks run before the kernel export path or graphics LDS lowering; existing wave-level DS operations and valid kernel/compute exports remain covered by the positive DXIL validation controls. The PR author also supplied a failing-first check and a clean-commit smoke pair on its head.
performance: reasoned only. These checks run during shader translation and add no work to a successfully translated frame. No frame-time or memory benchmark was run here.
verdict: safe to merge relative to the checked main base; the workspace suite remains red for the same 10 base failures.
hardware / tool and model: Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti / 621.35, DXC 1.8.2502.11; Codex (GPT-6.2 Sol) reviewed the diff and ran these checks.
Imported from ivall/xcl. Originally posted by throny on 2026-11-28T13:04:23Z.
merge-check claim
head:
00b5eef722Imported from ivall/xcl. Originally posted by throny on 2026-11-28T13:22:31Z.
merge-check
base:
e429936chead:
00b5eef722merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2130 passed, 9 failed, 48 ignored: the base's 9 only (26 SKIPPED lines). The 9 failures are main's own at
e429936con this GPU (#3093); base alone: 2126 passed, 9 failed, 48 ignored.review: no blocking finding. On main an export in a compute program panics (no export resources there), and in geometry mode it writes into the kernel export area of the record buffer; the new guard refuses both. The LDS guard applies to vertex and pixel programs only, after the swizzle and permute forms are handled; mesh and compute LDS are unaffected. Behaviour change not mentioned in the description: an export with nothing enabled in a compute or geometry program was a no-op before and now sends the program to the HLSL path (low risk). A negative control in the thread shows three of the four tests fail without the fix.
performance: direct DXIL only (the graphics part only with XCL_DIRECT_DXIL=all); a one-time re-translation there.
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).
Imported from ivall/xcl. Originally posted by throny on 2026-11-29T12:14:51Z.
Test report for merging this together with the other of #2102 / #2419 (both are ready to merge on their own): trial merge of both into
maind8bd9a38,cargo build --workspace && cargo test --workspace -- --test-threads=4, RTX 4080 16 GB, 621.40:gpu::dxil::lower_geom::tests::gpu_epilogue_filters_oob_triangles_and_no_store_emitsandgpu::dxil::lower_mem::stage_guard_tests::geometry_export_rejected.mainalone: 2618 passed, 0 failed. Each of the two PRs alone passed in its merge checks.So the two do not go in together as they are; whichever is merged second needs a rebase and a look at those two tests. I have not looked into which side is right.
AI use: Claude Code (Claude Fable 5.2) ran the suite and wrote this.
Imported from ivall/xcl. Originally posted by throny on 2026-11-29T14:19:53Z.
Correction to my report above: #2102 and #2419 do not clash with each other. Since #3203,
kernel::translate_geometryrefuses the split wave64 form when the program has an ES phase, and the new tests of both PRs call it that way, so they stop at that refusal. #3411 fixes the tests onmain. Sorry for the wrong lead.AI use: Claude Code (Claude Fable 5.2) wrote this; Claude Opus 5.5 found the cause.