perf: make textures picked by index ready off the recording thread (VICTORY_TEXTURE_PREPARE_THREADS) #395
No reviewers
Labels
No labels
accessibility
bloqué : binaire console
bug
chargeur
console-dll
cpu
documentation
duplicate
enhancement
good first issue
gpu
help wanted
invalid
performance
question
runtime-gdk
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LooperSalty--AnyXboxX!395
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-395"
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?
@Skyfrye on GitHub · 2026-11-26 16:18 UTC · original
Skyfrye:nep/texture-pass-off-thread→main· +1251 −17 · 6 files · 3 commits · merged 2026-11-26 18:07 UTCChange
VICTORY_TEXTURE_PREPARE_THREADS=N(off by default: unset or 0 runs today's code).The pass over the heap's texture views (
State::heap_textures, draw.rs) runs on the thread that records the frame. For each texture it brings in, it makes:CreateCommittedResource, or a reserved texture (resource::hosted);texture::staging).Then it records the copy. While a long queue is due, the pass may spend 250 ms (
VICTORY_TEXTURE_STAGE_MS), or 1.5 s while catching up, and it spent all of it. In the world of the title this fork works on (RTX 5080, Series X), the frame line read "heap buffers … passes 964-1740 ms" in the opening cutscene, with frames at 0.3-0.6 fps for a minute or two. Later in play, every newly streamed area gave dips to 0.6-1 fps, with passes of 678-975 ms.Where the time goes, measured with the ignored benchmark below (512 textures, 170 MB, RTX 5080, card idle):
Cold, today's 417 ms were mostly two driver calls:
The detile itself runs at submission, on the submitting thread.
With the switch,
texture/prepare.rshands each texture the pass would make to N threads of their own. They:room_lately()again before a new one;The pass records the uploads of the ones that are ready and passes over the others, which stay due. What is handed out in a frame, and what is out at once, is held to the pass's bytes a frame (
VICTORY_TEXTURE_STAGE_MB; 512 MB while catching up). The pass still asksroom()every 32 MiB handed out, and its full-card refusal runs unchanged before any hand-out. A bake draw's run still makes its textures at once.What stays as it was:
texture_slots_rechecked);texture::stagingis split so that a prepared staging buffer enters the table only when its upload is recorded.In every build, two new frame lines:
A texture now shows at least one frame later than before: it is handed out in one pass and recorded in a later one.
Linked issue: none.
Verification
Windows 11 26300, Rust 1.98.1 (MSVC), RTX 5080, on upstream
mainatf088a43(the in-game runs below were on84aa3c3; built and tested again after each rebase), fromthird_party/victory:New tests:
prepare_threads_make_the_textures_off_the_recording_threadruns in a child process with the switch at 2. Over four rounds it checks that:It does not build without the change. With the switch unset, the code it replaces fails its first check.
prepare_threads_are_off_unless_set.heap_texture_pass_benchmark(ignored: run by hand, on an idle card) gave the table above.In the world, my copy of the game, Series X, with the launcher's switches and #386's three. Two runs of the same stretch, the first 540 s, with screen captures every 15 s.
mainat84aa3c3with #354, #381, #382 and #392.VICTORY_TEXTURE_PREPARE_THREADS=2, and the rebased #360 and #362.Stacking note: #354 changes
texture::staging(base_mip, a guarded insert into the table). On top of it, this PR's split ofstagingneeds that guard in the shared insert and #354's lookup test inprepared_staging. I did that for the run above. Whichever of the two is merged second, I can rebase it.Oracle and test data
No game file. The figures come from my own runs of my copy of the game.
Checklist
E_NOTIMPL), never a fake success. (Nothing unimplemented here.)AI assistance:
🤖 Generated with Claude Code