perf: refreshes that precede a shader write run on the wide threads #362
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/362"
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 LooperSalty/AnyXboxX. Originally posted by Skyfrye on 2026-11-26T13:05:46Z.
Change
When a list's shaders write a range of a host copy (
Step::GpuWrite), the copy's pending refresh used to run first, synchronously on the submitting thread (Batch::flush_one, thenShadow::writing). That bypassed the threads that run the other refreshes of a submission (VICTORY_WIDE_REFRESH=1, which the launcher sets). In a frame of the world those refreshes are 2.6 to 3.1 ms of the submitting thread, over some 5,200 declarations.Now the batch keeps an ordered list of steps per copy (
ShadowStep):Batch::flushruns each copy's list as one job on the wide threads (with 4 copies or more), or serially otherwise, inside the flush's one write-watch asking. A repeated declaration of the same range is skipped, aswritingandFlights::declarealready did (once per submission).card_beforeand the copy-back still take the submission's declared ranges from #383'sdeclared_in/declared_writes, as onmain(by an index withVICTORY_STEP_INDEX). The batch only keeps a set of (copy, range) to tell a range's first declaration from a repeat.Order kept:
flush_one-then-writingdid.Step::Runstill flush everything, pending writes included, before they write title memory.writing/updateas before, so the lock order matches what the relay thread already does concurrently.Texture refreshes are left as on
main. With #383'sVICTORY_PARALLEL_REFRESH(on by default since #386),Batch::flushrunscheck_textures()first, then the copies' steps: no texture check runs beside a copy's work.A note on #383, not checked by me:
watch::writesresets the kernel's write-watch notes and then records them, which is not atomic across threads. Two texture checks side by side over the same pages, not asked ahead, could miss a write for a submission. This was the reason the original commit's parallel texture refreshes were left out of this PR.Linked issue: none.
Verification
Rebased on 2026-11-26 onto upstream
mainatf9f1181, over #383. The conflicts were incard_before's declared ranges and inBatch::flush: #383's code is kept in both, and this PR's own declared-range list is dropped. Checks were run on8473267; nothing inthird_party/victorychanged from there tof9f1181.Windows 11 26300, Rust 1.98.1 (MSVC), from
third_party/victory:The 3 failures are those of
main:spans_say_the_next_start_and_the_lowest_level_viewed,warp_card_fetch_copies_flagged_pieces_to_their_slots,warp_card_patch_writes_the_masked_bytes_and_no_others.New tests in
host::batch. They do not build without the change.refreshes_merge_up_to_the_next_step_between_thema_copys_refreshes_and_shader_writes_keep_their_order: interleavings over two copies, a repeated declaration, a copy with only shader writes, and what follows a flush.a_range_given_again_keeps_no_bytes_across_flushes: each (copy, range) gives oneWrite, in the flush where it was first given.In the world, before the rebase (not repeated since), my copy of the game, Series X,
VICTORY_INDIRECT_RAW=3, the launcher's switches (VICTORY_WIDE_REFRESH=1among them): one run of 300 s with this PR stacked with the other parts of the same split (#360, #361, #362) and #278, #279, #291, #292, #307, onmainat8ed1109.main. There was no exception and no device lost.Oracle and test data
No game file.
Checklist
E_NOTIMPL), never a fake success. (Nothing unimplemented here.)AI assistance:
main. It also kept texture refreshes serial and keptcard_before's own submission, after a separate Claude Opus 5.5 review of 22d77e4 found a race and a resource-state bug there.🤖 Generated with Claude Code
Imported from LooperSalty/AnyXboxX. Originally posted by LooperSalty on 2026-11-26T15:41:32Z.
This PR now conflicts with main in
third_party/victory/crates/victory-gpu/src/host.rs(main moved with #358, #377 and #386). Please rebase on main, re-run the victory-gpu tests and force-push your branch.🤖 Generated with Claude Code
Imported from LooperSalty/AnyXboxX. Originally posted by LooperSalty on 2026-11-26T17:26:23Z.
This changes the default copy path without a flag:
Step::GpuWriteno longer flushes the copy's pending refresh right away, andShadow::writingnow runs at the flush. WithoutVICTORY_WIDE_REFRESH=1the flush runs on the submitting thread; with it, on the wide threads. Could the new order sit behind aVICTORY_*=1switch? If not, please add the in-game measurement to the PR before merge. The tests cover the order of the steps, not the write-watch behaviour on the wide threads.🤖 Generated with Claude Code
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.