DXIL: filter OOB triangles, gate no-store emits, and clamp LDS in lower_geom #2409
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/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?
Imported from ivall/xcl. Originally posted by Decodere on 2026-11-25T18:21:28Z.
Part 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.Imported from ivall/xcl. Originally posted by DarkPanda69 on 2026-11-25T18:39:56Z.
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.
Imported from ivall/xcl. Originally posted by Decodere on 2026-11-25T19:12:47Z.
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).Imported from ivall/xcl. Originally posted by emirduran707 on 2026-11-25T19:41:15Z.
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
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T19:47:40Z.
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
Imported from ivall/xcl. Originally posted by Decodere on 2026-11-25T19:53:32Z.
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).Imported from ivall/xcl. Originally posted by bmjask on 2026-11-25T20:20:41Z.
Review: COMMENTED
No concrete code-level defect found. The vertex/triangle cap logic, no-LDS-store filtering, and split LDS clamp look sound; coverage includes straddling OOB triangles and both split/native wave64. Nonblocking validation gap: no direct-path retail title with geometry shaders was tested. Please retain that limitation in the merge evidence.
Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-28T06:24:46Z.
merge-check
base:
e429936c10head:
98692ec178merge: clean; an uncommitted merge onto this base changed only
crates/xcl/src/gpu/dxil/lower_geom.rs(+123/-20);git diff --cached --checkpassedbuild:
cargo build --offline --locked -j 4 --workspace-> ok on the merged treetests:
cargo test --offline --locked -j 4 --workspace --no-fail-fast -- --test-threads=4-> 2,127 passed, 10 failed, 48 ignored across 39 targets; 25 distinct GPU SKIPPED notices. Untouched basee429936con this machine: 2,125 passed, the same 10 failed, 48 ignored. Both newlower_geom::testspassed on the RTX 3080 Ti. Failing names are listed below.review: I read the full diff and the current geometry lowering. No runtime blocker found: emission stops at the per-lane record limit, the straddling lane counts only triangles whose vertices are written, and no-store lanes contribute zero. The change is absent from current
main. Nonblocking test improvement: the GPU test always tries split wave64, even on a possible mesh-capable adapter with wave64 but no wave32; gate each form on its own capability. Neither fixture reaches the per-lane emit ceiling, so a dedicated cap case would strengthen its regression coverage.performance: The default HLSL geometry route does not execute this direct-DXIL path. In explicit direct mode, the added emit guard is per message and the triangle scan runs only for a lane straddling the vertex cap; no frame-time measurement was made.
verdict: safe to merge
hardware / tool and model: Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti / 621.35, rustc 1.99.1 MSVC, DXC 1.8.2502.11. Codex (GPT-6.2 Sol) ran the merge, build and tests and checked the diff; Codex (GPT-6.2 Astra) independently reviewed the low-level geometry and test paths.
Ten failures shared with the exact base
gpu::dxil::module::split::tests::dispatch_chain_oversized_loop_matches_wholegpu::dxil::module::split::tests::dispatch_chain_wave32_live_loopsgpu::dxil::module::split::tests::dispatch_chain_wave64_live_loops_and_exchangegpu::recomp::heap_window_tests::gpu_heap_flat_reads_match_guarded_and_root_outputgpu::recomp::pso::shader_cache_tests::console_mesh_caches_hlsl_compute_pass_in_memory_and_on_diskgpu::recomp::tests::gpu_compute_mode_dispatch_abigpu::recomp::tests::gpu_float_cas_uses_ieee_equalitytest_title_draws_with_a_root_signature_under_the_debug_layertest_title_runs_and_game_folder_is_untouchedtest_title_runs_under_the_debug_layer_with_dredImported from ivall/xcl. Originally posted by throny on 2026-11-28T06:50:11Z.
merge-check claim
head:
98692ec178Imported from ivall/xcl. Originally posted by throny on 2026-11-28T07:06:57Z.
merge-check
base:
e429936chead:
98692ec178merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2128 passed, 9 failed, 48 ignored (26 SKIPPED lines). The 9 failures are main's own at
e429936con this GPU (reported with a bisect on #3041: they arrive with the merge of #2959); the set is identical with and without this PR. Base alone: 2126 passed, 9 failed, 48 ignored.review: no blocking finding. The emit and cut loop stops at the record's vertex cap, which keeps the 10-bit indices in range; the filter for triangles that straddle the cap is sound (the indices only rise); the LDS clamp matches the one in the memory lowering on main. Minor: one CPU test compares a literal that depends on the current exchange layout. Open from the thread, not blocking: no direct-path title with a geometry shader was run, and the test does not reach the per-lane emit cap.
performance: none by default: direct DXIL only (XCL_DIRECT_DXIL=1), and only its users re-translate once.
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:15:01Z.
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:55Z.
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.