Skip to content

CPU side from open fxceless PRs: heap worker, plain-copy write-back, Intel mwaitx sleep, alias copies once (all behind switches) - #4

Merged
dkdknight merged 15 commits into
dkdknight:feature/levels-on-demandfrom
tibzejoker:claude/speed-batch
Nov 25, 2026
Merged

dkdknight merged 15 commits into
dkdknight:feature/levels-on-demandfrom
tibzejoker:claude/speed-batch

Conversation

@tibzejoker

Copy link
Copy Markdown

Built on #3 (and so on #2): its last four commits are new here. Four CPU-side pieces from open fxceless/victory-fork PRs, each behind its own switch, off by default (the plain-copy one rides VICTORY_COPY_PLAIN=1, on in #2's play-lod.ps1):

commit from switch what
bca1c9b fxceless#1007 (TG0000) VICTORY_HEAP_WORKER=1 textures picked by index uploaded on a thread of their own (the heap pass is 25-28 ms of the recording side a frame here)
414e7cc fxceless#1032 (UwUCammie) with VICTORY_COPY_PLAIN=1 fault-guarded in-place write-back for write_mapped
7303658 fxceless#1029 (alexis27yt) VICTORY_MWAITX_SLEEP=1 on Intel, the title's monitorx/mwaitx fence wait sleeps on the fence instead of spinning through exceptions (~280,000 a second)
02dafe4 fxceless#1015 (shawshanker18) VICTORY_ALIAS_ONCE=1 alias copies of R9G9B9E5 targets go to the list's prelude, once per source write

Conflicts were small: fxceless#1007 keeps both list helpers (defer_texture_upload, refresh_textures_ahead) and a staging texture keeps both its last change and its ahead read; fxceless#1029's log line keeps your clzero wording; fxceless#1015's prelude also runs when there are texture uploads. fxceless#1029, fxceless#1032 and fxceless#1015 were cherry-picked without their PRs' shared base commits.

