[Report + Patches] RTX 3080 (10 GB) / 7800X3D / 32 GB RAM: 3–5 fps → 20–30 fps (95–99% GPU Busy), 3 Code Fixes, NVIDIA Wave32 Refusals & Visual/Lip-Sync Findings #346

Open
opened 2026-11-27 00:58:01 +00:00 by github-bot · 6 comments
Owner

@⁠ToolxMaster on GitHub · 2026-11-26 21:22 UTC · original

Test Environment

  • OS: Windows 11 Pro 64-bit (Build 26200)
  • CPU: AMD Ryzen 7 7800X3D (8C / 16T, AVX2)
  • RAM: 32 GB
  • GPU: NVIDIA GeForce RTX 3080 (10,051 MB dedicated VRAM, vram_budget_mb = 9283, Driver 32.0.16.2124)
  • Output: 1920x1080, Series X profile, LTO release build (after initial diag baselines)
  • Goal: Profile and optimize for mid-range NVIDIA / 10 GB VRAM / 32 GB RAM without regressing AMD / 64 GB defaults.

Performance Progression (10 Iterative Runs)

Run Key Changes Sustained FPS GPU Busy VICTORY_THIN (all threads) ASYNC_SUBMIT Residency Waits Visual / Stability Notes
#1 (diag) Stock fork + ADAPTER=NVIDIA + all 5 PORT_* 3–5 fps (peaks 9) 44% 1,810 ms 77.7 ms (43 ms flight wait) 212,000 (60.8 s) Cleanest stock look, heavy pagefile swap (27.3 GB private), 16.8 ms (283 MB/frame) CPU snapshots
#2 (diag) WAIT_RESIDENT=0, RESIDENCY=1, KEEP_FREED=0, CARD_BUFFERS=1MB/2048MB, dropped PORT_CBV 3–5 fps ~55% 2,377 ms 26.5 ms (0.0 ms flight wait) 0 Snapshots dropped 16.8 → 1.6 ms, RAM 27.3 → 24.2 GB; bottlenecked by 716 CreateCommittedResource/frame in shadow::exact()
#3 (diag) Added shadow::exact() recycled buffer pool ~10 fps 90–98% 326 ms ~32 ms 0 95.2% pool hit rate; artifacts from recycling buffers without multi-frame GPU quarantine
#4 (diag) 4-frame GPU quarantine + trailing-byte zeroing in shadow::exact(); CARD_BUFFERS_MIN_KB=64 / 2560 MB 15–18 fps 95%+ 286 ms ~34 ms 0 0.0 ms CPU snapshots; frequent 2–5 fps hitches from default PIPELINE_WAIT_MS=500 + 10 workers on 8 cores
#5 (release) LTO release + PIPELINE_WAIT_MS=15, PIPELINE_WORKERS=4 25–27 fps 95–99% 135–162 ms 31–35.7 ms 0 Only 1 >60 ms idle spike in 3 min; visible 16×16 non-RT probe halos around hair/clothing + brown indoor fog
#6 (release) Added VICTORY_AMBIENT_MOST=0, AMBIENT_AIR=1.5, BAKE_TEXTURES_MS=4000 ~24 fps 95%+ ~145 ms ~33 ms 0 16×16 hair halos & brown indoor haze gone; backlit faces too dark; 20.5 s texture memory wait
#7 (release) Lifted dark-face floor in ambient.rs; TEXTURE_LOOK_MS=300, PIPELINE_WAIT_MS=40, WORKERS=6 ~20 fps ~90% ~165 ms ~38 ms 0 Face lighting much better, texture lag -36%; rainbow confetti on counselor/waitress faces (PS_BakeDecorations vs WAIT_RESIDENT=0)
#8 (release, RT) Added VICTORY_WAIT_RESIDENT=textures; -RayTracing (MEMORY_CARD_MB=2048, CARD_BUFFERS_MB=1536) 8–11 fps 99% ~155 ms ~36 ms 800 (158 ms) Zero crashes on 10 GB VRAM (1,532 MB BVH); waitress face 100% clean; black prop/head artifacts + cutscene jumpsuit glitch
#9 (release) RT OFF + WAIT_RESIDENT=textures + PIPELINE_WAIT_MS=15, WORKERS=4, TEXTURE_LOOK_MS=1000 17–23 fps 94–100% 130–142 ms 32–34 ms 1,000 (696 ms) Counselor face 98% clean, guard arms clean; glowing white eyes (until loaded), shadow-edge halos; log revealed 427,634 missed descriptors from PORT_DESCRIPTORS=1
#10 (release) Disabled PORT_DESCRIPTORS; EARLY_TEXTURES_MS=50, TEXTURE_LOOK_MS=500, AMBIENT=0.95, AIR=1.4 21–30 fps (indoor) / 13–21 fps (heavy 7.5k-draw outdoor) 95–99% 130–253 ms 32–64 ms ~1,000 (<1 s) 0 missed descriptors (PORT_JOURNAL=1 lane wait only +1.3 ms: 3.57 → 4.88 ms), texture wait 17.7 → 14.4 s, fully GPU-bound on RTX 3080

3 Code Changes That Delivered the Biggest Wins

All three changes are hardware-adaptive or gated behind VICTORY_* env vars so AMD / 64 GB defaults remain untouched:

1. crates/victory-gpu/src/shadow.rs — Lock-Free Allocation + Quarantined Recycled Pool in shadow::exact()

  • Bottleneck: On heavy scenes, shadow::exact() was making ~716 CreateCommittedResource calls/frame while holding the global EXACT mutex and running a per-miss O(N) map.retain() over ~4,454 entries (~3.2M COM AddRef/Release calls/frame), blowing VICTORY_THIN up to 2,377 ms.
  • Fix:
    • Throttled periodic eviction (next_prune) instead of scanning map on every miss.
    • Moved host()?.shared_buffer(alloc_size) and excess Shadow drops completely outside the EXACT mutex.
    • Added a power-of-2 recycled D3D12 buffer pool (MIN_ALLOC = 64 KiB, capped at 256 MiB when residency::limited_host_ram() else 320 MiB) with 4-frame GPU quarantine (IDLE_FRAMES = 2 + QUARANTINE_FRAMES = 2) and trailing-byte zeroing (data[len..old_len] = 0) on reuse.
  • Result: VICTORY_THIN dropped 2,377 ms → 130–326 ms, heap pass 67–88 ms → 10.3 ms, present wait 254 ms → 5–11 ms, 95.2% pool hit rate, shadow::window_tests 8/8 passing.

2. crates/victory-gpu/src/host.rs — VICTORY_WAIT_RESIDENT=textures Split Mode

  • Bottleneck: On NVIDIA WDDM, default VICTORY_WAIT_RESIDENT=1 caused 212,000 waits (60.8 s) on committed buffer allocations, killing FPS to 3–5. Setting VICTORY_WAIT_RESIDENT=0 fixed FPS, but caused PS_BakeDecorations to sample unmapped 64 MiB texture pool heaps (pool.rs:685), baking rainbow confetti onto NPC faces/arms.
  • Fix: Added wait_resident_buffers() (false for "0" | "textures") while keeping wait_resident() true for "textures". Texture pool heaps (pool.rs) and depth twins (resource.rs) still wait for MakeResident + GPU mapping, while committed buffers skip per-buffer stalls.
  • Result: Waits dropped from 212,000 (60.8 s) → ~1,000 (0.7 s, max 24.7 ms) over 5.5 minutes, eliminating almost all waitress/counselor/guard confetti corruption at virtually zero FPS cost.

3. crates/victory-gpu/src/ambient.rs — VICTORY_AMBIENT_MOST=0 + Lifted Shadow Floor

  • Issue: Without RT, most = 4.0 lets untraced 16×16 screen-probe blocks bleed up to 4× over the smooth depth-aware GI estimate, creating bright blocky halos around hair/foreheads/clothing.
  • Fix: Added VICTORY_AMBIENT_MOST=<float> (default 4.0 to preserve upstream). When <= 0.0, raise() writes the smooth depth-aware estimate found directly (dir_scale = 0.65, min_floor = 0.48, room_mix = 0.38) so 16×16 probe halos vanish and backlit faces don't crush to pitch black.

