Repository navigation
Direct DXIL: reject invalid stage exports and graphics LDS ops - #2102
Conversation
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 xcl-dev#1269
Assisted-by: Google Antigravity (Gemini 4 Neon)
|
Full-suite run, since this PR has no test report yet. Tested exact head Tested
Not tested
AI use
|
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
Tested head
Not tested: retail title; AMD hardware. AI-assisted (Claude Code, Claude Sonnet 5.5 ran the tests; Claude Opus 5.5 checked and posted). |
|
Tested: Clean 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 ( |
|
merge-check |
|
merge-check claim |
|
merge-check |
|
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
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. |
|
Correction to my report above: #2102 and #2419 do not clash with each other. Since #3203, AI use: Claude Code (Claude Fable 5.2) wrote this; Claude Opus 5.5 found the cause. |
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
From #2102 (merge 848be4c). Adapted: the tests' CsInterface / PsInterface take this tree's lds_dwords and
early_depth fields, and geometry_export_rejected also accepts, for a split pass
with an ES phase, this tree's earlier refusal of it (kernel::translate_geometry
with the safe barrier: "split wave64 geometry: the ES phase exchanges at group
barriers"), which comes before the export is lowered. The guards themselves
as upstream.
(cherry picked from commit 848be4c)
Assisted-by: Google Antigravity (Gemini 4 Neon)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
From #2102 (merge 848be4c). Adapted: the tests' CsInterface / PsInterface take this tree's lds_dwords and
early_depth fields, and geometry_export_rejected also accepts, for a split pass
with an ES phase, this tree's earlier refusal of it (kernel::translate_geometry
with the safe barrier: "split wave64 geometry: the ES phase exchanges at group
barriers"), which comes before the export is lowered. The guards themselves
as upstream.
(cherry picked from commit 848be4c)
Assisted-by: Google Antigravity (Gemini 4 Neon)
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.