Measured (RTX 4090, i9-13900K, release, #2's switches plus ASYNC_SUBMIT=2 JOIN_PARTS=1, one run each, mean of 11-12 lines once whole):

fps
this branch, none of the four switches 14.01
+ HEAP_WORKER=1 14.00
+ MWAITX_SLEEP=1 ALIAS_ONCE=1 14.24

No measurable fps change on this machine: the card is the limit here (80-90% busy). They take work off the recording and submitting threads, which should show on slower CPUs or once the card's share drops, so they are offered as switches, not turned on. (One run with all four together read 6.8 fps with the card at 100%; the three runs above, taken right after, did not reproduce it, so it looks like a bad run, but worth knowing if you see it.)

Checks: release builds; cargo test -p victory-gpu --lib passes; clippy no new warnings.

🤖 Generated with Claude Code

fxceless and others added 15 commits November 25, 2026 05:20
…queue for fetches, indirect draw windows made safer, a profiler; all behind switches

- VICTORY_ASYNC_SUBMIT=1: submissions are prepared and sent by a thread of
  the layer, in order, instead of by the title's render thread; the
  queue's line stays open while its head is prepared.
- VICTORY_QUEUE2=1: fetches of what shaders wrote to copies in the card's
  memory go to a copy queue, with the fix for a piece fetched beside a
  later flight (fetched again when that flight lands).
- Pull request fxceless#220 (cheaper indirect draws) is in, its windows off by
  default; a draw record of 2^23 vertices an instance or more runs empty
  (its window checker found one list drawing 90 such records).
- Fills of upload memory and read-only title buffer copies no longer wait
  for flights; each is checked against what the flights then wrote, and
  the first mismatch turns the waiting back on (VICTORY_FILL_WAIT=1).
- Up to 512 idle host lists and the texture staging buffers are reused.
- VICTORY_MERGE_GAP / VICTORY_MERGE_RUNS (off / 512 by default; the gap
  form is not exact, see its comment).
- VICTORY_PROFILE=1 (diagnostics builds): a sampling profiler inside the
  layer.
- README: what was measured, the history of the device losses with
  windows, and what is still open (frame rate dips; cause not known).

Measured on an RTX 4070 in the first room: about 3.5-4 frames a second
before, 6-7 with all the switches, defaults about 4.5-5. Five runs with
windows on since the fix, no device loss. This merged tree was built; its
whole test suite was not run (the tests around flights, queues, indirect
draws and the copy queue were, on the development tree).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…atch, a forbidden self-copy removed; draw windows measured at 6.0 -> 8.9 frames a second

- VICTORY_FRAME_LOG (on in diagnostics builds): every frame's length, and
  what the usual frame and each long frame were made of; VICTORY_CARD_METER
  adds the card's time by kind of list.
- VICTORY_CAPTURE_WORLD_EVERY: a saved frame costs 235 ms inside the
  present, which was the regular dip of test runs (every 8th frame).
- A driver watch (VICTORY_DRIVER_WATCH=0: off): entries of a display driver
  in the system's event log are logged as they are recorded; the first one
  turns draw windows off for the rest of the run. Every device loss here
  was announced that way 2.7 to 55 seconds ahead.
- A copy between two title textures that share one host texture is left
  out (the host does not allow a texture copied onto itself): 402 in a
  five-minute run.
- The list of shader-visible heaps is a reader-writer lock; the heap sync
  takes a changed page's records under one lock; guarded view memory is
  left out of the write-watch askings ahead (after triippywhale cc368c7,
  d0581a5).
- Behind switches, off by default: VICTORY_COPY_PLAIN, VICTORY_REFRESH_ONCE
  (after upstream 6d021fe), VICTORY_VIEW_KNOWN, VICTORY_BACK_OWN_VIEW,
  VICTORY_ASYNC_PRESENT, VICTORY_BVH_HOLD (refused: the picture loses its
  indirect light), VICTORY_CARD_REHASH_RUNS=alt.
- The process opts out of the system's efficiency mode.
- README: what the instruments measured and what is still open.

Measured on an RTX 4070 in the first room: 6.0 frames a second on average
with windows off, 8.9 with VICTORY_INDIRECT_WINDOW=1 (one run each, the
second with the driver watch; no driver entry, no device loss). This merged
tree was built; the unit tests of the changed parts were run on the
development tree, the whole suite was not. One test of the indirect budget
on the software adapter is flaky (it was before these changes).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…d a corrected comparison of draw windows

- VICTORY_COPY_PLAIN=1 also serves reads of title memory into buffers of
  the layer; reads under 256 bytes stay with the kernel and a source that
  faulted is left alone for two seconds (the first form took the layer's
  one-byte askings too: 1,000 to 1,300 faults a frame).
- The submit and copy-back threads ask for the fast cores of a hybrid
  processor (VICTORY_FAST_CORES=0: not).
- VICTORY_DISK_CORES=slow (off): the DirectStorage workers ask for the
  slow cores.
- README: the 6.0 against 8.9 frames a second given for draw windows
  compared runs in different scenes and is withdrawn; frame time against
  draws per frame is given instead. A first play session past the first
  rooms lost the device in the open world with the card out of room for
  new textures; cause not known.

Measured on an RTX 4070 (one run each): at 4,500 draws a frame 145 ms with
windows off, 124 ms with windows on and copies in place; 7-8 frames a
second in the first rooms, 10-12 in lighter views. No driver entry, no
device loss in that run. This merged tree was built; the unit tests of the
changed parts were run on the development tree.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…EAP_WORKER=1, off)

The pass over textures picked by index asks what of each due texture is mapped, makes the host
texture, makes a staging buffer and records the copy, on whichever thread of the title records the
frame's first shader that picks textures by index. With a backlog that is up to 250 ms of a frame,
and the threads waiting for that list wait with it.

With VICTORY_HEAP_WORKER=1 (needs VICTORY_LATE_WAIT) the pass runs on a thread of its own and the
recording thread only wakes it. Its uploads go into host lists of our own, which the next late
submission runs ahead of the title's lists; a texture's host slot is given its view at that
submission, not before; the title's texture and heap are held while the worker uses them; the
uploads before the decoration bake stay on the recording thread.

Off by default; the numbers go in the pull request.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
On WARP the second group's draws can win the budget; the test asserts what holds either way,
that the record that is no draw runs empty.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… our own view (9.6 fps in the first rooms)

- Meters: how the title paces itself on its fences (fence.rs pace, console_insn.rs mwaitx
  waits and exceptions by kind), the card's time by list and by pipeline (cardmeter.rs),
  indirect commands by what became of their clamp, switches that alternate inside one run.
- VICTORY_JOIN_PARTS=1: parts that follow one another in the queues' lines go to the host
  as one submission (29 -> 9 a frame), about 6 %.
- VICTORY_BACK_OWN_VIEW=1 measured and proved (VICTORY_BACK_OWN_CHECK=1): about 9 %.
- The 15-byte clzero loop is taken whole; a section handle's number coming round again
  forgets our view of the earlier section.
