gpu(native): bound per-submission hot-texture probing in sync_dirty #28
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/28"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by claytonblythe on 2026-11-26T10:06:06Z.
Summary
During Story Mode world streaming, thousands of newly realized blank textures enter the
hotset simultaneously (t.hot = HOT = 600). Previously,Title::sync_dirty()iterated the entireself.texturesmap on everyExecuteCommandListsand allocated a freshVec<u8>(32 KiB–4 MiB) + performed 8read_guestcalls for every hot texture on every submission, collapsing frame rate during streaming.This change makes
sync_dirty()bounded and allocation-free per submission:unloaded: HashSet<usize>andhot_keys: Vec<usize>onTitle<B>sosync_dirty()no longer scans the entireself.texturesmap.probe: Vec<u8>snapshots with a 32-byteOption<blake3::Hash>(probe_hash), cutting memory overhead and eliminating per-submission heap allocations via a reusableprobe_buf.sync_dirty()toMAX_SYNC_HOT = 32textures per submission in round-robin order (hot_cursor). Small active sets (boot movie, glyph cache) are still probed every submission, while large bursts of streamed textures no longer stall the GPU thread.native::textures::tests::probe_hash_detects_writes_in_sampled_and_whole_modes.Verification
cargo test -p victory-gpu --target x86_64-apple-darwin --lib native::textures::tests— 1/1 passed.cargo test -p victory-gpu --target x86_64-apple-darwin --lib native::tests::texture_tests— 7/7 passed on Metal.cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings— 0 warnings.cargo xtask policy— 363 files ok.--console series-s,--headless,VICTORY_GUESS_GRAPHICS=1,VICTORY_DIAG=1):36.57 s) vs 16.2 FPS (63.30 s) before (1.73x faster).2.13 sper 64 frames) vs 9.1–14.6 FPS (4.38–7.03 sper 64 frames) before.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T10:09:55Z.
Review: CHANGES_REQUESTED
Nice find, and the streaming numbers look great. CI fails on Windows, though:
probe_hash_detects_writes_in_sampled_and_whole_modesasserts that hashes differ, butnative::safe_readis a no-op returningfalseoff macOS, so every probe hashes zeros there. Please gate the test with#[cfg(target_os = "macos")](asnative::testsis) and push again.Two follow-ups while you're in there:
MAX_SYNC_HOT = 32in round-robin order, a title write to a hot texture can now take up to ceil(hot/32) submissions to be noticed. Could you add a one-lineshortcut:comment stating that limit, and when to raise it?Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T10:29:59Z.
Review: DISMISSED
Pushed two small test fixes on top: the probe_hash test now only runs on macOS (safe_read is a no-op elsewhere), and texture_tests' blank-upload test syncs ceil(hot/MAX_SYNC_HOT) times, because other tests in the binary leave textures hot and the round-robin bound otherwise made it fail in the full run. The full suite passes three times in a row with clippy clean. Great speedup, thanks!
Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by claytonblythe on 2026-11-26T10:30:30Z.
Thanks for the review! Addressed both code items and rebased onto
main(a9399d9):native::textures::testswith#[cfg(all(test, target_os = "macos"))]so Windows CI doesn't run thesafe_readtest wheresafe_readis a no-op.shortcut:comment onMAX_SYNC_HOT = 32noting theceil(hot / MAX_SYNC_HOT)submission bound and when to raise it.Re: #15 / the 240 s Story Mode run:
--headlesson a 16 GB Apple M4 (--console series-s,VICTORY_GUESS_GRAPHICS=1,VICTORY_DIAG=1,VICTORY_KEYSpressing Enter through setup + selecting Story Mode), first on3d4ca18+ this PR, and then ona2940ab+ #25 + #28 + #30.mesh=0 indirect=0), actively streamingstory000.rpf,story000_restofworld.rpf,story000_bvh4.rpf, andstory000_script.rpfvia DirectStorage, activating spatial audio streams around frame 2788, and reaching frame 2880+ (recorded=16593 encoded=16593 no_pipeline=0 no_texture=0) before hitting an access violation (0xc0000005atimage+0x2215c35,info=[1, 0]) at ~240 s.Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-26T10:34:00Z.
Review: APPROVED
Re-approving after the rebase: the full victory-gpu suite passes 3x on macOS and CI is green. Thanks for the detailed #15 notes!