DXIL: filter OOB triangles, gate no-store emits, and clamp LDS in lower_geom #2419
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!2419
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2419"
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 18:21 UTC · original
Decodere:fix-lower-geom-epilogue-oob→main· +123 −20 · 1 files · 1 commits · openPart of #1401
Part of #1833
Fixes three bugs in the direct DXIL ES+GS lowering (
crates/xcl/src/gpu/dxil/lower_geom.rs) wheregeom_epilogueandgs_emit_cutcould reserve phantom vertices, emit out-of-bounds triangle indices, or read split-wave64 LDS exchange scratch words.What is in it
Lw::gs_emit_cut(crates/xcl/src/gpu/dxil/lower_geom.rs): guard vertex emission and triangle packing withk < maxv(<= 256), preventing out-of-range vertex counts and 10-bit packed index overflow.Lw::geom_epilogue(crates/xcl/src/gpu/dxil/lower_geom.rs):emittedandntribyhas = (gs_base != u32::MAX)before computingvb/tvwave sums so a lane that callss_sendmsg(emit)without a GS-phase LDS store reserves0vertex slots and emits0triangles.tri[j]((tri[j] >> 20) < v_written, scanning only when a lane straddlesmaxvwith3 <= v_written < emitted, zero extra iterations on non-straddling lanes) to computevalid_ntribeforetb/tt/np, guaranteeing every emitted triangle index is< nv.itoself.lds_topwhenself.split(matchinglower_mem::lds_index) so wrapped LDS addresses cannot read the split-wave64 exchange scratch words.gpu::dxil::lower_geom::tests(crates/xcl/src/gpu/dxil/lower_geom.rs):split_epilogue_clamps_lds_to_lds_top_and_validates(pure-CPU / DXC 1.9): validates both native and split geometry DXIL and asserts split-mode disassembly emitsumin(..., 8184)(lds_top) andicmp ult ..., 63(k < maxv).gpu_epilogue_filters_oob_triangles_and_no_store_emits(GPU-guardedmesh_draw): verifies (a) a 15-lane × 20-vertex wave exceedingmax_vertices = 256with a straddling lane outputs(nv = 256, np = 230)with all 230 triangles< 256and exact final straddled triangle, and (b) a no-store emit lane followed by a valid lane outputs(nv = 3, np = 1)with exact lane-1 vertex data and triangle(0, 1, 2).Tested
origin/main3f277701(preserving#2273's coalesced 4-wordraw_storeingeom_epiloguewith thelw.splitlds_topclamp beforegs_load); merges cleanly againstorigin/main2898511a.rustc 1.100.0, DXC1.9.2609.5, release profile (--release).origin/main68a284a5):cargo test --release -p xcl --lib gpu::dxil::lower_geom::tests:: -- --nocapture: 0 passed, 2 failed (missing umin(..., 8184) LDS clampandoverflow header left: (256, 256), right: (256, 230)).3f277701, commit98692ec1):gpu::dxil::lower_geom::tests:2 passed, 0 failed, 0 ignored(0.46 s,0skipped).gpu::dxil::geometry_tests:3 passed, 0 failed, 0 ignored(0.37 s,0skipped, includinggeometry_epilogue_coalesces_header_and_vertex_stores).gpu::dxil::lower_geom::tests:2 passed, 0 failed, 0 ignored(0.01 s; pure-CPU/DXC 1.9 test0skipped, GPU test cleanlySKIPPED: no GPU / DXC / mesh shaders).cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture: 1358 passed, 1 failed, 46 ignored across 24 test binaries (182/182gpu::dxil::*passed,0failed) — the sole failure is3f277701's pre-#2420gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier(fixed onmainby#2420); 29 pre-existingSKIPPEDlines (21 no wave64 on RTX 4060, 3 per-lane wave32 refused, 3 no D3D12 debug layer, 1 no heap windows, 1 cannot disable driver cache; 0 skipped inlower_geom::testsandgeometry_tests).Regression run
main:
PR:
Not tested
split_epilogue_clamps_lds_to_lds_top_and_validatesandgeometry_forms_validate).title: 29640639.AI use
gpu/dxil/lower_geom.rs, implemented thehasgating,k < maxvguard, straddling-lane triangle filter, splitlds_topclamp, and failing-first CPU/GPU tests, and ran targeted, WARP, workspace, and paired smoke verification.@Decodere on GitHub · 2026-11-25 19:12 UTC · original
Rebased
#2419cleanly onto3f277701(98692ec1): preserved#2273's coalesced header + 4-wordraw_storeingeom_epilogue(lower_geom.rs) alongside#2419'shas/k < maxv/valid_ntri/lds_topclamp fixes.Re-verified
lower_geom::tests(2/0RTX 4060 & WARP),geometry_tests(3/0, including#2273's coalescing test),gpu::dxil::*(182/182), and paired 60 s RTX 4060 smoke (3f2777011486frames /13989 MBvs98692ec11518frames /13987 MB,0device removals/crashes).@DarkPanda69 on GitHub · 2026-11-25 18:39 UTC · original · edited 2026-11-25 19:26 UTC
Update for head
98692ec: same result. Applied onmain2664021,gpu_epilogue_filters_oob_triangles_and_no_store_emitspasses on the RX 9070 XT (native wave64) and the RTX 3060. Wholegpu::filter: RX 9070 XT 694 passed, 2 failed (the #2115 fuzz seeds, same onmain); RTX 3060 696 passed, 0 failed.AMD native wave64 run (listed as untested), plus an RTX 3060: the new GPU test passes on both.
Head
2fe72c6applied onmainae6f284, debug, Windows 11 Pro 26200,cargo test -p xcl --lib -- gpu:: --test-threads=4:gpu_epilogue_filters_oob_triangles_and_no_store_emitsok. 684 passed, 3 failed, 22 ignored, 6 SKIPPED.All failures are on
mainwithout this PR:a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrieron both cards (fixed by #2379) and, on the RX 9070 XT, the AMD fuzz seeds tracked in #2115.Not tested: the D3D12 debug layer (not installed here), a title with geometry shaders on the direct path.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
@emirduran707 on GitHub · 2026-11-25 19:41 UTC · original
Independent AMD RDNA4 (native wave64) test report on exact head
98692ec178f711dd8388ff7496cf95ce0691767f(clean detached checkout, no local changes).Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2602.17; tests debug, smoke release.cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4: 1356 passed, 3 failed, 46 ignored; 8 SKIPPED (6 inlower_dxil::tests::{f16,f32}_programs_on_the_gpurefused by per-lane form;heap_window_out_of_memory_falls_back_to_the_switch_form;pso_measurement_compiles_an_exact_synthetic_record). All native wave64 GPU tests ran and passed.gpu::dxil::lower_geom::tests::split_epilogue_clamps_lds_to_lds_top_and_validatesandgpu_epilogue_filters_oob_triangles_and_no_store_emits.main:gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1(seed 722) andfuzz_validate_and_gpu_3(seed 1599) on this GPU, plusgpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier(from50a9fde/ #2074, fixed later onmainin #2420).Regression run (60 s retail-title smoke,
XCL_NETWORK=0, release)(Matched
main68a284abaseline on the same machine today: 1573 frames, 14420 MB peak, 0 device removals, 0 crashes.)Not tested
AI use
@DavidM1911 on GitHub · 2026-11-25 19:47 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: 1 real failure, deterministic (also fails--test-threads=1, 1219/1):The lowered program is missing an expected group barrier (or emits one where none is expected). Needs a fix before merge.
— Devin
@Decodere on GitHub · 2026-11-25 19:53 UTC · original
Thanks for testing! That
gpu::recomp::lower_dxil::tests::a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrierfailure comes from a pre-#2420mainbase (#2074) and was fixed onmainin#2420(c56e7448).This PR (
#2419) only touchescrates/xcl/src/gpu/dxil/lower_geom.rs, and CIBuild and teston currentmain(as well as the independent RDNA4 passes on98692ec1) is green (0failures).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.