Recompiler: filter OOB triangles, gate no-store emits, and clamp LDS in HLSL geometry shaders #2517
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!2517
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2517"
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 21:21 UTC · original
Decodere:fix-hlsl-geom-epilogue-oob→main· +114 −45 · 1 files · 1 commits · openPart of #1401
Part of #1833
What is in it
Deduplicates the native-wave64 and split-wave64 HLSL
Mode::Geometryepilogues incrates/xcl/src/gpu/recomp/emit.rsinto a singleemit_gs_epiloguehelper and fixes four record-packing bugs:MSG_GSemits atmax_vertices(<= 256): guards theop & 2 != 0emit path inEm::soppwithif (k < {maxv}u)so runaway emits cannot overflow the 10-bit packed vertex index fields inxcl_trior inflate wave prefix sums past the record vertex budget.xcl_emittedandxcl_ntriwhenxcl_gs_base == 0xFFFFFFFFubeforeWavePrefixSum/WaveActiveSum, preventing lanes that never wrote LDS from reserving uninitialized vertex slots and emitting phantom triangles that point to them.xcl_vw = (xcl_vb < maxv) ? min(xcl_emitted, maxv - xcl_vb) : 0ubefore summing triangles and trimsxcl_ntrito the exact prefix whose top vertex index (xcl_tri[xcl_vn] >> 20) is< xcl_vw. Becausexcl_trientries are recorded in strictly increasingkorder withkin bits20..29, every kept triangle has all three vertices< maxv.XCL_X_LDS_TOP: mirrorsEm::ds(min(((src + off) >> 2) & 8191u, XCL_X_LDS_TOP)) whenx64 == trueso vertex reads cannot alias the wave64 exchange region at the top of the 32 KBgroupshared uint xcl_lds[8192]array.Tested
origin/main(6d12f58a229bc73889878a448c64dc3af25eeba0) with the two new tests added togpu::recomp::emit::tests:hlsl_geometry_epilogue_filter_and_split_lds_clamppanicked atemit.rs:6855:missing k < maxv guard (split=false).gpu_hlsl_geometry_epilogue_oob_and_no_storepanicked on RTX 4060 atemit.rs:6882:15x20 overflowemitted(256, 256, ...)instead of(256, 230, ...)(26 triangles referencing out-of-bounds vertices>= 256).1.9.2609.5,0compiler warnings inemit.rs):cargo test --release -p xcl --lib gpu::recomp::emit::tests -- --test-threads=1 --nocapture:6 passed; 0 failed; 0 ignored(0skipped; bothhlsl_geometry_epilogue_filter_and_split_lds_clampandgpu_hlsl_geometry_epilogue_oob_and_no_storepassed, verifying the15x20overflow trims to(256, 230)with final straddled triangle254 | (253 << 10) | (255 << 20)and all 230 triangles< 256, and lane-0 no-store gating packs lane 1 at(3, 1)with vertices0x1111_0000..0x1111_0002).cargo test --release -p xcl --lib gpu::dxil::geometry_tests -- --test-threads=1 --nocapture:4 passed; 0 failed; 0 ignored(0skipped).XCL_ADAPTER=warp):cargo test --release -p xcl --lib gpu::recomp::emit::tests -- --test-threads=1 --nocapture:6 passed; 0 failed; 0 ignored(hlsl_geometry_epilogue_filter_and_split_lds_clamppassed with0skips including DXCcs_6_6compilation of bothsplit=falseandsplit=true;gpu_hlsl_geometry_epilogue_oob_and_no_storecleanly reportedSKIPPED: no GPU / DXC / mesh shaders).cargo test --release --workspace --no-fail-fast -- --test-threads=4 --nocapture):37test binaries:1425 passed; 0 failed; 46 ignored.29pre-existing runtimeSKIPPEDmessages (21no wave64on wave32-only RTX 4060,3per-lane form: refused,3no D3D12 debug layer/no d3d12SDKLayers.dll,1cannot disable the driver cache,1no heap windows).Regression run
Before (
origin/main6d12f58a229bc73889878a448c64dc3af25eeba0):After (
fix-hlsl-geom-epilogue-oob1017d247ff8677f5505d33aecbae9efb167719a2):Both 60 s runs reach steady
60 60 60presents per 2 s with0device removals,0crashes,1490vs1523frames shown (97.8%), and13978 MBvs13983 MBpeak commit.Not tested
split=falseHLSL geometry epilogue (RTX 4060 only supports wave32;split=falsewas verified via HLSL codegen checks and DXCcs_6_6compilation, while GPU execution exercisedsplit=true).d3d12SDKLayers.dllis not installed on this machine).AI use
Written and verified with Google Antigravity (Gemini 4 Neon). All code changes, failing-first reproductions, targeted RTX 4060 and WARP test runs, the full release workspace suite, and both paired 60 s GPU smoke runs were executed and checked locally.
@DavidM1911 on GitHub · 2026-11-25 21:32 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!
@DarkPanda69 on GitHub · 2026-11-25 21:36 UTC · original
AMD run (RX 9070 XT, RDNA4) plus an RTX 3060: the new GPU test passes on both cards.
Head
1017d24applied onmain6d12f58, debug, Windows 11 Pro 26200,cargo test -p xcl --lib -- gpu:: --test-threads=4, card chosen withXCL_ADAPTER:gpu_hlsl_geometry_epilogue_oob_and_no_storeok. 700 passed, 2 failed, 6 SKIPPED (the same asmain); the 2 failures are the AMD fuzz seeds tracked in #2115, the same onmain.main).One note on the "native wave64" gap: the test builds its program with
translate_geometry(code, g.clone(), true, 1), which meanssplit_wave64 = true. So on the RX 9070 XT it runs the split epilogue too, and the native (split=false) path still has no GPU run. A variant that passesrunner::split_wave64()there (assupported_modes()does in #2488) would run native wave64 on this card.Not tested: retail geometry shaders, Intel.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
@SlopTart on GitHub · 2026-11-25 22:33 UTC · original
Tested: current PR head merged onto current
origin/main(clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo targetx86_64-pc-windows-gnurun under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).gpu_suite (cold cache): 165 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR.gpu_hlsl_geometry_epilogue_oob_and_no_storeran inside the suite and is clean. Targeted run ofhlsl_geometry_epilogue_filter_and_split_lds_clamp: passed.Not tested: retail titles (no title data on this lane, counts only).
AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.
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.