Skip to content

perf(gpu): batch descriptor copies/releases, bitset dynamic slots, and AVX2 shadow merge - #18

Merged
HumanlyDev merged 1 commit into
mainfrom
perf/rtx4060-frame-time-optimizations
Nov 26, 2026
Merged

HumanlyDev merged 1 commit into
mainfrom
perf/rtx4060-frame-time-optimizations

Conversation

@HumanlyDev

Copy link
Copy Markdown
Owner

Summary

Code-level frame-time optimizations targeting RTX 4060 CPU/driver overhead (5 -> 10 FPS) with zero changes to graphics, rendering quality, shaders, or settings.

Optimizations

  1. Batched
    etire_resources (crates/victory-gpu/src/host.rs)
    :
    • Added host::retire_resources(Vec) to retire batches of COM resources under a single RETIRED mutex acquisition instead of locking per resource.
  2. L1-resident [u64] bitset for HostHeap::dynamic & batched release (crates/victory-gpu/src/descriptor/host.rs):
    • Replaced Mutex<(u32, Vec)> with DynamicSlots (Vec bitset — 16 KiB for 131,072 slots vs 128 KiB), scanning and clearing 64 slots at a time via railing_zeros / railing_ones / count_ones.
    • HostHeap::release() now collects displaced ID3D12Resources via keep_into() and retires them in one
      etire_resources() call.
  3. Batched ID3D12Device::CopyDescriptors & single-borrow LIST_VIEWS (crates/victory-gpu/src/descriptor/host.rs, crates/victory-gpu/src/draw.rs):
    • Added HostHeap::make_listed_batch() to process an entire descriptor table in one LIST_VIEWS borrow, one CopyDescriptors call per heap type (primary + twin), and one
      etire_resources() call, replacing
      –2n per-slot CopyDescriptorsSimple(1, ...) driver calls and
      LIST_VIEWS borrows.
  4. AVX2 SIMD changed_runs and merge_piece (crates/victory-gpu/src/shadow.rs):
    • Added runtime-dispatched AVX2 paths (changed_runs_avx2, merge_piece_avx2) processing 32 bytes per iteration with _mm256_cmpeq_epi8 / _mm256_movemask_epi8 / _mm256_blendv_epi8, skipping unchanged 32-byte blocks without touching itle or held.
  5. Per-draw / per-wakeup overhead & landing thread scaling (crates/victory-gpu/src/pipeline/host.rs, draw.rs, host.rs, land.rs):
    • Precomputed HostPipeline::is_bake_shader at pipeline creation instead of scanning stage shader hashes on every draw.
    • Switched State::root_srv_slots and State::root_uav_slots to AddressHash.
    • Replaced per-draw Vec::with_capacity(2) in State::bind() with a stack [Option; 2] array and reused selected_scratch, listed_words, and listed_out buffers in State::tables().
    • Hoisted ences Vec outside
      elay_worker()'s loop.
    • Scaled default land::threads() from (n / 4).clamp(1, 4) to (n / 2).clamp(2, 8).

Verification

  • cargo clippy --workspace --all-targets --locked -- -D warnings: PASS (0 warnings)
  • cargo clippy -p victory-hle --features gpu-bcpack --all-targets --locked -- -D warnings: PASS (0 warnings)
  • cargo test --workspace --locked: PASS (including new DynamicSlots bitset and AVX2 changed_runs/merge_piece unit tests)
  • cargo test --release -p victory-hle --features gpu-bcpack --locked gpu_bcpack: 2 passed; 0 failed
  • cargo build --release --locked -p victory --features gpu-bcpack: PASS
  • cargo run -p xtask -- policy: asset policy: 259 files ok

@HumanlyDev
HumanlyDev merged commit 60fe765 into main Nov 26, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant