Repository navigation
Conversation
…in HLSL geometry shaders Deduplicate the native-wave64 and split-wave64 HLSL Mode::Geometry epilogues into emit_gs_epilogue and fix four record-packing bugs: 1. Cap per-lane MSG_GS emits at the record vertex budget (k < maxv, <= 256) so runaway emits cannot overflow the 10-bit packed index fields in xcl_tri. 2. Zero xcl_emitted and xcl_ntri before wave prefix/active sums for lanes that emitted without ever storing to LDS (xcl_gs_base == 0xFFFFFFFFu), preventing uninitialized vertex holes and phantom triangles referencing them. 3. Compute each lane's in-bounds vertex count xcl_vw before summing triangles and trim xcl_ntri to the exact prefix whose top vertex index (t >> 20) fits within xcl_vw, preventing out-of-bounds vertex indices when a lane straddles or exceeds max_vertices. 4. Clamp split-wave64 epilogue LDS reads to XCL_X_LDS_TOP, matching ds() so geometry vertex reads cannot alias the wave64 exchange region at the top of the 32 KB groupshared array. Part of xcl-dev#1401 Part of xcl-dev#1833 Assisted-by: Google Antigravity (Gemini 4 Neon)
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
AMD run (RX 9070 XT, RDNA4) plus an RTX 3060: the new GPU test passes on both cards. Head
One note on the "native wave64" gap: the test builds its program with Not tested: retail geometry shaders, Intel. |
|
Tested: current PR head merged onto current
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. |
Part 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.