Host: harden write-back scratch scope, fallback, and buffer residency #1392
No reviewers
Labels
No labels
AMD
audio
bug
confirmed
crash
cutscene
dlss
documentation
duplicate
enhancement
fixed-on-main
frame-generation
good first issue
help wanted
input
INTEL
invalid
lighting
linux-proton
memory
needs-info
needs-logs
needs-rebase
NVIDIA
performance
pr-diagnostics
pr-docs
pr-feature
pr-fix
pr-performance
pr-refactor
pr-tests
question
RAYTRACING
rendering
report
series-s
shaders
spam
startup
upstream
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/trustno1-coder--VIctory-NVIDIA!1392
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1392"
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?
@Bazovsky on GitHub · 2026-11-28 18:44 UTC · original
Bazovsky:pr/writeback-scratch-and-submit-hotpaths→main· +79 −32 · 1 files · 1 commits · merged 2026-11-29 08:16 UTCFixes #
What it changes
Follow-up hardening for
writeback_upload_buffer/VICTORY_SCRATCH_WB(introduced inf67a453):crates/victory-gpu/src/host.rs): switchwriteback_upload_bufferfromnot_resident()/resident()tobuffer_not_resident()/buffer_resident()(matchingupload_buffer_own) soVICTORY_WAIT_RESIDENT=texturesskips residency waits on write-back scratch buffers as reported by @GreekNinja.<= SCRATCH_CHUNKchunks:scratch_wb(host)now defaults on only whenVendorId == 0x10DE && !arch.UMA(still overridden byVICTORY_SCRATCH_WB=1/0). Oversized> 4 MiBscratch allocations and streamingplane_uploadbuffers always stay write-combined (upload_buffer/take_chunk(..., false)).upload_buffer_maybe_wblatches write-back off only on capability refusal (E_INVALIDARG,E_NOTIMPL,DXGI_ERROR_UNSUPPORTED), avoids callingresidency::allocation_errorbefore the write-combined fallback is tried, and countsMADE[0..2]on success only (preventing double-counting on fallback).Spare::take_if+take_spare_wbkeepplane_uploadstrictly on write-combined chunks while allowing write-back scratch callers to prefer write-back chunks and still reuse write-combined fallback chunks inSPARE.host::tests::spare_pool_separates_streaming_and_reuses_wb_fallbacks.How it was tested
writeback_upload_buffercallednot_resident()/resident()directly (ignoringVICTORY_WAIT_RESIDENT=textures), defaulted on for non-NVIDIA/UMA adapters, used write-back for> 4 MiBscratch &plane_uploadchunks, loggedallocation_erroron fallback, and retried unsupported drivers every chunk.d4b5d51(3407c8d),cargo xwin clippy --target x86_64-pc-windows-msvc --locked --no-deps -p victory-gpu --all-targetsand--features diagnosticscheck clean (0 new warnings), native Windows unit tests pass including the newSPAREpool separation/fallback test.cargo testpassed for the crates it touches: yes (victory-gpu: 551 passed, 0 failed — 514 non-watch + 37watch::testsserial).Checked for overlap
pool.rsuntouched to avoid conflicting with #1553).gpu: write-back L0 HostList scratch buffers, zero-COM Chunk.gpu, lock-free Card::before, and unified parallel send::taketo gpu: harden write-back scratch fallback/pool scope and add mapped() barrier (follow-up to f67a453)38fd3d93aato438622a0c4@GreekNinja on GitHub · 2026-11-28 21:11 UTC · original · edited 2026-11-28 21:14 UTC
Great hardening work on
writeback_upload_buffer! One additional issue we measured on923e38c(RTX 3060 12 GB + 16 GB RAM,VICTORY_WAIT_RESIDENT=textures):crates/victory-gpu/src/host.rs:10031, 10039:writeback_upload_bufferstill callsnot_resident()andresident(&self.device, b)?directly instead ofbuffer_not_resident()/buffer_resident()(unlikeupload_buffer_own,shared_buffer_own,mapped_card_buffer, anduav_buffer).crates/victory-gpu/src/pool.rs:1133, 1143-1146:pool::cpu_bufferlikewise callshost::not_resident()/resident()/mapped()directly.On our 16 GB rig with
VICTORY_WAIT_RESIDENT=textures, this caused 16,000MakeResidentwaits (12.7 s, max 665.1 ms) in ~6 minutes before any OOM occurred; settingVICTORY_SCRATCH_WB=0droppednew memory waited forfrom 16,000+ to 0 (and eliminated81,489no write-back upload buffererrors during memory pressure).Suggestion for this PR or a small follow-up:
writeback_upload_buffer(andpool::cpu_buffer) tobuffer_not_resident()/buffer_resident().<= 4 MiBwrite-back scratch buffers from&SHAREDinpool::cpu_buffer(sameCUSTOM / WRITE_BACK / L0heap withD3D12_RESOURCE_FLAG_NONE) so 256 KiB / 4 MiB scratch chunks don't each create a committed L0 heap.Note: This report/comment was generated and submitted automatically by an AI assistant analyzing real local play logs and source code on behalf of the user.
gpu: harden write-back scratch fallback/pool scope and add mapped() barrier (follow-up to f67a453)to Host: harden write-back scratch scope, fallback, and buffer residency438622a0c4to3407c8d52e@Bazovsky on GitHub · 2026-11-28 22:39 UTC · original
Thanks @GreekNinja! Rebased onto
d4b5d51(3407c8d) and updated:writeback_upload_buffertobuffer_not_resident()/buffer_resident()(matchingupload_buffer_own, without an extrabuffer_mapped()barrier).0x10DE,!UMA) and pooled<= 4 MiBchunks, keepingplane_uploadstrictly write-combined while still reusing write-combined fallback chunks inSPARE.pool.rsuntouched here to avoid conflicting with #1553.clippy(default +--features diagnostics) andvictory-gpunative Windows tests (551 passed, 0 failed).@GreekNinja on GitHub · 2026-11-28 22:45 UTC · original
Awesome, thanks @Bazovsky for the super fast update and for keeping
pool.rsconflict-free with #1553! That cleanly addresses theVICTORY_WAIT_RESIDENT=texturesbypass we hit on RTX 3060 12 GB + 16 GB RAM — we'll re-test with defaultVICTORY_SCRATCH_WBonce merged.Note: This comment was generated and submitted automatically by an AI assistant on behalf of the user.
3407c8d52eto837bae7293@Bazovsky on GitHub · 2026-11-29 01:43 UTC · original
Rebased onto
origin/main(d585f88->837bae7) after15ad118+34672adlanded the earlier revision onmain. This PR now carries only the follow-up hardening delta (buffer_not_resident/buffer_residentper @GreekNinja,take_spare_wbfallback reuse inSPARE+ unit test, discrete NVIDIA0x10DE && !UMAdefault, and narrowerWB_OKlatch codes). Verified withclippy(default +--features diagnostics, 0 new warnings) and native Windowsvictory-gputests (590/590 pass).