recomp: AVX-512 recompile of vic_SpatialSegmentCullAvx2 #135
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ReTerryDavis--ReVIctory!135
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-134"
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?
@SovietBearz0r on GitHub · 2026-12-05 16:34 UTC · original
SovietBearz0r:rdna3-avx512-spatial-cull→main· +7596 −510 · 58 files · 49 commits · draftRecompile the title's spatial segment-cull kernel in Rust with an AVX-512 form: 16 segments tested at a time.
What
The title's
vic_SpatialSegmentCullAvx2(+0x2987e60, 632 bytes) culls scene segments against a spatial grid on the CPU. This adds a Rust replacement with three forms — AVX-512 (16-wide), AVX2 (8-wide) and scalar — chosen by CPU feature detection, wired through the existing surgical-recomp pool next tovic_SpatialRadiusCullAvx2:0x298_7e60and its 24-byte prologue are byte-verified before the detour is installed (a different build is a safe skip, as for every recompiled kernel);crates/victory-recomp/src/spatial.rs, with the equivalence test across edge cases (empty/zero-length segments, degenerate params, grid bounds, NaN/inf inputs, random cases) comparing all three against each other.Verification
cargo test -p victory-recomp: 29 passed in a private target dir, includingspatial_segment_cull_matches_scalar_across_edge_cases; the AVX-512 path actually runs on this machine's Ryzen 9 9900X (otherwise the test says it skipped).Source: ReVictory-RDNA3 commit
cc22fb9("recompile vic_SpatialRadiusCullAvx2 (AVX-512 16-wide)"; the fork registers it asvic_SpatialSegmentCullAvx2), ported onto this tree's spatial recomp module.Final verification (branch tip
df0ef2d, folding in the real-binary disassembly check):+0x2987e60and its caller (capstone): grid layoutcount/xs/ys/zs/r_sqat r9+0/8/16/24/32; args(out_idx, out_dist, out_pos, grid, start, end, seg_start, seg_end);t = clamp(dot(p-A, dir)/|dir|^2, 0, 1);d2 <= r_sqinclusive; ascending 8-wide chunks; the 24 prologue bytes match the fork's constant.cargo test -p victory-recomp(withVICTORY_TEST_GAME_EXE): 29 passed, includingspatial_segment_cull_matches_scalar_across_edge_cases(scalar, AVX2, direct AVX-512 and dispatch) andreal_title_prologues_match_when_game_exe_env_set(new RVA/prologue checked against the real exe).1/|dir|^2where the title usesvrcpps+ 1 NR step, and the folded error term; last-ulp differences (rarely an exact-boundary cull decision); garbage lanes past the returned count are not written (callers must not read past it); no measured perf delta published by the fork.80cea0ab22todf0ef2d9ca@ReTerryDavis on GitHub · 2026-12-05 17:39 UTC · original
Clean AVX-512 kernel and thorough edge-case equivalence tests! Marking as draft for two items before merge:
target_featuresoundness:recomp_spatial_segment_cullchecks onlyis_x86_feature_detected!(avx512f)before enteringspatial_segment_cull_avx512, which callsspatial_segment_cull_avx2(#[target_feature(enable = avx2,fma)]) for odd trailing chunks — please checkavx512f && avx2 && fmaso the Rusttarget_featurecontract is airtight.spatial.rsoverlap + in-game check: We have a large localvictory-recompbatch about to land that also addsCULL_FilterSpatialSegmentAvx2(+0x2987e60, AVX2+FMA) andADVANCE_SPATIAL_ITER_RVAinspatial.rs. Once that hitsmain, rebasing your AVX-512 path on top and verifying in-game (replaced log + no missing geometry) will make it an easy merge!@SovietBearz0r on GitHub · 2026-12-05 18:55 UTC · original
target_featurecontract fixed: dispatch now requiresavx512f && avx2 && fma(pureavx512_spatial_cull_allowedwith a unit test), and inside each AVX-512 kernel the odd trailing-chunk AVX2 call rechecksavx2 && fmabefore entering it, else the scalar tail — applied to the segment kernel and the identical radius-kernel hazard.origin/mainat8bff52bedoes not yet containCULL_FilterSpatialSegmentAvx2/ADVANCE_SPATIAL_ITER_RVA, so the branch is rebased on current main and ready to re-rebase on that batch when it lands. 31 recomp tests pass. Staying draft for the in-game check (replaced log + no missing geometry) after that batch.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.