fix stale decodes and streamer holes, speed up world textures and export #43

Manually merged
github merged 1 commit from gh-pr/43/head into gh-pr/43/base 2026-11-27 02:32:32 +00:00
Owner

@⁠asm512 on GitHub · 2026-11-22 16:46 UTC · original
asm512:review-fixes → main · +483 −220 · 3 files · 1 commits · merged 2026-11-22 17:15 UTC

Fixes for a few things I hit while reviewing the code against the latest files.

Bugs

  • Selection decodes (model, navmesh, TXD/TTPF, AWC) could finish out of order and replace what was just selected. Results from a superseded decode are now dropped, and a decoder panic no longer leaves the spinner up.
  • World streamer marked a model as loaded when it was queued. Moving the camera mid-batch left permanent holes; skipped models are now queued again.

Performance

  • World streamer reads a small stored mip instead of decoding mip 0 and shrinking it to 128px. Materials sharing a texture share one upload.
  • Placements are grouped into 1024 m cells so each cell is culled on its own (before, a model placed across the map was always drawn in full). Draw cap raised from 1400 to 6000 to match, and draw distance/shadow casting now use the size of one copy rather than the batch bounds.
  • TTPF texture cache is bounded by bytes (1 GiB) rather than 512 entries; inflated chunks are reused per thread.
  • Export All / Export Selected run in the background with progress and a Cancel button.
  • Scan cache is saved every 45s during a scan instead of every 5s.

Testing

  • cargo test --release: 98 pass
  • New test compares the capped decode with full decodes on real vehicle textures (needs PERCYSTAR_LEVELS_RPF), and one covers the stale-decode guard.
**@⁠asm512** on GitHub · 2026-11-22 16:46 UTC · [original](https://github.com/rpatty-dev/PercyStar/pull/43) `asm512:review-fixes` → `main` · +483 −220 · 3 files · 1 commits · merged 2026-11-22 17:15 UTC Fixes for a few things I hit while reviewing the code against the latest files. **Bugs** - Selection decodes (model, navmesh, TXD/TTPF, AWC) could finish out of order and replace what was just selected. Results from a superseded decode are now dropped, and a decoder panic no longer leaves the spinner up. - World streamer marked a model as loaded when it was queued. Moving the camera mid-batch left permanent holes; skipped models are now queued again. **Performance** - World streamer reads a small stored mip instead of decoding mip 0 and shrinking it to 128px. Materials sharing a texture share one upload. - Placements are grouped into 1024 m cells so each cell is culled on its own (before, a model placed across the map was always drawn in full). Draw cap raised from 1400 to 6000 to match, and draw distance/shadow casting now use the size of one copy rather than the batch bounds. - TTPF texture cache is bounded by bytes (1 GiB) rather than 512 entries; inflated chunks are reused per thread. - Export All / Export Selected run in the background with progress and a Cancel button. - Scan cache is saved every 45s during a scan instead of every 5s. **Testing** - `cargo test --release`: 98 pass - New test compares the capped decode with full decodes on real vehicle textures (needs `PERCYSTAR_LEVELS_RPF`), and one covers the stale-decode guard.
- drop results of superseded selection decodes; a decoder panic no longer leaves the spinner up
- world streamer: retry models skipped when the camera moves mid-batch
- world streamer: read a small stored mip instead of full textures, share uploads, cull placements per map cell
- texture cache bounded by bytes; reuse inflated ttpf chunks
- Export All/Selected run in the background with progress and cancel
- scan cache saved every 45s instead of 5s during scans
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 02:32:30 +00:00
github manually merged commit 6e13b73299 into gh-pr/43/base 2026-11-27 02:32:32 +00:00
Author
Owner

@⁠rpatty-dev on GitHub · 2026-11-22 17:15 UTC · original

Merged and verified (cargo test --release: 98 passed; 0 failed)! 🙌

Also layered a few extra optimizations on top of your PR:

  • src/world_gpu.rs: Removed the per-archetype Mutex lock and 1 ms sleep inside the streaming loop, moved set_thread_texture_cap(128) once per worker thread, and scaled worker count cleanly ((cores / 2).clamp(3, 6)).
  • src/tex.rs: Reused the open File handle across ttpf_read_virtual calls via thread-local LAST_TTPF_FILE and shared Rc<PathBuf> keys in CHUNK_CACHE to avoid per-chunk file opens and path allocations.

Thanks again for the stale-decode, streamer-hole, cell-batching, and mip-cap fixes!

**@⁠rpatty-dev** on GitHub · 2026-11-22 17:15 UTC · [original](https://github.com/rpatty-dev/PercyStar/pull/43#issuecomment-7082697812) Merged and verified (`cargo test --release`: **98 passed; 0 failed**)! 🙌 Also layered a few extra optimizations on top of your PR: - **`src/world_gpu.rs`**: Removed the per-archetype `Mutex` lock and 1 ms sleep inside the streaming loop, moved `set_thread_texture_cap(128)` once per worker thread, and scaled worker count cleanly (`(cores / 2).clamp(3, 6)`). - **`src/tex.rs`**: Reused the open `File` handle across `ttpf_read_virtual` calls via thread-local `LAST_TTPF_FILE` and shared `Rc<PathBuf>` keys in `CHUNK_CACHE` to avoid per-chunk file opens and path allocations. Thanks again for the stale-decode, streamer-hole, cell-batching, and mip-cap fixes!
This discussion has been locked. Commenting is limited to contributors.
No description provided.