perf(gpu): batch texture queue mirrors, optimize equality/staging pass, fix HERO LEAD & prelude recheck #18

Manually merged
github merged 1 commit from github-bot/gh-18 into mega-upgrade-v3 2026-12-04 20:20:10 +00:00 AGit
Owner

@⁠MahanYTT on GitHub · 2026-12-04 18:59 UTC · original
MahanYTT:perf/draw-texture-queue-lock → mega-upgrade-v3 · +356 −85 · 2 files · 1 commits · merged 2026-12-04 20:18 UTC

Summary

Targets the bottlenecks and edge-case warnings captured in victory-ma-play-20261204-165800-18832.log:

1. Texture queue lock (queue_site::WRITE / noting a slot's record) & view-making overhead

  • crates/victory-gpu/src/draw.rs:
    • Added a QueueFlusher inside Tells<'a> (flushed strictly before texture_slots_told in Tells::flush) so heap_textures mirrors (mirror, at_once, shows_other) batch up to 64 ops per lock instead of acquiring queue_site::WRITE per slot.
    • Cached already_made (texture_slot_made_from) per slot in heap_textures so slots already made from the current record (including the 155,500+ re-uploads under pressure) skip the duplicate texture_slot_made_from lock, texture_slot_shows_other, and redundant host.mirror calls, reusing (held, held_key).
    • Batched remaining unbatched host.mirror calls in heap_buffer_pass (batch.mirror) and flush_deferred_texture_standins (QueueFlusher).
    • Persisted table_flusher: Option<QueueFlusher<'static>> on State across consecutive draws in the same command list (flushing on reset, clear_state, tables_done, and Drop).

2. Host-copy equality checks, fingerprinting, and staging contention

  • crates/victory-gpu/src/texture.rs:
    • Converted STAGING from Mutex to RwLock so read-heavy paths (is_staged, staged, staged_from, staged_memory, staged_state, and staging cache hits) run concurrently without cross-thread mutex contention.
    • Added unstage_memory to remove and return (at, len) under a single write lock in heap_textures.
    • Added zero-copy in-place fast paths (title_memory_reading_of_now + !through_copy() + soft_runs.is_empty() + all_there) to fingerprint and unchanged_with_fingerprint (avoiding per-check kernel copies and buffer allocations), and computed the recheck fingerprint from the same read pass in heap_textures on a match.

3. HERO LEAD & prelude upload left out edge cases

  • crates/victory-gpu/src/texture.rs:
    • seed_later now marks view in HOST_WRITTEN (mark_host_written) without overwriting source's entry in HOST_WRITTEN_AT, and placed_in_host_written skips the false-positive WARN HERO LEAD when seed_later already scheduled a GPU copy from source at the same address.
    • PreludeUpload::finish_refresh deduplicates host-written upload suppression (suppress_host_written_upload) by setting uploaded = true and clearing dirty = false, preventing repeated refreshes and duplicate warnings across hoisted + own-list checks.
  • crates/victory-gpu/src/draw.rs:
    • heap_textures and flush_deferred_texture_standins now check crate::texture::host_wrote(resource) alongside title_written (and heap_textures defers slot visibility via texture_slot_show_after when seed_pending recorded a GPU seed copy on list).

Verification

  • cargo clippy -p victory-gpu --target x86_64-pc-windows-gnu -- -D warnings: pass (0 warnings)
  • cargo clippy -p victory-gpu --tests --target x86_64-pc-windows-gnu -- -D warnings: pass (0 warnings)
  • cargo clippy -p victory-gpu --features diagnostics --target x86_64-pc-windows-gnu -- -D warnings: pass (0 warnings)
  • Added focused unit tests in draw.rs and texture.rs.
**@⁠MahanYTT** on GitHub · 2026-12-04 18:59 UTC · [original](https://github.com/MahanYTT/VIctory-MA/pull/18) `MahanYTT:perf/draw-texture-queue-lock` → `mega-upgrade-v3` · +356 −85 · 2 files · 1 commits · merged 2026-12-04 20:18 UTC ## Summary Targets the bottlenecks and edge-case warnings captured in `victory-ma-play-20261204-165800-18832.log`: ### 1. Texture queue lock (`queue_site::WRITE` / `noting a slot's record`) & view-making overhead - **`crates/victory-gpu/src/draw.rs`**: - Added a `QueueFlusher` inside `Tells<'a>` (flushed strictly before `texture_slots_told` in `Tells::flush`) so `heap_textures` mirrors (`mirror`, `at_once`, `shows_other`) batch up to 64 ops per lock instead of acquiring `queue_site::WRITE` per slot. - Cached `already_made` (`texture_slot_made_from`) per slot in `heap_textures` so slots already made from the current record (including the 155,500+ re-uploads under pressure) skip the duplicate `texture_slot_made_from` lock, `texture_slot_shows_other`, and redundant `host.mirror` calls, reusing `(held, held_key)`. - Batched remaining unbatched `host.mirror` calls in `heap_buffer_pass` (`batch.mirror`) and `flush_deferred_texture_standins` (`QueueFlusher`). - Persisted `table_flusher: Option<QueueFlusher<'static>>` on `State` across consecutive draws in the same command list (flushing on `reset`, `clear_state`, `tables_done`, and `Drop`). ### 2. Host-copy equality checks, fingerprinting, and staging contention - **`crates/victory-gpu/src/texture.rs`**: - Converted `STAGING` from `Mutex` to `RwLock` so read-heavy paths (`is_staged`, `staged`, `staged_from`, `staged_memory`, `staged_state`, and `staging` cache hits) run concurrently without cross-thread mutex contention. - Added `unstage_memory` to remove and return `(at, len)` under a single write lock in `heap_textures`. - Added zero-copy in-place fast paths (`title_memory_reading_of_now` + `!through_copy()` + `soft_runs.is_empty()` + `all_there`) to `fingerprint` and `unchanged_with_fingerprint` (avoiding per-check kernel copies and buffer allocations), and computed the recheck fingerprint from the same read pass in `heap_textures` on a match. ### 3. `HERO LEAD` & `prelude upload left out` edge cases - **`crates/victory-gpu/src/texture.rs`**: - `seed_later` now marks `view` in `HOST_WRITTEN` (`mark_host_written`) without overwriting `source`'s entry in `HOST_WRITTEN_AT`, and `placed_in_host_written` skips the false-positive `WARN HERO LEAD` when `seed_later` already scheduled a GPU copy from `source` at the same address. - `PreludeUpload::finish_refresh` deduplicates host-written upload suppression (`suppress_host_written_upload`) by setting `uploaded = true` and clearing `dirty = false`, preventing repeated refreshes and duplicate warnings across hoisted + own-list checks. - **`crates/victory-gpu/src/draw.rs`**: - `heap_textures` and `flush_deferred_texture_standins` now check `crate::texture::host_wrote(resource)` alongside `title_written` (and `heap_textures` defers slot visibility via `texture_slot_show_after` when `seed_pending` recorded a GPU seed copy on `list`). ## Verification - `cargo clippy -p victory-gpu --target x86_64-pc-windows-gnu -- -D warnings`: pass (0 warnings) - `cargo clippy -p victory-gpu --tests --target x86_64-pc-windows-gnu -- -D warnings`: pass (0 warnings) - `cargo clippy -p victory-gpu --features diagnostics --target x86_64-pc-windows-gnu -- -D warnings`: pass (0 warnings) - Added focused unit tests in `draw.rs` and `texture.rs`.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-04 19:00:41 +00:00
github manually merged commit 4ba58378c8 into mega-upgrade-v3 2026-12-04 20:20:10 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.