perf(victory-gpu): reuse capped thread-local scratch buffer in texback::land_tiled #418

Manually merged
github merged 2 commits from github-bot/gh-418 into main 2026-11-26 18:46:55 +00:00 AGit
Owner

@⁠Lewandox on GitHub · 2026-11-26 18:01 UTC · original
Lewandox:perf/texback-reuse-tile-scratch → main · +69 −15 · 2 files · 2 commits · merged 2026-11-26 18:41 UTC

Summary

Reuses a capped thread-local scratch buffer for tiled texture readbacks in third_party/victory/crates/victory-gpu/src/texback.rs:

  1. Eliminate per-frame scratch allocation in land_tiled:
    • Previously land_tiled allocated and zeroed a fresh vec![0u8; back.size] on every non-packed texture readback (e.g. padded linear or swizzled ocean readbacks).
    • Now reuses a thread-local TILED_SCRATCH buffer (TILED_SCRATCH_CAP = 4 MiB), dropping oversized buffers immediately on return so idle threads never retain large allocations.
  2. Test:
    • Adds padded_linear_readback_reuses_capped_cpu_scratch verifying consecutive padded readbacks preserve row padding and reuse the same thread-local scratch allocation.

Verification

  • cargo test -p victory-gpu --lib texback::tests (default and --features diagnostics)
  • cargo xtask policy inside third_party/victory
**@⁠Lewandox** on GitHub · 2026-11-26 18:01 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/418) `Lewandox:perf/texback-reuse-tile-scratch` → `main` · +69 −15 · 2 files · 2 commits · merged 2026-11-26 18:41 UTC ## Summary Reuses a capped thread-local scratch buffer for tiled texture readbacks in `third_party/victory/crates/victory-gpu/src/texback.rs`: 1. **Eliminate per-frame scratch allocation in `land_tiled`**: - Previously `land_tiled` allocated and zeroed a fresh `vec![0u8; back.size]` on every non-packed texture readback (e.g. padded linear or swizzled ocean readbacks). - Now reuses a thread-local `TILED_SCRATCH` buffer (`TILED_SCRATCH_CAP = 4 MiB`), dropping oversized buffers immediately on return so idle threads never retain large allocations. 2. **Test**: - Adds `padded_linear_readback_reuses_capped_cpu_scratch` verifying consecutive padded readbacks preserve row padding and reuse the same thread-local scratch allocation. ## Verification - `cargo test -p victory-gpu --lib texback::tests` (default and `--features diagnostics`) - `cargo xtask policy` inside `third_party/victory`
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 18:03:32 +00:00
github manually merged commit 74dfb48b95 into main 2026-11-26 18:46:55 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.