perf(formats): add AVX2/SSE2 256B micro-tile texture detiler and DetilePool #42
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/PastiiJay--klbf-lab!42
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-42"
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?
@Vladimir-Human on GitHub · 2026-11-25 21:01 UTC · original
Vladimir-Human:perf/simd-detile-avx2→beta· +3447 −12 · 3 files · 2 commits · openAI-assisted clean-room contribution (
victory-formats, unit tests + synthetic throughput benchmark only — no title files used).Summary
Adds an AVX2/SSE2 SIMD + portable 256-byte micro-tile texture detiler/tiler and persistent worker pool (
DetilePool) incrates/victory-formats/src/{detile.rs, lib.rs, texture.rs}(victory-gpuuntouched):pipe_bank_xoralignment fromflipsandxordirectly (SW_256B_*,SW_4KB_*,SW_64KB_*,*_T,*_X,SW_64KB_R_X, andSW_64KB_Z_X4B/16B viaR8x32Z4Morton kernel), withcopy_fallbackhandling thick 3D and remaining modes cleanly while preserving existingLayout::{new, for_gpu, detile, tile, bytes_from}APIs.pub Layoutsoundness:prepare_thin_geometry -> Option<ThinGeometry>falls back safely tocopy_fallbackon any inconsistent mutatedpubLayoutfields, with checkedu64/usize/u32offset math,pitch_blocks >= blocks_xmacro-row disjointness, tail bounds, GF(2) injectivity check onlayout.blockflips, and zero-dim /element_bytesPOT<= 16checks.is_x86_feature_detected!("avx2")dispatch with#[target_feature(enable = "avx2")], unaligned loads/stores, separateConstSendPtr/MutSendPtr, worker/caller panic propagation and mutex poison recovery (DetilePool), and zero overlap with existingklbf-labcrates (git merge-treeclean againstbetaand sibling shader work).Verification (
betae328c88)cargo clippy -p victory-formats --all-targets -- -D warnings: 0 warnings.cargo test -p victory-formats --all-targets: 37 passed, 0 failed (7 ignored), including exhaustive scalar vs AVX2 vs portable parity across all 15 addressable swizzle modes (Series X & S, non-zeropipe_bank_xor, BPE 1..16, NPOT dims, odd pitches, mip tails, 1D/arrays/3D), 4-threadtry_lockfallback,DetilePoolpanic recovery, and release-modemutated_public_layout_fields_never_enter_unsound_fast_path.detile_speedup_benchmark(during parallel build load; uncontested benchmark follow-up planned): 2.21x–8.35x vs baseline (19.4x–90.7x vs scalar), e.g., 4K BC7SW_64KB_D25.8 GB/s(3.07x), 4K BC1SW_64KB_D45.4 GB/s(4.56x), 4K RGBA8SW_64KB_Z_X17.0 GB/s(8.35x).@PastiiJay on GitHub · 2026-11-25 21:07 UTC · original
Thanks a lot @Vladimir-Human! We test one change at a time on the RX 9070 XT (same save, same 7-minute run, fps and picture compared with our reference build), so this one goes into that queue on its own. Results will be posted here, then we merge or report back what we saw.
@HandshakeHackin on GitHub · 2026-11-25 21:17 UTC · original
I checked
853852eon Linux x86-64 (AMD EPYC 9V74, 9 logical CPUs available). The formats suite passed all 37 active tests, including the scalar-reference, odd-pitch, partial-mip and concurrent-caller comparisons. Seven tests were ignored. The combined Windows suite with #41, #43 and the queued beta fixes also passed (608 passed, 16 ignored). Windows CIOne size is worth a look before tuning the worker pool. I ran the PR’s release
detile_speedup_benchmarkfive times per build, alternating the order. The experimental build changed onlyPARALLEL_MIN_BYTESfrom 512 KiB to 2 MiB. Median milliseconds per BC7SW_64KB_Dtexture on this machine:The 1 MiB case benefited from staying on the calling thread here. The 4K case retained the same speedup with either threshold. Each benchmark checked the output against the old walker before timing. These are CPU texture-conversion timings.
@PastiiJay on GitHub · 2026-11-25 21:18 UTC · original
Thanks @HandshakeHackin, that's a very useful check. What we keep: all 37 formats tests pass, the combined Windows suite with #41 and #43 is green (608 passed), the output matches the old walker byte for byte, and the 4K speedup (~6x on BC7
SW_64KB_D) holds with either threshold, while 1 MiB textures do better staying on the calling thread with a 2 MiBPARALLEL_MIN_BYTES.When this PR's turn comes in our RX 9070 XT queue, we'll run it as-is first, then with the 2 MiB threshold as a separate run, and post both results here. @Vladimir-Human, feel free to weigh in on the threshold if you had a reason for 512 KiB.
@Vladimir-Human on GitHub · 2026-11-26 00:05 UTC · original
@PastiiJay @HandshakeHackin Thanks for running those cross-CPU EPYC 9V74 numbers! 512 KiB was an initial conservative threshold before seeing virtualized/multi-CCX pool-wake latency across CPUs.
I tested raising PARALLEL_MIN_BYTES from 512 KiB to 2 MiB on idle i5-13400F (--release detile_speedup_benchmark):
@PastiiJay on GitHub · 2026-11-26 00:05 UTC · original
Thanks for checking it on your side too @Vladimir-Human. We'll keep the plan: one run with the PR as-is and one with the 2 MiB threshold, and post both here.
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.