Skip to content

gpu: gate sampled_lately on consumed readback, accelerate held sweeps, and prioritize visible missing textures - #2608

Merged
trustno1-coder merged 1 commit into
trustno1-coder:mainfrom
nidea1:fix/sampled-marks-readback-and-wake
Nov 30, 2026
Merged

trustno1-coder merged 1 commit into
trustno1-coder:mainfrom
nidea1:fix/sampled-marks-readback-and-wake

Conversation

@nidea1

@nidea1 nidea1 commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes three latency/correctness issues in sampled-slot readback (sampled.rs) and texture queue scheduling (descriptor/host.rs) that delayed visible missing textures when VRAM is over the room line:

  1. In-flight readback false negatives (crates/victory-gpu/src/sampled.rs): sampled_lately() previously compared against last_copy_frame (updated when the GPU copy was recorded, before consume_readback() populated seen), causing Some(false) for all slots before the first readback landed and across every sweep boundary when frames < SWEEP_EVERY (24 < 30). Now tracks last_consumed_frame updated with Release after consume_readback() writes seen and read with Acquire in sampled_lately().
  2. Accelerated readback while slots are held (crates/victory-gpu/src/sampled.rs, descriptor/host.rs): tracks lock-free HELD_HEAPS count via QueueMarks::set_held / Drop and lowers readback cadence from SWEEP_EVERY (30 frames, ~1.5–2.0 s at 15–20 FPS) to HELD_SWEEP_EVERY (4 frames) only while any heap holds textures back for VRAM room.
  3. DueBuckets parity & visible-slot priority (crates/victory-gpu/src/descriptor/host.rs):
    • Restores sampled_wake (30-frame window matching SWEEP_EVERY) and FLAG_SOON handling in DueBuckets::collect_due_and_census and TextureQueue::changed_soon.
    • Prioritizes recently sampled missing/un-uploaded slots (fresh and NO_CHECKED retries) ahead of already-uploaded FLAG_CHECKED speculative rechecks in Due::ordered, preventing time-bounded passes from starving visible missing textures.

Verification

  • cargo test -p victory-gpu --lib -- sampled:: descriptor::host::tests::: 77 passed, 0 failed (including 5 new unit tests covering consumed-readback gating, held sweep cadence, DueBuckets vs flat parity on sampled_wake/FLAG_SOON, priority ordering over FLAG_CHECKED rechecks, and QueueMarks held-counter lifecycle).
  • cargo clippy -p victory-gpu --tests: 0 warnings in touched lines.
  • cargo xtask policy --staged: passed.
  • Live RTX 3060 Ti run (including under 3.2 GB WDDM VRAM pressure): sweep automatically stays at 30 frames in menus and switches to 4 frames when slots are held; speculative unchanged rechecks dropped from ~9,850 to ~790 per 5 s interval with zero missing character/scene textures in captured frames.

…weeps, and prioritize visible missing textures
@dyshay

dyshay commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Merged into our fork's integration branch for testing (dyshay/VIctory-NVIDIA, branch janus-prs). I read the full diff first: no network access, process spawning, binaries, build or dependency changes, or game data. It builds with --profile diag --features diagnostics, and the CPU tests of the touched crates pass. Runs on an RTX 4090 are queued (Series X 1440p, and Series S with ray tracing, DLSS Quality). Frame times will follow here.

@DBSN-code

Copy link
Copy Markdown

I tested #2608 on an RTX 3070 8 GB with the Series S profile, DLSS Quality and frame generation off. Both builds used v2026.11.29.05 with #2853, #3474 and #3406. The candidate added only commit 01a01ee from this PR.

The runtime picked up shader sampling marks every 4 frames under pressure, compared with 30 on the baseline. The player reported steadier motion and could still see textures arriving late.

Observation Baseline With #2608
Texture queue attempts held for room 48.7% 36.8%
Median entries due for service 1,231 467
Median local memory usage relative to the DXGI budget 353 MiB over 54 MiB under
Median rendered FPS 17 16
P90 of frame times reported in window-title samples 97.8 ms 67.7 ms

The second run loaded a later story checkpoint and a larger warm pipeline cache. I compared the first 6 min 40 s of each session, selecting 3,000–4,999 draws per frame. This yielded 37 and 46 window samples and 24 and 28 queue reports respectively. A slot can count as held more than once. Different scenes and memory pressure limit what we can infer about performance.

For a follow-up I would repeat both builds from the same save and camera position. The metric I would most like to see is the time from the first observed shader use of a pending slot to the corresponding texture becoming available, with a breakdown for budget waits and upload completion. This would help explain visible pop-in even when queue totals fall.

@trustno1-coder
trustno1-coder merged commit ed8bb2e into trustno1-coder:main Nov 30, 2026
1 check passed
@nidea1
nidea1 deleted the fix/sampled-marks-readback-and-wake branch November 30, 2026 16:00
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.

4 participants