- Measured at nothing, left off: REFRESH_ONCE, ASYNC_PRESENT, VIEW_KNOWN, SPREAD,
  QUEUE2=3, WINDOW_JUMP.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… copy-back through our own view, plain copies, fast cores (all behind their switches)

With no new variable set the layer behaves as levels-on-demand. Overlaps:
- VICTORY_ASYNC_SUBMIT: =1 stays our line thread; fxceless's submit thread
  is =2 here, and VICTORY_JOIN_PARTS / VICTORY_ASYNC_PRESENT need it. Our
  line runs unlocked; with =2 its head keeps a Running mark meanwhile.
- VICTORY_FAST_COPY and VICTORY_COPY_PLAIN both kept (fast copy first).
- Relay fetches: our copy queue stays the default; VICTORY_QUEUE2 goes first
  when set. VICTORY_LATE_FILL_AHEAD and fxceless's checked fills both kept;
  the latter with VICTORY_FILL_WAIT=0 (default here: fills wait).
- VICTORY_LATE_MERGE_GAP/RUNS read VICTORY_MERGE_GAP/RUNS as fallbacks.
- Heap list as RwLock on both sides; one sync at a time kept; whole-page
  mirroring opt-in (VICTORY_HEAP_SYNC_PAGE=1). VIEW_KNOWN beside our
  known-view bits. List pool stays 128 (VICTORY_LIST_POOL_MOST=512).
- Made opt-in here (on upstream): VICTORY_FAST_CORES=1, VICTORY_FRAME_LOG=1,
  VICTORY_CARD_METER=1, VICTORY_DRIVER_WATCH=1, VICTORY_STAGING_POOL=1,
  VICTORY_CLZERO_LOOP15=1, VICTORY_AHEAD_SKIP_VIEWS=1, VICTORY_EFFICIENCY_MODE=0.

Dropped: fxceless's indirect clamp rewrite (group-ordered budget charging,
the 2^23-vertex record guard, scratch state tracking, the window checker
VICTORY_INDIRECT_WINDOW_CHECK, indirect/bench.rs and their tests): it is
unconditional and entangled with our card budget and zero pass, so
indirect.rs and the HostList budget code are ours. Window jumps and the
window-miss counters are kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s on

Measured on an RTX 4090, release build, same scene, mean of 12 frame
lines once whole: 12.83 fps (78.1 ms/frame) with the merge and none of
them, 13.80 fps (72.6 ms/frame) with the three.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…red form on 32-lane hosts, mesh programs over 32 KiB linked with their pixel program

Conflicts: the mesh pipeline keeps this branch's amplified variant and
builds both from the linked pair when there is one; bitcode keeps both
new helpers; the mixed-precision half takes fxceless#854's error handling; the
pixel test helper keeps pixel_with over fxceless#854's pixel_of.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The console lets a pipeline ask for blending on an R8_UINT target (it
does nothing there); D3D12 refuses the whole pipeline (E_INVALIDARG,
debug layer: "this format does not support blending"), and its draws
were dropped every frame. host_blend() clears BlendEnable and
LogicOpEnable on integer targets, per target (shared blending becomes
independent when it has to). The test fails without the change.

Measured with fxceless PR fxceless#854 merged and this: 0 pipelines refused or
shaders untranslated in the scene (7 refused and 2 untranslated
before), 13.8-14.1 fps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…x uploaded on a thread of their own (VICTORY_HEAP_WORKER=1, off)

Conflicts: both list helpers kept (defer_texture_upload and
refresh_textures_ahead); a staging texture keeps both its last change and
its ahead read, hashed when either says so; this branch's indirect budget
test, bench field and resource cfg kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… per source write

VICTORY_ALIAS_ONCE=1 (off by default). The title writes R9G9B9E5 targets as
R32_UINT and reads them through views placed in the same memory, and every
list that read one copied it again through a buffer: 78 copies a frame,
26-31 ms of the card's time on an RTX 4050 Laptop. A copy a list needs
before it touches the source or the placed texture is now recorded in the
list's prelude at submission (preludes are recorded in the queue's order,
with both textures already in the copy states the list starts with). Each
submission gets a number; lists mark the host copies they put in a writing
state; a prelude leaves a copy out if it ran in a submission after the
source's last write. Copies later in a list stay where they were.

Series X, lit world, with the window, 1080p, copy-queue fetch and rehash
runs switches: 358 -> 333 ms a frame (2.8 -> 3.0 fps); 26 alias copies made
and 20 left out a frame in preludes. The picture looked the same.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants