Refresh the textures new to a submission on several threads (less texture pop-in on a Radeon 8060S; no frame-rate change shown) #222
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Belobug--VIctory-Belobug-AMD!222
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-222"
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?
@SPFCChris on GitHub · 2026-11-26 03:19 UTC · original
SPFCChris:perf/parallel-texture-refresh→main· +30 −5 · 1 files · 1 commits · openWhat this changes on screen was judged by eye and by a slot count, not by frame rate: I could not show a frame-rate change either way. It was measured on top of #148, #178 and #179, not on
mainalone. See "Measured".What it is for
While a scene streams in, many textures become visible to bindless slots at once. Each such texture is queued (
texture::upload_first) and, at the next submission,Early::takeread, hashed and detiled them one after another on the submitting thread. On a Radeon 8060S that is where textures arrive late after a scene cut.The change
One place,
Early::takeinhost.rs(30 lines):late, and not already refreshed in this submission).in_parallel, several at a time. EachStaginghas its own buffer, its own notes and its own lock, andBatch::texture_duelets a texture in only once, so no two threads touch the same one.VICTORY_TEXTURE_THREADS=0refreshes them one after another, as before. With one texture due nothing is spread.The textures the lists themselves ask for (
Step::Textureinrun_deferred) are still refreshed in turn; that is a separate step.The repository's
rx9070xtbranch does the same thing its own way (VICTORY_WIDE_TEXTURES,Batch::refresh_textures).Measured
Radeon 8060S (Ryzen AI Max+ 395), diag build, Series X profile, opening cutscene, 220 s in the world per run. All on
main(4f62c2a) plus #148, #178, #179 (with its fix), the terminator fix of #156/#207 and local diagnostics, with the switches of #215 off. On that buildin_parallelkeeps its threads (#178); onmainalone it makes them at each call, which I have not measured with this change.By eye: the two first runs with this on were the first on this machine without badly late textures after scene cuts.
A pair on one build, every frame logged (slots waiting = bindless slots not yet made, which show nothing):
VICTORY_TEXTURE_THREADS=0Two more runs with it on, against one run of the build before it: 1,118 and 1,068 frames against 1,141; 26 and 29 stalls (28.8 and 31.0 s) against 49 (41.7 s).
What I take from this: a third fewer slot-seconds in the pair, fewer stalls in one comparison and no change in the other, and frame rates that differ by less than two runs of the same build do (about 10 % here). The texture refresh itself costs more processor time summed over the threads (7.6 ms a frame against 4.9).
Stability
DEVICE_HUNG), and of two runs with this on and the switches of #215 on, one hung the whole machine (GPU engine timeout). I do not think this change is the cause (it happens with it off too), but I cannot rule it out from five runs.Tested
cargo test -p victory-gpu --lib --lockedon this branch: 113 passed, 0 failed, 4 ignored, in six runs of seven. In the first run after a clean buildpipeline::library::tests::concurrent_atomic_writes_publish_one_complete_filefailed and the test process ended with an access violation; it passed alone and in every run after. I have not looked into that test.cargo clippy -p victory-gpu --locked: 40 warnings in the library, as onmain; none in the changed lines.Not tested
mainalone renders wrongly on this GPU without #148).diagnostics.Early::takeneeds a device and a title's lists.AI-assisted (Claude Code); no game data.
🤖 Generated with Claude Code
@adrianmjim on GitHub · 2026-11-26 19:54 UTC · original
Native Windows results for
032e27e, base4f62c2a. Machine: Windows 11 (build 26300), Radeon RX 7900 XT (driver 32.0.32029.2010), 16 logical CPUs, Rust 1.98.1. Other jobs were running on the machine at the same time. I did not run the game.The description says this was not measured on
mainalone, without #178. The timings below cover that case.Code reading (build without
diagnostics):refreshwrites only its own staging buffer and takes only its ownlastlock. Two shared locks are involved: the write-watch journal, and briefly the windows map incommitted(). The journal is held acrossGetWriteWatch. For write-watched textures the queries therefore still run one at a time. Only the copy and the detiling run in parallel.refreshcallsin_parallel, so no call is nested inside another. The barriers are added in the same order as before.SCRATCHis per thread. Onmainthe helper threads are new at each call. Each one allocates and zero-fills a buffer as large as the largest texture it reads, at every call. With #178 the five kept threads each keep their buffer, up to 64 MiB each. I did not measure this.rx9070xt(81ebb7b),Batch::refresh_textures(host.rs:7962) also takes the write-watch journal throughwatch::writes(texture.rs:1186) and keeps one read buffer per thread (texture.rs:423-440). It runs on kept threads (wide_each, shadow.rs:1580), so it does not pay the per-call thread cost measured below onmainwithout #178.Local test, not part of the PR:
upload_firstuses. Sizes from 16x16 to 1024x1024, RGBA8, inSW_64KB_D,SW_4KB_Sor linear layout. Half are in write-watched memory and half are hashed.VICTORY_TEXTURE_THREADS=0. It also passed 5 times in each of those four setups on this PR merged with #178. The read-backs were identical in every run.Timing of
Early::takealone: release build, no GPU work, measured after the 7900 XT device is created. Each figure is the median of 5 alternating runs of 30 takes, in µs. Before each take, every texture's memory was changed, unless the row says "unchanged". The=0column is this PR withVICTORY_TEXTURE_THREADS=0.=0mainalone, this PR was faster in every row that took 300 µs or more with=0. It was about even at 174 µs. Takes with little work, or with unchanged write-watched textures, cost about 210 µs instead of 26 to 78 µs.VICTORY_HELPERS=0(threads made at each call), the figures are close to "this PR". So the extra cost onmaincomes from making the threads. With #178 andVICTORY_TEXTURE_THREADS=0, they match=0.=0in every row where the textures had changed. Unchanged write-watched textures were still slower than=0: 58 against 26 µs, and 113 against 77 µs.cfg(test). I left those cases out.Unit tests (
victory-gpu --lib, debug), alternating runs: 70 of4f62c2a, 70 of this PR, and 30 of this PR with=0. Runs with at least one failure: 17 on4f62c2a, 16 on this PR, 12 with=0.watch::guard-page tests: failed on all three.queue::tests: 1 run on4f62c2a, 2 with=0, 0 on this PR.query::tests::queries_not_run_keep_their_stand_in_values: 1 run with=0only.pipeline::library::tests::concurrent_atomic_writes_publish_one_complete_file: 4 of 70 on this PR, 1 of 30 with=0, 0 of 70 on4f62c2a. It has failed on4f62c2aon this machine in earlier runs, and the description mentions it too. It also failed with=0, whereEarly::takeuses no threads.descriptor::host::tests::bindless_plan_is_remade_only_when_slots_change: 1 of 70 on this PR, 0 of 70 on4f62c2a. It failed at its first assert (first.reads.len()was 0, not 1). That test only builds a heap's bindless plan and does not submit anything. I don't think it is related, but one failure is not enough to rule it out.Not tested:
diagnosticsfeature.I have the test as a local branch if it is useful.
@gut0to on GitHub · 2026-11-27 14:42 UTC · original · reviewed
AI-assisted static review (ChatGPT); I inspected the diff but did not run tests.
@ -3001,0 +3014,4 @@dirty[i].store(true, Ordering::Relaxed);}}};@gut0to on GitHub · 2026-11-27 14:42 UTC · original
Could this parallel refresh/result-to-barrier path be factored behind an injectable refresh callback and covered by a deterministic test?
dirtyis indexed separately fromdue, then the original order is used to emit transitions; a mixed set completing out of order should still refresh each eligible staging once, skip used/duplicate entries, and transition only changed textures in submission order. Covering both serial and parallel modes would protect the new ordering invariant without requiring title data or a GPU.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.