Key NVIDIA / 10 GB VRAM / 32 GB RAM Findings for Developers

1. Six Compute Shaders Refused by NVIDIA Wave32 (E_INVALIDARG 0x80070057)

On RTX 3080 (host wave lanes min=32 max=32), these 6 compute shaders fail host PSO creation with 0x80070057 (presumably still emitting WaveSize(64) when wave32 lowering fails without VICTORY_WAVE_WIDE):

  • Dropped 1× every single frame during gameplay (confirmed in diag Run #4):
    • compute 02384a60fda6f2d0 (size=3104, first bound frame 1086)
    • compute 369cbe906ea72764 (size=2180, first bound frame 1087)
    • compute 2da4beb386509b77 (size=4920, first bound frame 1087)
  • Also refused at startup / world entry:
    • compute 6b82bc7d22016cb5
    • compute 5dc3b25986622949 (size=12216, first bound frame 1709)
    • compute 6f225b641c5b0708 (size=18016, first bound frame 1709)

2. VICTORY_PORT_DESCRIPTORS=1 Missed 427,634 View Records

In Run #9, Renderer Port #2's memcpy/memmove hook marked 0 records out of ~1,813 copies/frame, and the 16-page/frame fallback caught 427,634 missed view records (~145/frame on the checked pages alone), with these top unpatched writers:

  • 0x7ff8b669c26f (external DLL): 151,250
  • title+0x18849c: 104,047
  • 0x7ff80c4e0000 (external DLL): 43,680
  • title+0x4e9b4e2: 41,198
  • 0x7ff8b669c1d3 (external DLL): 14,888
  • title+0x2474afc: 14,360

Disabling VICTORY_PORT_DESCRIPTORS while keeping VICTORY_PORT_JOURNAL=1 only increased lane wait from 3.57 ms → 4.88 ms (12.6 ms total for all ~387 dirty pages / 399k slots/frame in parallel) and eliminated all 427k missed view records.

3. NVIDIA View Heap Cap & 10 GB VRAM Buffer Placement

  • VICTORY_PORT_CBV=1 has 0 hits on NVIDIA because NVIDIA caps shader-visible CBV/SRV/UAV heaps at 1,000,000 (PORTABLE_VIEWS), disabling raw descriptor twins (RAW_TWINS = 1 << 21).
  • Default card_limits() on <= 12 GiB VRAM (16 MiB min / 512 MiB max) leaves ~253+ MB/frame of hot buffers in system RAM over PCIe. Overriding to VICTORY_CARD_BUFFERS_MIN_KB=64 + VICTORY_CARD_BUFFERS_MB=2560 dropped CPU snapshots from 16.8 ms → 0.0 ms and pushed RTX 3080 utilization to 95–99%.
  • Pipeline hitching on 8-core CPUs: Default VICTORY_PIPELINE_WAIT_MS=500 + 10 compiler workers caused frequent 2–5 fps stalls on the 7800X3D; VICTORY_PIPELINE_WAIT_MS=15 + VICTORY_PIPELINE_WORKERS=4 eliminated >100 ms pipeline freezes.

Remaining Visual & Animation Issues Observed (Runs #1–#10)

  1. No lip movement / facial lip-sync on character models: In all 10 runs, characters' mouths/lips never moved during dialogue/cutscenes (body and eye animations worked, lips stayed frozen). Worth checking whether one of the 3 per-frame NVIDIA-refused compute shaders (02384a60fda6f2d0, 369cbe906ea72764, 2da4beb386509b77) handles facial morph/blendshape skinning.
  2. Stair-stepped bright green/blue halo around dynamic shadow edges on walls/doors (non-RT): Appears right along shadow penumbra borders on flat surfaces — consistent with 8×8 tiled shadow-mask penumbra blocks missing rays when VICTORY_BVH_BUILDER=0.
  3. Intermittent PS_BakeDecorations skin corruption: Even with WAIT_RESIDENT=textures, PORT_DESCRIPTORS=0, and BAKE_TEXTURES_MS=4000, forearms/hands (e.g., prison guard) or small forehead patches still occasionally bake pale/purple-speckled, suggesting an upstream race between PS_BakeDecorations and unmapped/streaming texture slots.
  4. Backlit hair translucency & reflection artifacts: Backlit hair against bright sunset windows occasionally renders overly bright/translucent orange; some curved reflective props show coarse/banded reflections.
  5. Texture streaming tail on 32 GB RAM / 10 GB VRAM: Even with EARLY_TEXTURES_MS=50 + TEXTURE_LOOK_MS=500, textures shown ... after waiting for memory still averages ~14.4 s (improved from 20.5 s), causing late-loading walls/eye textures in early cutscenes.

Best Config Tested for RTX 3080 (10 GB) / 8-Core CPU / 32 GB RAM (Non-RT)

VICTORY_D3D12_ADAPTER=NVIDIA
VICTORY_OUTPUT=1920x1080
VICTORY_WAIT_RESIDENT=textures
VICTORY_RESIDENCY=1
VICTORY_KEEP_FREED=0
VICTORY_CARD_BUFFERS_MIN_KB=64
VICTORY_CARD_BUFFERS_MB=2560
VICTORY_PIPELINE_WAIT_MS=15
VICTORY_PIPELINE_WORKERS=4
VICTORY_EARLY_TEXTURES_MS=50
VICTORY_TEXTURE_LOOK_MS=500
VICTORY_TEXTURE_STAGE_MB=192
VICTORY_BAKE_TEXTURES_MS=4000
VICTORY_AMBIENT=0.95
VICTORY_AMBIENT_MOST=0
VICTORY_AMBIENT_SHADE=0.7,0.6
VICTORY_AMBIENT_AIR=1.4
VICTORY_PORT_CONSTANTS=1
VICTORY_PORT_GUARD=1
VICTORY_PORT_JOURNAL=1
# Omit VICTORY_PORT_CBV (0 hits on NVIDIA 1M heap) and VICTORY_PORT_DESCRIPTORS (misses 427k+ views)
**@⁠ToolxMaster** on GitHub · 2026-11-26 21:22 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/issues/346) ## Test Environment - **OS:** Windows 11 Pro 64-bit (Build 26200) - **CPU:** AMD Ryzen 7 7800X3D (8C / 16T, AVX2) - **RAM:** 32 GB - **GPU:** NVIDIA GeForce RTX 3080 (10,051 MB dedicated VRAM, `vram_budget_mb = 9283`, Driver `32.0.16.2124`) - **Output:** `1920x1080`, Series X profile, LTO `release` build (after initial `diag` baselines) - **Goal:** Profile and optimize for mid-range NVIDIA / 10 GB VRAM / 32 GB RAM without regressing AMD / 64 GB defaults. --- ## Performance Progression (10 Iterative Runs) | Run | Key Changes | Sustained FPS | GPU Busy | `VICTORY_THIN` (all threads) | `ASYNC_SUBMIT` | Residency Waits | Visual / Stability Notes | |---|---|---|---|---|---|---|---| | **#1** (`diag`) | Stock fork + `ADAPTER=NVIDIA` + all 5 `PORT_*` | 3–5 fps (peaks 9) | 44% | 1,810 ms | 77.7 ms (`43 ms` flight wait) | **212,000** (`60.8 s`) | Cleanest stock look, heavy pagefile swap (27.3 GB private), `16.8 ms` (`283 MB/frame`) CPU snapshots | | **#2** (`diag`) | `WAIT_RESIDENT=0`, `RESIDENCY=1`, `KEEP_FREED=0`, `CARD_BUFFERS=1MB/2048MB`, dropped `PORT_CBV` | 3–5 fps | ~55% | 2,377 ms | 26.5 ms (`0.0 ms` flight wait) | 0 | Snapshots dropped `16.8 → 1.6 ms`, RAM `27.3 → 24.2 GB`; bottlenecked by `716` `CreateCommittedResource`/frame in `shadow::exact()` | | **#3** (`diag`) | Added `shadow::exact()` recycled buffer pool | ~10 fps | 90–98% | **326 ms** | ~32 ms | 0 | 95.2% pool hit rate; artifacts from recycling buffers without multi-frame GPU quarantine | | **#4** (`diag`) | 4-frame GPU quarantine + trailing-byte zeroing in `shadow::exact()`; `CARD_BUFFERS_MIN_KB=64` / `2560 MB` | **15–18 fps** | 95%+ | 286 ms | ~34 ms | 0 | `0.0 ms` CPU snapshots; frequent 2–5 fps hitches from default `PIPELINE_WAIT_MS=500` + 10 workers on 8 cores | | **#5** (`release`) | LTO `release` + `PIPELINE_WAIT_MS=15`, `PIPELINE_WORKERS=4` | **25–27 fps** | 95–99% | **135–162 ms** | 31–35.7 ms | 0 | Only 1 `>60 ms` idle spike in 3 min; visible 16×16 non-RT probe halos around hair/clothing + brown indoor fog | | **#6** (`release`) | Added `VICTORY_AMBIENT_MOST=0`, `AMBIENT_AIR=1.5`, `BAKE_TEXTURES_MS=4000` | ~24 fps | 95%+ | ~145 ms | ~33 ms | 0 | 16×16 hair halos & brown indoor haze gone; backlit faces too dark; `20.5 s` texture memory wait | | **#7** (`release`) | Lifted dark-face floor in `ambient.rs`; `TEXTURE_LOOK_MS=300`, `PIPELINE_WAIT_MS=40`, `WORKERS=6` | ~20 fps | ~90% | ~165 ms | ~38 ms | 0 | Face lighting much better, texture lag `-36%`; rainbow confetti on counselor/waitress faces (`PS_BakeDecorations` vs `WAIT_RESIDENT=0`) | | **#8** (`release`, **RT**) | Added `VICTORY_WAIT_RESIDENT=textures`; `-RayTracing` (`MEMORY_CARD_MB=2048`, `CARD_BUFFERS_MB=1536`) | 8–11 fps | 99% | ~155 ms | ~36 ms | 800 (`158 ms`) | Zero crashes on 10 GB VRAM (1,532 MB BVH); waitress face 100% clean; black prop/head artifacts + cutscene jumpsuit glitch | | **#9** (`release`) | RT OFF + `WAIT_RESIDENT=textures` + `PIPELINE_WAIT_MS=15`, `WORKERS=4`, `TEXTURE_LOOK_MS=1000` | **17–23 fps** | 94–100% | **130–142 ms** | 32–34 ms | 1,000 (`696 ms`) | Counselor face 98% clean, guard arms clean; glowing white eyes (until loaded), shadow-edge halos; log revealed **427,634 missed descriptors** from `PORT_DESCRIPTORS=1` | | **#10** (`release`) | Disabled `PORT_DESCRIPTORS`; `EARLY_TEXTURES_MS=50`, `TEXTURE_LOOK_MS=500`, `AMBIENT=0.95`, `AIR=1.4` | **21–30 fps** (indoor) / **13–21 fps** (heavy 7.5k-draw outdoor) | **95–99%** | 130–253 ms | 32–64 ms | ~1,000 (`<1 s`) | **0 missed descriptors** (`PORT_JOURNAL=1` lane wait only `+1.3 ms`: `3.57 → 4.88 ms`), texture wait `17.7 → 14.4 s`, fully GPU-bound on RTX 3080 | --- ## 3 Code Changes That Delivered the Biggest Wins All three changes are hardware-adaptive or gated behind `VICTORY_*` env vars so AMD / 64 GB defaults remain untouched: ### 1. `crates/victory-gpu/src/shadow.rs` — Lock-Free Allocation + Quarantined Recycled Pool in `shadow::exact()` - **Bottleneck:** On heavy scenes, `shadow::exact()` was making ~716 `CreateCommittedResource` calls/frame while holding the global `EXACT` mutex and running a per-miss `O(N)` `map.retain()` over ~4,454 entries (~3.2M COM `AddRef`/`Release` calls/frame), blowing `VICTORY_THIN` up to `2,377 ms`. - **Fix:** - Throttled periodic eviction (`next_prune`) instead of scanning `map` on every miss. - Moved `host()?.shared_buffer(alloc_size)` and excess `Shadow` drops completely outside the `EXACT` mutex. - Added a power-of-2 recycled D3D12 buffer pool (`MIN_ALLOC = 64 KiB`, capped at `256 MiB` when `residency::limited_host_ram()` else `320 MiB`) with **4-frame GPU quarantine** (`IDLE_FRAMES = 2` + `QUARANTINE_FRAMES = 2`) and trailing-byte zeroing (`data[len..old_len] = 0`) on reuse. - **Result:** `VICTORY_THIN` dropped **2,377 ms → 130–326 ms**, heap pass **67–88 ms → 10.3 ms**, present wait **254 ms → 5–11 ms**, **95.2% pool hit rate**, `shadow::window_tests` 8/8 passing. ### 2. `crates/victory-gpu/src/host.rs` — `VICTORY_WAIT_RESIDENT=textures` Split Mode - **Bottleneck:** On NVIDIA WDDM, default `VICTORY_WAIT_RESIDENT=1` caused **212,000 waits (60.8 s)** on committed buffer allocations, killing FPS to 3–5. Setting `VICTORY_WAIT_RESIDENT=0` fixed FPS, but caused `PS_BakeDecorations` to sample unmapped 64 MiB texture pool heaps (`pool.rs:685`), baking rainbow confetti onto NPC faces/arms. - **Fix:** Added `wait_resident_buffers()` (false for `"0" | "textures"`) while keeping `wait_resident()` true for `"textures"`. Texture pool heaps (`pool.rs`) and depth twins (`resource.rs`) still wait for `MakeResident` + GPU mapping, while committed buffers skip per-buffer stalls. - **Result:** Waits dropped from **212,000 (60.8 s) → ~1,000 (0.7 s, max 24.7 ms)** over 5.5 minutes, eliminating almost all waitress/counselor/guard confetti corruption at virtually zero FPS cost. ### 3. `crates/victory-gpu/src/ambient.rs` — `VICTORY_AMBIENT_MOST=0` + Lifted Shadow Floor - **Issue:** Without RT, `most = 4.0` lets untraced 16×16 screen-probe blocks bleed up to 4× over the smooth depth-aware GI estimate, creating bright blocky halos around hair/foreheads/clothing. - **Fix:** Added `VICTORY_AMBIENT_MOST=<float>` (default `4.0` to preserve upstream). When `<= 0.0`, `raise()` writes the smooth depth-aware estimate `found` directly (`dir_scale = 0.65`, `min_floor = 0.48`, `room_mix = 0.38`) so 16×16 probe halos vanish and backlit faces don't crush to pitch black. --- ## Key NVIDIA / 10 GB VRAM / 32 GB RAM Findings for Developers ### 1. Six Compute Shaders Refused by NVIDIA Wave32 (`E_INVALIDARG 0x80070057`) On RTX 3080 (`host wave lanes min=32 max=32`), these 6 compute shaders fail host PSO creation with `0x80070057` (presumably still emitting `WaveSize(64)` when wave32 lowering fails without `VICTORY_WAVE_WIDE`): - **Dropped 1× every single frame during gameplay** (confirmed in `diag` Run #4): - `compute 02384a60fda6f2d0` (`size=3104`, first bound frame 1086) - `compute 369cbe906ea72764` (`size=2180`, first bound frame 1087) - `compute 2da4beb386509b77` (`size=4920`, first bound frame 1087) - **Also refused at startup / world entry:** - `compute 6b82bc7d22016cb5` - `compute 5dc3b25986622949` (`size=12216`, first bound frame 1709) - `compute 6f225b641c5b0708` (`size=18016`, first bound frame 1709) ### 2. `VICTORY_PORT_DESCRIPTORS=1` Missed 427,634 View Records In Run #9, Renderer Port #2's `memcpy`/`memmove` hook marked **`0` records** out of ~1,813 copies/frame, and the 16-page/frame fallback caught **427,634 missed view records** (~145/frame on the checked pages alone), with these top unpatched writers: - `0x7ff8b669c26f` (external DLL): `151,250` - `title+0x18849c`: `104,047` - `0x7ff80c4e0000` (external DLL): `43,680` - `title+0x4e9b4e2`: `41,198` - `0x7ff8b669c1d3` (external DLL): `14,888` - `title+0x2474afc`: `14,360` Disabling `VICTORY_PORT_DESCRIPTORS` while keeping `VICTORY_PORT_JOURNAL=1` only increased lane wait from `3.57 ms → 4.88 ms` (`12.6 ms` total for all ~387 dirty pages / 399k slots/frame in parallel) and eliminated all 427k missed view records. ### 3. NVIDIA View Heap Cap & 10 GB VRAM Buffer Placement - **`VICTORY_PORT_CBV=1` has `0` hits on NVIDIA** because NVIDIA caps shader-visible CBV/SRV/UAV heaps at `1,000,000` (`PORTABLE_VIEWS`), disabling raw descriptor twins (`RAW_TWINS = 1 << 21`). - **Default `card_limits()` on `<= 12 GiB` VRAM** (`16 MiB min / 512 MiB max`) leaves ~253+ MB/frame of hot buffers in system RAM over PCIe. Overriding to `VICTORY_CARD_BUFFERS_MIN_KB=64` + `VICTORY_CARD_BUFFERS_MB=2560` dropped CPU snapshots from `16.8 ms → 0.0 ms` and pushed RTX 3080 utilization to 95–99%. - **Pipeline hitching on 8-core CPUs:** Default `VICTORY_PIPELINE_WAIT_MS=500` + 10 compiler workers caused frequent 2–5 fps stalls on the 7800X3D; `VICTORY_PIPELINE_WAIT_MS=15` + `VICTORY_PIPELINE_WORKERS=4` eliminated `>100 ms` pipeline freezes. --- ## Remaining Visual & Animation Issues Observed (Runs #1–#10) 1. **No lip movement / facial lip-sync on character models:** In all 10 runs, characters' mouths/lips never moved during dialogue/cutscenes (body and eye animations worked, lips stayed frozen). Worth checking whether one of the 3 per-frame NVIDIA-refused compute shaders (`02384a60fda6f2d0`, `369cbe906ea72764`, `2da4beb386509b77`) handles facial morph/blendshape skinning. 2. **Stair-stepped bright green/blue halo around dynamic shadow edges on walls/doors (non-RT):** Appears right along shadow penumbra borders on flat surfaces — consistent with 8×8 tiled shadow-mask penumbra blocks missing rays when `VICTORY_BVH_BUILDER=0`. 3. **Intermittent `PS_BakeDecorations` skin corruption:** Even with `WAIT_RESIDENT=textures`, `PORT_DESCRIPTORS=0`, and `BAKE_TEXTURES_MS=4000`, forearms/hands (e.g., prison guard) or small forehead patches still occasionally bake pale/purple-speckled, suggesting an upstream race between `PS_BakeDecorations` and unmapped/streaming texture slots. 4. **Backlit hair translucency & reflection artifacts:** Backlit hair against bright sunset windows occasionally renders overly bright/translucent orange; some curved reflective props show coarse/banded reflections. 5. **Texture streaming tail on 32 GB RAM / 10 GB VRAM:** Even with `EARLY_TEXTURES_MS=50` + `TEXTURE_LOOK_MS=500`, `textures shown ... after waiting for memory` still averages `~14.4 s` (improved from `20.5 s`), causing late-loading walls/eye textures in early cutscenes. --- ## Best Config Tested for RTX 3080 (10 GB) / 8-Core CPU / 32 GB RAM (Non-RT) ```powershell VICTORY_D3D12_ADAPTER=NVIDIA VICTORY_OUTPUT=1920x1080 VICTORY_WAIT_RESIDENT=textures VICTORY_RESIDENCY=1 VICTORY_KEEP_FREED=0 VICTORY_CARD_BUFFERS_MIN_KB=64 VICTORY_CARD_BUFFERS_MB=2560 VICTORY_PIPELINE_WAIT_MS=15 VICTORY_PIPELINE_WORKERS=4 VICTORY_EARLY_TEXTURES_MS=50 VICTORY_TEXTURE_LOOK_MS=500 VICTORY_TEXTURE_STAGE_MB=192 VICTORY_BAKE_TEXTURES_MS=4000 VICTORY_AMBIENT=0.95 VICTORY_AMBIENT_MOST=0 VICTORY_AMBIENT_SHADE=0.7,0.6 VICTORY_AMBIENT_AIR=1.4 VICTORY_PORT_CONSTANTS=1 VICTORY_PORT_GUARD=1 VICTORY_PORT_JOURNAL=1 # Omit VICTORY_PORT_CBV (0 hits on NVIDIA 1M heap) and VICTORY_PORT_DESCRIPTORS (misses 427k+ views) ```
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 00:58:01 +00:00
Author
Owner

@⁠upipibi on GitHub · 2026-11-26 21:56 UTC · original

On the frozen lips: a-publier reads the integer-view word only for views picked from the heap (slot_word, emit/lower.rs:8205), and dynamic table slots get no word (no dynamic_word in descriptor/host.rs). avatarmanz/VIctory-7900XTX#114 (still open there) and ZSlayerHQ/victory-world-runtime#15 add both, and #15 reports moving faces on an RTX 4080 SUPER. So our guess is that this, not the refused compute programs, freezes the lips. By reading, not run.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠upipibi** on GitHub · 2026-11-26 21:56 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/issues/346#issuecomment-7204211711) On the frozen lips: a-publier reads the integer-view word only for views picked from the heap (`slot_word`, emit/lower.rs:8205), and dynamic table slots get no word (no `dynamic_word` in descriptor/host.rs). avatarmanz/VIctory-7900XTX#114 (still open there) and ZSlayerHQ/victory-world-runtime#15 add both, and #15 reports moving faces on an RTX 4080 SUPER. So our guess is that this, not the refused compute programs, freezes the lips. By reading, not run. AI-assisted (Claude Code, Claude Opus 5.5).
Author
Owner

@⁠mattkajorinc on GitHub · 2026-11-26 22:24 UTC · original

Hardware: NVIDIA GeForce RTX 4070 (12 GB VRAM), Intel Core i9-14900F, 32 GB RAM, Windows 11.
Profile: Series X profile on Windows 11.

Findings & Progression:

  • Prologue (Cafeteria / Window Scene): Lucia's face model, hair, eyes, uniform, and room geometry load completely. Reached 8–30 FPS in dialogue and ~2–3 FPS (470 ms) when rendering 5,390 draws looking out into the prison yard window.
  • Lighting Tuning: Lowering VICTORY_AMBIENT from default 0.80 down to 0.25–0.35 completely resolved the severe blinding interior orange bloom blowout. Running with -RayTracing cured the coarse, splotchy probe dither on the ceiling and room corners.
  • NVIDIA Wave32 Refusals: Confirmed the exact same 3 compute shaders dropped 1x every single frame during gameplay with error 0x80070057 (E_INVALIDARG):
    • compute 02384a60fda6f2d0
    • compute 2da4beb386509b77
    • compute 369cbe906ea72764
      Along with the other three startup refusals: 5dc3b25986622949, 6f225b641c5b0708, 2cc4c197ee29e291.
  • Byte View Refusals: Log reports ~2,700 elements asked for per frame (refused and read zeros; VICTORY_VIEW_BYTES=0).
  • Big thanks to the contributors and @⁠ToolxMaster for the detailed RTX progression in Issue #346!
**@⁠mattkajorinc** on GitHub · 2026-11-26 22:24 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/issues/346#issuecomment-7204650571) **Hardware:** NVIDIA GeForce RTX 4070 (12 GB VRAM), Intel Core i9-14900F, 32 GB RAM, Windows 11. **Profile:** Series X profile on Windows 11. **Findings & Progression:** - **Prologue (Cafeteria / Window Scene):** Lucia's face model, hair, eyes, uniform, and room geometry load completely. Reached 8–30 FPS in dialogue and ~2–3 FPS (470 ms) when rendering 5,390 draws looking out into the prison yard window. - **Lighting Tuning:** Lowering `VICTORY_AMBIENT` from default `0.80` down to `0.25–0.35` completely resolved the severe blinding interior orange bloom blowout. Running with `-RayTracing` cured the coarse, splotchy probe dither on the ceiling and room corners. - **NVIDIA Wave32 Refusals:** Confirmed the exact same 3 compute shaders dropped 1x every single frame during gameplay with error `0x80070057 (E_INVALIDARG)`: - `compute 02384a60fda6f2d0` - `compute 2da4beb386509b77` - `compute 369cbe906ea72764` Along with the other three startup refusals: `5dc3b25986622949`, `6f225b641c5b0708`, `2cc4c197ee29e291`. - **Byte View Refusals:** Log reports `~2,700 elements asked for per frame (refused and read zeros; VICTORY_VIEW_BYTES=0)`. - Big thanks to the contributors and @⁠ToolxMaster for the detailed RTX progression in Issue #346!
Author
Owner

@⁠Miquella135 on GitHub · 2026-11-26 22:34 UTC · original

Another 3080-class data point: RTX 3080 Ti 12 GB, i9-9900K, 32 GB, Windows 10 22H2 (19045), non-RT, 1920x1080, Series X profile, diag build. It also confirms that your three fixes do work when they are implemented from the description alone: they are not in a-publier and your account has no public repo, so we reimplemented them from the text.

0. On Windows 10 this build needs the Agility SDK first, or it renders nothing. The inbox d3d12core (10.0.19041.5794) refuses the heap-directly-indexed root signature flags with E_INVALIDARG (root signature flags c00), every host root signature is then refused and every frame ends drawn=0. With D3D12SDKVersion=610 and D3D12\D3D12Core.dll beside the exe, the same call succeeds and the title renders. Before that: 1.2 fps, 833 ms/frame (126 preparing, 466 on the GPU, 71 copying back), 2622 draws/frame, GPU 33% busy, ~11.6 logical cores busy; menus were 30 fps even then (4-48 draws), so it is only 3D scenes.

1. VICTORY_PIPELINE_WAIT_MS=15 can leave a black picture with working sound. The draws dropped while pipelines compile are the whole scene (dropped 1000-3000 without a host pipeline); subtitles and audio keep going, the screen stays black. At 150 the picture is there, 2.8-6 fps on this machine. Worth a line in the config notes: "cutscene is black but the audio works" points at this, not at the renderer.

2. Your config, measured. Everything from your list except PORT_CBV and PORT_DESCRIPTORS: 4.7-11.5 fps, GPU time 466 -> 7-31 ms, menus still 30 fps, no black frames.

3. The three fixes, as numbers. Reimplemented: throttled eviction plus allocation outside the EXACT mutex in shadow::exact(); wait_resident_buffers() so VICTORY_WAIT_RESIDENT=textures skips per-buffer residency waits; VICTORY_AMBIENT_MOST. Same scene, before -> after: 3.4-4.1 fps / 244-294 ms -> 5.1-8.9 fps / 112-195 ms, GPU 33-38 ms -> 14-29 ms, the 16x16 probe halos around hair and clothing are gone, and shadow::exact() went from 2084 asks / 321 creations per frame to 1856 / 279.

4. What we did not do, and what is left. We did not implement the 4-frame quarantined pool: it needs Drop for Shadow and we did not want to guess at the quarantine bookkeeping. We still create ~279 committed buffers per frame, so that is probably the biggest remaining win if you can publish the actual diff. Also open here: the six compute shaders are refused every frame (2da4beb386509b77, 369cbe906ea72764, 02384a60fda6f2d0, 6b82bc7d22016cb5, 6f225b641c5b0708, 5dc3b25986622949, 1151 refusals in five minutes); remaining CPU is lists' steps 40 ms and copies into the card's memory 23 ms per frame; private memory 23 GB of 32 GB; and lips still do not move, which matches the dynamic_word note in the comment above.

**@⁠Miquella135** on GitHub · 2026-11-26 22:34 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/issues/346#issuecomment-7204801302) Another 3080-class data point: RTX 3080 Ti 12 GB, i9-9900K, 32 GB, Windows 10 22H2 (19045), non-RT, 1920x1080, Series X profile, `diag` build. It also confirms that your three fixes do work when they are implemented from the description alone: they are not in `a-publier` and your account has no public repo, so we reimplemented them from the text. **0. On Windows 10 this build needs the Agility SDK first, or it renders nothing.** The inbox `d3d12core` (10.0.19041.5794) refuses the heap-directly-indexed root signature flags with `E_INVALIDARG` (`root signature flags c00`), every host root signature is then refused and every frame ends `drawn=0`. With `D3D12SDKVersion=610` and `D3D12\D3D12Core.dll` beside the exe, the same call succeeds and the title renders. Before that: `1.2 fps, 833 ms/frame (126 preparing, 466 on the GPU, 71 copying back), 2622 draws/frame`, GPU 33% busy, ~11.6 logical cores busy; menus were 30 fps even then (4-48 draws), so it is only 3D scenes. **1. `VICTORY_PIPELINE_WAIT_MS=15` can leave a black picture with working sound.** The draws dropped while pipelines compile are the whole scene (`dropped 1000-3000 without a host pipeline`); subtitles and audio keep going, the screen stays black. At `150` the picture is there, 2.8-6 fps on this machine. Worth a line in the config notes: "cutscene is black but the audio works" points at this, not at the renderer. **2. Your config, measured.** Everything from your list except `PORT_CBV` and `PORT_DESCRIPTORS`: 4.7-11.5 fps, GPU time 466 -> 7-31 ms, menus still 30 fps, no black frames. **3. The three fixes, as numbers.** Reimplemented: throttled eviction plus allocation outside the `EXACT` mutex in `shadow::exact()`; `wait_resident_buffers()` so `VICTORY_WAIT_RESIDENT=textures` skips per-buffer residency waits; `VICTORY_AMBIENT_MOST`. Same scene, before -> after: 3.4-4.1 fps / 244-294 ms -> **5.1-8.9 fps / 112-195 ms**, GPU 33-38 ms -> 14-29 ms, the 16x16 probe halos around hair and clothing are gone, and `shadow::exact()` went from `2084 asks / 321 creations per frame` to `1856 / 279`. **4. What we did not do, and what is left.** We did not implement the 4-frame quarantined pool: it needs `Drop for Shadow` and we did not want to guess at the quarantine bookkeeping. We still create ~279 committed buffers per frame, so that is probably the biggest remaining win if you can publish the actual diff. Also open here: the six compute shaders are refused every frame (`2da4beb386509b77`, `369cbe906ea72764`, `02384a60fda6f2d0`, `6b82bc7d22016cb5`, `6f225b641c5b0708`, `5dc3b25986622949`, 1151 refusals in five minutes); remaining CPU is `lists' steps` 40 ms and `copies into the card's memory` 23 ms per frame; private memory 23 GB of 32 GB; and lips still do not move, which matches the `dynamic_word` note in the comment above.
Author
Owner

@⁠JFIREonFIRE on GitHub · 2026-11-26 23:09 UTC · original

Two data points from an RTX 3090 (24 GB, driver 32.0.16.2101) / i9-9900K / 32 GB, for the findings above.

VICTORY_WAIT_RESIDENT=textures on a cool_fox-based tree. I wrote the split as described (plain buffers made without CREATE_NOT_RESIDENT and not waited for, incl. their mapped() wait; texture blocks and textures as before). Waits per 4-minute run fell from ~120,000 to 1,000 (an 11-minute run had 332,000 waits, 150 s in all). Frame time did not change on that tree (134 ms mean vs ~118–121 before, a heavier scene), but the working set fell ~1.5 GB (15.9 GB avg / 16.8 peak vs 17.5 / 19.2). No device removal, no black frames, VICTORY_D3D12_DRED=light on. VICTORY_PIPELINE_WAIT_MS=15 + PIPELINE_WORKERS=4 + CARD_BUFFERS_MB=2560 made it worse there (world later, 182 ms mean), so those look specific to this fork's defaults.

The six refused compute programs reproduce on the RTX 3090. a-publier@cd8dfc0, victory translate --list --pipelines with VICTORY_TRANSLATE_ONLY on the six hashes: all six are emitted, and all six host pipelines fail with "The parameter is incorrect" (02384a60fda6f2d0 vfx_triangleClip:CS_DefragHeap_ComputeRelocations, 6b82bc7d22016cb5 vfx_triangleClip:CS_CollectTriangles_Meshlets, 369cbe906ea72764 GpuParticleUpdate:CS_Visibility, 2da4beb386509b77 alphaResolve:CS_AlphTransmissionPrefilterMip, 5dc3b25986622949 and 6f225b641c5b0708 water_shading:CS_TransmissionVolumetrics_Tiled[_LocalLights]). The cool_fox tree refuses three of them earlier, at translation ("no wave32 lowering for this wave64 program"); with VICTORY_WAVE_WHY=1 the retries stop at "a wave reduction where not every lane runs" (0x7e8, 0x2e94, 0x4e0c) and "a first-lane read where not every lane runs" (0x1ee0, 0x1fa8). On the same card, #128's branch had not finished translate --pipelines on the six after 30 minutes; I'll report #128, #345 and #366 on these hashes separately.

Measured and written with Claude Code (AI).

**@⁠JFIREonFIRE** on GitHub · 2026-11-26 23:09 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/issues/346#issuecomment-7205304265) Two data points from an RTX 3090 (24 GB, driver 32.0.16.2101) / i9-9900K / 32 GB, for the findings above. **`VICTORY_WAIT_RESIDENT=textures` on a cool_fox-based tree.** I wrote the split as described (plain buffers made without `CREATE_NOT_RESIDENT` and not waited for, incl. their `mapped()` wait; texture blocks and textures as before). Waits per 4-minute run fell from ~120,000 to 1,000 (an 11-minute run had 332,000 waits, 150 s in all). Frame time did not change on that tree (134 ms mean vs ~118–121 before, a heavier scene), but the working set fell ~1.5 GB (15.9 GB avg / 16.8 peak vs 17.5 / 19.2). No device removal, no black frames, `VICTORY_D3D12_DRED=light` on. `VICTORY_PIPELINE_WAIT_MS=15` + `PIPELINE_WORKERS=4` + `CARD_BUFFERS_MB=2560` made it worse there (world later, 182 ms mean), so those look specific to this fork's defaults. **The six refused compute programs reproduce on the RTX 3090.** `a-publier@cd8dfc0`, `victory translate --list --pipelines` with `VICTORY_TRANSLATE_ONLY` on the six hashes: all six are emitted, and all six host pipelines fail with "The parameter is incorrect" (02384a60fda6f2d0 `vfx_triangleClip:CS_DefragHeap_ComputeRelocations`, 6b82bc7d22016cb5 `vfx_triangleClip:CS_CollectTriangles_Meshlets`, 369cbe906ea72764 `GpuParticleUpdate:CS_Visibility`, 2da4beb386509b77 `alphaResolve:CS_AlphTransmissionPrefilterMip`, 5dc3b25986622949 and 6f225b641c5b0708 `water_shading:CS_TransmissionVolumetrics_Tiled[_LocalLights]`). The cool_fox tree refuses three of them earlier, at translation ("no wave32 lowering for this wave64 program"); with `VICTORY_WAVE_WHY=1` the retries stop at "a wave reduction where not every lane runs" (0x7e8, 0x2e94, 0x4e0c) and "a first-lane read where not every lane runs" (0x1ee0, 0x1fa8). On the same card, #128's branch had not finished `translate --pipelines` on the six after 30 minutes; I'll report #128, #345 and #366 on these hashes separately. Measured and written with Claude Code (AI).
Author
Owner

@⁠ToolxMaster on GitHub · 2026-11-26 23:12 UTC · original · edited 2026-11-26 23:13 UTC

@⁠Miquella135 Thanks for testing and reproducing all of this! Good catch on VICTORY_PIPELINE_WAIT_MS=15 too that worked cleanly here only because my host-pipelines.bin was already warmed up (~2,770 pipelines cached); on a cold cache, 150 (or warming first) definitely avoids black cutscenes.

For the 4-frame quarantined pool in shadow::exact(), it actually does not need Drop for Shadow at all:

  • Eviction happens inside exact() during throttled pruning once now_frame >= last_frame + IDLE_FRAMES (2) and Arc::strong_count(shadow) == 1 && crate::host::references(&shadow.buffer) == 1.
  • At that point EXACT clones shadow.buffer, stashes (now_frame, bucket, buffer, shadow.data as usize, old_len) into quarantine: VecDeque, and drops shadow (leaving the ID3D12Resource alive with COM refcount 1 in quarantine).
  • After QUARANTINE_FRAMES (2) more full frames (4 frames total), it graduates from quarantine into the power-of-2 pool (MIN_ALLOC = 64 KiB), and trailing bytes [len..old_len] are zeroed on reuse.
  • shadow::window_tests stays 8/8 passing and shadow::exact() dropped to ~95.2% pool hits.

Here is the exact ExactCache / exact() / exact_line() replacement in crates/victory-gpu/src/shadow.rs:

struct ExactCache {
    tick: u64,
    next_prune: u64,
    /// `(shadow, last_used_frame)`.
    map: BTreeMap<(u64, u64), (Arc<Shadow>, u64)>,
    /// Evicted buffers waiting for in-flight GPU frames to retire before reuse:
    /// `(evicted_frame, bucket_bytes, buffer, data_addr, old_len)`.
    quarantine: std::collections::VecDeque<(u64, u64, ID3D12Resource, usize, u64)>,
    /// Ready-to-reuse buffers keyed by bucket bytes: `(buffer, data_addr, old_len)`.
    pool: BTreeMap<u64, Vec<(ID3D12Resource, usize, u64)>>,
    /// Total bytes held in `quarantine` + `pool`.
    pool_bytes: u64,
}

impl ExactCache {
    const fn new() -> Self {
        Self {
            tick: 0,
            next_prune: 0,
            map: BTreeMap::new(),
            quarantine: std::collections::VecDeque::new(),
            pool: BTreeMap::new(),
            pool_bytes: 0,
        }
    }
}

static EXACT: Mutex<ExactCache> = Mutex::new(ExactCache::new());

/// Since the last frame line: askings for such copies, newly allocated copies,
/// and copies satisfied by recycling a pooled buffer.
static EXACT_STATS: [AtomicU64; 3] = [const { AtomicU64::new(0) }; 3];

pub(crate) fn exact(address: u64, len: u64) -> Option<Arc<Shadow>> {
    const MANY: usize = 256;
    const IDLE_FRAMES: u64 = 2;
    const QUARANTINE_FRAMES: u64 = 2;
    const MOST: u64 = 64 << 20;
    const MIN_ALLOC: u64 = 64 << 10;
    if len == 0 || len > MOST || !address.is_multiple_of(4) {
        return None;
    }
    let alloc_size = len.max(MIN_ALLOC).next_power_of_two().min(MOST);
    let pool_limit: u64 = if crate::residency::limited_host_ram() { 256 << 20 } else { 320 << 20 };
    let now_frame = crate::frame::current();
    EXACT_STATS[0].fetch_add(1, Ordering::Relaxed);

    let mut to_drop: Vec<Arc<Shadow>> = Vec::new();
    let pooled: Option<(ID3D12Resource, usize, u64)> = {
        let mut cache = EXACT.lock().unwrap_or_else(|e| e.into_inner());
        cache.tick += 1;
        let now_tick = cache.tick;
        if let Some((shadow, last_frame)) = cache.map.get_mut(&(address, len)) {
            *last_frame = now_frame;
            shadow.used.store(crate::host::moment(), Ordering::Relaxed);
            return Some(shadow.clone());
        }
        // Graduate quarantined buffers whose GPU flights have retired.
        while let Some(&(evicted_frame, ..)) = cache.quarantine.front() {
            if now_frame < evicted_frame.saturating_add(QUARANTINE_FRAMES) {
                break;
            }
            if let Some((_, bucket, buf, data_addr, old_len)) = cache.quarantine.pop_front() {
                cache.pool.entry(bucket).or_default().push((buf, data_addr, old_len));
            }
        }
        if cache.map.len() >= MANY && now_tick >= cache.next_prune {
            cache.next_prune = now_tick + (cache.map.len() as u64 / 2).max(256);
            let mut dead = Vec::new();
            for (&key, (shadow, last_frame)) in &cache.map {
                if now_frame >= last_frame.saturating_add(IDLE_FRAMES)
                    && Arc::strong_count(shadow) == 1
                    && crate::host::references(&shadow.buffer) == 1
                {
                    dead.push(key);
                }
            }
            for key in dead {
                if let Some((shadow, _)) = cache.map.remove(&key) {
                    let bucket = shadow.width();
                    let old_len = shadow.len;
                    if cache.pool_bytes.saturating_add(bucket) <= pool_limit {
                        let recycled = (now_frame, bucket, shadow.buffer.clone(), shadow.data as usize, old_len);
                        drop(shadow);
                        cache.quarantine.push_back(recycled);
                        cache.pool_bytes += bucket;
                    } else {
                        to_drop.push(shadow);
                    }
                }
            }
        }
        if let Some(bucket) = cache.pool.get_mut(&alloc_size)
            && let Some(item) = bucket.pop()
        {
            cache.pool_bytes = cache.pool_bytes.saturating_sub(alloc_size);
            Some(item)
        } else {
            None
        }
    };
    drop(to_drop);

    if let Some((buffer, data_addr, old_len)) = pooled {
        let data = data_addr as *mut u8;
        if old_len > len {
            let clear_from = len as usize;
            let clear_bytes = (old_len - len) as usize;
            // SAFETY: buffer is mapped for `alloc_size >= old_len > len` and retired from GPU.
            unsafe { std::ptr::write_bytes(data.add(clear_from), 0, clear_bytes) };
        }
        // SAFETY: a live buffer recycled after multi-frame GPU quarantine.
        let gpu = unsafe { buffer.GetGPUVirtualAddress() };
        let shadow = Arc::new(Shadow::new(buffer, data, gpu, address, len));
        let mut cache = EXACT.lock().unwrap_or_else(|e| e.into_inner());
        if let Some((existing, last_frame)) = cache.map.get_mut(&(address, len)) {
            *last_frame = now_frame;
            existing.used.store(crate::host::moment(), Ordering::Relaxed);
            let out = existing.clone();
            if cache.pool_bytes.saturating_add(alloc_size) <= pool_limit {
                let recycled = (shadow.buffer.clone(), shadow.data as usize, len);
                drop(shadow);
                cache.pool.entry(alloc_size).or_default().push(recycled);
                cache.pool_bytes += alloc_size;
            }
            return Some(out);
        }
        cache.map.insert((address, len), (shadow.clone(), now_frame));
        EXACT_STATS[2].fetch_add(1, Ordering::Relaxed);
        return Some(shadow);
    }

    // Allocate outside `EXACT` so worker threads never serialize on D3D12 resource creation.
    let (buffer, data) = host()?.shared_buffer(alloc_size)?;
    crate::host::name(&buffer, || format!("title view {address:#x}+{len:#x}"));
    // SAFETY: a live buffer.
    let gpu = unsafe { buffer.GetGPUVirtualAddress() };
    let shadow = Arc::new(Shadow::new(buffer, data, gpu, address, len));
    let mut extra: Option<Arc<Shadow>> = None;
    let out = {
        let mut cache = EXACT.lock().unwrap_or_else(|e| e.into_inner());
        if let Some((existing, last_frame)) = cache.map.get_mut(&(address, len)) {
            *last_frame = now_frame;
            existing.used.store(crate::host::moment(), Ordering::Relaxed);
            let out = existing.clone();
            if cache.pool_bytes.saturating_add(alloc_size) <= pool_limit {
                let recycled = (shadow.buffer.clone(), shadow.data as usize, 0);
                drop(shadow);
                cache.pool.entry(alloc_size).or_default().push(recycled);
                cache.pool_bytes += alloc_size;
            } else {
                extra = Some(shadow);
            }
            out
        } else {
            cache.map.insert((address, len), (shadow.clone(), now_frame));
            EXACT_STATS[1].fetch_add(1, Ordering::Relaxed);
            OWN_MADE.fetch_add(1, Ordering::Relaxed);
            shadow
        }
    };
    drop(extra);
    Some(out)
}

pub(crate) static OWN_MADE: AtomicU64 = AtomicU64::new(0);

pub(crate) fn exact_line(frames: f64) {
    let [asked, made, reused] = [0, 1, 2].map(|i| EXACT_STATS[i].swap(0, Ordering::Relaxed));
    if asked == 0 {
        return;
    }
    let (kept, quarantined, pooled_mb) = {
        let cache = EXACT.lock().unwrap_or_else(|e| e.into_inner());
        (cache.map.len(), cache.quarantine.len(), cache.pool_bytes >> 20)
    };
    tracing::info!(
        "buffer views off their copy's elements (they were refused and read zeros; VICTORY_VIEW_BYTES=0 refuses them again): \
         {:.1} asked for per frame, {:.1} new + {:.1} recycled copies per frame, {kept} kept ({quarantined} quarantined, {pooled_mb} MB pooled)",
        asked as f64 / frames,
        made as f64 / frames,
        reused as f64 / frames,
    );
}

Also huge thanks to @⁠upipibi for pointing out dynamic_word for the frozen lips and @⁠JFIREonFIRE for identifying the exact names of all 6 refused compute shaders!

**@⁠ToolxMaster** on GitHub · 2026-11-26 23:12 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/issues/346#issuecomment-7205345447) · edited 2026-11-26 23:13 UTC @⁠Miquella135 Thanks for testing and reproducing all of this! Good catch on `VICTORY_PIPELINE_WAIT_MS=15` too that worked cleanly here only because my `host-pipelines.bin` was already warmed up (~2,770 pipelines cached); on a cold cache, `150` (or warming first) definitely avoids black cutscenes. For the **4-frame quarantined pool in `shadow::exact()`**, it actually **does not need `Drop for Shadow` at all**: - Eviction happens inside `exact()` during throttled pruning once `now_frame >= last_frame + IDLE_FRAMES` (`2`) **and** `Arc::strong_count(shadow) == 1 && crate::host::references(&shadow.buffer) == 1`. - At that point `EXACT` clones `shadow.buffer`, stashes `(now_frame, bucket, buffer, shadow.data as usize, old_len)` into `quarantine: VecDeque`, and drops `shadow` (leaving the `ID3D12Resource` alive with COM refcount 1 in `quarantine`). - After `QUARANTINE_FRAMES` (`2`) more full frames (4 frames total), it graduates from `quarantine` into the power-of-2 `pool` (`MIN_ALLOC = 64 KiB`), and trailing bytes `[len..old_len]` are zeroed on reuse. - `shadow::window_tests` stays 8/8 passing and `shadow::exact()` dropped to ~95.2% pool hits. Here is the exact `ExactCache` / `exact()` / `exact_line()` replacement in `crates/victory-gpu/src/shadow.rs`: ```rust struct ExactCache { tick: u64, next_prune: u64, /// `(shadow, last_used_frame)`. map: BTreeMap<(u64, u64), (Arc<Shadow>, u64)>, /// Evicted buffers waiting for in-flight GPU frames to retire before reuse: /// `(evicted_frame, bucket_bytes, buffer, data_addr, old_len)`. quarantine: std::collections::VecDeque<(u64, u64, ID3D12Resource, usize, u64)>, /// Ready-to-reuse buffers keyed by bucket bytes: `(buffer, data_addr, old_len)`. pool: BTreeMap<u64, Vec<(ID3D12Resource, usize, u64)>>, /// Total bytes held in `quarantine` + `pool`. pool_bytes: u64, } impl ExactCache { const fn new() -> Self { Self { tick: 0, next_prune: 0, map: BTreeMap::new(), quarantine: std::collections::VecDeque::new(), pool: BTreeMap::new(), pool_bytes: 0, } } } static EXACT: Mutex<ExactCache> = Mutex::new(ExactCache::new()); /// Since the last frame line: askings for such copies, newly allocated copies, /// and copies satisfied by recycling a pooled buffer. static EXACT_STATS: [AtomicU64; 3] = [const { AtomicU64::new(0) }; 3]; pub(crate) fn exact(address: u64, len: u64) -> Option<Arc<Shadow>> { const MANY: usize = 256; const IDLE_FRAMES: u64 = 2; const QUARANTINE_FRAMES: u64 = 2; const MOST: u64 = 64 << 20; const MIN_ALLOC: u64 = 64 << 10; if len == 0 || len > MOST || !address.is_multiple_of(4) { return None; } let alloc_size = len.max(MIN_ALLOC).next_power_of_two().min(MOST); let pool_limit: u64 = if crate::residency::limited_host_ram() { 256 << 20 } else { 320 << 20 }; let now_frame = crate::frame::current(); EXACT_STATS[0].fetch_add(1, Ordering::Relaxed); let mut to_drop: Vec<Arc<Shadow>> = Vec::new(); let pooled: Option<(ID3D12Resource, usize, u64)> = { let mut cache = EXACT.lock().unwrap_or_else(|e| e.into_inner()); cache.tick += 1; let now_tick = cache.tick; if let Some((shadow, last_frame)) = cache.map.get_mut(&(address, len)) { *last_frame = now_frame; shadow.used.store(crate::host::moment(), Ordering::Relaxed); return Some(shadow.clone()); } // Graduate quarantined buffers whose GPU flights have retired. while let Some(&(evicted_frame, ..)) = cache.quarantine.front() { if now_frame < evicted_frame.saturating_add(QUARANTINE_FRAMES) { break; } if let Some((_, bucket, buf, data_addr, old_len)) = cache.quarantine.pop_front() { cache.pool.entry(bucket).or_default().push((buf, data_addr, old_len)); } } if cache.map.len() >= MANY && now_tick >= cache.next_prune { cache.next_prune = now_tick + (cache.map.len() as u64 / 2).max(256); let mut dead = Vec::new(); for (&key, (shadow, last_frame)) in &cache.map { if now_frame >= last_frame.saturating_add(IDLE_FRAMES) && Arc::strong_count(shadow) == 1 && crate::host::references(&shadow.buffer) == 1 { dead.push(key); } } for key in dead { if let Some((shadow, _)) = cache.map.remove(&key) { let bucket = shadow.width(); let old_len = shadow.len; if cache.pool_bytes.saturating_add(bucket) <= pool_limit { let recycled = (now_frame, bucket, shadow.buffer.clone(), shadow.data as usize, old_len); drop(shadow); cache.quarantine.push_back(recycled); cache.pool_bytes += bucket; } else { to_drop.push(shadow); } } } } if let Some(bucket) = cache.pool.get_mut(&alloc_size) && let Some(item) = bucket.pop() { cache.pool_bytes = cache.pool_bytes.saturating_sub(alloc_size); Some(item) } else { None } }; drop(to_drop); if let Some((buffer, data_addr, old_len)) = pooled { let data = data_addr as *mut u8; if old_len > len { let clear_from = len as usize; let clear_bytes = (old_len - len) as usize; // SAFETY: buffer is mapped for `alloc_size >= old_len > len` and retired from GPU. unsafe { std::ptr::write_bytes(data.add(clear_from), 0, clear_bytes) }; } // SAFETY: a live buffer recycled after multi-frame GPU quarantine. let gpu = unsafe { buffer.GetGPUVirtualAddress() }; let shadow = Arc::new(Shadow::new(buffer, data, gpu, address, len)); let mut cache = EXACT.lock().unwrap_or_else(|e| e.into_inner()); if let Some((existing, last_frame)) = cache.map.get_mut(&(address, len)) { *last_frame = now_frame; existing.used.store(crate::host::moment(), Ordering::Relaxed); let out = existing.clone(); if cache.pool_bytes.saturating_add(alloc_size) <= pool_limit { let recycled = (shadow.buffer.clone(), shadow.data as usize, len); drop(shadow); cache.pool.entry(alloc_size).or_default().push(recycled); cache.pool_bytes += alloc_size; } return Some(out); } cache.map.insert((address, len), (shadow.clone(), now_frame)); EXACT_STATS[2].fetch_add(1, Ordering::Relaxed); return Some(shadow); } // Allocate outside `EXACT` so worker threads never serialize on D3D12 resource creation. let (buffer, data) = host()?.shared_buffer(alloc_size)?; crate::host::name(&buffer, || format!("title view {address:#x}+{len:#x}")); // SAFETY: a live buffer. let gpu = unsafe { buffer.GetGPUVirtualAddress() }; let shadow = Arc::new(Shadow::new(buffer, data, gpu, address, len)); let mut extra: Option<Arc<Shadow>> = None; let out = { let mut cache = EXACT.lock().unwrap_or_else(|e| e.into_inner()); if let Some((existing, last_frame)) = cache.map.get_mut(&(address, len)) { *last_frame = now_frame; existing.used.store(crate::host::moment(), Ordering::Relaxed); let out = existing.clone(); if cache.pool_bytes.saturating_add(alloc_size) <= pool_limit { let recycled = (shadow.buffer.clone(), shadow.data as usize, 0); drop(shadow); cache.pool.entry(alloc_size).or_default().push(recycled); cache.pool_bytes += alloc_size; } else { extra = Some(shadow); } out } else { cache.map.insert((address, len), (shadow.clone(), now_frame)); EXACT_STATS[1].fetch_add(1, Ordering::Relaxed); OWN_MADE.fetch_add(1, Ordering::Relaxed); shadow } }; drop(extra); Some(out) } pub(crate) static OWN_MADE: AtomicU64 = AtomicU64::new(0); pub(crate) fn exact_line(frames: f64) { let [asked, made, reused] = [0, 1, 2].map(|i| EXACT_STATS[i].swap(0, Ordering::Relaxed)); if asked == 0 { return; } let (kept, quarantined, pooled_mb) = { let cache = EXACT.lock().unwrap_or_else(|e| e.into_inner()); (cache.map.len(), cache.quarantine.len(), cache.pool_bytes >> 20) }; tracing::info!( "buffer views off their copy's elements (they were refused and read zeros; VICTORY_VIEW_BYTES=0 refuses them again): \ {:.1} asked for per frame, {:.1} new + {:.1} recycled copies per frame, {kept} kept ({quarantined} quarantined, {pooled_mb} MB pooled)", asked as f64 / frames, made as f64 / frames, reused as f64 / frames, ); } ``` Also huge thanks to @⁠upipibi for pointing out `dynamic_word` for the frozen lips and @⁠JFIREonFIRE for identifying the exact names of all 6 refused compute shaders!
Author
Owner

@⁠BE29ZZ on GitHub · 2026-11-27 02:27 UTC · original

Opened #451 targeting \-publier\ implementing item 1 from this report (\shadow::exact()\ out-of-lock allocation + throttled pruning + power-of-two GPU-quarantined recycling pool, with shared read-lock hits, submission-fence + frame quarantine, stale-byte zeroing, and pressure trimming in \let_go_idle()). Verified locally on an RTX 3060 (Clippy default & --all-features, \ ictory-gpu\ 402/402 passing including 6 new unit/GPU tests, \xtask\ 9/9) — credit to @⁠ToolxMaster and @⁠Miquella135! Ready for in-game testing.

**@⁠BE29ZZ** on GitHub · 2026-11-27 02:27 UTC · [original](https://github.com/Belobug/VIctory-Belobug-AMD/issues/346#issuecomment-7208143989) Opened #451 targeting \-publier\ implementing item 1 from this report (\shadow::exact()\ out-of-lock allocation + throttled pruning + power-of-two GPU-quarantined recycling pool, with shared read-lock hits, submission-fence + frame quarantine, stale-byte zeroing, and pressure trimming in \let_go_idle()\). Verified locally on an RTX 3060 (Clippy default & \--all-features\, \ ictory-gpu\ 402/402 passing including 6 new unit/GPU tests, \xtask\ 9/9) — credit to @⁠ToolxMaster and @⁠Miquella135! Ready for in-game testing.
This discussion has been locked. Commenting is limited to contributors.
No description provided.