Skip to content

D3D12.X: integration branch that reaches the in-world HUD on NVIDIA (reference, not for merge) - #2057

Draft
theaustinayers wants to merge 87 commits into
xcl-dev:mainfrom
theaustinayers:integration/nvidia-world
Draft

theaustinayers wants to merge 87 commits into
xcl-dev:mainfrom
theaustinayers:integration/nvidia-world

Conversation

@theaustinayers

@theaustinayers theaustinayers commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Draft, for reference only: the tree my runs of the newer retail title of #505 use on an RTX 5090, so that others can build and run the same thing. It is not meant to be merged as it is. Most of it is other people's open PRs; my own commits on top will be split into small PRs (list below). Merged with main at 568e7db.

The game runs listed under Tested were made with the same commits on an older base (7f7e768, no rebuild of the shader caches needed there). This merged tree has unit and GPU tests but has not run in the game yet: its compute pipelines are being built now.

What is in it

Other people's work:

New commits, each to become its own PR or a note on the PR it changes:

  • Hang and freeze: 16826cb, 3877446, c28d531 the counts of an ExecuteIndirect are read by a program of XCL's before the GPU runs them; f98a1d6 D3D12.X: a wait an earlier signal covers does not make a signal a cycle #2052's rule for title fences; 0d25b89 the console's cache flushes (list #131, Add synthetic Cargo benchmark suite #132, FlushPipelineX) are UAV barriers; dc651ea a tile a placed buffer uses stays mapped
  • Loading: 70a160e, 0764a57 on Memory: new sparse tiles are mapped together before the next submit #1517 (a mapping put off goes before a CPU or queue signal, before lists that follow a CPU wait, and after 2 ms at the latest); 6112bd8 on kernelx: commit a mapping call's sparse pages once per run, not per page #1792 (a page with data is told to the sparse windows before its bytes come: a look in between dropped them); f659f75 the mapped runs and the pieces to clear are kept in order; 77be198 a thread that maps memory lets waiting submits have the sparse lock first (171 ms median wait → 0.14 ms in a test); 04c2fe7 a texture whose memory is not all there is read region by region
  • Uploads: 80dc4dc small CPU writes go up in one dispatch; 73fc616, 0b66349, b659291, f064c82 the parts of a texture that changed go up, through lists and buffers that are kept, in order across queues; a261e72 what a file read puts into graphics memory is a known write; 55e58c3 readable asks the working set
  • Recording: 6e7040b, 2987c19 what each recorded call looks up is kept in parts with a lock each; 680a719, 0ba3b8c last releases
  • Looks: 7c18bc4 and after it (blocks written lately, a thread walks the rest; off with XCL_WATCH_HOT=0). Not strict: a write to a block that was idle reaches video memory up to about 20 ms late. a004fe7 XCL_LOOK_AHEAD=ms (off; known gaps, see its commit)
  • 414adb2 one device is opened at a time (two test threads made two and opened the memory windows for each)
  • 9baaa6f a compute pipeline's driver blob reaches the disk cache although the memory store is full; 5ea55e2 XCL_PRECOMPILE_SLICE=i/n
  • 1225bb9, 5e3c657, b5e8baf on top of D3D12.X: a copy back after a submission does not wait for the title #1993
  • Diagnostics (XCL_ACTIVITY call times, XCL_LOOK_STATS)

Tested

Regression run

  • none: a reference branch, not for merge.

Not tested

  • This merged tree in the game; AMD; other titles; a cold shader cache.

AI use

  • Claude Code, Claude Fable 5.2 and Claude Opus 5.5: wrote the new commits and their tests, made the runs on the hardware above and wrote this description. The upload and loading commits were reviewed by separate agents (Claude Opus 5.5).

🤖 Generated with Claude Code

vakaobr and others added 24 commits November 24, 2026 17:48
Helpers for the copy path that changes no behaviour yet:

- sparse.rs: extract new_state from the inline closure in init, so
  shadow_window (next commit) can call it when no sparse windows exist
- uma.rs: Uma::shadowed flag and is_gpu_copy(p): a sparse window or a
  committed one the GPU has a copy of. Never set to true in this commit.
- list_x.rs: note_copy_into tracks PC copies into console buffers whose
  memory the GPU has a copy of; note_write uses is_gpu_copy
- real.rs: uma_shadowed helper, res_map and dev_create_placed_resource_x
  use is_gpu_copy (= is_sparse while shadowed is false)

Based on Ahmet-Dedeler's c70bf8a on mac-on-main-wip.

Co-authored-by: Ahmet Dedeler <105894172+Ahmet-Dedeler@users.noreply.github.com>
Assisted-by: Claude Code (Claude Opus 4.6 ported it; Claude Opus 5.5 reviewed it)
D3DMetal 3.0 applies SetPredication for draws, dispatches and
ExecuteIndirect but not for copies: a predicated CopyBufferRegion runs
unconditionally. The UMA shadow path (next commit) makes UMA available
on this host, so the predication test would run and fail.

A one-copy probe detects whether a predicated copy is skipped (Windows,
any real D3D12) or run (D3DMetal). When run, the test skips with
"host ignores SetPredication for copies" instead of failing.

Based on us3r40456's bisect and measurement in xcl-dev#258.

