[PR #1] Perf Phases 2-6: GPU/CPU pipeline & memory sync optimizations #2

Open
opened 2026-11-26 20:06:21 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/4ld0-vito/victory-gta6/pull/1
Author: @4ld0-vito
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: work


📝 Commits (5)

  • 98cb97a perf: parallelize CARD_COMPARE, incremental heap_buffers, small card buffers, release VICTORY_KEYS
  • 1c4f8e5 Phase 3 perf: VEH safe_copy, O(dirty) card_dirty, fused card_before submit, indirect window 512, batched defer_refreshes
  • c3100eb Phase 4 perf: async COPY queue relay fetch, BlockRuns interval guards, RwLock journal, Deferred buffer reuse
  • c6cda00 Phase 5 perf: O(K) BlockRuns::missing_ranges, parallel word-wise relay merge, zero-syscall write_mapped, incremental heap_buffers
  • bcc0465 Phase 6 perf: GPU cbv_copy & direct CBVs, kernel fallback in read_pieces/write_mapped, coalesced REMAPPED

📊 Changes

7 files changed (+1455 additions, -256 deletions)

View changed files

📝 crates/victory-gpu/src/descriptor/host.rs (+16 -4)
📝 crates/victory-gpu/src/draw.rs (+160 -33)
📝 crates/victory-gpu/src/host.rs (+658 -75)
📝 crates/victory-gpu/src/indirect.rs (+7 -10)
📝 crates/victory-gpu/src/shadow.rs (+153 -33)
📝 crates/victory-gpu/src/watch.rs (+461 -96)
📝 crates/victory-hle/src/modules/gameinput.rs (+0 -5)

📄 Description

Summary

This PR aggregates Performance Optimization Phases 2-6 on top of upstream/fork base (578d459):

  • Phase 2 (98cb97a): Enabled VICTORY_KEYS in release builds; parallelized the CARD_COMPARE compute shader; added VICTORY_CARD_BUFFERS_MIN_KB threshold tuning; added incremental HeapCache & VICTORY_HEAP_TEX_MS budgeting for heap_buffers/heap_textures.
  • Phase 3 (1c4f8e5): Added VEH-recovered safe_copy (global_asm!) replacing kernel ReadProcessMemory in hot read paths; O(dirty) DIRTY_CARDS tracking; hoisted root/PSO bindings & fused card_before sync submission; removed redundant NULL UAV barrier in indirect.rs; raised indirect window limit (64 -> 512); batched State::heap_buffers refreshes via HostList::defer_refreshes.
  • Phase 4 (c3100eb): Added dedicated D3D12 COPY queue (VICTORY_COPY_QUEUE, default on) for async relay_card_back fetches; replaced Guards BTreeSets with interval-merging BlockRuns; converted JOURNAL to RwLock; added 3-state Shadow::watched + writes_ex guard fast-path; reused heap allocations in HostList::reset (Deferred::clear()).
  • Phase 5 (c6cda00): Added BlockRuns::missing_ranges() for O(K) guarding; 8-byte word-wise merge_piece + parallel wide_run relay merge in relay_card_back; coalesced disjoint <=256 KiB spans; safe_copy fast-path in write_mapped; incremental HeapCache::by_copy + smaller background sweep.
  • Phase 6 (bcc0465): Split read_kernel (ReadProcessMemory) for unmapped-page fallbacks in read_pieces/write_mapped (eliminating VEH fault storms); added Host::default_buffer + HostList::cbv_copy (VICTORY_GPU_CBV_COPY, default on) & direct 256B-aligned CBVs in root_view/View::Constant (eliminating all fill of upload memory stalls); coalesced REMAPPED intervals in descriptor::host.

Verification & Benchmarks (Xbox Series X profile, RTX 4070 12 GB, 32 GB RAM)

  • cargo test -p victory-gpu: 114 passed, 0 failed, 1 ignored (warp_copy_queue_reads_after_direct_fence, warp_cbv_copy_aligns_unaligned_offset, block_runs_tests, safe_copy_tests, merge_piece_matches_bytewise_behavior).
  • World FPS progression (0 errors, peak RAM ~20.4-22.2 GB):
    • Baseline (Phase 0): 1.0-3.5 fps (700-1400 ms/frame)
    • Phase 2 (speed4_opt_release, 210s): 4.13 avg / 4.3 med / 9.7 max fps
    • Phase 3 (speed7_p3_diag, MIN_KB=64 + WIDE_REFRESH=1): up to 14.8 fps peak (67.4 ms)
    • Phase 4 (speed8_p4_release): 6.7-7.5 fps (3.2k-3.9k draws), 15.2 fps peak (65.6 ms at 544 draws)
    • Phase 5 (speed10_p5_release, LATE_WAIT_LISTS=512): 15.9 fps peak (63.1 ms), 512 lists in the air stalls = 0.0 ms
    • Phase 6 (speed12_p6_seriesx, 210s, 4K default): 8.5 fps (118.1 ms) at 3,040 draws/frame, 13.0 fps peak (77.2 ms) at 537 draws/frame, fill of upload memory settles = 0.0 ms (down from 25-31 ms), GPU busy 66-75%
    • speed14_p6_1080p (VICTORY_DISPLAY_MODE=1920x1080, HEAP_TEX_MS=2, 180s): 0 errors, peak 21.4 GB RAM, 4.8-13.3 fps (106-207 ms/frame at 1.3k-5.2k draws, CPU preparing 84-122 ms + relay 53-75 ms)
    • speed15_p6_1080p_inplace (+ VICTORY_INPLACE=1, 180s): 0 errors, peak 21.3 GB RAM, 76 windows (348 MB) placed in-place, process CPU dropped 1163s -> 873s, 5.2-12.9 fps (GPU settles slightly higher reading L0 in-place memory)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/4ld0-vito/victory-gta6/pull/1 **Author:** [@4ld0-vito](https://github.com/4ld0-vito) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `work` --- ### 📝 Commits (5) - [`98cb97a`](https://github.com/4ld0-vito/victory-gta6/commit/98cb97a1129a5944799e7f0b17b652624d83c322) perf: parallelize CARD_COMPARE, incremental heap_buffers, small card buffers, release VICTORY_KEYS - [`1c4f8e5`](https://github.com/4ld0-vito/victory-gta6/commit/1c4f8e5d4937097de25d82bc2c8a9df18bb767cf) Phase 3 perf: VEH safe_copy, O(dirty) card_dirty, fused card_before submit, indirect window 512, batched defer_refreshes - [`c3100eb`](https://github.com/4ld0-vito/victory-gta6/commit/c3100eb1de1ba21dae18df4c66266e70489727d2) Phase 4 perf: async COPY queue relay fetch, BlockRuns interval guards, RwLock journal, Deferred buffer reuse - [`c6cda00`](https://github.com/4ld0-vito/victory-gta6/commit/c6cda0005ec8bf39dca925fe12a07760393daaba) Phase 5 perf: O(K) BlockRuns::missing_ranges, parallel word-wise relay merge, zero-syscall write_mapped, incremental heap_buffers - [`bcc0465`](https://github.com/4ld0-vito/victory-gta6/commit/bcc0465a994560d06b5cc7916c5149e9b4057339) Phase 6 perf: GPU cbv_copy & direct CBVs, kernel fallback in read_pieces/write_mapped, coalesced REMAPPED ### 📊 Changes **7 files changed** (+1455 additions, -256 deletions) <details> <summary>View changed files</summary> 📝 `crates/victory-gpu/src/descriptor/host.rs` (+16 -4) 📝 `crates/victory-gpu/src/draw.rs` (+160 -33) 📝 `crates/victory-gpu/src/host.rs` (+658 -75) 📝 `crates/victory-gpu/src/indirect.rs` (+7 -10) 📝 `crates/victory-gpu/src/shadow.rs` (+153 -33) 📝 `crates/victory-gpu/src/watch.rs` (+461 -96) 📝 `crates/victory-hle/src/modules/gameinput.rs` (+0 -5) </details> ### 📄 Description ## Summary This PR aggregates Performance Optimization Phases 2-6 on top of upstream/fork base (`578d459`): - **Phase 2 (`98cb97a`)**: Enabled `VICTORY_KEYS` in release builds; parallelized the `CARD_COMPARE` compute shader; added `VICTORY_CARD_BUFFERS_MIN_KB` threshold tuning; added incremental `HeapCache` & `VICTORY_HEAP_TEX_MS` budgeting for `heap_buffers`/`heap_textures`. - **Phase 3 (`1c4f8e5`)**: Added VEH-recovered `safe_copy` (`global_asm!`) replacing kernel `ReadProcessMemory` in hot read paths; O(dirty) `DIRTY_CARDS` tracking; hoisted root/PSO bindings & fused `card_before` sync submission; removed redundant NULL UAV barrier in `indirect.rs`; raised indirect window limit (`64 -> 512`); batched `State::heap_buffers` refreshes via `HostList::defer_refreshes`. - **Phase 4 (`c3100eb`)**: Added dedicated D3D12 `COPY` queue (`VICTORY_COPY_QUEUE`, default on) for async `relay_card_back` fetches; replaced `Guards` `BTreeSet`s with interval-merging `BlockRuns`; converted `JOURNAL` to `RwLock`; added 3-state `Shadow::watched` + `writes_ex` guard fast-path; reused heap allocations in `HostList::reset` (`Deferred::clear()`). - **Phase 5 (`c6cda00`)**: Added `BlockRuns::missing_ranges()` for O(K) guarding; 8-byte word-wise `merge_piece` + parallel `wide_run` relay merge in `relay_card_back`; coalesced disjoint <=256 KiB spans; `safe_copy` fast-path in `write_mapped`; incremental `HeapCache::by_copy` + smaller background sweep. - **Phase 6 (`bcc0465`)**: Split `read_kernel` (`ReadProcessMemory`) for unmapped-page fallbacks in `read_pieces`/`write_mapped` (eliminating VEH fault storms); added `Host::default_buffer` + `HostList::cbv_copy` (`VICTORY_GPU_CBV_COPY`, default on) & direct 256B-aligned CBVs in `root_view`/`View::Constant` (eliminating all `fill of upload memory` stalls); coalesced `REMAPPED` intervals in `descriptor::host`. ## Verification & Benchmarks (Xbox Series X profile, RTX 4070 12 GB, 32 GB RAM) - `cargo test -p victory-gpu`: **114 passed, 0 failed, 1 ignored** (`warp_copy_queue_reads_after_direct_fence`, `warp_cbv_copy_aligns_unaligned_offset`, `block_runs_tests`, `safe_copy_tests`, `merge_piece_matches_bytewise_behavior`). - **World FPS progression (0 errors, peak RAM ~20.4-22.2 GB):** - Baseline (Phase 0): 1.0-3.5 fps (700-1400 ms/frame) - Phase 2 (`speed4_opt_release`, 210s): 4.13 avg / 4.3 med / 9.7 max fps - Phase 3 (`speed7_p3_diag`, `MIN_KB=64` + `WIDE_REFRESH=1`): up to 14.8 fps peak (67.4 ms) - Phase 4 (`speed8_p4_release`): 6.7-7.5 fps (3.2k-3.9k draws), 15.2 fps peak (65.6 ms at 544 draws) - Phase 5 (`speed10_p5_release`, `LATE_WAIT_LISTS=512`): 15.9 fps peak (63.1 ms), `512 lists in the air` stalls = 0.0 ms - Phase 6 (`speed12_p6_seriesx`, 210s, 4K default): **8.5 fps** (118.1 ms) at 3,040 draws/frame, **13.0 fps peak** (77.2 ms) at 537 draws/frame, `fill of upload memory` settles = **0.0 ms** (down from 25-31 ms), GPU busy **66-75%** - `speed14_p6_1080p` (`VICTORY_DISPLAY_MODE=1920x1080`, `HEAP_TEX_MS=2`, 180s): 0 errors, peak 21.4 GB RAM, 4.8-13.3 fps (106-207 ms/frame at 1.3k-5.2k draws, CPU `preparing` 84-122 ms + relay 53-75 ms) - `speed15_p6_1080p_inplace` (+ `VICTORY_INPLACE=1`, 180s): 0 errors, peak 21.3 GB RAM, 76 windows (348 MB) placed in-place, process CPU dropped 1163s -> 873s, 5.2-12.9 fps (GPU settles slightly higher reading L0 in-place memory) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
4ld0/victory-gta6#2
No description provided.