Co-authored-by: Ahmet Dedeler <105894172+Ahmet-Dedeler@users.noreply.github.com>
Assisted-by: Claude Code (Claude Opus 4.6 ported it; Claude Opus 5.5 reviewed it)
D3DMetal answers E_NOTIMPL for OpenExistingHeapFromAddress. A committed
UMA window is then a buffers-only heap of video memory (Uma::shadowed),
kept in step like a sparse window's tiles (sparse::shadow_window): CPU
writes go up before each ExecuteCommandLists (the window's write watch),
GPU writes come back on Map and after the lists' memory writes, and PC
copies into console buffers there are read back after the submit
(list_x::note_copy_into). XCL_UMA_SHADOW=1 forces the path on a GPU
that has such heaps, =0 never.

On main 930e8b4: the start-up check that the GPU sees CPU writes
(check_uma_import) is not run for a shadowed window (it is a copy by
design); sparse::new_state carries the new parked list. The runner's
run_in_region falls back to upload/readback copies per window on
E_NOTIMPL. The sparse test's shadowed readback and constant-rewrite
stress validate the data path.

Part of xcl-dev#258.

Based on Ahmet-Dedeler's c70bf8a on mac-on-main-wip.

Co-authored-by: Ahmet Dedeler <105894172+Ahmet-Dedeler@users.noreply.github.com>
Assisted-by: Claude Code (Claude Opus 4.6 ported it; Claude Opus 5.5 reviewed and fixed the import-check assertion)
…ough the memory store is full

The disk cache of compute driver blobs (xcl-dev#634) wrote a blob only when the
in-memory store had taken it first: keep_compute_blob stored it there within
COMPUTE_BLOBS_MAX (512 MB) and the caller then looked it up for the file. Once
the store was full the lookup found nothing and no later build was written.
Those are the builds that matter most: a retail title's world needs compute
pipelines of 20 to 150 s each in the NVIDIA driver, made after hundreds of
smaller ones, and it built them again in every run.

keep_compute_blob now returns the blob it fetched; it is kept in memory only
while there is room (remember_compute_blob), and goes to the disk either way.

Assisted-by: Claude Code (Claude Fable 5.2)
D3D12.X: eliminate multi-heap UpdateTileMappings and per-texture Signal stalls in vram::Pages
D3D12.X: an ExecuteIndirect reads the arguments written before it
D3D12.X: promote R9G9B9E5_SHAREDEXP render/UAV targets to R11G11B10_FLOAT
`readback_after_execute` made the sparse queue GPU-wait for the title's
queue and then waited on the CPU for the copy, on the thread that was
submitting. The title's queues can wait for work that same thread submits
next (four compute queues waiting for a Write64 on q1 whose list is
recorded but not submitted yet). So the copy waited its 5 s on every such
submission, and the uploads queued behind it on the sparse queue waited
too (`before_execute` waiting for ring room). In thread dumps of a retail
title on an RTX 5090, the submitting thread is in `readback_ranges` ->
`wait_for` while another title thread waits for the sparse state's lock in
`commit_range`. lucsoft found the same cycle on RDNA3 / Linux (xcl-dev#505).

The copies now run on a queue of their own, which GPU-waits for the
title's queue, and the submitting thread returns. Readback buffers are
sized to the copy (64 KiB and up) and reused. Without a readback queue (it
could not be made), the old path runs.

The data lands in the title's memory once the copy is done, before the
title can see the work it follows is done:
- on the next submit, and from a thread that looks every 0.5 ms;
- before Map's readback and in the CPU memory waits of Wait64BitValueX
  (`settle_readbacks`), which wait for the copy once the title's lists it
  follows are done;
- in the title's fence observations: `GetCompletedValue` settles the copies
  first. `SetEventOnCompletion` hands the fence an event of XCL's own, and a
  thread-pool wait on it settles them, then sets the title's event.

The new test `a_copy_back_does_not_wait_for_the_title_queue` waits 5.0 s
on the old path and under 1 s with this change. Without the fence hooks,
the e2e test title read 0 for its Write32BitValueBottomOfPipeX after its
fence wait. With them, both e2e tests pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A retail title's intro cutscene ran at 0.3-0.5 fps with the GPU at
98-100 %, and nothing in XCL measured GPU time per draw or dispatch: the
logs could not say which console programs the GPU time went to.

With XCL_GPU_PROFILE=1 each translated draw, dispatch and ExecuteIndirect
(and an ExecuteIndirect with a PC pipeline) gets a timestamp query on its
PC list before and after it, resolved right behind it into a readback
ring of 2^17 pairs. Nothing on the CPU waits: a reporter thread takes
the written pairs every 100 ms, and every 2 s logs the 15 console
programs with the most GPU time (every 20 s also since the start):
hash, kind, calls, total and longest ms, group counts of the longest
call, and for compute the thread group size, wave64 / split form, code
and DXIL size. Ticks are converted with a title queue's
GetTimestampFrequency. Off by default; with it off each op pays one
LazyLock read.

Overlapping queues are each charged in full, so the sum can exceed wall
time; bundles get no stamps; a recording run again without a Reset is
counted once. The resolve waits on the GPU for the op to finish, so with
the profile on a queue runs its ops one after the other. The unit tests
cover the pair states and the ranking.

Assisted-by: omp (Claude Opus 5.5)
When a bridged Wait64BitValueX times out, the watchdog logs the producer
queue's state, but not the queue.Waits XCL adds on its own: texture page
mappings (vram::before_execute), sparse uploads and tile mappings, and
sparse readbacks. They are not in SYNC_GRAPH, so a producer queue that
stands behind one of them looked like a queue with "no tracked wait".

On an RTX 3080 10 GB (driver 621.01) with the retail title, every timeout
came with the producer queue (and another title queue) waiting for the
texture page-mapping fence, about 25 mappings behind after 7.7 s; skipping
that one wait in a local experiment took the CPU releases from 4 to 0-1
per run.

note_internal_wait records each such wait per queue, and each watchdog
round logs the unmet ones next to the pending title fences. The watchdog
timeout (5000 ms) can now be changed with XCL_GPU_WAIT_TIMEOUT_MS, like
XCL_WAIT_TIMEOUT_MS for the CPU waits. No behaviour change otherwise.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015JSG96tVb4ZSAZ5WH4v95v
The newer factory's CreateQueue (slot 10) takes a 0x20-byte desc whose
u64 @0x18 is the queue's DSTORAGE_QUEUE_OPTIONS; a new retail game sets
bit 0, AutoSubmitDisabled. XCL ignored it, and a half-full queue still
submitted by itself. The title writes a request's destination page list
after EnqueueRequest and before its own Submit, so a request that the
half-full submit sent to the worker could run before its list was
written, with the pages of the slot's previous request.

Such a queue now runs its requests only at Submit, and an enqueue into
it at capacity waits until Submit, a cancel or Close takes entries, as
the console's queue stalls one. Queues made without the option, or
through the first CreateQueue, submit when half full as before. Other
option bits are logged once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ir fence; looks counted against list closes (local test)
theaustinayers and others added 4 commits November 24, 2026 21:31
`would_signal_close_cycle` took every armed wait on the target cell with
`val <= sig_val` as waiting on the new signal. A wait that an earlier
signal of the cell already satisfies (submitted on the GPU or released on
the CPU) does not depend on it. With pipelined frames – queue A waits on
cell X >= N, queue B then signals X = N + 1 after waiting on something A
signals later – every such frame was reported as a cycle, signalled on
the CPU and its waiters released before the GPU work they wait for ran.

A retail title on an RTX 4070 Laptop broke 14-32 such "cycles" in each
run's world load (traced: queue 1 waiting on 0x...fde0 >= 0x6db, covered
by queue 2's earlier 0x6db signal, counted against queue 2's 0x6dc
signal). With the fix: no cycle break in two runs of the same load.

The waiters taken now are those no earlier signal covers
(`val > max(submitted_max, cpu_signaled_max)`); a test reproduces the
traced case and keeps the true cycle detected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A retail title keeps its destination page lists in slots of its own
table and writes a slot's pages after EnqueueRequest. At enqueue such a
slot can still name the pages of the slot's previous request, and the
snapshot taken then is what execute() wrote to (xcl-dev#289 rereads only the
entries that are 0). Over 16 000 requests a run were written into pages
the title had since reused: its objects got garbage pointers and it
crashed about 20 s into world loading; when the old pages were freed,
the request failed with E_ACCESS_VIOLATION.

The console reads the list when it runs the request. execute() now
reads it again (through read_own, as the snapshot) and takes it when it
differs and every page in it is allocated (kernelx::physical_pages_live);
otherwise the snapshot stays, so arrays on the stack that were
overwritten since still work.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…al a cycle"

Local test only (the upstream PR is a draft, xcl-dev#2052). On this title the change left a real
multi-queue wait cycle: at 111 s of the world load all five queues waited on each other for
values one past their completed ones, the watchdog released 102 GPU waits and the title froze.
The cycle breaks logged before the change had been the false positives it meant to avoid; the
true ones it no longer breaks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@minimalhipster990

minimalhipster990 commented Nov 25, 2026 •

Copy link
Copy Markdown

Follow-up on RTX 4090 with #1798 applied to this reference head

Adding #1798 got this machine through the long presentation pause and into the opening titles. Over the same 54 s of world loading (about 168–222 s on XCL’s clock), the clean build logged 0 presents and the patched build logged 345, averaging 6.4 presents/s. This is one run per build.

Clean #2057 #2057 + #1798
Worker stacks at 180, 200 and 220 s Same title worker in execute_indirect → resolve_wait → Condvar::wait in all three No thread sampled in that wait in any of the three. At 165.720 s XCL logged skipping pending indirect calls.
Screen Loading background or black in all samples after setup. Two late presents around 240–242 s fell between readbacks. First legible prologue card at 171.619 s, “Rockstar Games Presents” at 186.157 s, then the animated logo. The operator heard the intro audio and observed stuttering. No recognizable world geometry or gameplay HUD in the 30 captures from 167.681 to 222.318 s.
End Device removal 0x887a0005 at 244.098 s, then title breakpoint 0x80000003 at +0x2474606. Still presenting at the last activity sample. The runner stopped the process when available Windows system commit fell to 0.93 GiB. Peak sampled process private memory was 38.65 GiB. No device removal appeared in the log before the stop.

Both used release MSVC builds of 4df1e6e3d40a011501c046148b6aa470437aa2eb; the only source delta was #1798 (55e7beb6de9fcc8817d40d0a663857e3553c3632, applied locally). RTX 4090 24 GB, driver 621.40, Ryzen 7 5800X3D, 32 GB RAM. Same switches as the original report, DRED off, fresh title profiles, identical scripted input and readback every 12 presents. Each arm started with a separate byte-verified copy of the same warm XCL cache (6,432 files). The clean arm ran first. NVIDIA’s internal cache was uncontrolled.

This pair shows the opening sequence can present on this 4090 with #1798. Time in playable 3D, post-HUD stability and the cause of the control’s device removal remain unverified. AI use: OpenAI Codex (GPT-6) built the patched tree, ran both arms, checked logs, stacks and images, and drafted this update. The audio observation came from the operator.


Original four runs on clean #2057

RTX 4090 24 GB, NVIDIA 621.40, clean 4df1e6e. World loading stopped presenting in four runs. The longest ran for 900 s. A fourth run with thread dumps caught the same title worker waiting inside ExecuteIndirect in all four samples taken after presents stopped.

Run, in order Compute cache DRED Last 2 s interval with any presents ended at Total PresentX Cutoff
1 Partial On 168.057 s 4,242 600 s
2 Fully precompiled On 168.061 s 4,357 600 s
3 Reused Off 164.061 s 4,291 900 s
4, thread dumps Reused Off 166.085 s 4,350 250 s

What was on screen. After setup, every frame sampled on the way into the world showed the loading background with a spinner, or black. No in-world HUD or visible world geometry in those samples. All four processes exited at their configured cutoff with code 0, a null crash field and no device removal in the XCL log.

Where the wait was. In run 4 at 180.079, 200.071, 220.061 and 240.069 s, TID 144556 had the following stack, resolved with the release build’s matching PDB (caller first):

title+0x248d19f
  bind::execute_indirect             bind.rs:267
  pso_async::resolve_wait            pso_async.rs:541
  std::sys::sync::condvar::futex::Condvar::wait

TID 150820, which logged the first PresentX and the last captured frame, sampled at a different title address (title+0x56a0d) in all five dumps, including at 155 s while frames were still appearing. The stack above identifies the call site changed by #1798. The samples leave open whether the worker was waiting on a graphics or compute pipeline at each instant, whether it was the same pipeline across samples, and whether that wait held up the presenter.

Cache reuse. During run 3, after the last interval with any presents, XCL logged 76 large graphics pipeline builds starting without a driver blob and 75 finishing before cutoff. In run 4, XCL supplied blobs for 110 of 120 logged large graphics builds across the whole run. After the last present interval it started seven more without a blob. This may help compare with the cache progression on the RTX 5090.

Setup. Windows 11 build 26300, Ryzen 7 5800X3D, 32 GB RAM, retail 1.0.2.1, release MSVC build. Fresh title data and identical inputs each run. Used the five switches from the PR description (XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_UMA_SHADOW=1 XCL_COHERENT_HEAPS=sparse:16 XCL_LOOK_SKIP=1), network off, frame readback every 12 presents. Between runs 1 and 2, all 2,689 compute pipelines precompiled with zero errors or refusals. XCL’s disk cache carried over between subsequent runs. NVIDIA’s internal cache was uncontrolled. Post-HUD stability, intermediate render targets and #1798 remain untested here.

AI use: OpenAI Codex built the branch, ran the tests on the hardware above, checked the sampled images and stacks, and drafted this report.

@HKEY-Funk-Machine

Copy link
Copy Markdown

AMD RX 9070 (RDNA4) reaches the world with the HUD drawn: this branch + #2163 + two refused programs. ~4 fps for ~3 min, then a device reset that took the whole PC down (hard hang, no bugcheck).

Follow-up to my 7152473795 and 7153653511 above, and to #675 7153836855. One run, same machine, warm caches.

Setup: AMD Radeon RX 9070 16 GB (driver 32.0.32015.7029, native wave64), Ryzen 9 7945HX3D, 32 GB RAM, Windows 11 Pro 26300, release. Tree: this PR at 8ff4b02, plus 0d25b89 (its runtime part), plus #2163's two commits (637b82a, 78fba7b; one line in real.rs conflicted with this branch's submit timing and I kept both). Local, not for upstream: xgameruntime/api.rs (start-up hang here; XCL_NO_PC_RUNTIME=1) and an XCL_REFUSE_CS list (the program takes the untranslated path; its dispatches are skipped) with 39f23deaf6a63310, b78fa10b425b8e54 (@madaraXor's pair on #675) and 95cc13288a27a96e. XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_PSO_WAIT_MS=50 XCL_GPU_PROFILE=1 XCL_PRESS_A_AT=8,10,…,90 XCL_RUN_SECONDS=600, no XCL_UMA_SHADOW, compute caches filled first (XCL_PRECOMPILE_SLICE), the same exe name as earlier runs.

world loading (first ListX #101) ~69 s
on screen loading art, the prologue's first title card, then the intro (audio, captions on a black screen), then the world: the minimap drawn bottom left, flickering, the scene black
in the world ~4 fps (3 300 frames by ~517 s)
work 2 761 456 dispatches (7 558 skipped), 524 288 draws (198 421 skipped, 137 544 with PC pipelines)
#2163's check fired once: a command list is submitted while its previous submit is still on the GPU (the same recording, the same queue; #1 so far). So the re-submit happens on AMD too
Wait64BitValueX time-outs / GPU waits over 5 s 1 / 0 (my runs without #2163 ended after several on one cell)
end 0x887a0007 (reset) at ~543 s and the title's 0x80000003 at +0x2474606; seconds later the machine stopped responding and needed a power cycle. Windows logged only Kernel-Power 41 / an unexpected shutdown: no bugcheck, no dump, no live kernel report
memory 39.8 GB private, 54 GB system commit at the end (32 GB RAM)
  • On this card, the barriers took the run from hanging ~30 s into the world load to the first title card. The refusals then kept the GPU up, and with D3D12.X: a list reset while its last submit runs records on a spare #2163 it went through the intro into the world. Each step on its own is in the earlier comments.
  • What still compiles in the world: 33 big graphics pipelines (only compute was precompiled), and 241 big compute ones given a cached driver blob that the AMD driver built again anyway. @Rednaxeh saw the same rebuilds on RDNA3 above.
  • A warning for AMD testers: the reset at the end took Windows down with it here. I'd keep in-world runs on AMD short (XCL_RUN_SECONDS) until that is understood.

Not tested: more runs (this is one); the newer heads of this branch; graphics pipelines precompiled; why the two refused programs do not finish on AMD; why the reset brought the system down.

AI use: Claude Code (Claude Opus 5.5) built the tree, ran the run, read the logs and the Windows event log, and wrote this comment.

@Rednaxeh

Copy link
Copy Markdown
Contributor

@HKEY-Funk-Machine one correction to the RDNA3 reference, so that it does not stand as "AMD rebuilds cached blobs": on the RX 7800 XT the driver blobs XCL keeps do work. In a warm run of the same build every big compute program an earlier run had built came back driver blob supplied in 1–5 ms (the whole chain of twenty 270–330 KB programs and the 0.5–1.1 MB ones, 418 of them in the 900 s run); what was compiled again were programs no earlier run had created (82 new records in the second run, 25 of them over 256 KB), because the title asks for different pipelines as it gets further. If your 241 had a blob from the same build and the same driver and were still rebuilt, that is a different case from mine and worth its own look (a blob of another build, or of a --pipelines pass under another exe name, is refused by design: AMD keys its cache by application).

@frenziedcoder

Copy link
Copy Markdown

RTX 5080 16 GB, driver 621.40: #1798 on top of 4df1e6e removes the long stop at world load here too (frames every 30 s instead of none between 90 and 210 s), but what follows is a flat dark-grey frame at about 0.5 fps, and the run ends in a device removal with a DRED page fault at VA 0x0 at 424 s. One run per row, so this is a data point next to @minimalhipster990's RTX 4090 run above, not a measurement.

Setup: NVIDIA GeForce RTX 5080 16 GB (driver 621.40, 32-lane waves), AMD Ryzen 7 9800X3D, 64 GB RAM, Windows 11 Pro 26200, release. Trees: this PR at 4df1e6e unchanged, and 4df1e6e with #1798 (55e7beb) merged (clean merge, only bind.rs). Retail title of #505, 1.0.2.1. XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_DRED=1 XCL_NETWORK=0 XCL_FRAME_DUMP=30, scripted A presses every 4 s from 20 to 120 s, 600 s limit. Compute pipelines precompiled for 621.40 with XCL_PRECOMPILE_SLICE=i/4 (2,689, 0 refused); graphics pipelines warm from earlier runs for both rows.

Without XCL_UMA_SHADOW:

4df1e6e 4df1e6e + #1798
presents per 30 s after the world load starts (~50–63 s) 98, then 0, 0, 0, 0 (90–210 s), then 10–15 117, then 10–16 in every window, no gap
GPU utilisation (nvidia-smi) ~0 % from 65 to 223 s, then 100 % in stretches 100 % from 76 to 372 s
presents after the world load starts 93 341
screen (frame dumps) flat dark grey flat dark grey
end no removal; last present 416 s, ran to the 600 s limit 0x887a0005 at 424 s; DRED: page fault at GPU VA 0x0, no allocation there or recently freed
peak local video memory (whole GPU, nvidia-smi) 15,867 MiB 15,879 MiB

With XCL_UMA_SHADOW=1 (same switches otherwise): the #1798 tree kept presenting from 66 to 118 s, then 0x887a0006 at 121 s with a DRED page fault at VA 0x0; the one list DRED shows partly done (25 of 30) stopped inside a run of CopyTextureRegions (op 8), the same picture as @kanade333's. Video memory sat at ~15,845 MiB from 99 s. The 4df1e6e run with the shadow was stopped by my own guard at 57 s (15,904 MiB > a 15,900 MiB limit I keep on this card), so there is no pair for that row.

So on this card #1798 turns the stop into slow grey frames rather than a wait, and the run then ends in the VA 0x0 page fault. My frame rate in the world is far below @kanade333's 10–12 fps on the same card; I ran without XCL_COHERENT_MB=512 and with XCL_WATCH_HOT at its default, and with DRED and frame dumps on.

Not tested: more than one run per row; XCL_COHERENT_MB=512 / XCL_WATCH_HOT=0 with #1798; #2270 together with #1798; runs without DRED.

AI use: Claude Code (Claude Opus 5.5) built the trees, ran the title on my machine, read the logs and frame dumps, and wrote this report.

@claudetools-gh

Copy link
Copy Markdown

A test report on this branch from an RTX 5070 Ti: it reaches the in-world HUD here too. The minimap showed bottom left for about a second at ~250 s, over the grey scene (nothing of the 3D drawn), after the intro. That was one run of several; the others ended earlier (below).

Setup: RTX 5070 Ti 16 GB (Blackwell), Ryzen 7 9700X, 62 GB RAM, Windows 11 Pro 26300, release. Retail 1.0.2.1, Series X profile.

What a run looks like: menus at 30 fps, loading artwork, the intro's opening titles with subtitles and audio from ~100 s at about 2 fps, then the grey scene; in the run above the minimap at ~250 s.

What changed things on this card, in order:

Still open here:

  • The world is grey: a probe of the targets at an intro frame shows 254 draws with the 2560×1440 depth target bound and it left at its clear value everywhere, the G-buffer the same (Memory: more than 4 memory windows once #680 lands, so title memory stops falling back to plain memory #697).
  • The GPU is busy ~90 % of the time in that stretch, mostly in a few small compute programs with 100–355 ms dispatches (24de2aef6c31d55e, b78fa10b425b8e54, 1b5466f261a70cde, d79af1d04922a49b).
  • Two runs ended in a title crash, a read of 0xFFFFFFFFFFFFFFFF (game+0x54a5543 at 314 s, game+0x4e8b4be at 183 s), the same kind @DTsordas reported on AMD.

Not tested: more runs of the HUD configuration; AMD; this PR alone without the rest of the stack.

AI-assisted.

@frenziedcoder

Copy link
Copy Markdown

Follow-up to my #1798 pair above, same RTX 5080 / 621.40 / trees: with @kanade333's switches the long stop isn't there even without #1798, so in my first pair the stop goes with the default switches. Both runs still end in the VA 0x0 page fault.

Switches: XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_COHERENT_HEAPS=sparse:16 XCL_LOOK_SKIP=1 XCL_COHERENT_MB=512 XCL_WATCH_HOT=0 XCL_DRED=1 XCL_NETWORK=0 XCL_FRAME_DUMP=30, same A presses. No XCL_UMA_SHADOW: with it this card's video memory reaches my 15.9 GB guard. One run each.

4df1e6e 4df1e6e + #1798
presents per 30 s from 60 s 211, 100, 51, 6 208, 107, 37, 41, 65, 52
GPU utilisation ~100 % from 65 s ~100 % from 86 s (one dip at 108 s)
presents after the world load starts (62 s) 285 433
end 0x887a0005 at 153.6 s 0x887a0005 at 227.9 s
DRED page fault at GPU VA 0x0, no allocation the same
screen flat dark grey flat dark grey
  • So under these switches D3D12.X: a draw does not wait for a graphics pipeline still being built #1798 makes no difference I can tell apart from run-to-run spread; the gain in my first pair is the default switches' stop going away.
  • That is about 1–3.5 fps in the world, against 0.5 fps with the default switches and @kanade333's 10–12 fps on the same card with XCL_UMA_SHADOW=1 (610.88). I can't run the shadow here inside my memory limit, so I can't say whether that's what makes the difference.

AI use: Claude Code (Claude Opus 5.5) ran the title on my machine, read the logs and wrote this follow-up.

@HKEY-Funk-Machine

Copy link
Copy Markdown

@Rednaxeh thank you, you're right, and I withdraw "the AMD driver built them again anyway" from my 7164354843. My precompile ran as xcl_pre*.exe and the title as another exe name, so the driver refused the blobs by design (its cache is keyed by application).

Rerun with the precompile and the title under the same exe name, RX 9070 (driver 32.0.32015.7029), main 06c9f55 + 0d25b89 (local), XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_PSO_WAIT_MS=50, 300 s, nothing refused:

  • 68 of the 75 big compute builds in the run came back from their blob in under 100 ms.
  • The other 7 were driver blob absent: programs my precompile had not reached yet (I stopped it part-way). They took 22–34 s each and are what the run then waited on, from ~107 s to the end.
  • No device removal in this run on current main with nothing refused (the earlier 8ff4b02 runs needed 39f23deaf6a63310 / b78fa10b425b8e54 refused).

So on RDNA4 too, the cached blobs work when the names match. For AMD testers: run --precompile … --pipelines under the same exe the title runs as.

AI use: Claude Code (Claude Opus 5.5) ran the runs and wrote this comment.

Ariorh1337 added a commit to Ariorh1337/xcl that referenced this pull request Nov 25, 2026
`readback_after_execute` made the sparse queue GPU-wait for the title's
queue and then waited on the CPU for the copy, on the thread that was
submitting. The title's queues can wait for work that same thread submits
next (four compute queues waiting for a Write64 on q1 whose list is
recorded but not submitted yet). So the copy waited its 5 s on every such
submission, and the uploads queued behind it on the sparse queue waited
too (`before_execute` waiting for ring room). In thread dumps of a retail
title on an RTX 5090, the submitting thread is in `readback_ranges` ->
`wait_for` while another title thread waits for the sparse state's lock in
`commit_range`. lucsoft found the same cycle on RDNA3 / Linux (xcl-dev#505).

The copies now run on a lane per title queue: a fence the title's queue
signals after its lists, and a queue of its own that GPU-waits for that
fence. The submitting thread returns. With one fence for all title
queues, a later signal on another queue let a copy start before its own
queue's lists ran (CharlyRien); with one queue for all, a title queue
waiting for work still to come held back the copies of the others.
The lanes (8) are made in `init`, before the device's methods are hooked:
made later, a lane's queue was adopted as one of the title's, and the e2e
title under the debug layer read 0 for what its lists wrote. A lane serves
a title queue while that queue has copies back in flight; with all lanes
busy (or none made), the old path runs. Readback buffers are sized to the
copy (64 KiB and up) and reused; idle ones above 256 MB are given back
(each holds commit, and with the title's queues stalled every submit's
copies wait, one buffer each; found by Chrysana's RDNA4 run). Each time the
buffers pass another doubling from 64 MB, their size is logged.

The data lands in the title's memory once the copy is done, before the
title can see the work it follows is done:
- on the next submit, and from a thread that looks every 0.5 ms;
- before Map's readback (waiting for the copy once the title's lists it
  follows are done), and in the CPU memory waits of Wait64BitValueX, which
  only try the sparse state's lock: its holder can be waiting for work the
  waiting thread is to submit;
- in the title's fence observations: `GetCompletedValue` settles the copies
  first. `SetEventOnCompletion` hands the fence an event of XCL's own, and a
  thread-pool wait on it settles them, then sets the title's event.
  These only try the lock; a copy whose title work is done but which still
  runs is waited for with the lock let go, then landed. Waiting for it with
  the lock held stood every submit behind a copy that stood behind a stalled
  GPU (lucsoft, RDNA3).
Lanes land in their own order, so an older copy back of one lane can land
after a newer one of another: it leaves the bytes the newer one landed.
A CPU wait for a copy uses its lane's event, not the sparse state's: a wait
that gave up leaves its registration behind, which set the shared event
later and ended a tile-queue wait early (theaustinayers, in xcl-dev#2057).

Tests:
- `a_copy_back_does_not_wait_for_the_title_queue` waits 5.0 s on the old
  path and under 1 s with this change;
- `a_copy_back_waits_for_its_own_title_queue`: two title queues, the first
  blocked; with one lane for both, the first one's copy lands before its
  list ran;
- `an_older_copy_back_does_not_overwrite_a_newer_one`.
- `a_copy_still_running_after_its_title_work_is_waited_for_outside_the_lock`.
- `idle_copy_back_buffers_above_the_cap_are_given_back`.
They run on a WARP device of their own: they block a queue on purpose, and
on the GPU's device, which the tests in the process share, other queue
tests then hung in the driver releasing resources (upipibi; reproduced in 3
of 3 runs of the d3d12x queue tests). Without the fence hooks, the e2e test
title read 0 for its Write32BitValueBottomOfPipeX after its fence wait.
With them, both e2e tests pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bstillbstill

Copy link
Copy Markdown

Test report for #2057 at 4df1e6e on a smaller machine than the 5090: the recommended settings run the menus at
3–5 fps here; without XCL_COHERENT_HEAPS=sparse:16 it runs at 30 fps and gets through the scene start, then the
silent 0x887a0005 comes ~18 s later.

Setup

Runs (all with XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1)

run build more env result frames
g1 4df1e6e XCL_UMA_SHADOW=1 XCL_COHERENT_HEAPS=sparse:16 XCL_LOOK_SKIP=1 3–5 fps from the first menu, never reached the world; no removal 872
g3 + upload wait – (coherent window in place, UMA import check: ok) 30 fps; world-load burst at 64 s; 0x887a0006 + nvlddmkm 153 at 70.2 s ~1,900
g4 + upload wait XCL_UMA_SHADOW=1 XCL_LOOK_SKIP=1 30 fps; burst at 64 s, then 16 s at 7–9 fps (28–42 k dispatches / 2 s); stopped presenting at 82 s, no removal, exit 0 1,641
g5 + upload wait same as g4 same picture; 0x887a0005 (no nvlddmkm event) at 83.3 s –
g6 + upload wait same as g4 burst at 62 s, 11 s at 6–9 fps; 0x887a0005 at 73.6 s –
g7 + upload wait same as g3 burst at 70 s; 0x887a0006 at 74.8 s –
  • Why g1 is slow here: submit cost, average of 1024 ExecuteCommandLists: 28.33 ms … (look 20.96 … textures 6.92), 11 submits/s. The look watches ~10.4 GB (looks for CPU writes: … 535 MB a look on average (10441 MB watched in 9 ranges)): XCL_COHERENT_HEAPS=sparse:16 put the title's GPU heaps (1172 + 2199 + 563 + 596 MB)
    into the sparse windows. 15 GB of RAM stayed free, so it is not paging. Without that switch (g4) the look is
    0.15–0.22 ms a submit.
  • What g4/g5 show after the burst: the cutscene's title card renders correctly, then letterboxed flat grey with the
    cutscene's subtitles (the "grey scene").
  • No GPU wait released by the watchdog and no cycle break in any run.

Not tested: main alone with these switches; AMD; runs past 300 s; the 0x887a0006 in g3 with Aftermath (no dump).

AI use: Claude Code (Claude Opus 5.5) built the trees, ran everything above and wrote this report.

@jennydeth

Copy link
Copy Markdown

RTX 3060 12 GB / 32 GB RAM, this merged tree 4df1e6e in the game: the loading screens present for longer than on main, but the world is not reached. With the description's settings the device is removed (0x887a0006) at 98 s; without XCL_UMA_SHADOW there is no removal, but no frame after ~104 s to the end of 600 s. Commit reaches 39.5–40.8 GB in both, ~10 GB over main on the same load and over this machine's RAM. One run of each.

Setup: NVIDIA GeForce RTX 3060 12 GB, driver 32.0.16.2101 (wave32), Ryzen 5 5600X, 32 GB RAM, Windows 11 Pro 10.0.26300.9974. Release build of 4df1e6e as it is (not rebased), DXC 1.9.2609.5. Retail title 1.0.2.1, XCL_NETWORK=0, XCL_FRAME_DUMP=300, profile already past the first-run flow, A presses on the same schedule as my main run in #846. Before run 1, xcl shaders <shaders.rpf> --precompile --only cs --pipelines --used-only: 325 made, 0 refused, 0 errors, 76.8 s.

  • Run 1: the description's settings, XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_UMA_SHADOW=1 XCL_COHERENT_HEAPS=sparse:16 XCL_LOOK_SKIP=1
  • Run 2: the same without XCL_UMA_SHADOW, right after run 1 (driver blobs from run 1 in the cache)
xcl-smoke v1
commit: 4df1e6e3d40a011501c046148b6aa470437aa2eb
gpu: NVIDIA GeForce RTX 3060
title: 4a4b54dc
seconds: 600
exit: 0x887a0006
frames shown: none logged (the run did not reach its end)
presents per 2 s (last 3): 56 23 40
device removals: 1
crashes: 1
peak commit: 39515 MB
xcl-smoke v1
commit: 4df1e6e3d40a011501c046148b6aa470437aa2eb
gpu: NVIDIA GeForce RTX 3060
title: 4a4b54dc
seconds: 600
exit: 0x0
frames shown: 2268 (PresentX 2268)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 40776 MB
run 1 (with UMA shadow) run 2 (no UMA shadow) main 06c9f55 (#846)
story load starts ~74 s ~72 s ~68 s
last present-bearing 2 s window 98 s (frames up to the removal) 104 s 100 s
end D3D12 device removed: 0x887a0006 at 98.2 s still running at 600 s, black still running at 600 s, black
world reached no no no
peak commit 39 515 MB (at 98 s) 40 776 MB (at 378 s) 30 827 MB
video memory at peak: local / non-local 20 978 / 853 MB 17 570 / 4 895 MB 13 888 / 4 721 MB
sparse pools 6 144 MB 6 144 MB 1 920 MB
AS slot – refused / would close a GPU cycle / wanted at once 40 / 0 / 0 40 / 0 / 3 40 / 0 / 0
  • Run 1: every 2 s window has frames through the load until the removal at 98.2 s (no DRED lines in the log), the same class as the RTX 5060 Laptop removals in The retail title 1.0.2.1 (RTX 5070): reaches the end of the first-run setup, then deterministic 0xC0000005 write at 0x0 in game_scarlett_master.exe+0x23cf683 #846 at 122–125 s. Local video memory is at 21 GB on a 12 GB card at that moment.
  • Run 2: no removal, but after 104 s the activity windows are empty except for 704 dispatches and 215 draws in 500 s. 103 of 105 driver compiles finished, 77 of them after 104 s; the last two (compute, 845 KB and 748 KB of DXIL, driver blob absent) started at 592 and 595 s. Three huge graphics pipelines wanted at once (no slot) at 182 s (738–740 KB of DXIL, the first 11.9 s), like the description's second 5090 run.
  • Memory: taking XCL_UMA_SHADOW off did not lower the commit (39.5 → 40.8 GB). Against main, the visible differences in the memory line are the sparse pools (6.1 vs 1.9 GB) and the local video memory over the card's 12 GB. I have not split it further by setting or commit.

Not tested: a second run of each setting; the tree without XCL_HEAP_WINDOWS / XCL_COHERENT_HEAPS; the unit / GPU suite on this tree; AMD; a machine with more RAM.

AI use: Claude Code (Claude Opus 5.5) built the tree, ran the precompile and the title on my machine, read the logs and wrote this.

@bstillbstill

Copy link
Copy Markdown

@claudetools-gh could you push the tree from your RTX 5070 Ti run, the one that went 20 minutes without the silent 0x887a0005, as a branch, with your local ExecuteIndirect whole-form change in it? I'd like to run that exact tree on an RTX 3090 Ti (Ampere), where the removal still comes in the world.

What I have on this card so far (details on #2270): #2270 on top of #2057 changes nothing (removed 105–133 s with it, 97–130 s without, same day), and its probe passes here. So if your tree holds on this card, the main merge is the likelier half of what stopped it for you; if it doesn't, the difference is the card. Merging #2057 into today's main myself conflicts in 10 files, and I'd rather test what you ran than my own resolution of it.

The branch and its commit are all I need; the switches are in your comment.

AI use: Claude Code (Claude Opus 5.5) wrote this comment.

@claudetools-gh

claudetools-gh commented Nov 25, 2026 •

Copy link
Copy Markdown

@bstillbstill I'd rather not push a branch: we keep this account anonymous and don't upload files with their metadata, so we help in text. Here is the exact recipe for that run instead, and one caveat about it that matters for your comparison.

Caveat first: the 20-minute run without a removal (on main 1a0bbe3, before the whole-form change) did not keep the title moving: presents stopped at ~110 s while it compiled 146 new compute pipelines in the driver, one after another, to the end. So "no removal" there may mostly mean "the title didn't advance to where it removes". The later runs on the same merge that did keep presenting (with XCL_PSO_WAIT_MS=50 and the whole-form change; on a tree that also had main afc5ee8 merged and #2306 + the #2308 stack) had no silent 0x887a0005 either: the three that ran to their end ended in a title crash reading 0xFFFFFFFFFFFFFFFF at 183–622 s. Before the merge, every warm run on this card lost the device at 130–420 s. So the merge plus #2270 does look like what stopped the removal here, but with the title crash taking its place I can't say how far past it the world would get.

The tree of that run (XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_UMA_SHADOW=0 XCL_WATCH_HOT=0 XCL_PSO_PRELOAD=0 XCL_NETWORK=0), in order:

  1. D3D12.X: integration branch that reaches the in-world HUD on NVIDIA (reference, not for merge) #2057 at 4df1e6e.
  2. treybertram06's upload wait in title_textures.rs (super::vram::before_execute(&q); before submit_on(dev, &q, &items) in the title-queue arm, as on Retail game (retail title, Series X build): GPU device removal after Wait64BitValueX waits with no producer; also watchdog stalls on slow compute pipeline builds #1452).
  3. D3D12.X: execute two-pass mesh shaders on DispatchMesh and ExecuteIndirect (supersedes #724) #2092 (99b9816…47c7cc1), D3D12.X: a console MS in the AS slot is translated as the mesh shader it is #541's own four commits (70f9185, 48c1517, 7654a2a, 6bd8f64; its three Recompiler: commits are already in the base), D3D12.X: shaders that index the heaps themselves get the heaps' addresses #1803 (cb00751), D3D12.X: the console's DispatchMesh indirect argument (107) is a PC DispatchMesh #1887 (5fe5b41), plus D3D12.X: shaders that index the heaps themselves get the heaps' addresses #1803's heap addresses passed to both two-pass stages (two_pass_io takes the list's heaps and calls with_heaps(l, None, user_data_ms(..), heaps) for the compute pass and with_heaps(l, None, user_data_gfx(..), heaps) for the mesh pass).
  4. git merge origin/main at 1a0bbe3. Conflicts in six files; every one kept both sides:
  5. D3D12.X: unmap a superseded texture only once the work before it is done #2270 (b7f6b76) on top; it applied cleanly after the merge.

That is all of it for that run (no #2306, no page-alias stack, no whole-form change yet). If you would rather skip the merge, the cheaper comparison is probably main itself today plus #2057's handful of commits you need, since Kalmarv's #2372 / #2404 now cover the ExecuteIndirect whole form properly.

AI-assisted.

@shortside

Copy link
Copy Markdown

A Mac data point for the stop @kole07139 describes above (#2057 (comment)) and again on main in #1773 (comment): the same sequence shows up on Apple's D3DMetal, on a different tree, so it does not look tied to NVIDIA or to this branch. On the Mac the title then goes on for two more frames before the queue stops.

Setup. Not this PR's tree: @vakaobr's mac/integration at 5f9a58f (the Mac branch mac7 plus #615, #1405, #1993 and Mac fixes, see #258), release build. MacBook Pro M5 Pro, 24 GB, macOS 27.2.1, CrossOver 26.3, D3DMetal (32-lane waves). The retail title of #505 (my own copy), device_type = "lockhart", raytracing = "off", XCL_VRAM_ARENAS=1 XCL_PSO_WAIT_MS=50, HLSL path, compute pipelines built as the title asks for them, A pressed every 6 s. One run, 330 s. Details of the three runs of that evening are in #258 (comment).

The sequence

s what the log has
up to 193 37 – 47 presents per 2 s
194.9 – 195.1 8 × Wait64BitValueX at … >= 0xeec bridged to GPU queue.Wait (waiter=q0/q2/q3/q4, prod=qSome(1)/tySome(0); wait-before-signal, after_write64=false)
195 – 197 0 presents, 7 submits, 4,812 dispatches in the 2 s window
196.5 split command list (type 2) around mid-list Wait after Write64 (#1)
197 – 221 no presents, almost no submits; compute pipelines are being built (one of 823,448 B of DXIL took 5.5 s at 221 s)
220.8 – 222.3 splits #2, #3, #4
221 – 226 two presents, with 2,533 and 6,044 dispatches and 74 and 222 draws in their 2 s windows; on screen one flat colour after black
229.4 4 × GPU queue.Wait at … >= 0xeee did not complete within 5000 ms (… recorded=0xeef, submitted=0xeed/0xeee, completed=0xeed) – released on CPU to prevent GPU hang
after no present; writes after the GPU … although their queue had not got there after 10000 ms every 10 – 20 s; the title's stall watchdog fires three times and is skipped; D3D12 queue drain: GPU fences still pending after 10 s at exit

Same as on the RTX 3070: the burst of dispatches with no presents, the mid-list split right after it, the Wait64BitValueX … wait-before-signal lines, and a flat-colour frame followed by black.

Different: here the producer of every wait is named (prod=qSome(1) or qSome(4), none qNone), the title presents twice more about 25 s after the first split, and the stop is reported: the GPU-wait watchdog releases four waits at 229 s. I have no thread dumps of that run, so I cannot say what the title's threads wait on.

Not tested: this PR's tree on the Mac; main; a second run; compute pipelines built ahead (the 25 s without presents may be nothing but pipeline builds).

AI use: Claude Code with Claude Fable 5.2 built the tree, ran the run on my machine, read the log and wrote this comment.

Ariorh1337 added a commit to Ariorh1337/xcl that referenced this pull request Nov 25, 2026
`readback_after_execute` made the sparse queue GPU-wait for the title's
queue and then waited on the CPU for the copy, on the thread that was
submitting. The title's queues can wait for work that same thread submits
next (four compute queues waiting for a Write64 on q1 whose list is
recorded but not submitted yet). So the copy waited its 5 s on every such
submission, and the uploads queued behind it on the sparse queue waited
too (`before_execute` waiting for ring room). In thread dumps of a retail
title on an RTX 5090, the submitting thread is in `readback_ranges` ->
`wait_for` while another title thread waits for the sparse state's lock in
`commit_range`. lucsoft found the same cycle on RDNA3 / Linux (xcl-dev#505).

The copies now run on a lane per title queue: a fence the title's queue
signals after its lists, and a queue of its own that GPU-waits for that
fence. The submitting thread returns. With one fence for all title
queues, a later signal on another queue let a copy start before its own
queue's lists ran (CharlyRien); with one queue for all, a title queue
waiting for work still to come held back the copies of the others.
The lanes (8) are made in `init`, before the device's methods are hooked:
made later, a lane's queue was adopted as one of the title's, and the e2e
title under the debug layer read 0 for what its lists wrote.
A copy back's allocator and list are made with the device's own methods,
past its hooks (`real::create_own_list`), as `init`'s objects are: made
through the adopted device, the list took XCL's list hooks on the lane's
queue, and vkd3d-proton crashed at its Close (St5sz2Jk, RDNA4 / Wine).
Tiles quarantined behind the title queues' marks (xcl-dev#2345) also wait for
the copies back still to run on a lane: they read the windows after the
title's work. A lane serves
a title queue while that queue has copies back in flight; with all lanes
busy (or none made), the old path runs. Readback buffers are sized to the
copy (64 KiB and up) and reused; idle ones above 256 MB are given back
(each holds commit, and with the title's queues stalled every submit's
copies wait, one buffer each; found by Chrysana's RDNA4 run). Each time the
buffers pass another doubling from 64 MB, their size is logged.

The data lands in the title's memory once the copy is done, before the
title can see the work it follows is done:
- on the next submit, and from a thread that looks every 0.5 ms;
- before Map's readback (waiting for the copy once the title's lists it
  follows are done), and in the CPU memory waits of Wait64BitValueX, which
  only try the sparse state's lock: its holder can be waiting for work the
  waiting thread is to submit;
- in the title's fence observations: `GetCompletedValue` settles the copies
  first. `SetEventOnCompletion` hands the fence an event of XCL's own, and a
  thread-pool wait on it settles them, then sets the title's event.
  These only try the lock; a copy whose title work is done but which still
  runs is waited for with the lock let go, then landed. Waiting for it with
  the lock held stood every submit behind a copy that stood behind a stalled
  GPU (lucsoft, RDNA3).
Lanes land in their own order, so an older copy back of one lane can land
after a newer one of another: it leaves the bytes the newer one landed.
A CPU wait for a copy uses its lane's event, not the sparse state's: a wait
that gave up leaves its registration behind, which set the shared event
later and ended a tile-queue wait early (theaustinayers, in xcl-dev#2057).

Tests:
- `a_copy_back_does_not_wait_for_the_title_queue` waits 5.0 s on the old
  path and under 1 s with this change;
- `a_copy_back_waits_for_its_own_title_queue`: two title queues, the first
  blocked; with one lane for both, the first one's copy lands before its
  list ran;
- `an_older_copy_back_does_not_overwrite_a_newer_one`.
- `a_copy_still_running_after_its_title_work_is_waited_for_outside_the_lock`.
- `idle_copy_back_buffers_above_the_cap_are_given_back`.
- `a_copy_back_list_of_an_adopted_device_is_not_adopted`.
- `quarantined_tiles_wait_for_copies_back_still_to_run`.
They run on a WARP device of their own: they block a queue on purpose, and
on the GPU's device, which the tests in the process share, other queue
tests then hung in the driver releasing resources (upipibi; reproduced in 3
of 3 runs of the d3d12x queue tests). Without the fence hooks, the e2e test
title read 0 for its Write32BitValueBottomOfPipeX after its fence wait.
With them, both e2e tests pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.