Nvidia dev #2572

Open
github-bot wants to merge 371 commits from github-bot/gh-2572 into main AGit
Owner

@⁠bmjask on GitHub · 2026-11-25 23:18 UTC · original
theaustinayers:nvidia-dev → main · +34213 −2749 · 89 files · 371 commits · open

What is in it

Tested

  • hardware (GPU + driver, CPU), Rust version, debug / release:
  • cargo test --workspace -- --test-threads=4: N passed, N failed, N ignored (SKIPPED GPU tests: …)

Regression run

main:

PR:

Not tested

AI use

  • none / tool and model, and what it did
**@⁠bmjask** on GitHub · 2026-11-25 23:18 UTC · [original](https://github.com/xcl-dev/xcl/pull/2572) `theaustinayers:nvidia-dev` → `main` · +34213 −2749 · 89 files · 371 commits · open <!-- What changes and why, in a few sentences. "Fixes #N" / "Part of #N". Stacked: "Stacked on #N". --> **What is in it** - **Tested** - hardware (GPU + driver, CPU), Rust version, debug / release: - `cargo test --workspace -- --test-threads=4`: N passed, N failed, N ignored (SKIPPED GPU tests: …) **Regression run** <!-- Required when the PR changes crates/xcl/src outside tests: `scripts/smoke.ps1` on a real title, built from main and from this PR's head commit (no uncommitted changes); paste both blocks. Rerun the PR's after every push. Not needed for docs / tests / scripts only. --> main: PR: **Not tested** - **AI use** - none / tool and model, and what it did
A retail title's NGG transform programs (128 vertices / 128 primitives,
21 params + SV_ClipDistance0 = 352 B per vertex) all failed ms_6_6 with
"vertex plus primitive output size is greater than 32768": the split
budget divided 32768 by the stride, but DXC accounts whole chunks of 32
vertices even when fewer are declared - verts[78] at 352 B is accounted
as 96 (33792 B) and refused. Measured with dxc 1.8.2502 on this machine:
every boundary from 9 to 26 float4 rows agrees with the chunk model.

passthrough_split now floors the vertex budget to a multiple of 32
(capped at 256); the wide records go out in 7 groups of 19 triangles
instead of 5 groups of 26 that DXC refuses. Test: the wide record splits
and compiles, a 96-vertex group at 320 B compiles, a narrow record stays
whole; fails without the change (5 != 7).

Assisted-by: DSH (GPT-6.2 Astra)
The emitter picked the whole-record layout from passthrough_split == 1, but
that count is the dispatch's: a record of 80 vertices with 22 float4 rows
does not fit the mesh output budget as a whole (DXC accounts 96 vertices,
33792 B > 32768) while its single triangle's compact copies fit one group,
so the count is 1 and verts[80] was declared and refused. The declaration
now follows the vertex budget independently of the group count; the compact
form covers every record over the budget, including the one-group ones.

mesh_layout_independent_of_group_count covers the asymmetric limits (80
vertices, 1 triangle, 22 rows): compact declaration, count 1, DXC accepts.
Found in review by shdann (PR #304).

Assisted-by: DSH (GPT-6.2 Astra)
Review nits (Parakeet-Wheat): mesh_layout_independent_of_group_count ended with a block that rebuilt the same MsInterface and asserted verts[3] again; it now compiles the whole-record declaration (verts[80], accounted as 96: 33792 B) and asserts DXC refuses it. passthrough_split's doc claimed a comparison of the two forms it does not make; the doc now states what it does. Tests only plus a doc line; no behaviour change.

Assisted-by: DSH (GPT-6.2 Astra)
A retail title's minimap pipelines carry their console MS container in the AS
subobject with no MS subobject. They were refused: translated, the title had
rendered nothing from then on. That black screen was the translated mesh
shaders failing their ms_6_6 output budget, fixed by the DXC vertex-chunk
budget (#304); the slot itself was never the problem. With the budget in
place the same shaders translate and the title keeps rendering.

mesh_shader_slots moves the container to the MS slot (and it is not an AS any
more); a real AS, an MS already present, or a PC shader are left as they are.
Unit test covers all five cases.

Assisted-by: DSH (GPT-6.2 Astra)
The title creates tens of thousands of console-MS-in-AS-slot pipelines during boot and uses few. Translating each in the cached-only attempt ran on the title's thread: on RTX 3060 Ti the intro's first bright frame came ~5 s later than main (frame 1100 vs 980 at XCL_FRAME_DUMP=120), and on RX 9070 XT (wave64, the split path) Chrysana's 60 s captures stayed black throughout with 57163 pipelines queued. The attempt now defers a moved MS like a console compute pipeline (dxc::defer under pso_async::lazy): go_background hands the title a stand-in and the worker or the first bind translates. The detection log moved to a sparse counter at the build (first 5 + every 1000th); it used to fire twice per deferred pipeline (2930 lines in 120 s).

Assisted-by: DSH (GPT-6.2 Astra)
fallback_stream decided 'mesh' by an MS subobject; the retail title's moved-MS streams have none (the console MS sits in the AS subobject), so the stand-in emptied the AS and kept a plain PS: a stream with neither a VS, CS nor MS, which the driver refuses (E_INVALIDARG). go_background then returned None and dev_create_pipeline_state built every such pipeline in the title's call, so the deferral never took effect (NishantParajuli on RTX 5060 Ti, Chrysana on RX 9070 XT: black frames, ~57k pipelines queued; thehollowedone's native fixture: D3D12 message 1022, no VS/CS/MS). The stand-in of such a stream retypes the AS subobject to MS with the dummy mesh shader and uses the mesh dummy's PS, as translated_mesh_stream reads the title's stream; a real AS is emptied as before. Test the_stand_in_of_a_moved_ms_is_a_mesh_pipeline fails without the change.

Assisted-by: DSH (GPT-6.2 Astra)
The retail title's depth-only mesh pipelines use console-only formats (D16_UNORM_S8_UINT). allback_stream copied the title's formats as they were, so the driver refused the stand-in (E_INVALIDARG). go_background then returned None and dev_create_pipeline_state built every such pipeline in the title's call, so the deferral never took effect (NishantParajuli's follow-up, reproduced natively by thehollowedone). The stand-in's RENDER_TARGET_FORMATS and DEPTH_STENCIL_FORMAT now go through device_x::pc_target_format, as the real pipeline's do. Test 	he_stand_in_of_a_stream_has_the_pcs_target_formats fails without the change.

Assisted-by: DSH (GPT-6.2 Astra)
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 <[email protected]>
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 ivall/xcl#258.

Co-authored-by: Ahmet Dedeler <[email protected]>
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 #258.

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

Co-authored-by: Ahmet Dedeler <[email protected]>
Assisted-by: Claude Code (Claude Opus 4.6 ported it; Claude Opus 5.5 reviewed and fixed the import-check assertion)
A root signature with CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED or SAMPLER_HEAP_DIRECTLY_INDEXED has the
console put the 32-bit address of the bound view heap / sampler heap into user SGPRs after the
root arguments, the view heap's first. XCL left these registers 0, so the shaders read their
descriptors from address 0 on.

Measured on a retail title: 110 of 153 root signatures at its first screen have one of the flags.
All 540 of its compute shaders with such a root signature that were built (218 with the view heap
flag, 3 with the sampler heap flag, 319 with both) have exactly one user SGPR more per flag than
their arguments take; those with both load T# from the first. The pixel shaders of 49 572 pipelines with the
sampler flag have one more as well (by where their m0 comes from). The pictures of its loading screen took a wrapping sampler
instead of the clamping one they ask for: a flickering line at their top edge.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The disk cache of compute driver blobs (#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)
Console mesh shaders translated to a two-pass pair (compute + mesh/PS,
TwoPassPso) were built by CreatePipelineState but had no execution path:
DispatchMesh was not hooked on the console command list vtable, and
ExecuteIndirect did not dispatch the compute pass or bind the record
buffer (u1) before invoking the mesh pass.

Hook DispatchMesh (slot 127, newer layout slot 129) and handle TwoPassPso
in ExecuteIndirect:
- Track console mesh root-argument layout (s[8:9] spill table, inline
  arguments from s16 across 16 SGPRs) in console_list::user_data_ms.
- Create a companion DISPATCH command signature alongside non-root-changing
  DISPATCH_MESH command signatures in device_x::create_command_signature_x.
- Allocate/recycle a DEFAULT-heap UAV record buffer per command list
  (recycled on allocator reset), bind u0 (io), u1 (res), u2..u5 (UMA),
  run the compute pass -> UAV barrier -> mesh pass -> UAV barrier, and
  scale indirect DispatchMesh group counts on the GPU when
  mesh_groups_per_record > 1.

Assisted-by: Antigravity (Gemini 4 Neon)
Without IO_UMA_BASE_HI the pair picked no memory window for any access.
DispatchMesh runs at most the groups the buffer holds; ExecuteIndirect's
arguments are rewritten on the GPU with the same bound for both passes.
Both passes index records by gid.x, so the rewritten arguments put x·y·z in X.
The rewrite reads the commands through the memory window, not the title's buffer
in a guessed state, into shared scratch blocks capped at 16 MiB a recording.
CreateCommandSignature passed the console's argument type 107 to the PC,
which refuses it (debug layer 743, "Unexpected parameter type"). A UE5
title (Xbox Series build) creates its DispatchIndirectMeshCommandSignature
with this one argument and stops at E_INVALIDARG during RHI init. It now
becomes D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH_MESH, as DispatchX (105)
becomes Dispatch. A refused signature is logged with its arguments.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Each command's records start at record 0, so its mesh pass draws them before the
next command's compute pass; commands past a count buffer's count get no groups.
Keep NGG compute and passthrough mesh graphics driver blobs under independent canonical keys. Retry rejected entries under the existing cold-compile policy and validate fresh-process replay, per-pass corruption, and GPU output on synthetic inputs.

Part of #1269. Related to #1836 and #902.

Assisted-by: OpenAI Codex (GPT-6)
A black presented frame does not say whether the scene was drawn and the
composite lost, or the scene never drawn at all; nor which of the draws
that should have made it actually ran. XCL_FRAME_DUMP shows only the
presented image.

XCL_DUMP_TARGETS=<work>[,<frames>]: in the first <frames> frames (default
1) with at least <work> draws and dispatches, each render target drawn
into, and the depth buffer drawn with most, is logged with its address,
size, format and its draws split into ran (translated pipeline), stand-in
(pipeline still being built: draws nothing), PC (untranslated) and
skipped. The eight drawn into most are read back with the presented frame
and written next to it (target<k>_<n>.bmp), with how many of their
sampled texels are not zero and how many differ from the first one (a
cleared target has none that differ). The census reads by the footprint's
texel size and stops at the end of the readback buffer. The depth buffer
is not copied: XCL does not know the state the title left it in, and a
copy from DEPTH_WRITE is invalid. A frame counts as dumped once its
copies are submitted; one waiting for a present that copies is kept.

XCL_DUMP_AFTER_S=<s>: no frame is dumped until <s> seconds (fractions
too) after the first present (a title's menus are busy frames too).
Invalid values of either switch are logged once.

Off by default: every hook returns on a cached check of the switch, and
DSVs are only recorded with it set, so nothing is locked or allocated
without it.

Assisted-by: Claude Code (Claude Opus 5.5)
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 (#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 <[email protected]>
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 <[email protected]>
Claude-Session: https://claude.ai/code/session_015JSG96tVb4ZSAZ5WH4v95v
With XCL_HEAP_WINDOWS=1 the pair reads the memory windows from the shared heap, as
bind_abi's programs do; a list that set none got no heap.
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 <[email protected]>
`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 <[email protected]>
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 (#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 <[email protected]>
Local test only (the upstream PR is a draft, #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 <[email protected]>
When a draw's arguments find no room in unified memory (the arena's pool is used up and the
window has no free run), log once (and every power of two) the window's free bytes, largest
free run, bytes in use, pool blocks left and the blocks the pending allocators hold. Log the
title's GPU heaps that do not fit in the coherent window.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A title's GPU heaps (committed with a PAGE_GRAPHICS_* protection) go to
the coherent window, process memory the GPU reaches over the bus. On an
RTX 5090 a shader's dependent reads there are ~30x slower than from video
memory (no L2 hits, about 2.4 us each). Its store instructions whose lanes
leave gaps (per-lane dwordx2/x4, 8- and 16-byte formats) run at ~0.1 GB/s,
against ~50 GB/s for lane-contiguous ones and >1 TB/s in video memory. The
retail title of #505 keeps 4.4 GB of heaps there (1172, 2199, 563 and
596 MB), and its world passes take 0.4-2.7 s each. Keeping the heaps out
of the window was reproduced as removing the stall on an RTX 5080, an
RTX 3080 and RDNA3 / Linux (#505), but there the shaders read zeros.

With `XCL_COHERENT_HEAPS=sparse` every such heap, with `sparse:N` those of
at least N MB, goes to the sparse windows instead: video memory, with the
CPU's writes uploaded before each submission, like the title's other
graphics memory. A heap that goes there is not counted in the coherent
window's size for the next run (`note_coherent_need`). Off by default: it
costs a second copy in video memory and the write-watch scan of it, and it
needs the asynchronous copies back of the commit below. Without them, the
copies back of the title's lists' writes into these heaps wait for the
submitting thread.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The watchdog's first three time-outs log, for every GPU wait not yet met, which queue waits for
which value of which cell or title fence, and which submitted signal (queue and its place among
that queue's calls) will meet it; a wait for a value nothing has signalled yet says so. Used to
find the loop all five queues of a title were in.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Every 1024 ExecuteCommandLists, the log says how long one took on average: the wait for the
refresh lock, the refresh itself (look for CPU writes, state lock wait, chunk scan, upload and
the rest, from the existing counters), the PC ExecuteCommandLists and everything XCL does after
it (signals, copies back), and the submits a second. A few relaxed adds a submit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A retail title keeps 65,000 textures in step with its memory. Every submit went through all of
them for the ones whose memory changed, and every change of a page mapping in a GPU view
re-checked the source of each (with a VirtualQuery): 2-9 ms a submit. Now the textures are
indexed by the 1 MiB pieces of their source and the waiting ones are kept in a set, so a submit
looks at those the dirty pages touch; a mapping change re-checks only the textures in the changed
ranges (kernelx keeps the ranges of the last 4,096 changes).

The looks for CPU writes join hot blocks up to 64 MiB apart (XCL_WATCH_GAP_MB), keep a block hot for
1.5 s (XCL_WATCH_HOT_MS), and the walk thread makes fewer, larger calls.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A submit's scan (64-byte chunk hashes of 4 KiB pages) took up to 1.6 ms and the copies into the
ring up to 2 ms of one thread in a heavy scene. From 256 pages on the scan is cut into pieces of
64 pages, from 512 KiB on the copies into about 16 pieces, and the submitting thread shares them
with XCL_COPY_THREADS (4) worker threads that wait between jobs. The results keep the address
order, and the thread does not go on before every piece is done.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
title_textures::refresh runs on the title's thread before each of its
submits and uploaded the CPU's writes to its textures on XCL's own queue,
then waited on the CPU until the GPU had run them (texture::upload_batch).
While a retail title streams its world with video memory past the card,
those waits are long: thread dumps show its submit thread blocked in
fence::wait under refresh, presents drop to a few per 20 s, and the title's
watchdog ends it on the loading screen.

When the submitting queue is a DIRECT queue on the texture's device, the
upload list now runs on that queue, ahead of the title's lists, so the GPU
orders the copies before the work that samples them, with no cross-queue
wait. A fence on that queue retires each batch's allocator, list and staging
buffers at later submits; over 512 MB in flight the oldest batches are waited
for, and a batch whose wait fails or times out stays in flight. Compute and
copy queues, and a queue of another device, keep the upload queue and its
wait. texture::submit_batch is upload_batch without the wait.
A title's loads write gigabytes of its memory with XCL's own copies (DirectStorage), and the looks
for CPU writes found those pages through the write watch: each written 2 MiB block stayed hot for
1.5 s and every look walked it, which is most of what a look costs while a title loads. Now the
DirectStorage writers tell the next look their ranges (`note_known_write`) and clear the write
watch for the pages inside them; the pages at the ends stay watched. The next submit takes the
ranges as dirty pages, also when it skips its look. `XCL_DS_KNOWN_WRITES=0`: as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
From a review of the local changes:
- The fence cells the title reads (`fence_x`) are stored after the copies back a value covers have
  landed (a value the title waits for promises the memory behind it), read and stored one refresh
  at a time.
- A copy back (and a stored immediate) lands 64-byte chunk by chunk, never over a chunk the CPU
  wrote since it was last sent: those bytes are newer and go up with the next look.
- `settle_readbacks_within` waits for the state's lock up to a bound; GetCompletedValue no longer
  spins 2 ms per copy back.
- Memory the title commits, and the memory of a texture it places, is looked at for a while
  (`mark_hot`): a write made right after the commit was seen up to 20 ms late.
- A copy back that finds no readback buffer still signals its queue's fence; at most 32 finished
  readback buffers are kept; `pagelog::counts` takes no blocking lock in the exception filter.

Loading:
- The watched ranges are made of 16 MiB blocks of the textures' sources, not from all textures (tens
  of thousands of them, each submit while a title loads).
- A DirectStorage destination in a sparse window is written without a VirtualQuery (a query there
  walks the whole committed heap: 3-5 ms a request, with a 2 GB heap). A part the title gave back
  fails the write (`write_title`).

The unit test of #1993 waits for the per-queue fences now. `submit_cost` also counts ranges,
re-checks and texture uploads.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The counts come from memory the GPU wrote. Where that is not what the title meant (a wait that was
released early, memory another resource used before) they can be anything, and a dispatch of
billions of groups holds the GPU for seconds or until Windows resets the driver: in a retail
title's world the culling passes (wave64 split in halves, RTX 5090) ran for 1.4 to 30 s in 4 of 8
runs. Measured with this: six ExecuteIndirects within 1 ms with counts like 0xff000000 x 0xe3 x
0xff7f0000, not run, and no program ran longer than 0.5 s in that run.

A program of XCL's own reads the counts first (through the memory window the shaders write),
hands them to the ExecuteIndirect in a buffer of XCL's own, 0 groups where they are out of range,
and records them for the CPU: the log names the program, the counts and the address of the first
64 out of range, and the GPU profile shows the counts of each ExecuteIndirect. It also counts how
often the title's buffer showed other counts than the window. XCL_INDIRECT_GUARD=0 turns it off,
XCL_INDIRECT_MAX_GROUPS is the limit (4 Mi groups).

Test: an_execute_indirect_with_garbage_counts_runs_no_groups (GPU).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A buffer a title places in a sparse window is a reserved resource over the window's tiles, mapped
once. A tile decommitted and flushed was unmapped from the window only; memory committed there
again got another tile in the window while the buffer kept the old one: shaders write the window,
an ExecuteIndirect or a copy reads the buffer. The tile is kept mapped in the window while a buffer
uses it (its video memory was kept already) and comes back with the next commit.

A buffer's release looks its tiles up by their address instead of searching all mapped tiles.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
XCL_SYNC_TRACE=1 keeps the last 1500 sync events (each list's waits and writes, what became of
them, submits) and logs them at the first three cycle breaks and before the watchdog's first two
releases. The wait edges are logged before the release too: after it they are gone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
On the newer console command-list layout (real::QUEUE_SHIFTED), titles reset pooled lists through slot #139 Reset(allocator, initial_pso, flags), which real.rs routes to list_x::reset_x.

title_list's wrapper vtable only overrode slots 0, 1, 2, 9, and 10, leaving slot #139 as a raw forwarder to F_BACKING. Once a mid-list Wait64 split switched F_BACKING to a continuation segment, #139 reset only that continuation segment and never ran title_list::reset: F_PRIMARY stayed bound to the previous recording/allocator, F_BACKING was never restored to F_PRIMARY, and extra_active kept accumulating split segments across frames.

On pre-#897 main that caused D3D12 device removal (0x887a0001 / debug-layer id 541) as soon as the old allocator was reused; even with #897/#907 allocator pooling, stale primary/prior segments continue to be resubmitted and extra_active grows until MAX_EXTRA_SEGMENTS.

The wrapper's #139 is now a guard::make_layout_split of its own: a title on the newer layout goes to a four-argument adapter that runs wrapper reset, while a title on the older layout and the runtime take the generated forwarder. The forwarder's tail jump keeps the caller's return address and arguments, which the backing list's own layout guard at #139 needs to tell a title from the runtime; calling the backing slot from Rust would hide it and send an older-layout title to the PC method.

Tests: one covers the forwarder and the newer-layout reset on fake lists; one calls the slot from a caller in a registered mapped image, with the backing slot behind a layout guard as real.rs installs it and a test-local layout flag (flag clear: the older handler with the title's arguments; flag set: the primary is reset and the split segment reclaimed).

Co-Authored-By: Antigravity <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit b3a969b72c)
`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 <[email protected]>
(cherry picked from commit b67c8f0cb5)
Two bugs in title_list segment and wrapper lifecycle:
- When a title_list split onto an extra PC segment and later returned
  that segment to `spares` via Reset or KickoffX, `alloc_pool::forget_list`
  was never called on the retired segment. The segment stayed in its
  backing allocator's `users` set indefinitely, preventing that backing
  allocator from being reused and leaking new PC allocators on every Reset.
- In `title_list::release`, after `f(pc)` freed the primary PC list,
  `WRAPPER_OF.remove(&pc)` and `bind::forget(pc)` ran unconditionally.
  If another thread created a new command list that reused the freed `pc`
  address in the window after `f(pc)`, the old wrapper's cleanup detached
  the new wrapper and wiped the new list's bind state.

Call `alloc_pool::forget_list(list)` inside `list_x::clear_segment_state`
(covering both `title_list::reset` and `KickoffX`) and before releasing
spare segments; in `title_list::release`, only remove `WRAPPER_OF` entries
still mapped to `this` and skip redundant `bind::forget(pc)` when `pc` was
adopted (already cleaned up inside `real::cl_release`).

Assisted-by: OpenCode (Gemini 4 Neon)
(cherry picked from commit d827520e3d4741137e4b569fde77e415024cb186)
A title's allocator Reset while the GPU still runs what was recorded on
it puts that PC allocator aside (alloc_pool, #897) and returns S_OK.
real::alloc_reset took the S_OK as "the GPU is done" and freed every
unified-memory block that ended recordings on the title's allocator had
used: root argument tables, io and AllocateUploadMemory blocks. Coherent
blocks go back on the pool's LIFO stack, so the next translated draw can
take one and write its arguments over those a submitted draw has not
read yet; sparse ones are decommitted. #897 counted 240 such swaps in
60 s of a retail title's world.

The blocks were also held under the title's allocator, which since #897
stands for PC allocators that change, so no one Reset could tell whether
the GPU was done with all of them.

A recording's blocks are now held for the PC allocator it is on (the one
alloc_pool's reset_list hands to the PC Reset), and alloc_pool gives a
PC allocator's blocks back at the title's Reset once the GPU has passed
every submit on it, whether it is in use, was reset or was put aside. A
PC allocator made here that is released gives its blocks back with it.

The device test through the Reset hook finds the blocks freed at the
swap on the old code (run on Wine's D3D12 over MoltenVK; no Windows
machine here).

Fixes #1358.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 790185635d)
Found and fixed by @WebIdentity1 in #2092.
The same rule as for Write64 cells (the covered waits of would_signal_close_cycle) in
break_cycles_before_title_signal: a wait that an earlier submitted signal of the title's fence
satisfies does not wait on the new one. Counting it released a cell's GPU wait on the CPU in every
pipelined frame that has such a pair, before the work it waits for had run.

Test: a_title_fence_wait_an_earlier_signal_covers_is_no_cycle.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
As for dispatches: an indirect draw whose vertex or instance count was garbage held the 3D engine
for 8 s in a retail title's world (RTX 5090) and ended in a driver error (nvlddmkm 153). The guard
reads the arguments of signatures of one Draw or DrawIndexed too, and hands zeros on where a count
or the product is beyond what a frame draws (2^28 vertices, 2^24 instances). XCL_INDIRECT_GUARD=dispatch
checks dispatches only.

Test: an_execute_indirect_with_garbage_counts_draws_nothing (GPU: the arguments the draw would get,
copied out).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`readable` asked the working set for up to 16 pages and VirtualQuery for more. VirtualQuery sizes
the whole committed region behind an address by walking it: in a title's 2 GB heap 20-30 ms a call
(measured: 29 ms at the start of a 2.2 GB block, 2.8 ms with 300 MB behind, 50 us for 4096 pages
from the working set). Each submit checks every texture of more than 64 KiB that was written: 30-50 ms
of a frame in a retail title's world.

The working set is asked in batches of 512 pages. In a range of more than 16 pages a page that is
not resident is read by the kernel (one byte), as the caller's reads would: committed, or not
readable. Short ranges (a title's pointer that may be garbage) are answered as before: such a page is
not touched, VirtualQuery answers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
From a review: the program of a count out of range is known without XCL_GPU_PROFILE, and forgotten
with its pipeline; what was found is logged from the GPU wait watchdog too (nothing is recorded any
more when the GPU stands); a record says that it is there before it is logged; a count of 0 beside
garbage is no garbage (it runs nothing); the title's address is logged; the title's buffer is read
for the comparison only with XCL_INDIRECT_GUARD=compare; the ring holds 256 Ki slots; the tests
reuse a slot that holds good counts.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflicts:
- the translator's version is one of its own (its output differs from main's: globallycoherent
  windows only where a program needs them, #1850);
- compute and graphics driver blobs reach the disk cache also when the store in memory is full
  (main's read_pso_cached_blob and graphics blobs, our return of the blob);
- sparse: our copies back with main's lock_state and wait notes;
- title textures: our uploads on the title's queue in main's batches (256 textures, 32 MiB);
- DirectStorage: a page list is read again at execution (#1405) through main's read_own (#509);
- list_x / bind: our diagnostics and the ExecuteIndirect guard kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The copy of the frame to XCL's window is a submit on the title's queue that reads none of the title's
memory: it took a full look for CPU writes (one of three a frame, 6.6 ms in a retail title's world).

submit_cost also counts the textures looked at, unchanged and uploaded, their bytes, and the time
comparing, detiling and submitting.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	crates/xcl/src/hle/d3d12x/title_textures.rs
FlushGpuCacheRangeX and FlushShaderCacheRangeX of the newer list layout were answered with nothing.
They are how a title orders a pass behind the one that wrote what it reads: a retail title calls them
thousands of times a minute, and its compute passes (the ones that write indirect arguments and the
ones that read them) had no order there. FlushPipelineX (#67, newer layout #69) as well; at #69 a
newer-layout title's call ran Write32BitValueBottomOfPipeX with the flags as the address.

The PC has no ranges of caches: a UAV barrier for all resources, on direct and compute lists.

Test: cache_flushes_are_uav_barriers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A title changes thousands of scattered 64-byte chunks between two submits (a retail title's world:
~2 000 runs of ~240 bytes a submit). Each was a CopyBufferRegion, 0.3 us in the driver however
little it copies. The runs under 4 KiB now go into the staging ring one after another behind a table
of their places, and one compute dispatch puts them there; longer runs keep their copies. Measured
with upload_dirty on an RTX 5090: 2 000 runs of 256 bytes 594 -> 66 us, 400 runs 160 -> 60 us.

Only the changed chunks are written, as before: what lies between them may be the GPU's.
XCL_SPARSE_SCATTER=0 goes back to a copy each. The "sparse windows timing" line counts both.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A title's texture went up as a whole whenever a page of it was written: hashed as a whole on the
submitting thread, every level of every slice detiled into fresh memory, copied again into a new
upload buffer, on a new allocator and list, and released through the hooks that ask every queue how
far it is. A streamed texture arrives 64 KiB at a time, so it went up many times over. In a retail
title's world that was half of what a submit cost (73 ms of a 180 ms frame).

- The written pages are compared one by one with what they held, and only the blocks of the levels
  (mip tails, rows of linear levels) the changed ones are go up (`tiling::Chain::parts`).
- They are detiled block by block by the standing workers, straight into a mapped upload buffer, in
  runs of up to 16 bytes (`detile_blocks`).
- Lists, allocators and upload buffers are kept and used again; what XCL makes for its own work is
  not hooked as a title's object.
- An upload for a compute or copy queue's submit runs on XCL's own queue as before, but the title's
  queues wait for it on the GPU; the submitting thread waited for it on the CPU with everyone
  behind it.
- A texture that becomes active again (the one over it was released) goes up as a whole at its next
  write; one whose upload failed too. Pages that go while they are read (another thread decommits
  them) read as zeros.

Measured (RTX 5090, 9950X3D): 64 KiB of a 22 MB BC7 texture 15 ms -> 0.08 ms before copies and
objects, all of it 15 -> 1.7 ms.

XCL_TEXTURE_PARTS=0 uploads changed textures as a whole. submit_cost counts pages compared and bytes
uploaded.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Each last Release of a resource signalled every queue and spun for up to 300 us in case the GPU had
nothing to do. With work in flight (always, in a scene) that is 300 us of the title's thread and a
Signal on every queue per resource, and a title that streams releases many at a time. Queues found
busy are now taken to be for 5 ms: those releases go to the thread that lets them go (as before, when
the wait did not help). An idle GPU still lets a resource go before its Release returns.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A title records its lists on many threads, and every root argument, draw and dispatch looked up the
list's state, the pipeline's stand-in, whether it is translated, its root signature and user SGPRs
and the windows' addresses, each under one lock for all threads. The maps are in 64 parts by address
now, each on a cache line of its own; the windows' addresses are read without a lock, and whether a
heap of views is bound is asked once per recording.

A dispatch with six root constants (XCL's part, 9950X3D, warm memory): 1 thread 0.52 -> 0.44 us, 4
threads 4.1 -> 0.43, 8 threads 17.1 -> 0.52, 16 threads 45.8 -> 0.93 us on each.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
What XCL keeps of each list (bindings, pipeline, queries, writes) was one map under one lock, taken
by most recorded calls of every recording thread; it is in 64 parts by list now. A hooked draw,
SetPipelineState, Close or fence poll looked its PC method up by name in its object's class, under
the lock of all classes: a method is at one slot in every version of its interface (tested), which
is looked up once.

A dispatch binds XCL's compute pipeline with the PC method, past the hook of a title's
SetPipelineState (which keeps a graphics pipeline's depth bias); so does the check before an
ExecuteIndirect, whose program is then no longer noted as what the title bound.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- An upload on the title's direct queue waits for what went up on XCL's own queue before it, not
  after it. One on XCL's own queue that an older one, still waiting on a direct queue, can land over
  goes up again behind that one (`texture_upload::sent`, `take_again`): with parts going up, nothing
  sent them again before.
- A texture with a reported page goes up with all its written pages, those outside the blocks the
  look took too (they stay reported). What its pages held at an upload of all of it is remembered, so
  a page written with the same bytes leaves alone what the GPU wrote there.
- The wait for upload buffers polls: giving a wait up left its event registered after it was closed.
  Lists and buffers the GPU may still run stay when the queue's fence cannot say so.
- The driver's refusal of a program or root signature of XCL's own is what its user gets, not a
  program that does nothing (the scatter falls back to copies, the indirect check says so).
- The debug-layer test of an upload's states goes through these uploads, for all and for part of a
  texture.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- The page hashes are of the bytes an upload read, taken as it reads them: pages read along with a
  changed one, and pages a title writes on between the comparison and the upload, were kept as what
  they had been compared as, and the PC texture could stay at zeros or half-drawn bytes. A first
  upload leaves them known too, so a page written with the same bytes is nothing to send.
- The textures of a batch that could not be uploaded (no memory for its buffer) go up again after
  100 ms instead of at their next write; buffers over 64 MiB are not rounded up to a power of two.
- A render target or UAV the CPU writes too goes up as a whole, as before: the GPU's writes to one
  are not all seen.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
An unbuffered read arrives by DMA: the write watch reports at most that its pages were locked,
before the bytes are there, and a look in between left the bytes out of video memory (sparse
windows) and of textures until something else wrote there. ReadFile's range is noted when it
returns finished, an overlapped one's at the first look that finds its OVERLAPPED done.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	crates/xcl/src/gpu/texture.rs
#	crates/xcl/src/hle/d3d12x/title_textures.rs
- The bytes an upload reads are hashed before they are detiled: in the window that stays committed
  they are the title's own, and a write in between was kept as sent.
- A texture over the video memory of one it supersedes comes behind that one's unfinished uploads.
- Resolves into a texture are noted as GPU writes, like copies.
- A texture whose blocks the look took anyway is not asked about again; what goes up of a batch is
  counted in whole blocks.
- GPU tests: the order of a texture's uploads on two queues, both ways; a program of XCL's own that
  the driver refuses.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A last Release signalled every queue and waited for the GPU to say it is idle, then ended the object:
130 - 190 us each on the title's thread (the driver takes ~100 us to end a texture), and a title ends
thousands when it changes places. Only a buffer can be over pages that are freed next (an imported
heap pins them), so textures and XCL's own buffers in video memory go to the thread at once: 2 - 5 us.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
How many of a look's pages the looks before it had found too, in how many
runs they lie, how many of the scanned pages changed, and how long before
its submit the youngest list was closed: the figures that say whether a
look ahead of the submit, or leaving always written pages out of the
write watch, would pay.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A title starting on a Series S profile maps 4.3 GB of physical pages in
small pieces (MapTitlePhysicalPages -> sparse::committed), and each new
tile cost one UpdateTileMappings + signal (~0.4 ms). Its loading thread
was held ~25 s with nothing presented and its stall watchdog ended it.

New tiles now get their pool tile in `mapped` at once and their mapping
call is queued (`pending`); `flush_pending` sends them, one call per
window, before the title's next submit, before XCL's own copies and
readbacks on the windows, or past 4,096 tiles. A tile decommitted
before the flush is skipped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit b52f7cb672)
(cherry picked from commit f03d411812)
XMemMapPhysicalPagesScatter takes each unmapped page home on its own: one
VirtualAlloc, one VirtualQuery and, in a sparse window, one
UpdateTileMappings and one Signal per 64 KiB page. A retail game unmaps
4136 and then 6720 pages in two calls while it loads, and the homes of
each call are one run of neighbours: 2.7-3.2 s in those two calls, the
larger part in the tile mappings.

The parts of a call that only unmap (1024 pages, 64 MiB, at a time) now
commit their homes ahead, a run of neighbouring pages per VirtualAlloc and
per sparse::committed. Homes that are committed already, or cannot be,
still go page by page, and a call that fails part way gives back the homes
no page went to. The two calls take 0.4-0.5 s.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 3b54c24f57)
On top of "new sparse tiles are mapped together before the next submit":
work already on the GPU can reach memory the title commits now without
another submit, when it waits for a fence the CPU signals or a value the
CPU writes. The mappings put off are sent before a title's CPU Signal,
and by a thread 2 ms after the first of them when nothing else sends
them. A tile kept for a placed buffer before its mapping was sent keeps
it pending, as a parked one does.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Two threads that both found no device made one each and opened the
memory windows for it: GPU work on the one with window addresses of the
other read zeros or hung the GPU (four driver resets in two minutes of
unit test runs; tests call `real::init` directly next to others that go
through `backend`). A title comes in through `backend`, which asks once.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The runs of mapped tiles were sorted out of all of them again for the
first look behind each commit (a retail title has 150,000 mapped), under
the state's lock. They are kept with the tiles now, as ranges. The
pieces to clear are an ordered set: a decommit takes out its tiles' and
does not go over all of them, which grew with the square of the pages
while a title loads and submits nothing; neighbours go up as one copy.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A look's time goes up with the pages it takes, ~0.5 us each with the
title's threads running, and a retail title's world had ~8,000 a look:
5 ms on the thread that submits. With XCL_LOOK_AHEAD a thread takes the
written pages of the hot blocks every so many milliseconds; the next
submit takes those with what its own look finds, and one whose lists
were closed before such a round began needs no look. What is uploaded,
and when, stays as it was. Ranges that come out the same stay the same
object, so the hot blocks are kept.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
XCL_ACTIVITY logs every 2 s how many placed textures and buffers, page
mapping calls, memory calls and pipelines the title's threads made and
the milliseconds XCL took for them: where the time of a loading screen
goes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The lock goes to the first to ask once it is free: a thread that takes it
again and again (a title mapping its memory a page at a time) is back
before a waiting one has woken. Measured with 0.4 ms holds and no gap:
171 ms median and 1.8 s at worst for the waiting thread; with the rule
0.14 and 0.4 ms. Also: XCL_TEST_WARP for the test device.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A look for CPU writes between a page's copy and its `sparse::committed`
took the written pages of a tile that has no video memory yet: they were
reset and dropped, and nothing reported them again, so the GPU read zeros
there until the CPU wrote the page once more. With a mapping call's pages
told in runs that gap was the rest of the call. Pages with data are told
first, the run stays for fresh ones; a page moved between addresses the
same.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`copy_readable` fell back to splitting the range at every failed
ReadProcessMemory: for memory that is only reserved that is two calls a
page. A retail title makes its textures before it maps their memory, and
13.6 GB of them went up at 0.5 GB/s while its world loaded (27 s of its
submitting thread). The regions are asked for once each, as
`read_committed` did; both share the code now.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
What independent reviewers confirmed in the commits since 0ba3b8c:
- the flag that says mappings wait went before they were sent: a CPU
  signal of another thread saw nothing to do and let waiting work run
  ahead of them. It goes after the flush, and a signal asks each time;
- a queue's Signal (and SignalX) sends what waits, as a fence's does;
- lists that go out after a wait on the CPU inside a submit see what the
  title committed meanwhile mapped and cleared;
- a heap made with the state locked: what waits is sent first;
- the walk gets the watched ranges at every submit, and a submit goes
  without a look of its own only when the walk has found no written
  block since the last look began.
Tests: two GPU tests skip where the device cannot run them (the software
device is removed by copies into a reserved buffer of 3 GiB, and a device
without sparse windows puts nothing off).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflicts: bind.rs State keeps both the allocator's alloc_pool note and
the new heaps field; bind_abi keeps the tree's window-0 lookup and its
shadowed-memory refusal and reads the heaps with the layout and
arguments; SetDescriptorHeaps both marks the heaps changed (the shared
view heap is bound again) and records their console addresses.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflict: NEWER_LIST_SLOTS keeps the tree's (69, 67) and adds the PR's
(129, 126): 23 pairs. The older slot it names gets its handler from the
two-pass merge that follows, which settles the pair.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The branch carries #304's budget commits, which the tree has already
(merged under other hashes, with a later doc of the measured range).

Conflicts: passthrough_max_vertices keeps the tree's later doc (the
whole measured range); the recompiler tests keep #1984's edge-flag
test next to #304's; translated_mesh_stream keeps the tree's deferral
of every console mesh pipeline in the cached-only attempt (it covers
the moved MS the PR defers, and the attempt's result is not used when
it misses) and adds the PR's sparse log of moved shaders after it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The mesh pass of a two-pass (MS / GS) pipeline had no driver blob on disk:
every run compiled it in the driver again. #1942 keeps both passes under
keys of the stream's contents (pointers replaced by what they point to),
the static samplers, the window count and the adapter and driver.

Conflicts with the graphics blob cache resolved: the graphics cache and
remember_compute_blob stay as they were; the two-pass passes use #1942's
build_two_pass_pso (its compute pass key replaces the DXIL-only name, so
compute-pass files of earlier runs are compiled once more); its blob
reader is the existing read_pso_cached_blob; the gate keeps the commit
headroom of the program's size. driver_compile is left to the tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Supersedes #724; its commits are kept with their authors.

Conflicts:
- bind.rs State keeps the tree's heap_bound and #1803's heaps next to
  the record buffers and scratch; reset clears the heaps and holds the
  record buffers for the old allocator; forget takes the state out of
  the sharded map (bind::STATES) and holds its buffers. HashMap is
  imported again for the PR's maps.
- console_list.rs Layout keeps #1803's heaps and the PR's inline_ms;
  with_heaps and user_data_ms both stay.
- device_x.rs keeps #1887's log of a refused signature and the PR's
  companion Dispatch signature; the CreateCommandSignature doc is back
  above its function (the merge had put it above indirect_arg_bytes).
- real.rs console slots keep the tree's #131 / #132 FlushCacheRange and
  the PR's DispatchMesh at #127.
- list_x.rs: the PR's bound_heaps test helper removes the list from
  its own part of the sharded recording map.

DispatchMesh slot: #1984 mapped the newer layout's #129 to the older
#126, this PR to #127, where it hooks DispatchMesh. Kept #127: it is
the shift of two slots the other methods have, and #1984's own reading
of the newer layout (#126 / #127 the shading-rate methods, the older
#124 / #125) puts its #128 at the older #126. #1984's test is rewritten
for (129, 127) and checks that the older slot runs bind::dispatch_mesh.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
#1803 gives compute and graphics stages whose root signature has
CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED / SAMPLER_HEAP_DIRECTLY_INDEXED the
32-bit addresses of the view heap and the sampler heap set, in the user
SGPRs after their arguments. The two-pass mesh path left them 0: its io
blocks are made by two_pass_io, not bind_abi.

Decoding the root-layout table of every stage in a retail title's shader
pack (testers' report on the two-pass PRs) found the mesh stages' root
arguments from s16 exactly as user_data_ms packs them, and all but 23
mesh stages taking the heap addresses right after them (view heap, then
sampler heap): s23 / s24 for the most common layout of three tables, a
root view and two constants, its code loading a V# from s23 + index * 32.
With #1803 and the addresses in the two-pass compute pass, a tester logged
s23 / s24 holding the heap bases in 10 000 of 10 000 binds.

two_pass_io now appends them with console_list::with_heaps after the
compute pass's user_data_ms and after the pixel shader's user_data_gfx;
bind_two_pass_stage reads the list's heaps with its layout and arguments.
Test: two_pass_heap_addresses_follow_the_arguments (the mesh layout's
s23 / s24, either heap alone, none without the flags, the pixel shader's
after its arguments from s8); it fails without the change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A retail title reserves 24 GiB of 64 KiB pages twice: a CPU view that
holds the bytes and a GPU-only view of the same pages, and gives the GPU
only addresses of the second. With 4 windows that view is outside every
window and each shader read of it is 0. The 16-window layout
(XCL_HEAP_WINDOWS=1, XCL_UMA_WINDOWS=16) had room for it but did not use
it, and it was not safe as it stood:

- Windows 4..15 were neither reserved nor given memory, yet shaders count
  their addresses as in range and their heap slots aliased window 0's
  buffer: whatever Windows placed there read window 0, and GPU writes
  there landed in it (descriptor heaps).
- The window address table had 8 places, so uma_va_of returned None for
  windows 8..15 and their addresses went to the PC raw.
- The coherent windows could grow to 13 (uma_coherent.txt only grows),
  over every window a GPU view needs.

The layout with 16 windows is now: sparse windows 0..2 as before (C and
the physical-page homes stay there: sparse_reserve / sparse_alloc stop at
the last sparse window), the coherent window(s), at most 7, then 6 view
windows (a kind of their own: reserved PAGE_NOACCESS, not write-watched,
never committed), the rest empty. The whole 64 GiB is reserved, the
coherent windows' uncommitted tails too. Uma::view_reserve hands out
window-aligned ranges of the view windows, view_release gives them back.
contains / is_sparse / is_committed stay false there (the CPU cannot
touch a GPU view); window_of and real::uma_va_of work, and
is_title_address is true for a reserved view range.

sparse::init makes the view windows' tiled buffers as for the sparse
windows (nothing mapped), so they get heap views; a window without memory
gets a null raw UAV instead of window 0's. uma_window_buffer refuses view
windows: the memory operations' readback would touch G on the CPU.
If 16 windows were asked for and cannot be reserved, the fallback to 4
is now an error that names what is lost.

Layouts of 4 and 8 windows are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A GPU-view reservation (64 KiB pages, PAGE_NOACCESS |
PAGE_GRAPHICS_NOACCESS, no address) whose CPU view of the same size is
waiting for it now goes to Uma::view_reserve when the layout has view
windows (16), and is paired with mirrors::reserved there; without room,
or with 4 windows, it takes the path it took before. The CPU view's path
is unchanged: plain write-watched memory outside the windows.

VirtualFree of a GPU view in the view windows tells sparse first
(sparse::decommitted, so mirrored tiles can go), decommits what the
title may have committed there, then unpairs (mirrors::released) and
gives the range back. A commit at a GPU view address and physical pages
mapped there stay plain pages, never the sparse commit path, with a
warning once: the CPU cannot touch G.

mirrors: a pair that forms or goes is now a new GPU-view generation with
its range in the log, so readers of GPU views look at it again; and
released runs before the address can be handed out again (sparse
release, the UMA free path, plain graphics reservations), where it ran
after.

A test of its own process sets XCL_HEAP_WINDOWS=1 and XCL_UMA_WINDOWS=16
before the first uma::get() and reserves the two 24 GiB views through
VirtualAlloc: G lands at a view window's start, mirrors::source(G + x) is
C + x, C is outside the aperture, a release frees the range for the next
GPU view. No device needed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The switch form reaches the windows through the 4 root UAVs. With 16
windows and the heap form off (its views could not be made) or a thread
in the switch form, pso::mem_windows still said 16: the HLSL path then
refused every shader and DXIL quietly made it 4. It now says at most
MAX_WINDOWS whenever the windows do not come from the descriptor heap.

With that, the refusal of the switch-form retry for more than 4 windows
goes: a pipeline the driver refuses with heap windows is built in the
switch form again, reaching windows 0..3 (bound to u2..u5 already);
addresses in the other windows read 0 in that pipeline only.

xcl shaders: --windows defaults to the run's count
(uma::configured_runtime_windows) and is checked with
recomp::valid_window_count, so a precompile for a 16-window run has its
cache keys.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflict in bind.rs (execute_indirect's PC branch): both the GPU profile's
timer of the call and the diagnostic's note of it are kept.
The diagnostic notes each draw with how it went (ran, a stand-in, a PC
pipeline, skipped). DispatchMesh and the ExecuteIndirect of a mesh
signature that run as two passes were not noted, so a frame whose
geometry is drawn by translated mesh pipelines listed its targets with
no draws. The two passes count as the one draw they stand for.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
A retail title reserves its memory twice for the same physical pages: a
CPU view that holds the bytes and a GPU view with no CPU access, and it
gives the GPU only addresses in the GPU view. Once the GPU view lies in
a sparse window, its tiles need video memory filled from the CPU view
and kept in step with it, and nothing may touch the view's own
addresses on the CPU (they fault).

- TileEntry.src: the CPU address a tile's bytes are read from and land
  at (0: its own). The upload scan, the ring copies (cpu_span cuts a run
  where the CPU bytes break), copy_back/land_page, store_imm,
  chunk_clean, sync_sent_range and readback_now go there. A copy back
  recorded while the tile showed another CPU tile is left out.
- map_mirror(va, len): queues the window tiles from any thread (no
  STATE, no VirtualQuery). The next submit maps up to 4096 of them over
  kernelx::mirrors::source, with the CPU tile's holes from one batched
  working-set query and VirtualQuery once per region (a call per tile
  grew with the square of a committed range), and fills them whole.
- before_execute (now State::before_execute_on): CPU pages written go
  to every tile over them; a written page that was a hole is asked
  about again (lazily committed pages); pages are sorted and deduped by
  window address.
- source_decommitted (to be called before Windows decommits CPU pages),
  forget_mirrors, decommit/commit of the view's own tiles, place_buffer
  over a GPU view, mapped_ranges with the CPU tiles (never the view),
  cpu_of for callers outside.
- XCL_MIRROR_MB (default 4096) caps the video memory of such tiles; the
  timing line counts them.

Nothing calls map_mirror yet and the GPU views are not in a sparse
window yet, so this changes nothing in a run. Tests: CPU-side ones on a
state of their own with the view reserved with no access (a touch
faults the test), plus GPU ones, all run on the software adapter.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The two-pass bind (#2092) came from a base before the committed window
could be a copy in video memory (Uma::shadowed): it took window 0 and the
others from uma_window_vas, under its lock at every stage, and bound a
null root descriptor when shadowed memory had no buffer in window 0,
which bind_abi refuses. Both now take it from first_window (the lock-free
uma_window_va and the same refusal), and the two-pass stages bind the
other windows from uma_window_va like bind_abi.

Test: binds_refuse_shadowed_memory_without_window_0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
inherit_for_split (a deferred mid-list split: the next list records into
another allocator) gives that list a fresh arena and holds its previous
recording's unified memory for the previous allocator, as reset does.
The two-pass record buffer and argument scratch that #2092 added to the
list state were only handled in reset and forget, so a split list kept
its previous recording's record buffer, which the GPU may still read
while the new recording's compute pass writes it, and its scratch budget.

They now go to the old allocator (hold_res_until_reset) and the scratch
counts start again, as in reset.

Test: a_split_holds_the_previous_record_buffers_for_their_allocator
(buffers of a software device, no GPU work); fails without the change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
#2092 notes a DispatchMesh command signature with its companion Dispatch
signature by address and never forgets it. A signature the title makes
later at a freed one's address (a plain Dispatch or draw signature, or a
root-changing one) kept the old entry, and an ExecuteIndirect with it and
a two-pass pipeline bound went down the two-pass path with the old
companion, stride and offset. Every creation now forgets the address
first, as note_signature_dispatches already does for the Dispatch kind;
a mesh dispatch signature is noted again after it.

Test: a_signature_at_a_freed_mesh_signatures_address_has_no_companion.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A translated graphics pipeline's driver blob was kept on disk under a hash
of its description and DXIL alone. That is not all the PC pipeline is made
against: the driver refuses a blob of another adapter or driver, so two
adapters sharing the cache (a GPU and the software one the tests use)
overwrote each other's files and each compiled again, and a change of the
memory windows in the ABI root signature was found only by the driver's
refusal. The file is now named after graphics_file_hash: the key in
memory, the adapter and driver (driver_identity, from the two-pass cache)
and the window count. Without the adapter's identity nothing is kept.

The cache steps move into graphics_pso_through_cache, so the software
device can run the path production uses. The keep threshold is the
two-pass one (XCL_PSO_DISK_CACHE_MIN_MS, default 250 ms), now
keep_threshold.

Measured on the software adapter (tests): a pipeline made twice is
compiled once and made from the kept blob the second time; a damaged file
is dropped and replaced; a blob refused with D3D12_ERROR_ADAPTER_NOT_FOUND,
D3D12_ERROR_DRIVER_VERSION_MISMATCH or E_INVALIDARG is dropped and the
pipeline compiled; the file hash is fixed for fixed inputs and pointers
never enter the key.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A title gives the GPU addresses in its GPU view on many paths: buffer
views made by address, constant buffer views, root views, vertex and
index buffers, memory operations, waits. Each of them has to ask for the
view window's tiles before the GPU work that uses the address
(sparse::map_mirror) and must not do anything for other addresses.
view_want::want(path, va, len) is that call; it counts calls and bytes
by path, and the activity log prints what was asked for every 2 s
("GPU view (2 s): ..."), so a run shows which paths a title uses.

No caller yet: nothing changes.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The diagnostic was written against one map of all lists. Here the lists
are kept in parts with a lock each (list_x::recording), so its lookup
did not compile after the merge.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
uma_window_buffer answers None for a view window, because the callers it
has read their range back to the CPU at its own address, and a GPU view
has no CPU memory. uma_window_buffer_gpu answers for view windows too:
for a caller that gives the range to the GPU only, or lands what it
reads back at the CPU view (view_want::cpu), and that has asked for the
tiles. No caller yet.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
A retail title gives the GPU only addresses in a GPU view of its memory
(PAGE_NOACCESS on the CPU; with the 16-window layout it lies in the view
windows). The device's views and placed buffers took such an address as
memory nobody has: a constant buffer view was left empty, a buffer placed
there became a committed resource of its own that stayed zero (so its GPU
address, the buffer views of it, indirect arguments, copies and vertex
buffers read zeros), and a view made by address carried the address but
never asked for the tiles behind it, so the shader read zeros there too.

Each now asks for the tiles of exactly the range it covers
(view_want::want): views by address (device #70 / #71, the range
buffer_words_at computes), constant buffer views, views of buffer
resources, the acceleration-structure view (from the root on; its size is
not known) and a Map read of a buffer in the view. A constant buffer view
and an acceleration-structure view in a view window carry the address. A
buffer placed in a GPU view goes over the view window's tiles through
sparse::place_buffer, as one in a sparse window does, and may run on into
the next view windows; when that is refused it is a resource of its own
as before, logged once. A Map read of such a buffer reads back what the
GPU wrote into its CPU view, and its release does not wait as one over
CPU pages does.

Without the 16-window layout no address is in a view window and nothing
changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A retail title showed no frame for 34 s in one run and 156 s in another
while its world loaded: its draws waited for pipelines that were built one
after another, each 4 - 7 s of translation and DXC per stage (nothing
logged) and 3 - 8 s in the driver. The logs could not say where that time
went, nor how many of the title's pipelines were built before they were
needed.

- The driver compile start line of a graphics pipeline now says how long
  ago its build started and how that time went: VS and PS translation and
  DXC compile (DXC's waits for memory included), the wait for the huge
  pipeline gate (slot / commit), and the rest.
- A line of its own every 2 s while it changes: lazy pipelines made
  (graphics among them), built, built before their first use, built with
  a huge program, and the time binds waited for pipelines in those 2 s.
- A bind's wait for a pipeline being built is a call of its own in
  api_cost (the XCL_ACTIVITY "calls" line), and the first wait for a
  pipeline that passes 1 s is logged with the thread and whether the
  pipeline is graphics or compute.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A retail title gives the GPU only addresses in a GPU view of its memory,
which with 16 windows lies in the view windows; a tile there gets video
memory only when an address in it is asked for (view_want). Nothing
asked yet: root CBV / SRV / UAV addresses read zeros, and a two-pass
mesh ExecuteIndirect refused arguments in a view window because
uma_window_buffer has no buffer for one.

Each bind on XCL's ABI (bind_abi, the two-pass mesh stages, the console
lists' dispatches) asks for the tiles of its root views that lie in a
view window: 64 KiB each, as a root view has no size and nothing looks
a buffer up by address. The view windows' range is taken once, so any
other address costs one compare, and a layout without view windows one
compare a bind. The two-pass arguments and count, which only the GPU
reads, ask for their range and take the view window's buffer; the
indirect guard asks for the arguments it reads through the window; a
rect list in a view is expanded from its CPU view.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
With 16 windows an index or vertex buffer, a memory operation, a wait
or a copy destination can lie in a GPU view of the title's memory. The
PC got the console address of such a buffer when its window had no PC
address (no PC address: the device hangs), memory operations there were
"not in unified memory - not done", a wait read the view the CPU cannot
touch and passed at once, and a write and a wait naming the two views of
one value kept two sync cells.

Index and vertex buffers ask for their tiles and go to the PC at the
view window's address, or as none, never as the console address; the
CPU-side buffer mirrors never take a view address. Copies, fills,
immediates, timestamps and predication ask for their ranges and run on
the view window's buffer; what they and GPU copies into a buffer placed
in a view write is read back to the CPU view, where sparse lands it.
Waits read their value at the CPU view, and the sync cells are kept by
that address. Without view windows every address stays as it was.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The tiles of a GPU view in the view windows show the pages of its CPU
view: a submit fills them from those pages and scans them for changes
with the sparse state's lock held. Nothing told sparse when the title,
or XCL for it, decommitted or released such pages, so that read could
run on memory Windows had just taken away (the submit thread's copy
faulted that way once on a sparse window's pages).

- VirtualFree of a paired CPU view (plain write-watched memory, a sparse
  window's or unified memory's) calls sparse::source_decommitted for the
  range, the whole view on a release, before Windows does it; a decommit
  through VirtualFreeEx of a graphics reservation now takes that path.
- release_at, where a physical page leaves an address (unmapped, or
  moved to another), does the same for that page.
- mirrors::released, when a pair goes, has sparse forget the tiles over
  either view once its own lock is dropped (both addresses may be handed
  out again).

A count of pairs keeps it to one atomic load while nothing is paired;
sparse itself returns after one more while no tile shows a CPU view.

Tests: the title's decommit, VirtualFreeEx decommit and release of a CPU
view are told while the pages are still committed, memory of no pair is
not, and the release forgets both views; a page mapped lazily into a CPU
view and written is found by the look (how sparse clears its hole), and
its move and unmap are told before the decommit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A retail title gives DirectStorage addresses in the GPU view of its
memory, which the CPU cannot touch: with the GPU view in the view
windows (XCL_UMA_WINDOWS=16) such a request failed with
E_ACCESS_VIOLATION. Its bytes are now written at the CPU view behind
the address, and that is the range noted as a known write, so the
look hands those pages to the tiles that show them; a memory source in
a GPU view is read there too. A range that runs past its view is
refused. Without view windows no address is a view address and nothing
changes. Requests into a GPU view are counted in the log.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A bottom-of-pipe write the CPU does for the GPU into a GPU view of the
title's memory in a view window was refused (the CPU cannot touch the
view: writable said no). It is now checked and made at the CPU view
behind the address, whose writes reach the view's tiles like any CPU
write. Other addresses, and every address without view windows, are
written where they are, as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
source_decommitted marked the pages of a CPU view as holes in the tiles
shown over it and dropped the state's lock; the caller's VirtualFree came
after, with no lock. A submit that took the lock in between still had a
page in its write-watch list, asked Windows again (still committed),
cleared the hole and scanned the page while VirtualFree landed (access
violation on the submit thread), or kept it committed in the tile for
good (later copies back, immediates and chunk checks touched it). A tile
asked for in that window was filled from such pages the same way. The
ANY_MIRRORS gate was check-then-act: a decommit that saw no mirror while
the first one was being linked was missed entirely.

A leaf lock (Sources) now holds a copy of the CPU runs that tiles show
(changed with src_runs) and the page ranges whose decommit is under way.
source_decommit / source_release bracket the caller's OS call: the range
is listed, the state is told only when tiles show the range, the OS call
runs with no XCL lock, then the range is unlisted (a release forgets the
tiles first). Submits link a tile before they ask Windows about its CPU
tile, and take listed pages as holes (holes_now, in map_mirrors,
mirror_writes and buffer_tiles), so through the one lock either the
decommitter sees the link or the submit sees the range. A tile is looked
up again once linked, so a forget_mirrors that found nothing linked and a
link after it cannot miss each other; the leaf's runs replace ANY_MIRRORS.
source_decommitted and forget_mirrors keep their signatures.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A CPU view can lie in a sparse window itself: kernelx puts some of a
title's 64 KiB-page reservations there and pairs them with their GPU
view. Its decommits reach sparse through decommitted -> decommit_range,
which only marked the entries keyed by the decommitted addresses (the
view's own tiles). The tiles over that memory, keyed by their GPU-view
addresses, kept the pages as committed, so the next copy back, immediate,
chunk check or scan through them touched decommitted memory.

decommit_range now also runs source_decommitted_in for the range when
any tile shows CPU memory. decommit(a, n, os) brackets the caller's
VirtualFree for window addresses as source_decommit does outside them:
the pages are held as being freed until Windows is done, so a submit
that asks Windows in between does not take them as committed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A retail title creates its ~2 700 pipelines in its first 6 s. With lazy
pipelines each got a stand-in and was built only at its first bind, or
ahead of it when an earlier run had used its shaders. Pipelines new to
the run were bound up to ~140 s after they were made, and each such draw
waited 7 - 15 s for translation, DXC and the driver; the title records
about one draw between two of them, so 14 pipelines meant 156 s without
a frame.

The lowest-priority preload workers now keep a backlog of every lazy
graphics pipeline: those of earlier runs first (as before), then all
others are translated and compiled by DXC (no driver memory kept, and the
disk caches hold them for the next run), then built by the driver one by
one. The title gets the same pipeline, only earlier.

- A pipeline a bind wants is not taken from the backlog: the workers
  build it, and a bind's wait still raises a backlog worker building it.
- A huge driver compile of a pipeline nobody has used yet waits behind
  any other build waiting for a slot (big_compile_turn): one a bind gave
  up waiting for goes first. Gate size and commit headroom are unchanged.
- Pipelines of no earlier run wait in the backlog while less than 8 GB
  of commit is free; at most XCL_PSO_AHEAD (default 4096) of them are
  built by the driver ahead (each keeps ~400 KB there); XCL_PSO_AHEAD=0
  turns it off. Compute pipelines, and pipelines with no shader key, are
  still built at their first use.
- The pipeline line counts pipelines translated ahead and the backlog.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Draws wait for a pipeline still being built until it is there: on a cold
cache a logo and UI text drawn once and kept were missing when they did
not. A retail title's world draws waited 7 - 15 s each for pipelines
built one after another, and no frame came for 156 s; while a bind waits,
kernelx stretches the title's long sleeps too.

XCL_GFX_PSO_WAIT_MS=<ms> (unset: wait as before) bounds the wait of a
draw for a graphics pipeline: after it the draw goes on with the stand-in
(it draws nothing), and the later draws of that pipeline do not wait
again until it is built - what XCL_PSO_WAIT_MS does for every pipeline.
Compute pipelines are still waited for without a limit: a skipped
dispatch would corrupt data for later work. It is decided in pso_async,
which knows the kind of the pipeline: the binds are unchanged.

A bind's wait marked the build wanted for good, so a build nobody waited
for any more still skipped the huge-pipeline gate and ran at a normal
priority: with time-outs, many big driver compiles could run at once.
The wanted mark is now a count of waiting binds; one that runs out of its
budget leaves it, and the build goes back behind the gate and to the
lowest priority on a preload worker. Having been used, it still goes
before the builds ahead of first use.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Vertex and index buffers and root views are asked for at every bind, on
the thread that records the list, and a title binds the same ones for
draw after draw. Each ask walked every 64 KiB tile of the range through
a shared set (sparse::map_mirror). A thread now remembers its last 8
ranges with the generation of the GPU views they were asked in, and a
view that goes or comes empties that memory (its tiles are forgotten
with it). The counters keep every call; the bytes count when a range is
new to its thread.

Acceleration-structure views get a path of their own in the counters.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
A copy back recorded its tile's CPU address and landed if the tile still
had that address; an immediate compared nothing. When a page of the CPU
view behind a tile was decommitted and committed again (or the view was
released and paired anew at the same address) before the copy landed,
the submit re-validated the page with sent = None, and land_page wrote
the GPU's old bytes into the new memory's zero chunks (or over chunks
already sent). An immediate recorded before a repoint was stored into the
new CPU view. Finished readbacks were also drained only after
map_mirrors / mirror_writes, so a page that stopped being a hole in that
submit took what the GPU had in it.

TileEntry gets a generation: new for each tile over a CPU view, and again
whenever a page of it becomes a hole. Copies back and immediates record
it and land only into an entry with the same one. Tiles of the window's
own keep generation 0, so their landings behave exactly as before. The
finished readbacks are now drained before the tiles change at a submit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
source_going told sparse before Windows decommitted pages of a paired
CPU view. That left a gap: a submit that took sparse's lock between the
notice and the VirtualFree asked Windows about the page again (still
committed), took it back and read it while it went (review of the
mirrored tiles; sparse::source_decommit has the sequence).

The four places now hand their Windows call to sparse::source_decommit /
source_release, which list the range before, tell the state when tiles
show it, run the call with no lock held and unlist it after: the sparse
window path and the plain path of VirtualFree, a block of a committed
window that is freed (nothing goes in Windows there, the tiles do), and
release_at for a physical page that leaves its address. On the plain
path the part of the CPU view is looked up before a release unpairs the
views.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
buffer_tiles ignored new_mirror's result. At XCL_MIRROR_MB a GPU-view tile
of a placed buffer was refused, left out of the buffer's tile list, and
the buffer's reserved resource kept a NULL tile there for good, while a
later CPU write gave the window tile its own video memory: the two views
of one address disagreed. new_mirror also checked the cap before taking a
tile back from parked / kept, so a tile kept mapped for a placed buffer
was refused after its CPU view was committed and written again, and
stayed mapped in the window and the buffer with the old bytes while the
new ones never went up.

new_mirror takes a force flag that skips the cap (the tile still counts),
passed by buffer_tiles, and takes a parked or kept tile back before the
cap is looked at: that memory is held already.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A tile refused at XCL_MIRROR_MB stayed linked and in MIRROR_ASKED, so
asking again did nothing, and map_mirrors skipped linked tiles: the only
retry was mirror_writes, on a later CPU write to its CPU tile. Data the
title wrote once before the link (meshes, tables) never reached the GPU,
even after decommits and releases brought the room back. A tile for
which take_tile found no video memory was not even recorded, so a short
spell of VRAM pressure zeroed it for good. And while at the cap, every
submit that wrote a refused tile's CPU tile asked Windows about it again
under the state's lock, only to refuse it again.

new_mirror now records take_tile failures in `refused` too (counted once,
and for a second after one no other tile tries to make a heap unless a
tile is at hand). map_mirrors ends with retry_refused: when there is room,
up to MIRROR_ASKS_MAX refused tiles still linked and without memory get
one batched hole query and video memory (a fill of their CPU view); those
with no committed page leave `refused` for the write path. mirror_writes
skips refused tiles while there is no room or memory for them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
map_mirrors took up to 4096 asked tiles a submit and gave each video
memory at once, so a burst of asks filled up to 256 MiB at the next
submit: every committed page hashed and pushed through the 64 MiB
staging ring (waiting on the GPU for ring room) on the title's
submitting thread with the state's lock held, while its loading threads'
commits and decommits waited for that lock.

Asked tiles are now linked as before (their CPU tiles are watched from
then on) and queued in `later`; map_mirrors fills from the front of that
queue until XCL_MIRROR_FILL_MB of committed pages (16 MB by default) went
this submit, counting the pages a tile's CPU tile has committed, not
tiles. The rest wait for the next submits in their order: new asks are
taken in only once the queue is empty, and refused tiles go through the
same queue when there is room again, so a burst is not overtaken by
later asks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
XCL_GFX_PSO_WAIT_MS gave every pipeline its own wait. The first frames of
a title's world bind hundreds of pipelines never used before, one draw
after another on one thread. On a cold cache a retail title's thread
waited the whole 500 ms for more than 500 of them in a row: no frame from
92 s to 232 s, although every one of those pipelines was being built
meanwhile ("binds waited 2001 ms for pipelines being built (4 waits in
2 s)" for two minutes).

The budget is now what a thread may wait in a second in all
(gfx_wait_left: it fills again at the budget a second, to the budget at
most). It is spent on the first pipelines and on any that is built within
milliseconds (one made from a kept blob); after that the thread goes on,
and the rest draw once they are built. Compute pipelines are waited for
as before.

Test: the_graphics_budget_is_a_threads_for_a_second.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
A device removal was only looked for after a submit and at a present. A
title whose threads all wait (for pipelines being built, for a fence)
does neither, so the report of the faulting address was never written:
a retail title's device was lost by a shader's access to an unmapped
address while its threads waited for pipelines, and the log ended
without a word about it. With XCL_DRED a thread now asks every 100 ms.

What the report names at an address had no names: the memory windows'
buffers (with their number and whether they hold GPU views), the pools
of the sparse tiles, a title's buffer placed over tiles (with its
address and size) and the two-pass record and argument buffers now have.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The compute pass of a console mesh program writes each thread's position,
parameters and primitive into the group's record: slot = the thread's
index, with room for max_vertices vertices and max_primitives primitives.
Nothing checked the index. A thread past either limit that still exports
(a group can have more threads than the record has slots; the console's
hardware drops an export past the room the program asked for) wrote into
the next record, and past the last record of the buffer into whatever
follows it. The record buffer is a root UAV, so that is a store to an
unmapped address.

A retail title's first frames with mesh programs lost the device that
way on an NVIDIA RTX 5090: five "Graphics SM Warp Exception ... MMU
Fault" (shader units touching unmapped memory at once) seconds after its
first two-pass mesh draws ran, with the GPU nearly idle before, so no
time-out. Two reviewers of the two-pass path named this store as the one
shader access there that nothing bounds; it is not shown that it was the
access that faulted.

Both translators now store only when the thread's index is below the
limit of the part it writes: the direct DXIL one (kernel::mesh_init /
Lw::mesh_export, which the compute pass uses) and the HLSL one.

Test: gpu_mesh_mode_exports_stay_inside_the_record (128 threads export
with room for 64 vertices and 32 primitives; the buffer has room behind
the record, so the test faults no device without the bound either). Its
HLSL half runs without a GPU.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
XCL_DRED turns on the page-fault report and the breadcrumbs; the
breadcrumbs put a marker around every operation of every list and made a
title stall in its first seconds. XCL_DRED=pagefault asks for the
faulting address and what was (or had been) there only. The log says
which of the two is on.

An address just past the end of a buffer has no allocation the report
could name. The first two-pass record and argument buffers therefore
log their GPU address ranges when they are made.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The report of a device removal lists the allocations at the faulting
address, and those freed there lately, by name. A title's resources have
none, so the list said "type 34" and nothing else. With XCL_DRED set,
what the PC device makes for the title is named after what it is when XCL
takes it over (adopt): a buffer with its size and flags, a texture with
its dimension, size, mips, format, samples and flags, a heap with its
size, type and flags. More telling names given later replace it. Nothing
is named without the switch.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Translated shaders take a texture's index in the shared shader-visible
heap from a T# they read from memory and accept it when it is below
2^21 - 1. The heap was made at MaxViewDescriptorHeapSize (1 000 000 on an
RTX 5090, also the fallback when the query fails), so an index between
that and 2^21 passed the shaders' guard and read a descriptor past the
heap's end: memory the GPU has not mapped. Since the shaders read real
descriptor data from the title's memory, stale or garbage T#s reach that
path.

The heap is now tried with 2^21 descriptors first (resource binding tier
3 hardware takes more than the query says) and made at the queried size
only when that fails; a heap below 2^21 is logged as a warning that names
the uncovered index range. D3D12 leaves a new heap's descriptors
undefined, and only descriptors 0..MEM_HEAP_BASE were null views: every
descriptor past them now gets a null view (even SRV, odd UAV, as a
console slot's pair), copied from a CPU-only heap of 4096 once at
creation (2^21 copies, 64 MiB at a 32-byte increment; the time is in the
creation's log line). A range released by an unregistered heap gets null
views again before it can be handed out, since its views may name
resources that are gone. The heap is made and filled without GLOBAL
held: the adopted device's descriptor hooks look up the console heaps.

Cost: once at the first view heap (the fill), one copy per released
page range; nothing per draw or bind. The heap takes 2^21 instead of
1 000 000 descriptors of video memory.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Four ways a draw reached the GPU with a pipeline and a root signature or
draw kind that do not belong together:

- DispatchMesh and ExecuteIndirect resolved the pipeline with
  resolve_wait and then again in two_pass_of. With a wait budget the
  first can give the stand-in and the build can finish before the
  second: the two passes were recorded with the stand-in as the mesh
  pass's pipeline under the two-pass root signature. The draw now
  decides once (draw_pipeline): the two-pass entry of exactly what
  resolve_wait gave (real::two_pass_entry, no second resolve), else the
  stand-in of a pipeline being built or built since (skipped, as a
  pending one was), else the rest as before.
- ExecuteIndirect with a built two-pass pipeline and a signature that is
  not a noted DispatchMesh one (one that changes root arguments, or
  whose companion Dispatch could not be made) fell through to the PC
  call under the title's root signature, with the pass-through mesh
  pipeline on the list reading root views that signature lacks. Skipped
  and counted, warned the first 4 times.
- A Draw whose pipeline resolves to a two-pass one (a console VS+GS)
  took the PC branch: a Draw on a mesh pipeline. Skipped, warned once.
- The PC branches bound the title's root signature only when one was
  set; without one the PC call ran under whatever a translated draw left
  (XCL's ABI or the two-pass root signature). Such a draw is now skipped
  (warned the first 4 times), except on a bundle, which takes its
  caller's, and an ExecuteIndirect dispatch, which does not use it. Two
  tests set the root signature a title sets after Reset.

Cost: the same lookups as before (one TWO_PASS and one pending-pipeline
lookup per mesh draw, one TWO_PASS lookup per draw with an untranslated
pipeline); nothing on translated draws.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The 256-look line says how long a look for CPU writes takes, not
whether that time is the walk over memory nobody wrote or the pages
taken (each a page-table entry changed and flushed). The two call for
different fixes: looking at less memory, or taking fewer pages.

XCL_LOOK_STATS=2 times every write-watch call of a look on the thread
that submits and adds them up apart for the calls that returned no page
and those that returned some: time, bytes covered, pages, calls. A line
every 256 looks:

  look split (256 looks): X ms a look in N calls over G MB that found
  nothing + Y ms in M calls over H MB with P pages

It answers the study's first question: what a look's time is made of.
XCL_LOOK_STATS=1 prints what it printed before; with the switch off a
look costs one more atomic load per write-watch call.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A title keeps T#s, each with an index into the shared shader-visible view
heap, in its own memory, and its shaders read them from there. On the
console a T# of a released texture still names memory (leftover bytes,
nothing faults), so a title can sample a texture it has released (a
material table not updated yet, a sample of weight zero). On the PC the
heap slot kept the descriptor of the resource XCL destroyed: a shader
that samples it touches an unmapped address on the shader units. Nothing
cleared a slot when its resource went.

console_heap now remembers, for each index of the shared heap, the PC
resource its descriptor names (8 bytes an index, made with the first
view: 16 MiB for 2^21), and for each resource the indexes that named it
(entries may be stale; the per-index value is the truth). A view
published from CreateShaderResourceView / CreateUnorderedAccessView
(and the _at forms, which go through them) sets it, a copy between
console slots carries the source's, a null fill clears it. Right before
the PC object is destroyed - in late_release's drain before the real
Release of a held resource, and after the last Release of one that was
not held - every index that still names it gets the null view of its
kind (SRV at even, UAV at odd indexes); an index overwritten since by a
view of another resource is left alone. One lock (SLOT_WRITES) orders
the descriptor writes and the nulls, so a null never lands on a view
another thread just wrote; the copies under it go past the adopted
device's descriptor hook, which looks up the console heaps.

Cost: per view published, a lock, a descriptor copy (as before), an
atomic swap and, when the slot named another resource, a push to a
sharded map; per descriptor copy of n slots, n more slot lookups. Per
resource destroyed, one sharded-map lookup, and a copy per view it
still has. Nothing on draws or binds. Logged at the first 16 releases
that nulled any view and at powers of two.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
submit_cost's "scan" is the time from the sparse lock's work to the
uploads: building the slots of the written pages (the gather) and the
chunk scan of those pages, which is shared with the worker pool. Which
of the two it is, and whether the pool helps at all, decides whether
the scan wants a cheaper gather, more workers or workers that are
awake.

worker_pool::run now says who did a job's items (the caller, the
workers) and how long after the job was handed out the first worker
took one. With XCL_LOOK_STATS=2 the submit's gather and scan are timed
apart, and a line every 256 looks says:

  scan split (256 looks): gather A ms, scan B ms a submit; of N items a
  job the caller did C %, the first worker began after D µs (J jobs in
  S submits, W with a worker)

It answers the study's question of what the scan's time is made of and
whether the shared scan is shared. Nothing changes in what the pool or
the scan do; with the switch off a submit costs one atomic load more.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
hold_res_until_reset returned at once for allocator 0, which dropped the
recording's two-pass record and argument-scratch buffers: their last
reference went while the list that writes them through root UAVs might
not have run yet (a list XCL never saw reset, a reclaimed segment reset
onto none). A released committed buffer's GPU address is unmapped, and
the compute pass's stores and the mesh pass's loads through it fault.

They are now kept with the time they were handed over and go to the
reuse pool (or are released) once 10 s old, looked at whenever an
allocator's buffers are released. No fence or allocator says when the
GPU is done with them, so time does, far past any frame in flight. At
most 1 GiB is kept; past it the oldest go early and that is logged
(first 4 times).

Cost: one more lock at each allocator's release of two-pass buffers;
nothing per draw.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
What submit_cost calls "sparse lock" is the wait for the sparse
state's lock and all the work done under it before the scan: landing
the finished copies back, the tiles over CPU views, the mappings sent
and the unmappings. A long wait asks for less work under the lock on
other threads; a long part asks for less of that part on this one.

With XCL_LOOK_STATS=2 each step is timed, and the tiles mapped (with
the calls), the tiles unmapped and the bytes of copies back landed are
counted. A line every 1024 submits, averages a submit:

  sparse lock split (1024 submits): wait W ms, copies back L ms (B KB),
  GPU-view tiles M ms, mappings P ms (T tiles in C calls), unmappings
  U ms (V tiles), rest R ms a submit (of S ms)

It answers the study's question of what "sparse lock" is made of. With
the switch off a submit costs one atomic load more, and each map or
unmap call and copy back a relaxed add.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The ExecuteIndirect count check reads the 20 bytes of an argument record
through a raw root UAV at the window address of the title's buffer.
uma_va_of checks only that the start lies in a window. A buffer in a GPU
view may run across a view window's end, and the view windows are
separate 4 GiB resources: a record straddling the end was read past
window k's buffer, an SM load from an address nothing maps (root views
have no bounds).

The record is now read through the window only when all 20 bytes are in
it (uma_window_buffer_gpu, as make_scaled_args_buffer does); otherwise
the program reads the title's own buffer, as it does for an address that
is not in a window.

Cost: one window lookup per checked ExecuteIndirect (max 1, no count
buffer).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The title's GPU view is one range, but on the PC its windows are
separate 4 GiB buffers whose addresses are not adjacent. pc_va_in maps
only the start address: a vertex or index buffer view (or DrawIndexedX's
indices) that crosses a window's end was handed to the PC with the
title's SizeInBytes, so the input assembler could fetch past window k's
buffer into addresses no resource covers.

IASetVertexBuffers, IASetIndexBuffer and DrawIndexedX now clamp
SizeInBytes to the end of the window the address is in (warned once);
the GPU reads zeros past a view's size. A view inside one window is
unchanged.

Cost: per vertex / index buffer bind, a window lookup (arithmetic); the
title-memory lookup (a lock) only for a view that crosses a window end.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
When one thread makes every submit and every present, a frame's time
on it is its submits, its presents, its waits for the frame event and
its waits on fences. submit_cost says what the submits cost; nothing
said what the rest costs on that thread, so a frame's budget could not
be added up, nor could the calls XCL counts already (placed textures,
physical page calls, ...) be told apart from other threads'.

api_cost remembers the thread of the first title submit seen (with
XCL_LOOK_STATS=2) and counts every call on that thread apart as well.
New entries, timed with XCL_LOOK_STATS=2 only: the title's
ExecuteCommandLists as a whole (not XCL's own submits inside one or
inside a present), presents (PresentX, and the fallback's at a console
method) with their wait for the copy of the frame before apart,
WaitFrameEventX, and the copies back settled when a title thread looks
at a fence. The entry for the title's blocking fence waits is there for
the fence hook to use. With XCL_ACTIVITY, every 2 s:

  calls of the submitting thread (2 s): N ExecuteCommandLists in X ms,
  N presents in X ms, ...

It answers the study's question of where a frame's time goes on the
thread that submits outside the submit hook. The all-threads line is
unchanged with the switch off; a call XCL already counted costs one
atomic load more.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
res_release called sparse::forget_buffer, which unpins a placed buffer's
tiles, at the title's last Release, also when late_release kept the PC
object alive until the queues are past the work in flight. The kept
object still maps those tiles: sparse could hand them to another address
or retire the pool heap under them while work queued through the buffer
had yet to run. late_release's drain ends the object through the
original Release, which never told sparse. forget_buffer now runs from
res_release only for an object that is not held, and from late_release
right before the real Release of a held one. Right before, not after:
after it, another thread can make a buffer at the same address, whose
tiles this would unpin (the queues are past the work by then, and
forget_buffer takes no late_release lock and does not wait for the
sparse state's).

The same reuse made the address-keyed removals in res_release unsafe
when its Release had already ended the object (late_release off, or two
releases of the last two references at once): a resource made at the
address in between lost its UMA_BUFFERS / BUFFER_DELTA / TITLE_ADDRESS
entries and its pinned tiles. The last reference is now told by the
count after an AddRef and Release of our own (1: ours alone) on every
path, and the removals, the null views and, with late_release off, the
unpinning run while the object is alive, before the Release that ends
it. Of the two fixes the finding proposes this is the smaller: an
identity guard would need a generation in sparse's buffer table. What
is left is two threads releasing the last two references at the same
instant: both see 2, and the one whose Release ends the object cleans up
after it, as before.

Cost: none on draws or binds; per resource Release, the AddRef and
Release that late_release already made, now also with
XCL_LATE_RELEASE=0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Two things bound what a cheaper look could leave out or save.

A look takes the blocks written lately only; a write to another block
waits for the walk thread to find it. With XCL_LOOK_STATS=2 every look
counts whether the walk had made a block hot since the look before
began (a block no look had taken: written up to a walk pass ago), and
the walk times its passes over all watched memory.

XCL writes the title's memory itself: copies back landed and
immediates stored. The write watch reports those pages like the
title's, so a look takes them and the scan goes over them for nothing.
With XCL_LOOK_STATS=2 those writes keep their pages (64 Ki at most,
under the sparse state's lock they are made with) until the next look,
which counts how many it found and how many of those the scan found
unchanged.

Lines every 256 looks:

  walk staleness (256 looks): K of N looks began with a block the walk
  found that no look had taken yet; a walk pass took A ms (B ms the
  longest, P passes)
  XCL's own writes (256 looks): W pages a look written by XCL since the
  look before (copies back landed, immediates stored), F of them in the
  look, S scanned, U % of those found unchanged

They answer the study's questions of how stale the hot-block look is
and how much of a look is XCL's own writes. With the switch off a look
costs one atomic load more, a copy back landed or immediate stored one
per page.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The pipeline objects XCL owns - the compute pass of a two-pass pipeline
(Drop for TwoPassPso) and the background-built real pipeline behind a
title's stand-in (pso_release) - were released the moment the title
released its pipeline. A list recorded before that and still queued or
running binds them (the two-pass draws bind both), and D3D12 asks that a
pipeline outlives the work that runs it: the GPU would fetch shader code
of a destroyed pipeline.

late_release now takes them as well: a batch entry is a resource or a
pipeline, and a pipeline is released (its COM Release) once every known
queue has passed a fence value signalled after the hand-over, by the
same thread and drains as resources. With XCL_LATE_RELEASE=0 they go at
once, as before. Pipelines XCL releases that were never bound (a build
nobody waits for any more, a duplicate depth-bias pipeline) still go at
once; the depth-bias pipelines derived from a released base pipeline
(device_x) are not changed here.

Cost: a lock and a push per such release (a title's pipeline release);
nothing on draws or binds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
The eight targets drawn into most are a frame's G-buffer. The passes that
turn it into the picture (lighting, the HDR chain, the composite) draw once
or twice each and rank last, so a flat picture over a drawn scene could not
be followed past the scene's targets. A third number names how many of the
ranked targets are written (default eight, 64 at most).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The memory line named the video memory in use, not what Windows lets the
process have. A retail title's world held 29 to 30.5 GB of a 32 GB card with
1 GB already moved off it, and nothing in the log said it was past the
budget. The budget is logged once, and every 2 s while the process is over
it, by how much.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
A retail title's world ended in a driver error whose cause the log did not
hold: the process was killed from outside 3 s after the driver's first event,
before the device was reported removed, and then hung half-terminated in the
driver for five and a half minutes with 27 GB held.

- a ring of the last 16 384 draws and dispatches (pipeline, kind, size,
  frame), written at each one and read only for a report;
- a thread that looks for a removed device ten times a second (it was only
  looked for with XCL_DRED set) and times ExecuteCommandLists and Present in
  the driver: one that has not returned after XCL_GPU_STALL_MS (2 000) is
  reported with the ring, and the title's other submits wait until it
  returns; one that took 250 ms and returned is logged;
- XCL_STOP_FILE=<path>: when the file appears the title ends itself through
  end_title. A file beginning with "fault" first gives the driver 12 s to
  report the device removed, with nothing more submitted.

Not run on a GPU yet: the unit tests cover the ring, the report, the stall
step and the stop file's reading.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The direct translator turned s_barrier into a plain group barrier. That
barrier waits for every hardware wave of the group, and a console wave that
has left, or that ran one barrier fewer, never arrives: on the console the
waves left go on, on NVIDIA they wait for ever and the GPU hangs. The HLSL
path has had the barrier that counts the waves still there since 0c02b87
(xcl_s_barrier); with XCL_DIRECT_DXIL=1 compute programs and the compute
pass of mesh pipelines did not get it.

A retail title has it in 216 compute programs (19 of them branch a wave
with no active lane around barriers the other waves run) and in all 36 of
its mesh programs: the first wave of a group whose vertex or primitive count
is 0, or past 128, runs a barrier the other waves branch around, then the one
they all run. Its world, the first to draw meshes in two passes, ended in a
driver time-out with no shader exception in two runs of three.

A compute or mesh program with s_barrier in a group of more than one
hardware wave is now an error of the direct translator, which sends it to the
HLSL path (XCL_SAFE_BARRIER=0: as before, in both translators).

Not run on a GPU: whether this was the cause of those time-outs is not
shown, and the HLSL compute pass of that title's mesh pipelines has not run
in its 16-window layout.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Translated shaders index the bound sampler heap with S# word 3 & 0x7FF
(SamplerDescriptorHeap in the HLSL path, SAMPLER_HEAP_MASK in direct DXIL),
so an index from 0 to 2047. A console sampler heap got as many PC samplers
as the title asked for (128 in a retail title): an S# the title builds itself
with a nonzero border color pointer in word 3 [11:0], or any index from 128
on, read past the end of the bound PC sampler heap, which D3D12 leaves
undefined.

A shader-visible console sampler heap now gets 2 048 PC samplers (the D3D12
maximum for a shader-visible sampler heap) whatever the title asked for, all
of them made as the zero sampler XCL already wrote into the title's slots
(point, wrap, mip 0). The console side does not change: the heap keeps the
title's slot count, its 16-byte increment and its indexes, and copies,
CreateSampler and the release only touch the title's slots. A CPU-only
sampler heap keeps the title's count (shaders never bind it). The cost is
up to 2 048 CreateSampler calls and 2 048 PC sampler descriptors a heap.

The PC heap's own GetDesc (not hooked) now says 2 048 for such a heap; a
console view heap's already says twice its slots.

Tested on the software adapter only (WARP): the new test
every_sampler_index_a_shader_forms_is_in_the_pc_heap checks the count for
every index a shader forms and that D3D12 makes a shader-visible sampler
heap of that size. Not run on the hardware GPU or on a title.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
view_want's per-thread memory of the ranges it asked for lately matched an
exact (va, len) among the last 8. Mesh-stage root views of a retail title
come at a new offset of tiles asked for already, draw after draw, so
12 000-74 000 of them every 2 s missed it and walked their tiles again in
sparse::map_mirror (a shard lock and a hash insert a tile) for nothing.

The memory now holds the span of 64 KiB tiles each range covers, 32 of
them, and a range is skipped only when all its tiles lie in one span
asked for while the GPU views were as they are now: it is still emptied
when kernelx::gpu_view_map_gen() changes, and a range reaching one tile
further still goes to map_mirror. What gets mapped does not change.

map_mirror returns how many tiles it queued, and the "KB new" figure of
the "GPU view (2 s)" line counts those tiles (64 KiB each) instead of the
length of every range that missed the memory: before, 0.3-35 % of it ever
became a filled tile.

Tested: cargo test --release -p xcl --lib view_want (3 passed) and
map_mirror (1 passed), on the software adapter. Not run on a GPU or a
title: the miss rate on a title is not measured.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The compute path kept a driver blob on disk only when its build took
250 ms (driver_cache::KEEP), and XCL_PSO_DISK_CACHE_MIN_MS, which the
graphics and two-pass paths read, did not reach it. A compute program
whose build takes 100 to 250 ms was compiled again in every run, at its
first bind, and a compute pipeline is waited for: often on one of the
title's threads. In a retail title's run one of its threads spent 228 ms
in the driver on a 4 KB program that no file was kept for.

driver_cache::keep (its only caller is translated_compute_pso) now keeps
a blob of a build of 20 ms or more, and XCL_PSO_DISK_CACHE_MIN_MS chooses
for it as for the others. The graphics and two-pass default stays 250 ms.
The cost is more small files in the driver folder, at most one a compute
program. Programs under 16 KB of DXIL still keep no blob
(COMPUTE_BLOB_MIN_DXIL), as before.

Tested with the unit tests only (software adapter): the new test keeps a
100 ms compute build and fails on the old threshold. Not run on a GPU or
on the title.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A wave64 program on 32-lane hardware runs as two hardware halves that
exchange ballot words and lane values. Groups of more than one console wave
do that through bounded group-shared counters; a group of exactly one
(33 to 64 threads) met at a group barrier at every exchange. Those barriers
hung NVIDIA GPUs when several such programs ran at once (#1727: device hung
and driver event 153 in 11 of 25 parallel runs of the lib tests on an
RTX 5070, none on the HLSL path, whose exchange spins by default). A retail
title's world runs such programs on several queues at once and ended in a
driver time-out with no shader exception.

A compute or mesh group of one console wave now takes the counter exchange
too (its slots and counters are made for it when the program has no LDS).
Geometry programs, which set their partner by phase, and the tests' kernel
form keep the barrier. The change is that of #1741 (hajduzsolt), which is
open and written against an older main; applied here by hand.

Not run on a GPU. The test checks the translated program: one group barrier
(the start's) and the counters' atomics for 33, 64 and 128 threads.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
A retail title's world made about 33 committed buffers of 1-32 MiB a second
for two-pass mesh draws, and let as many go, on a card that was nearly full
(the "two-pass res buffer #n" lines: #2048 at 201 s, #8192 at 384 s). Most
of them are 32 MiB, and they do not come from DispatchMesh: an
ExecuteIndirect of two-pass commands always asked for 32 MiB of records
(each with a 1 MiB argument scratch block), since a command's groups are
known on the GPU only. A DispatchMesh asked for its need, at least 4 MiB.

Each recording keeps its buffers until its PC allocator is reset; then they
went to FREE_RES, which kept 16 buffers or 256 MiB at most: eight of the
32 MiB ones. 24-27 of them were made in the world's first two seconds, so
each round of allocator resets let go of most of what the next recordings
made again. The pick from FREE_RES also took the
first buffer large enough, so a DispatchMesh of a few groups could take a
32 MiB one that the next ExecuteIndirect then made anew.

- Record buffers are a power of two from 1 MiB (the scratch block's size)
  to 128 MiB. A draw gets at least the groups it got before (a test checks
  this over record sizes, splits and group counts). An ExecuteIndirect keeps
  32 MiB of records unless a command's groups in X (65 535 / split) need
  less, which leaves its group cap as it was.
- FREE_RES keeps every buffer handed back, up to 1 GiB, and lets go of one
  no recording took for 2 s; a recording takes the smallest one that fits,
  the last handed back of that size. What it keeps is bounded by what
  recordings took in the last 2 s and by 1 GiB.

When a buffer goes back to FREE_RES does not change: when its allocator is
reset (or alloc_pool sees the GPU past its submits), or 10 s after a
recording with no known allocator. A buffer leaves FREE_RES only for a
recording or to be let go, both after that point.

The DispatchMesh floor goes from 4 MiB to 1 MiB: fewer bytes past the last
record. Every store to a record is bounded by its vertex and primitive
counts (HLSL and direct DXIL mesh and geometry paths), so a store does not
reach past the records a draw dispatched.

Tested on the software adapter only (unit tests of the sizing and of the
pool). Not run on a GPU or with the title: how many buffers a frame now
makes is not measured.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The coherent window is committed when unified memory is made, so it is
sized from what the title asked of it in an earlier run
(<data>/cache/uma_coherent.txt), and that value only grew. A retail
title's 4582 MB of GPU heaps, stored by a run that put them in the
window, made two coherent windows of 4095 + 998 MB in later runs with
XCL_COHERENT_HEAPS=sparse:16. Those runs sent every such heap to the
sparse windows and put at most 105 MB in the coherent window, but with
XCL_UMA_SHADOW=1 each window is shadowed by a video-memory heap of its
full size: about 4.6 GB of video memory and as much commit for nothing,
on a card that was full. The sparse branch returned before the need was
noted, so the stale value never came down.

uma_coherent.txt now keeps one size per XCL_COHERENT_HEAPS setting
(lines "<bytes> <setting>"; the old single number counts as the setting
that puts every heap in the window), and the window is sized from the
one of the run's setting. A heap sent to the sparse windows is noted
too, and a run that has lasted 60 s stores what it put in the window by
then even when that is less than the stored size. A run that ends
sooner only grows it, so a run cut short before it made its heaps does
not leave the next one a window too small for them. XCL_COHERENT_MB
still chooses the size.

With one coherent window instead of two, the view windows of the
16-window layout start at window 4 instead of 5. Everything that uses
them asks the layout (is_view_window, bind::view_span_of,
list_x::pc_va_in, real.rs), and the uma tests already build that layout
with a 512 MB window. Shader translation and the shader and driver
caches are keyed on the number of windows (pso::mem_windows), which
does not change.

Tested: cargo check -p xcl --tests; the uma and kernelx unit tests
(new: the_stored_coherent_need_is_the_one_of_the_heaps_setting,
coherent_heaps_routes), on the software adapter. Not run on the title
or on a hardware GPU.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
When the shared view heap is full, a page of a console view heap that is
first used gets no place there. console_heap::slot then gave its slots the
index 2k, the one they would have in a PC heap of their own, and XCL wrote
that index into the slot's T# (CreateShaderResourceView,
CreateUnorderedAccessView, copies). But that heap is CPU-only once it is
meant for the shared heap, and lists bind only the shared heap, so the
shaders read descriptor 2k of the shared heap: another heap's view, a memory
window's raw buffer UAV for k from 2 to 9 (read as a texture, which hangs
NVIDIA), or, for k of 500 000 or more in a large heap, a descriptor past the
heap's end that the translators' guard (below 2^21 - 1) lets through.

Such a slot now has index 0, the null SRV / UAV pair at 0 / 1, with no
shared descriptor and no GPU handle (nothing is copied for it, and a UAV
clear of it is skipped as before). A heap that has no shared heap at all
keeps its own PC heap and 2k. The frame-trace census takes 0 as such a
slot's own index. Every page that finds no room is counted (each try), and
the warning comes at the first and at every power of two with the count,
where it came only once before.

Nothing in the logs of the last three runs of a retail title shows the
shared heap full, so this does not explain them; that title's heaps would
need 2.56 times the shared heap if every page were placed.

Tested on the software adapter only: the new test
a_slot_whose_page_finds_no_room_names_the_null_views (a fake shared heap with
room for one page, run in a child process) fails without the change (slot
258 got index 516) and passes with it. Not run on the hardware GPU or on a
title.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
How many two-pass record buffers and argument scratch blocks were alive at
once was not logged: the analysis of a retail title's world had to work it
out from the addresses of the first 48 and the powers of two of "two-pass
res buffer #n", and could only guess their share of the 5 GB of video memory
the memory line does not name.

A two-pass buffer is now a TwoPassBuf that counts itself when it is made and
when it is dropped, wherever that happens (FREE_RES letting go of an idle
one or one past its cap, the no-allocator hold past its cap, a test). A line,
always on, at most every 2 s while the counts change:

  D3D12.X: two-pass buffers: N made, N taken again, N let go; N alive
  (N MiB), N of them kept for reuse (N MiB)

The line is left out when FREE_RES is locked on the same thread (a buffer
dropped there); the next change writes it.

No behaviour change besides the line. Tested on the software adapter only
(the bind unit tests; the line shows in their output).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A dispatch waits for its compute pipeline until it is built, and a bind
whose pipeline no worker has started builds it on its own thread, outside
the gate of huge driver compiles. A lazy compute pipeline is sent to no
worker before its first bind, so its first bind always builds it there. In
a retail title's run one of its threads spent 57 s in the driver's
compiler on one program no earlier run had used (827 KB of DXIL, no driver
blob), and another of its threads waited for that pipeline all the time:
no frame for 57 s.

XCL_CS_PSO_WAIT_MS=<ms> is a budget of compute pipelines, as
XCL_GFX_PSO_WAIT_MS is one of graphics pipelines (it goes before
XCL_PSO_WAIT_MS for them). With it a bind takes the path XCL_PSO_WAIT_MS
takes today (resolve_within): the build goes to the xcl-pso workers, where
a huge driver compile waits for its slot once no thread waits for it, the
bind's thread waits at most the budget and never builds the pipeline
itself, and past the budget the pipeline is late: its dispatches get the
stand-in until it is built. Dispatch, the console list replay and
ExecuteIndirect already skip a dispatch with a stand-in and count it
(Dispatch and the replay as a skipped dispatch, ExecuteIndirect as a
skipped draw). Each late program is logged once ("compute pipeline of
record X not built after N ms: its dispatches are skipped until it is"),
by its console program's hash, which the pipeline now carries from its
creation.

Unset or 0, a compute pipeline is waited for exactly as before: the
budget is XCL_PSO_WAIT_MS, and without that, until it is built.

What a skipped dispatch breaks: what it computes is missing or old until
the pipeline is built. When that is the count of a later ExecuteIndirect
(culling and compaction programs), indirect_guard replaces only counts out
of range; an old count in range still draws or dispatches over old data.

Tested with the unit tests only (software adapter): the choice of the
budget, a bind that waits no longer than it while a worker (not the bind's
thread) builds a lazy compute pipeline, and one log line a program. Not run
on a GPU or on the title: what skipped dispatches do to its frames is not
known.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A pool tile that flush_parked unmapped went straight to the free list,
and take_tile popped it last in, first out: the tile unmapped last was
the next one mapped, cleared and filled for another address on the
"xcl sparse queue". When the free list was empty, take_tile even flushed
the parked tiles itself and took one of them in the same submit. That
queue waits for no title queue (with the readback queue, the normal
case), so work the title submitted before the unmap and still running on
its own queues could read the new owner's zeros or bytes, or write into
its tile through the old mapping. vram.rs keeps its freed pages cooling
for 2 s (COOL) for the same reason; sparse.rs had nothing of the kind.

Freed pool tiles (flush_parked, and release_if_unused when a placed
buffer's last user goes) now go to State::cooling with the time they
were freed. take_tile takes the oldest tile freed 2 s ago or more, then
one of the free list (tiles of a pool never used), and otherwise takes
back a retired pool or makes a heap: a tile freed less than 2 s ago is
never handed out, and take_tile no longer flushes the parked tiles (they
would only start cooling). retire_free_pools counts only free and cooled
tiles, so a pool with a tile still cooling is not retired.
new_mirror's "tiles at hand" check after a failed heap counts free,
cooled and retired tiles, no longer parked ones. pool_bytes counts the
cooling tiles as not mapped.

This is a time bound, not a fence: a GPU frame longer than 2 s can still
race. It holds more video memory while a title gives back and asks for
tiles (about 2 s of freed tiles, 60 MB at the 466 tiles/s measured).

Tested on the software adapter: cargo test --release -p xcl --lib sparse
(51 passed, 0 failed, 1 ignored). New tests
a_freed_pool_tile_cools_before_it_is_used_again and
a_pool_with_a_tile_still_cooling_is_not_retired (an injected clock), and
a_tile_given_back_is_not_used_again_before_it_cooled (a state on the
software device); all three fail with COOL set to 0.
a_tile_decommitted_and_committed_again_keeps_its_video_memory, changed
here for the new rule, opens the hardware device and was not run. Not
run on a GPU or a title.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The 64 MiB pool heaps that back the 64 KiB pages of textures in title
memory (vram::Pages) only grew: bind made a heap when the pool had no
free tile, and nothing ever let one go. In two runs of a retail title
350 MB of those pools sat free, more after a streaming burst, on a card
that was full.

A pool heap all of whose tiles are free goes now. A tile is only in a
free list after COOL in the cooling queue, so such a heap has no page
in use, idle or cooling. After each placement, TilePool::take_free_heaps
takes such heaps out: their tiles are not handed out again, and their
index becomes free (TilePool::live, Pages.pools holds None there). The
next heap takes the first free index. take_batch now gives make_heap
the index to fill, so the pool and Pages.pools cannot disagree on it.
A tile of a given-back heap that came back to the pool (none should)
is dropped instead of handed out.

A heap that came free is retired first, as sparse.rs retire_free_pools
does with its pools. The next pool that is needed takes it back before
a new heap is made, so placing and freeing in turn does not make and
end a heap each time. It is let go once the page-mapping fence is past
the value it had when the heap came free and 2 s went by. Even then it
does not go at once: it goes through late_release (new: hold_heap,
Dead::Heap), in a batch sealed after it. A texture the title released
is held there and still maps pages of the heap, and work queued before
that release may still read them. A heap destroyed under that work is
a GPU page fault, where a page reused under it only gives wrong texels.
So the heap goes once every queue XCL knows of is past that work, never
before the textures held with it. If a queue never gets past, the heap
is never released, which is no worse than before.

The 'pools' figure of the memory line (page_bytes) counts the retired
heaps that are not let go yet.

Tested: cargo check -p xcl --tests; the vram and late_release unit
tests on the software adapter (new: tile_pool_gives_back_wholly_free_heaps_and_reuses_their_index,
retired_pool_heaps_go_after_the_fence_and_a_moment). The test of the
churned pool now also checks the index each new heap gets. Not run: the
tests that place textures on a hardware device
(d32s8_targets_take_their_own_size_of_video_memory,
reservable_agrees_with_the_driver and the other hardware tests), the
title, and any real D3D12 run of bind with a heap given back.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The build-ahead backlog took a lazy compute pipeline only when an earlier
run had used its shaders (used-pipelines.txt). Any other compute pipeline
was built at its first bind, which waits for it: in a retail title's run
one of its threads spent 57 s in the driver's compiler on a program the
two runs before had never used, while another of its threads waited for it.

Compute pipelines of shaders no earlier run used now go to the backlog
too, in a lane of their own. The backlog serves the known compute
pipelines first, then this lane, then the known graphics ones, then the
other graphics ones (translated first, then built) as before. The known
compute ones, which used to share a lane with the known graphics ones in
the order they were made, now all come before them. The new lane is under
the rules of every pipeline no earlier run used: built only with
XCL_PSO_AHEAD's cap not reached and 8 GB of commit free (ahead_room),
counted against that cap, on the lowest-priority preload workers, a huge
driver compile behind the gate and giving its turn to any build a bind
waited for, and one a bind wants is left to the bind's workers.

This shortens how long a new compute pipeline is waited for (or, with
XCL_CS_PSO_WAIT_MS, how long its dispatches are skipped) and fills the
driver blob folder for the next run. It cannot build all of a title's
compute programs in its menus on a first run: a retail title has ~1 600
it never used, many of them taking the driver seconds to a minute.
The cost: each pipeline built keeps ~400 KB in the driver whether it is
used or not, and the known graphics pipelines are built later than
before, so a draw is more likely to wait for one (or, with
XCL_GFX_PSO_WAIT_MS, to be skipped).

The test of known pipelines built ahead no longer says an unknown compute
pipeline is still pending before its first bind (it may now be built
ahead); it still says nobody used it before then. Tested with the unit
tests only (software adapter): the lane order, room and cap, and a lazy
compute pipeline of new shaders built with no bind when commit is free.
Not run on a GPU or on the title.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A dumped texel was read as 4 bytes at a 4-byte stride whatever its format,
and only four formats had a colour. A retail title's scene colour (RGBA16F),
its normals and velocities (R16G16), ids (R32_UINT) and masks (R8) were
written as black pictures, "format not decoded", with every other half
texel in the raw values; a one-byte target was read past its rows. The
picture stayed flat over a drawn G-buffer and the stages between could not
be looked at.

Texels are read at the size of their format and the float, 16-bit, 8-bit and
integer render-target formats get a colour (floats tone-mapped as R11G11B10
is, NaN and infinity white).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The sparse windows' timing line is written only at power-of-two submit
counts, and TILE_WORK is read only with XCL_LOOK_STATS=2, so the logs of
a run that ended in a graphics driver hang had no rate of mapping
changes in its last minute: the UpdateTileMappings calls and tiles a
second could only be inferred.

map_tiles and unmap_tiles now count their calls and tiles with relaxed
atomics, always, split by the kind of window the resource lies in
(sparse windows, view windows for GPU views; a placed buffer counts with
its window), and the activity thread logs them every 2 s:

  tile mappings (2 s): sparse windows N calls mapping N tiles, N calls
  unmapping N tiles; GPU views N calls mapping N tiles, N calls
  unmapping N tiles

The line is left out when there were no calls. The vram.rs tile-mapping
queue (textures in title memory) is not counted here.

Tested on the software adapter: cargo test --release -p xcl --lib sparse
(52 passed, 0 failed, 1 ignored), new test
the_tile_mapping_line_counts_since_the_last. The line was not seen in a
run of a title.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Nothing in the log said how full the shared view heap got: the only line
was the warning once it was full, so a run that came near the end, or how
fast pages were placed, could not be told from the log. A retail title's
heaps would need 2.56 times the heap if every page were placed.

The shared heap now counts the pages of console heaps placed in it (placing
one adds, a heap's release takes its pages off), and the first time the
descriptors in use (those below the cursor, less the released ranges; the
null views and memory windows at the start count) pass 50, 75 and 90 % of
the heap, one info line says the mark, the descriptors in use, the heap's
size and the pages placed. The full warning gives the same numbers.

The 2 s "memory:" line in host.rs is left as it is: adding the heap there is
more than a one-line change, and the marks give the same answer.

Tested on the software adapter only: shared_heap_use_and_the_marks_it_passes
(the arithmetic) and the placed-page count and marks in
a_slot_whose_page_finds_no_room_names_the_null_views. Not run on a title,
so the log lines have not been seen in a run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Nothing bounded the two-pass record buffers and argument scratch blocks
alive at once: each recording holds its own until the GPU is done with it,
and a retail title's world had about 0.8 GB of them a few seconds in, on a
card its process kept nearly full. A committed buffer made there succeeds
above the OS budget, so nothing else would have stopped them.

A two-pass buffer is now made only if the bytes of those alive (held by
recordings, waiting for their allocator, or free) stay within the cap:
1024 MiB by default, XCL_TWO_PASS_MB to choose. When they would not, the free
ones in FREE_RES are let go first, oldest first, as many as it takes (the
GPU is done with them). If that is not enough, the buffer is not made and
the draw that asked for it is skipped, as one whose record does not fit the
record buffer is today, with a warning the first 8 times and a count on the
"two-pass buffers" line. The count is reserved before the buffer is made,
so threads making them at once do not pass the cap together.

Buffers held for a recording are never let go for the cap: when they go
does not change.

Tested on the software adapter only (unit test of the reservation and of
making room). Not run with the title: whether 1 GiB skips draws in its
world is not known.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The previous commit lowered the compute keep threshold to 20 ms, but
translated_compute_pso reaches driver_cache::keep only when
keep_compute_blob returns a blob, and keep_compute_blob returned none
for a program under 16 KB of DXIL (COMPUTE_BLOB_MIN_DXIL). So the case
that commit gave as its reason, a 4 KB program a retail title's thread
spent 228 ms on in the driver, still kept no file and was compiled
again in every run; its test called keep() directly and skipped that
floor.

The 16 KB floor now applies to the in-memory store only
(compute_blob_kept): a compute build of the keep threshold or longer
gives its blob to the disk cache whatever the program's size, and a
small program's blob is not put in memory. A program of 16 KB or more
is kept exactly as before. The graphics path keeps its floor.

The blob of a small program goes through the same file and load path
as the others (the driver refuses one of another driver, adapter or
root signature, and the program is compiled as before).

Tested with the unit tests only (software adapter): the new test of
compute_blob_kept says a 4 KB program built in 228 ms goes to disk
and not to memory. Not run on a GPU or on the title.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The previous commit wrote one line "<bytes> <setting>" per
XCL_COHERENT_HEAPS setting into <data>/cache/uma_coherent.txt. Every
build of a title shares that folder, and builds from before that commit
read the file with trim().parse::<usize>(): on the new text they got 0
and made a 512 MB coherent window with XCL_COHERENT_HEAPS unset, too
small for a retail title's 4.4 GB of GPU heaps, which then go to plain
memory where its shaders read zeros. They then wrote a bare number over
the file and dropped the other settings' sizes, so the two formats kept
overwriting each other, and a main run after a run of this build (as
the smoke comparison does) started with the small window.

uma_coherent.txt now stays one number, the size for the setting that
puts every heap in the window, read and written as before. The other
settings keep theirs in uma_coherent_<setting>.txt (':' as '_'), which
earlier builds never open. A uma_coherent.txt in the per-line format
reads as none here too and is written over with a number at the run's
first GPU heap.

Tested: cargo check -p xcl --tests; cargo test --release -p xcl --lib
coherent (7 passed, on the software adapter), with the changed test
the_stored_coherent_need_is_the_one_of_the_heaps_setting. Not run on
the title or on a hardware GPU.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Since freed pool tiles cool for 2 s before reuse, a pool can only be
retired once its last tile has cooled. retire_free_pools was still called
only right after flush_parked() freed tiles, and the tiles that flush
freed were stamped with its own instant, so they could never complete a
pool there. When the title stopped giving tiles back after a level unload
or forget_mirrors, nothing called retire_free_pools again: the 64 MB heaps
stayed (and retired heaps were not dropped) until some later give-back.

A submit now also tries retire_free_pools when no tile was flushed but a
tile in cooling has cooled or a retired heap waits to be dropped, at most
once per COOL after the last try (retire_due, retire_tried), so a submit
does not count the cooling queue every frame. A pool goes at most about
2 x COOL after its last tile was freed. The other call sites (the
PARKED_MAX flushes while decommitting) are unchanged. Retiring later than
the flush uses a fence value at least as new as the one the flush signalled
after its unmap, so the heap is not dropped earlier than before.

Tested through the software adapter only (no hardware GPU):
a_submit_with_nothing_freed_retires_pools_once_tiles_cooled (pure, with
an injected clock) and a_pool_goes_once_its_last_tile_cooled_with_nothing_parked
(state on WARP: the pool's last tile is freed at a submit, then a submit
COOL later with nothing parked retires it; it fails without the change).
cargo test --release -p xcl --lib -- --test-threads=2: 1221 passed,
0 failed, 23 ignored, 52 tests that open the hardware GPU not run. Not run
on a GPU or a title.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
When a new two-pass buffer would take the buffers alive past
XCL_TWO_PASS_MB, TwoPassBuf::make let the freed ones in FREE_RES go,
oldest first, until they came to the bytes over the cap. It did so also
when all of them came to less: the whole pool was let go, the second
reserve still failed and the draw was skipped anyway. The recordings
after it, which would have taken those buffers again and drawn, then
found the pool empty, asked make() for new ones and were refused too.
At the cap that skipped more draws than needed and sent a burst of
resource destructions to the driver when the card is fullest.

FreePool::take_room now gives nothing and keeps the pool when all it
holds is less than asked, and make() works out the bytes over the cap
with FREE_RES locked, so the free ones are in the load it compares. One
attempt still (a buffer another thread reserves in between can make it
fail after the free ones went, as before).

Verified: the two_pass unit tests on the software adapter (take_room
of more than the pool holds gives None and keeps it). Not run: a title,
and the tests that open the hardware GPU.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The lane of compute pipelines no earlier run used, added two commits
ago, came before the known graphics pipelines with no bound: every
preload worker took from it while it held anything, and pipelines made
later joined it ahead of all queued known graphics ones. A retail title
makes ~1 600 compute pipelines it never used, some taking the driver a
minute, and there are 2 to 4 preload workers, with one huge driver
compile at a time behind the gate: all workers could sit on that lane
(one compiling, the others parked at the gate) for the whole session,
and no known graphics pipeline, not even one whose driver blob loads in
milliseconds, would be built ahead. Each would then be built at its
first draw on the title's thread. That commit's message said they are
built "later than before"; they could be starved.

Backlog::next now hands out one pipeline of that lane at a time
(compute_out, cleared by Backlog::built when the worker's build is over
or a bind took the job): while a worker builds one, the other workers
take the known graphics pipelines and the rest in the order as before.
The known compute pipelines still come first, and the lane is still
under ahead_room, ahead_cap and the gate.

Left out: when nothing else is queued the other workers stay idle
rather than build more new compute pipelines; the lane drains at one
worker's speed. A known huge graphics build can still wait at the gate
while the lane's build holds the only huge slot (XCL_HUGE_PSO_CONCURRENCY
default 1), as any two huge builds ahead of their use do.

Tested with the unit tests only (software adapter): the new test takes
pipelines from the backlog without finishing them and gets the known
graphics ones while a new compute one is out, and the next new compute
one only after it is built; the lane order test still passes. Not run
on a GPU or on the title.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Since the per-setting sizes, a run that had lasted 60 s stored what it
had put in the coherent window by then, also when that was less, with
every XCL_COHERENT_HEAPS setting. With the default one (every GPU heap
in the window) the size used to only grow. A run that stays in the menu,
or a fixed-length smoke run that loads no level, has asked for about
1 GB of a full run's 4.5 GB by then: stored, it makes the next full
run's window about 1.5 GB, and the heaps past it go to plain memory,
where a retail title's shaders read zeros.

The stale size of the incident only needed the per-setting split, so
lowering is kept for the settings that send heaps to the sparse windows
(sparse, sparse:N), where a size measured with more in the window cost
video memory for nothing, and there it comes down by half at most per
run, so one short run cannot take a full run's size away at once. The
default setting only grows the stored size again.

Tested: cargo test --release -p xcl --lib coherent (8 passed, on the
software adapter), new test
only_the_sparse_heaps_settings_lower_the_stored_coherent_need. Not run
on the title or on a hardware GPU.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
With XCL_LAZY_PSO=0, go_background sent a compute pipeline to the
workers with pso_async::submit, which gave it no console program
(record 0), although go_background had computed it for the lazy path.
resolve_within writes the "compute pipeline of record X not built
after N ms" line only for a known record, so with XCL_CS_PSO_WAIT_MS
set a late pipeline on that path fell back to the generic line, which
is written for the first 16 and then at powers of two: most late
programs were not logged at all.

The non-lazy path now passes the record (pso_async::submit_with).
Nothing but the log line reads it.

Tested with the unit tests only (software adapter): the new test says
a pipeline sent to the workers when made carries its record. Not run on
a GPU or on the title.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review of d4624b7: its test covered only pc_samplers() and that D3D12 makes a
2 048-sampler shader-visible heap. Sizing the PC heap with the title's count
again, or filling only the title's slots, passed every test; the second leaves
indexes 128 to 2047 unwritten sampler descriptors, which D3D12 leaves
undefined, the hazard d4624b7 removes.

The PC heap's description moves into pc_descriptor_heap_desc and the zero
sampler fill into zero_samplers, which now fills every sampler the PC heap
holds (its own GetDesc, called from XCL, so the PC's) instead of a count passed
beside it. No behaviour change.

The new test a_shader_visible_sampler_heap_has_the_zero_sampler_at_every_index
makes a shader-visible sampler heap of 128 slots through device #14 on a WARP
device adopted as a title's, and checks that its PC heap holds 2 048 samplers
and that the descriptor bytes of every one, 2047 included, are those of slot 0.
Checked that it fails with the PC heap sized at the title's 128 ("the PC heap":
128, not 2048) and with the fill stopped at 128 ("PC sampler 128": zero bytes).

Tested on the software adapter only (WARP). Not run on the hardware GPU or on a
title.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
At the title's last Release of an allocator, alloc_pool::forget handed
back (console_list::allocator_reset) only what the PC allocators made
for it held, never what the allocator itself held. So the two-pass
buffers in ALLOC_RES for it, and the unified-memory blocks in PENDING
for it, went back only if a later allocator got the same address and
was reset. Before the two-pass cap that was a leak; with the cap
(XCL_TWO_PASS_MB, 1 GiB by default) the buffers stay counted alive, and
a title that destroys and makes allocators again (level changes) could
reach the cap and lose its two-pass draws for the rest of the session.

forget now hands back what the allocator itself held when its backing
is free: no list records on it and every submit of one is passed by the
GPU (the fences `executed` set) - the same test a Reset of it passes
before allocator_reset runs. It is taken before the loop, since the
allocator may be both its own stand-in and put aside, and its backing
goes at the first. Still left as before: an allocator a list still
records on at its Release, or whose submits the GPU has not passed,
keeps what it held (its backing is no longer tracked, so nothing says
when the GPU is done with it); the next commit logs those bytes so a
cap held by them can be seen.

Test: a_released_allocator_gives_back_its_two_pass_buffers (WARP
buffers, synthetic allocators): the released allocator's buffer goes
to FREE_RES, that of one a list still records on stays in ALLOC_RES.
It fails with the hand-back disabled. The d3d12x unit tests pass on the
software adapter; the tests that open the hardware GPU and a title run
were not run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The two-pass stats line said how many bytes are alive and how many of
them are kept for reuse, but not where the rest wait. Bytes held in
ALLOC_RES for an allocator that is never reset again (one released
while a list still recorded on it or its submits were in flight, which
alloc_pool::forget still leaves), or in UNKNOWN_RES, count against
XCL_TWO_PASS_MB; the line now gives both, so a cap held by them can be
told from one held by recordings.

The locks are only tried, as FREE_RES already is: a buffer can be let
go with ALLOC_RES locked on the same thread. Logging only; no test.
Built and the two_pass unit tests run on the software adapter.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review of d4624b7: the PC heap behind a shader-visible console sampler heap
now holds 2 048 samplers, and descriptor heap #8 GetDesc was not hooked, so a
title asking its 128-slot sampler heap for its description read 2 048. A title
that sizes an allocator or a loop from that count makes samplers or copies at
console handles past its 128 16-byte slots: console_heap::slot finds none
there, dev_create_sampler_x hands the handle to the PC CreateSampler as it is,
and the driver writes a sampler descriptor at that address in the title's
memory. A view heap already read twice its slots, and one whose views are in
the shared heap read no shader-visible flag. Whether the retail title calls
GetDesc on these heaps was not checked (no trace taken).

Device #14 now keeps the description each console CBV/SRV/UAV and sampler heap
was made with (the title's type, 4 included, count, flags and node mask) until
the heap's last Release, and #8 answers it to calls from the title's images,
returned through the hidden pointer called the C++ way or the C way
(this_first, as device #25 / #26). Other heaps, and every call from XCL itself
(the split slot: list_x::pc_heaps reads the PC flags), get the PC
description as before.

New test a_console_heap_describes_itself_as_the_title_made_it, on a WARP device
adopted as a title's: a shader-visible sampler heap of 128 made through device
#14 answers [1, 128, 1, 0] both ways while XCL's own GetDesc says 2 048; a view
heap answers the PC description until it is known as a console heap of type 4
and 64 slots, then that; both are forgotten when released; #8 is in the
descriptor heap's console slots. Checked that it fails with the hook answering
the PC description ("the sampler heap": [1, 2048, 1, 1]). The view heap's
recording at creation is not covered (making a view heap through #14 makes the
process-wide shared heap).

Tested on the software adapter only (WARP). Not run on the hardware GPU or on a
title.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
A thread remembers the tiles it asked for in GPU views so that draw after
draw does not ask again, and forgot them only when a view's mappings
changed. A tile given back when the title decommits its source, or dropped
because its source was not there yet, leaves the set of asked tiles without
that: the thread still remembered asking, did not ask again when the title
committed and bound the memory again, and the tile stayed unmapped. A mesh
read zeros for its vertices, and a retail title's mesh programs take a count
of 0 as an empty group. The title gives back about 470 tiles a second while
its world streams in. The exact-range memory before had the same hole for a
range bound again at the same address; remembering whole tile spans widened
it.

The asks forgotten are counted (sparse::mirror_asks_forgotten) and a
thread's memory is emptied when the count changes, as when the views change.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Twelve files conflicted. Where both sides had solved the same problem the
upstream implementation is taken and the local one removed, with what the
local one covered beyond it kept on top:

- the shared view heap is 1 000 000 descriptors and the shaders' T# index
  guard is tied to it (19bef42) instead of the heap tried at 2^21; the null
  fill of the whole heap and its build outside the lock stay
- empty 64 MiB page-pool heaps are reclaimed by upstream's sweep with its
  fences and warm spare (5a515f0) instead of the local retire list; the
  check that a heap has no live tile and the hand-over to late_release stay
- wanted huge driver compiles are hard-capped (ae00ec7) instead of going on
  without a slot; build-ahead still gives its turn to a wanted build
- a newer-layout #139 Reset reaches the wrapper's Reset through reset_x
  (78fba7b) instead of the local slot_139
- a Draw on a two-pass pipeline is skipped by upstream's guard (a7b478b);
  the local ExecuteIndirect path that runs a noted DispatchMesh signature
  as two passes stays, as does the skip without a graphics root signature
- write_u64_now checks through upstream's u64_writable_now

Both kept: the shared sampler heap (71639e0) with the local 2 048 PC
samplers and names bookkeeping, XCL_PSO_IMAGE_SKIP (5f4d32f) beside
XCL_CS_PSO_WAIT_MS, the image_load-after-store read (ec356bc) beside the
coherent-memory gating.

Software adapter: cargo test --release -p xcl --lib -- --test-threads=4:
1319 passed, 0 failed, 23 ignored; the 55 tests that open the hardware GPU
were not run.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
ensure_view_heap binds the shared sampler heap in the same call as the
shared view heap when there is one (71639e0). The test of the two-pass
binds, which runs only with XCL_HEAP_WINDOWS=1 on a hardware device, still
expected the view heap alone and would fail as soon as a test before it had
made the sampler heap. It now expects what the bind sets, as upstream's
unbinding_all_heaps_lets_the_shared_heap_be_bound_again does.

Type-checked only: the test opens the hardware device and was not run.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The stream recheck fingerprints a texture that is not fully write-watched
when it is uploaded, and re-queues it at later frame milestones when its
memory no longer matches that fingerprint. It assumed every upload sends
the whole texture, so the fingerprint equals what the PC texture holds.
Here an upload can be partial: a Due with whole == false sends only the
written pages it knows of, or nothing when texture_upload::changed finds
them unchanged. seed_stream_recheck seeded every Due, so after an
unwatched write followed by a partial upload of other pages the baseline
already held the unwatched bytes, the milestone recheck matched it, and
the texture kept the old contents on the GPU.

Only a whole Due now sets the baseline. A partial one leaves the entry
alone, its schedule too: moving the schedule on every partial upload would
keep a texture written every few frames from ever reaching a milestone.
A partial Due that turns into a full upload (Parts on a render target, or
XCL_TEXTURE_PARTS=0) does not reseed either; its milestone then sees the
old baseline and queues one extra whole upload.

The new test seeds with a whole upload, writes an unwatched byte, runs a
partial Due through the seeding and checks that the milestone queues the
texture; it fails without the change. Both stream recheck tests now take
TEST_LOCK, since a recheck in one checks the other's STREAM_RECHECK entry.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A split segment moved to the spares (title_list::reset, KickoffX) went
through alloc_pool::forget_list to drop its allocator pin. forget_list
also removes the list's last submit and recording count, which
alloc_pool::in_flight reads: pop_spare then handed out a PC list the GPU
was still running, the title recorded into it and submitted it again
(debug layer id 553; NVIDIA removes the device), and note_resubmits had
nothing left to report it with. It happens with a stand-in moved to the
spares while its submit runs, a segment still queued behind a queue Wait
after the primary is done, and the segments KickoffX has just submitted.

clear_segment_state now calls alloc_pool::unpin_list, which removes only
the allocator pin (of_list and the backing's users). forget_list, which
removes everything, stays for the paths where the PC list is destroyed
(on_release, title_list::release) and its address can come back.

Tests: the reset-while-the-last-submit-runs test resets and submits once
more while the queue is held, so a stand-in still in flight is in the
spares and must not be used; a new test splits a list, KickoffX submits
it, and the next split must not get the segment just submitted. Both
fail without the change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
in_flight and note_resubmits read the fence of a list's last submit
through the fence's own vtable. alloc_pool makes that fence on the
queue's device, so it can carry XCL's GetCompletedValue hook for the
title, which tries the sparse state's lock to land copies back. These
are XCL's own queries, made with alloc_pool's lock held (and in
pop_spare with title_list's segments lock too, once per spare); the same
hook cost about 2 ms per query in Backing::idle until that moved to
real::fence_completed. Both now use real::fence_completed as well.

The value read is the same, so no test tells the two apart; the existing
alloc_pool and list_x tests of in_flight and note_resubmits still pass.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
When a PC resource is destroyed, resource_gone makes its views in the
shared shader-visible heap null views and records those indexes as
naming nothing. The title's own PC heap, the CPU-only mirror views are
made in and copied from, keeps the destroyed resource's descriptor. A
later copy of that console slot (CopyDescriptorsSimple from a CPU-only
heap, a stale material table) copied the mirror's dead descriptor into
the destination's place in the shared heap and recorded it as naming
nothing, so no later destroy would ever null it: a shader sampling it
touches unmapped memory, the fault resource_gone exists to prevent.

A claimed index is now recorded as GONE instead of 0. names_of hands
that to publish_range, which writes the null view of its kind over a
GONE source's copy in the shared heap and records the destination as
GONE too, so a copy of that copy is nulled the same way. The check is
made where the copy is published, under SLOT_WRITES, and nothing is
written into the title's mirror, so a view the title makes in that slot
meanwhile is not overwritten. The lock order at SLOT_WRITES is kept:
the null views' source (GLOBAL) is taken before SLOT_WRITES, as in
resource_gone.

The new WARP test (in a child process, the shared heap being the
process's) makes an SRV of a texture in a CPU-only console heap, ends
the texture, copies the slot into a shader-visible heap and again from
there: the shared descriptors of both copies must be the null view and
named GONE. Without the publish_range change the first copy holds the
texture's view.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The lane of giant driver compiles (4 MiB of DXIL or more) has one slot,
for wanted builds too (the hard cap from upstream), and the backlog
builds pipelines ahead of their first use on its lowest-priority workers.
Together a giant build ahead could take the free slot, and a giant build
a bind waits for then stood behind it for that whole compile (minutes),
because a slot is never given back before the compile ends.

A build ahead of its pipeline's first use now takes no slot in that lane:
it waits there, holding none, until its pipeline is used (a bind wants it
and it takes the wanted slot, or a bind gave up on it and it waits like
any unwanted build). It does not spin: it sleeps on the lane's condvar
with the same 50 ms re-check as every waiter. So that a pipeline the title
never uses cannot hold up the backlog, the waiting build's backlog worker
gives back the lane of new compute pipelines and a new worker starts in
its place (pso_async::build_parks); the waiting thread ends after its
build. The BIG lane is unchanged: it keeps a wanted slot free beside the
one an unwanted build can take.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
With XCL_PSO_IMAGE_SKIP=1 a bind does not wait for a big compute program
that writes only images; resolve_spared sent its build to the normal
worker queue. Those builds are unwanted, so each one, after translation
and DXC, waits in big_compile_turn for the single unwanted slot of huge
driver compiles. A world start binds hundreds of such programs: with more
of them queued than there are workers, every worker sat in that wait, and
with a wait budget (XCL_CS_PSO_WAIT_MS or XCL_PSO_WAIT_MS) a build a bind
waits for, which only the workers build then, stood in the queue behind
them until the bind's budget ran out.

Their builds now go to the build-ahead backlog, in the lane of new compute
pipelines (Backlog::spared): handed out one at a time with that lane,
before its pipelines, and also short of commit or past XCL_PSO_AHEAD,
since these pipelines are used. The normal workers stay free for builds a
bind waits for. Without the backlog (XCL_PSO_PRELOAD=0) the build goes to
the normal workers as before, and with XCL_PSO_IMAGE_SKIP unset no
pipeline is spared, so nothing changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Several comments still described an older rule, that a build a bind
waits for goes on at once without a slot of huge driver compiles. Since
the hard cap on wanted builds, a wanted build skips only the wait for
free commit and takes one of the slots kept for wanted builds, up to
their cap. The comments of driver_compile, build_is_wanted,
Pending::unwant, cs_wait_budget and the backlog now say so, and the
backlog's also says that a build ahead takes no giant slot.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Since only a whole upload seeds the stream recheck baseline, a partial
upload of an unwatched texture that has no recheck entry (it retired
after its last milestone, was pruned while its range was watched, or
was never seeded) did nothing. Writes to its unwatched pages after that
upload went unnoticed until something else made the texture pending.
Before, the partial upload re-created the entry, with a fingerprint of
memory the GPU never got.

Such a partial upload now inserts an entry without a baseline
(last_fp: None). Its first milestone always queues the texture, and the
whole upload that follows sets the real baseline. An existing entry is
still left alone by a partial upload, so its baseline and schedule stay
those of the last whole upload.

The cost is at most one extra whole upload per partial upload of a
texture without an entry, four frames later.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A giant driver compile of a pipeline nobody has used yet waits for that
first use and takes no slot (real::huge_compile_turn). On a backlog
worker, build_parks gives back the lane of new compute pipelines and
starts a worker in its place, and the waiting thread ends after its build
without giving the lane back again. Nothing tested that part. If it
regresses, the lane of new compute pipelines, and the spared lane that
shares its turn, stops for good behind a pipeline the title may never
use.

The new test runs on the global backlog. A lazy compute pipeline with a
key no run used is built on a backlog worker, and its job calls
huge_compile_turn for the giant lane. The test checks four things:
- the next new compute pipeline is built while the giant one waits, and
  another worker has taken the waiting one's place;
- once a bind waits for the giant one (resolve_wait_for), it goes
  through the giant slot and is built;
- the waiting thread then ends, leaving as many backlog workers as
  before (counted by thread name);
- while another new compute build holds the lane, the end of the giant
  build does not give the lane back a second time.

With build_parks made a no-op, the test fails on the first check. With
the parked thread calling Backlog::built again, it fails on the last.
huge_compile_turn, SlotGuard and GIANT_DRIVER_COMPILE become pub(super)
so the test can reach them. No behaviour changes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
The direct translator now refuses a compute or mesh program with
s_barrier in a thread group of several 32-lane hardware waves, so that
the HLSL path's bounded barrier takes it. A program the HLSL path could
not translate completely would then lose its dispatches or draws
altogether, and nothing checked that for a title's real programs in the
layout its runs use (16 memory windows from the descriptor heap, split
wave64).

XCL_SAMPLE_BARRIER=<folder of dumped shaders> (ignored test, as the other
tests on a title's data): for every such program it checks that the
direct translator refuses it for the barrier and nothing else, that the
HLSL translation is complete and has the bounded barrier, and that DXC
compiles it.

Measured on a retail title's 216 compute and 36 mesh-pass programs with
the barrier (software adapter, XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1):
252 refused for the barrier, 252 complete on the HLSL path, 252 compiled.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
XCL_SAFE_BARRIER=0 changes what both translators emit (the HLSL path's
plain group barrier instead of xcl_s_barrier) and, since the direct
translator leaves a compute or mesh program with s_barrier in a group of
several hardware waves to the HLSL path, which translator takes such a
program. It is neither part of the translated cache's identity nor in
cache_allowed's list, while XCL_WAVE64_SPIN and XCL_X64_ALL_MASKS are.
One diagnostic run with XCL_SAFE_BARRIER=0 therefore stored DXIL with
plain group barriers in multi-wave compute and mesh-pass programs, and
every later default run loaded it from disk first; the other way round,
the switch had no effect on programs a default run had already cached.

It is now in the list: while it is set, compute and mesh programs are
translated without the disk cache, as with the other switches that
change the translated code. The cache test checks it for compute, mesh,
vertex and pixel stages.

Tested (software adapter, through the agent wrapper):
  cargo test --release -p xcl --lib -- --test-threads=4 gpu::recomp::
    370 passed, 0 failed, 18 ignored
  ... gpu::dxil::   150 passed, 0 failed, 3 ignored
  ... barrier       6 passed, 0 failed, 1 ignored
Not run: the 55 tests that open the hardware GPU themselves (the wrapper
skips them on this machine); no GPU run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The watch held every later submit of every thread once an
ExecuteCommandLists or Present had not returned for XCL_GPU_STALL_MS,
with no time limit. A call that only waits for GPU progress which
depends on a submit the gate then parks (a cross-queue fence, a Write64
wait bridged to a queue Wait) never returns, so a slow moment became a
permanent stop. The stop file was read on the same thread, after the
device poll: had GetDeviceRemovedReason not returned in a driver error,
the stop would never have been taken and the process would have been
killed from outside with GPU work in flight.

- A long call is logged when it passes the limit (with the ring), every
  5 s while it lasts, and when it returns, with the real length of the
  stall (its start is kept on its own; the old line computed it from
  the time last said, which every 5 s overwrote). The decision is a pure
  step function (watch_step) with tests, among them a 13 s stall.
- Command lists are held only while a stop for a driver error is being
  handled (HOLD, set by the stop file's fault path). The wait takes the
  flag, and returns at once on a thread that is itself inside a timed
  call (it would wait on itself).
- The stop file is read on its own thread (xcl-stop-file), also with
  XCL_GPU_WATCH=0, which calls nothing in the driver before the title
  ends. It is read as bytes: a file that is still empty is ignored (10
  polls in a row: end), a UTF-8 BOM is stripped, UTF-16 LE is decoded.
  On a fault it waits 12 s for the watch thread's device poll, and
  says when that poll itself has not returned (a heartbeat).
- The 65th thread that asks for a slot is logged once.

Tested on the software adapter, through the agent wrapper:
  test --release -p xcl --lib -- --test-threads=4 watch::
    9 passed, 0 failed, 0 ignored
  test --release -p xcl --lib -- --test-threads=4 hle::d3d12x::
    344 passed, 0 failed, 1 ignored
Not run: the 55 tests that open the hardware GPU themselves, and no
title or driver hang (the stall and stop paths are covered by their
pure functions and the hold test only).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
On 32-lane hardware the direct translator runs the ES phase of a
geometry pass in both hardware halves of the console wave with
Partner::Present (translate_on_this_thread sets it per phase), so every
ballot and lane read meets the other half at a plain group barrier.
That is the pattern of #1727 (NVIDIA GPUs hung with the direct
translator's exchanges at group barriers), which the previous commits
removed for compute and mesh programs; the HLSL geometry path exchanges
through the bounded spin by default (x64_spin: XCL_WAVE64_SPIN unset).

kernel::translate_geometry now refuses the split form when the program
has an ES phase and the safe barrier is wanted (XCL_SAFE_BARRIER=0: as
before). Its only runtime caller, pso::console_geometry, logs the
refusal through direct_fallback and translates the pass on the HLSL
path; the shader cook does not translate geometry passes, and the
direct coverage sweep counts the refusal as a fallback reason. The GS
alone (no partner half) and the native wave64 form stay direct.

Tests: a new one checks the refusal (ES+GS and ES alone, 1, 4 and 16
heap memory windows) and that the native form and the GS alone still
translate; it returns early under XCL_SAFE_BARRIER=0. The tests that
sent split geometry through the direct translator (geometry_forms_validate,
gpu_geometry_direct_records, geometry_mode_validates,
gpu_geometry_wave32_prefix_count_over_a_mask) take the HLSL path's
container on exactly that refusal, check its translation is complete and
compile it with DXC, as tests.rs's direct_or does for compute and mesh.

Tested (software adapter, through the agent wrapper):
  cargo test --release -p xcl --lib -- --test-threads=4 gpu::dxil::
    151 passed, 0 failed, 3 ignored
  ... gpu::recomp::  370 passed, 0 failed, 18 ignored
  ... barrier        6 passed, 0 failed, 1 ignored
Not run: the 55 tests that open the hardware GPU themselves (the wrapper
skips them on this machine); gpu_geometry_direct_records skipped (no
mesh shaders on the software adapter); no GPU run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The report of the last draws and dispatches had three gaps:

- It named a pipeline through pso_async::resolve, which notes a use
  and sends a lazy pipeline not yet built to the workers: a stall or
  removal report could start a pipeline build on a driver that hangs.
  pso_async::peek returns the real pipeline behind the handle (or the
  handle) with no side effect, and the report uses it.
- Graphics pipelines are in real::pso_shaders only while profiling, so
  every draw line said "no console shader known". With XCL_DRED the
  pipeline's DRED label (its console shaders) names it now.
- A DispatchMesh with a PC pipeline (a translated pass-through mesh
  pipeline) went to the driver without a note, so those draws were
  missing from the ring. It is noted now (kind 8, "DispatchMesh").

The ring is written when a draw is recorded on a list, not when it is
submitted: the report says "recorded last" where it said "in flight".

Tested on the software adapter, through the agent wrapper:
  test --release -p xcl --lib -- --test-threads=4 watch::
    9 passed, 0 failed, 0 ignored
  test --release -p xcl --lib -- --test-threads=4 hle::d3d12x::
    345 passed, 0 failed, 1 ignored (a_peek_changes_nothing is new)
Not run: the 55 tests that open the hardware GPU themselves, and no
title (the DRED label and the mesh note are not covered by a run).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Three corrections to the forgotten-ask count of c9fe50e (sparse.rs):

- take_asks counted every ask it left out (no pair for the tile, a tile
  with its own memory, no window index). An address a title binds at
  every draw is left out at every submit: every thread's memory of its
  asks was emptied at every submit, the threads asked again and the next
  submit counted again, a steady loop that defeated the memory. That
  branch removes the tile from the asked set uncounted again, as before
  c9fe50e; a pair made later already changes the views' generation.
- forget_mirrors took the tiles out of the asked set first and out of
  the queue after. An ask on another thread in between inserted the tile
  as new and queued it, and the queue's retain then deleted it: the tile
  stayed asked for, in no queue, with no count after it, and was never
  mapped (the GPU read zeros there). The queue goes first now: an ask in
  between finds the tile still asked for, or stays queued, and the count
  after it has the thread ask again.
- forget_mirrors_in dropped asks a submit had taken (their CPU view
  forgotten) and left them in the asked set: asked for again, they were
  not queued. Each ask it drops is forgotten (and counted) now.

Tests: an_ask_left_out_is_not_counted_and_may_be_asked_for_again,
a_tile_asked_for_while_it_is_forgotten_is_not_lost (a test hook runs an
ask between the two steps of the forget) and
an_ask_dropped_by_a_forget_may_be_asked_for_again. They count on a
thread-local copy of the count, since every test shares the global one.
All three fail with the old code and pass with this.

Tested on the software adapter (WARP) through the agent cargo wrapper:
cargo test --release -p xcl --lib -- --test-threads=4 <filter>
  sparse: 61 passed, 0 failed, 1 ignored (2 SKIPPED: no GPU)
  view_want: 3 passed; mirror: 7 passed; targets::: 7 passed;
  frame_dump: 1 passed; dumped_texels: 1 passed; 0 failed in each.
Not run: the 55 tests that open the hardware GPU themselves (the
wrapper skips them), and no run on a title.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The guard script ends a run that stays over the video memory budget
for 10 s, counting the over-budget lines. XCL wrote a line it matches
only while over the budget, and the budget once, so the guard's counter
never went back to 0 when the process dropped under the budget again:
five over-budget samples spread over a whole run ended it.

The activity thread's "memory: ..." line (every 2 s) now ends with
"; video memory budget N MB" when the budget is known, so the guard can
decide on every memory line. The rest of that line is unchanged (other
tools read its beginning); the over-budget warning stays as it was, and
the one-time budget line is gone.

Tested on the software adapter, through the agent wrapper:
  test --release -p xcl --lib -- --test-threads=4 watch::
    9 passed, 0 failed, 0 ignored
  test --release -p xcl --lib -- --test-threads=4 hle::d3d12x::
    345 passed, 0 failed, 1 ignored
Not run: the 55 tests that open the hardware GPU themselves; the
activity thread's line has no test (logging only) and no title was run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
mapped_frame_dump_distinguishes_dark_bright_and_undecoded_content wrote
its third frame as R32_FLOAT and expected "format not decoded"; since
337c309 texel_rgb gives R32_FLOAT a colour, so the bytes [31, 0, 0, 255]
decoded (about -1.7e38, tone-mapped white) and the test failed. The
agent runner skips it as one that opens a device itself (it creates a
WARP device), so the failure was not seen.

It uses R9G9B9E5_SHAREDEXP now: no arm of texel_rgb or rgb takes it, it
is no render-target format (so a dump is not about to decode it), and its
texel is 4 bytes (texel_bytes' default), the footprint the test fills
(8 x 8 texels, 256-byte rows). The test asserts that texel_rgb does not
decode it, and keeps "undecoded is different from dark".

Type-checked only: cargo check -p xcl --tests (no new warnings). The test
itself was NOT run: the agent wrapper skips it with the tests that open a
device themselves, and no GPU may be used here; it is left to a run with
the hardware tests.
Run on the software adapter (WARP) with the other changes of the branch:
cargo test --release -p xcl --lib -- --test-threads=4 <filter>
  frame_dump: 1 passed (reports_without_frame_dumps_remain_readable);
  dumped_texels: 1 passed; 0 failed. 55 hardware tests not run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
When the 2 s wait for a frame or target dump copy timed out, present_now
logged the fence error's text, "present: frame dump copy: GPU fence still
pending after 2000 ms". A guard script outside the process reads "GPU
fence still pending" as the graphics card having stopped answering and
blocks every later run. A dump copy queued behind a long backlog of the
title's work on its queue is not that.

A timeout now logs a warning without that text: "present: frame dump
copy: not finished after <ms> ms – this dump is skipped". Every other
error is logged as before. The path is otherwise unchanged: the dump is
not written, its readback buffers and copy source stay with the
presenter and go to the ring slot at the next present
(prepare_pipelined_slot), and only a removed device disables it.

Logging only; no test. Checked: cargo check -p xcl --tests (no new
warnings). Run on the software adapter (WARP):
cargo test --release -p xcl --lib -- --test-threads=4 <filter>
  frame_dump: 1 passed; dumped_texels: 1 passed; targets::: 8 passed;
  0 failed. 55 hardware tests not run; the timeout path itself was not
  run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
XCL_DUMP_TARGETS copies up to 64 render targets at one present, each
into a readback buffer of its own. At 2560x1440 RGBA32F that is about
3.8 GB of readback memory at once, on a card that may already be full.

to_dump keeps the targets, in the order they are dumped, until their
readback bytes (width x height x texel_bytes) pass 1 GiB; the rest are
left out, and one line says how many of how many and which. A first
target larger than that is still dumped. The decision is a pure helper
(dumped_within, with readback_bytes) beside to_dump.

Test: targets::tests::a_target_dump_stops_at_a_gib_of_readback (18 of 64
RGBA32F targets at 2560x1440, everything under the cap, exactly 1 GiB,
the order kept, a first target over the cap).

Run on the software adapter (WARP) through the agent cargo wrapper:
cargo test --release -p xcl --lib -- --test-threads=4 <filter>
  sparse: 61 passed, 1 ignored; view_want: 3 passed; mirror: 7 passed;
  targets::: 8 passed; frame_dump: 1 passed; dumped_texels: 1 passed;
  0 failed in each.
cargo test --release -p xcl --lib -- --test-threads=4
  1335 passed; 0 failed; 24 ignored; 177 of the passed printed
  SKIPPED on WARP (no GPU features there).
Not run: 55 tests that open the hardware GPU themselves (the wrapper
skips them), among them the frame dump test changed two commits back;
no run on a title.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The tests of the previous barrier changes passed whatever form the
exchange took:

- split_wave64_dead_scc_skips_exchange_barrier counted every
  dx.op.barrier, the spin exchange's two groupshared fences included, so
  it passed whether one console wave met at a group barrier or spun, and
  its comment still spoke of two group barriers. It now counts the group
  barrier with sync (mode 9, GROUP_SYNC: only the start's in both
  programs) and the exchange's fences (mode 8, TGSM_FENCE: +2 with live
  SCC) apart.
- a_single_split_wave_of_a_compute_group_exchanges_without_a_group_barrier
  now also checks mesh entries of 48 and 64 threads (one console wave:
  they must not keep Partner::Present), that the counters are zeroed
  before the start's group barrier, the spin storage of its own without
  LDS (4 slot words, 2 counters), and with LDS the HLSL layout: thread
  counter at word 8191, counters at 8189/8190, slots from 8185, the
  program's LDS clamped to 8184.
- a_group_barrier_of_several_hardware_waves_is_left_to_the_hlsl_path
  returns early under XCL_SAFE_BARRIER=0, as recomp/tests.rs does, so the
  suite does not fail with that switch.
- The HLSL path had no synthetic Mode::Mesh test with heap memory
  windows: gpu_mesh_mode_exports_stay_inside_the_record's program (128
  threads, s_barrier between two console waves) is now also translated
  split with HEAP_WINDOWS | 16, checked complete, with the bounded
  barrier, and compiled by DXC (cs_6_6), before its GPU part.

Tested (software adapter, through the agent wrapper):
  cargo test --release -p xcl --lib -- --test-threads=4 gpu::dxil::
    151 passed, 0 failed, 3 ignored
  ... gpu::recomp::  370 passed, 0 failed, 18 ignored
  ... barrier        6 passed, 0 failed, 1 ignored
Not run: the 55 tests that open the hardware GPU themselves (the wrapper
skips them on this machine); the GPU parts of the dead-SCC and mesh
export tests skipped (no 32-lane GPU / no wave64); no GPU run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Since one split console wave of a compute or mesh group exchanges by
counters (Partner::Spin), several comments were wrong: the lanes module
said the two halves always meet at a group barrier, and VAR_XK /
VAR_XDEAD, Partner::Spin, exchange_spin and DxilIr::split tied the spin
exchange to groups of several console waves. They now say that compute
and mesh groups spin however many console waves they have, and that only
the ES phase of a geometry pass (direct only with XCL_SAFE_BARRIER=0)
and the tests' kernel form meet at a group barrier.

XCL_WAVE64_SPIN=0 still forces group barriers for one wave64 group in
the HLSL path only; the direct translator always spins for one split
wave of a compute or mesh group. x64_spin's comment says so. (Changing
emit.rs changes the HLSL translation cache's source identity: cached
translations are made again once.)

No code changes. Tested (software adapter, through the agent wrapper):
  cargo test --release -p xcl --lib -- --test-threads=4 gpu::dxil::
    151 passed, 0 failed, 3 ignored
  ... gpu::recomp::  370 passed, 0 failed, 18 ignored
  ... barrier        6 passed, 0 failed, 1 ignored
Not run: the 55 tests that open the hardware GPU themselves (the wrapper
skips them on this machine); no GPU run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The fault path of XCL_STOP_FILE says how long the watch thread's check of
the device has not returned when the device was not reported removed in
12 s. It counted from when the 12 s wait began, so a check that was
already stuck before the stop was asked was reported too short (12000 ms
for one stuck for 17 s). The heartbeat is now the time the last poll
returned (now_ms, set when the watch thread starts as well), and the
line gives now minus that. The text of the line is unchanged.

The comment at watch::start in real.rs still said the watch thread takes
the stop; that is the xcl-stop-file thread now, from device creation on.

Tested (software adapter, agentcargo.ps1 -Key w5pipes):
- 'test','--release','-p','xcl','--lib','--','--test-threads=4','watch::':
  9 passed, 0 failed, 0 ignored
- same with filter 'hle::d3d12x::': 345 passed, 0 failed, 1 ignored
Not run: the 55 tests that open the hardware GPU (skipped by the
wrapper), any title run. The stop thread's 12 s path has no unit test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
to_dump wrote its line per target, with " → targetK" for each target to
copy, before it applied the 1 GiB readback cap; the warning after it
then named some of those same targets as left out. The log contradicted
itself. The cap is now decided as each target is listed: a target past
it is logged "(not dumped: targetK is past the readback cap)" and is not
copied, and the one warning line still gives how many of how many were
left out and which. dumped_within is asked with the sizes so far; it
depends only on the targets before, so a target cut stays cut and the
targets kept are the same as before.

Test: targets::tests::a_target_dump_stops_at_a_gib_of_readback also
checks that asking with 1..64 targets keeps min(n, 18).

A correction to e0a1b4a ("a frame dump copy that is not done in 2 s is
a warning"): its body gives "targets::: 8 passed", but that run was made
on the branch's full working tree with b850d2e's test in it; at e0a1b4a
targets.rs has 7 tests. The intermediate commits f85ef6b and e0a1b4a
were not built or tested on their own.

Run on the software adapter (WARP) through the agent cargo wrapper:
cargo check -p xcl --tests: no new warnings.
cargo test --release -p xcl --lib -- --test-threads=4 <filter>
  targets::: 8 passed; frame_dump: 1 passed; dumped_texels: 1 passed;
  sparse: 61 passed, 1 ignored; view_want: 3 passed; mirror: 7 passed;
  0 failed in each.
cargo test --release -p xcl --lib -- --test-threads=4
  1335 passed; 0 failed; 24 ignored.
Not run: 55 tests that open the hardware GPU themselves (the wrapper
skips them); no run on a title, so the cap's log lines were not seen at
run time.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
From the review of c9fe50e, 337c309 and 0a8cd59:

- an ask for a GPU-view tile that a submit leaves out (no pair, own memory,
  no window) is dropped without the count that empties every thread's
  memory of its asks: an address left out at every submit emptied them at
  every submit;
- forget_mirrors drops the queued asks before the asked set's tiles, and
  forget_mirrors_in counts the asks it drops: a tile asked for while it
  was being forgotten stayed asked for, in no queue, and was never mapped;
- the frame dump test's undecoded frame uses a format no dump decodes
  (R32_FLOAT is decoded since 337c309, so the test had been failing
  unseen: the software-adapter runner skipped it);
- a dump copy that is not finished after 2 s is a warning of its own, not
  the fence's text (a guard outside reads that as a stopped GPU);
- one present's target dump reads back 1 GiB at most.

Software adapter, whole library suite on the branch: 1335 passed, 0 failed,
24 ignored; 55 tests that open the hardware GPU not run.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
a_held_submit_goes_on_when_the_hold_ends_and_at_once_inside_a_timed_call
checked the hold only by seeing nothing arrive within 300 ms. A thread
scheduled more than 300 ms late would have passed that check with no
hold at all. The thread now sends once before it calls wait_while; the
test waits for that, then asserts that the second send does not come
while the flag is set, and does come once it is cleared.

Tested (software adapter, agentcargo.ps1 -Key w5pipes):
- 'test','--release','-p','xcl','--lib','--','--test-threads=4','watch::':
  9 passed, 0 failed, 0 ignored
- same with filter 'hle::d3d12x::': 345 passed, 0 failed, 1 ignored
Not run: the 55 tests that open the hardware GPU (skipped by the
wrapper).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Since 685cf9c the direct translator leaves a split geometry pass with an
ES phase to the HLSL path while the safe barrier is wanted, so on a
32-lane GPU every ES+GS pass now goes through
recomp::translate_geometry(.., split, mem_windows()), which in a
title's layout is HEAP_WINDOWS | 16. No test translated HLSL split
geometry with those windows (only 1 or 4 plain windows); an incomplete
translation there fails the whole PSO in translated_gs_pso.

geometry_forms_validate now also sends ES+GS and ES alone with
HEAP_WINDOWS | 16 through direct_or_hlsl in both forms: the native form
validates through the direct translator, the split form takes the HLSL
container on exactly the refusal, asserts the translation is complete
and compiles it with DXC (cs_6_6).

With the safe barrier wanted (the default), the direct split ES+GS form
is now validated only by runs with XCL_SAFE_BARRIER=0.

Tested (software adapter, release, agentcargo.ps1 wrapper):
  cargo test --release -p xcl --lib -- --test-threads=4 gpu::dxil::
    151 passed, 0 failed, 3 ignored
  cargo test --release -p xcl --lib -- --test-threads=4 gpu::recomp::
    370 passed, 0 failed, 18 ignored
  cargo test --release -p xcl --lib -- --test-threads=4 barrier
    6 passed, 0 failed, 1 ignored
Not run: the 55 tests that open the hardware GPU themselves; nothing
ran on a GPU (gpu_geometry_direct_records is SKIPPED: no mesh shaders).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
a_single_split_wave_of_a_compute_group_exchanges_without_a_group_barrier
found the first address of a counter before the start's group barrier
and then accepted any `store i32 0,` after it, so a zero stored to some
other word in between satisfied it. It now takes the value the
counter's getelementptr defines (@xcl_xc without LDS; with LDS the
address built from the `add .., 8189` index into @xcl_lds) and asserts
`store i32 0, i32 addrspace(3)* %N` through exactly that value before
the barrier, for the compute and the 48 / 64 thread mesh cases.

Tested (software adapter, release, agentcargo.ps1 wrapper):
  cargo test --release -p xcl --lib -- --test-threads=4 gpu::dxil::
    151 passed, 0 failed, 3 ignored
  cargo test --release -p xcl --lib -- --test-threads=4 gpu::recomp::
    370 passed, 0 failed, 18 ignored
  cargo test --release -p xcl --lib -- --test-threads=4 barrier
    6 passed, 0 failed, 1 ignored
Not run: the 55 tests that open the hardware GPU themselves; nothing
ran on a GPU.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
docs/wave64-on-wave32.md still said that one console wave per group
(most compute, ES+GS) meets at GroupMemoryBarrierWithGroupSync and that
`XCL_WAVE64_SPIN=1` forces the counters everywhere. Spinning is the
default in the HLSL path (=0 is the switch), the direct translator
spins for one split wave of a compute or mesh group whatever the
variable says (1be95b1), and it leaves split geometry with an ES phase
to the HLSL path while the safe barrier is wanted (685cf9c). The group
barrier is now used only in the tests' kernel form, with
XCL_WAVE64_SPIN=0 in the HLSL path and in the direct ES phase with
XCL_SAFE_BARRIER=0. The doc says so, and that =0 affects the HLSL path
only.

The comment of DxilIr::split (recomp/lower_dxil.rs) said the spin meet
is for a compute group "of one console wave or more"; a group of 32
threads has no partner and no exchange, so it now says "more than 32
threads". Comments and docs only.

Tested (software adapter, release, agentcargo.ps1 wrapper):
  cargo test --release -p xcl --lib -- --test-threads=4 gpu::dxil::
    151 passed, 0 failed, 3 ignored
  cargo test --release -p xcl --lib -- --test-threads=4 gpu::recomp::
    370 passed, 0 failed, 18 ignored
  cargo test --release -p xcl --lib -- --test-threads=4 barrier
    6 passed, 0 failed, 1 ignored
Not run: the 55 tests that open the hardware GPU themselves; nothing
ran on a GPU.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
From the review of fb55e49 and 1be95b1:

- XCL_SAFE_BARRIER changes what both translators emit and which of them
  takes a compute or mesh program, and was not part of the translated
  cache: one diagnostic run with it at 0 stored DXIL with plain group
  barriers that every later run loaded. The cache is not used while it is
  set;
- the direct translator leaves a split wave64 geometry pass with an ES
  phase to the HLSL path: its exchanges met at plain group barriers, the
  pattern of #1727, while the HLSL path's exchange spins;
- the tests of the split exchange count the group barriers with sync and
  the spin's fences apart, cover mesh groups of 48 and 64 threads and the
  LDS layout, and a mesh pass with 16 heap windows on the HLSL path;
- comments say which exchanges still meet at a group barrier.

Software adapter, whole library suite on the branch: see the branch's last
commit; the tests that open the hardware GPU were not run.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
From the review of fb9e302 and e271679:

- a call into the driver that has not returned for 2 s parked every later
  submit of every thread with no time limit: a call that only waited for
  GPU progress which depended on a parked submit then never returned. The
  watch now only logs such a call (when it passes the limit, every 5 s,
  and when it has returned, with its real length); the title's command
  lists are held only while a stop for a driver error is being handled;
- the stop file is read on a thread of its own that calls nothing in the
  driver before the title ends, as bytes (empty, BOM, UTF-16 tolerated);
- the report names pipelines without starting a build and uses the DRED
  labels for graphics pipelines; pass-through DispatchMesh draws are in
  the ring; its lines say "recorded last";
- the memory line carries the video memory budget, so a reader can tell a
  report within the budget from one past it.

Software adapter, whole library suite on the branch: see the branch's last
commit; the tests that open the hardware GPU were not run.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
A lane may run 65 536 loop passes before LOOP_GUARD ends its loops, so
that console code looping on a count XCL gave it wrong does not keep the
GPU busy for minutes. That bound is per lane: the work it allows grows
with the dispatch, and a large dispatch outlasts the 2 s Windows waits
before it removes the device.

WindNew:CS_AdvectFromParentStep (a542b07e605c8fd7, 4 x 4 x 4 threads) is
dispatched as 16 x 16 x 16 groups and loops while a counter differs from
a count in title memory. Run alone on an RTX 3060 Ti with synthetic
inputs, the translated program takes 1.0 ms with a count of 0, 6.7 ms
with 64, 25 ms with 256 – and with a count that never comes 111 ms when
the loop is ended after 256 passes and 485 ms after 1024 (0.47 ms a
pass), which is 31 s for 65 536. That is the dispatch left open when the
device was removed (#1452).

A compute dispatch whose group counts are known now passes its share of
2^28 loop passes for one group in a free io slot (IO_LOOP_BUDGET), and
in a compute program every entry of a loop has its own count of passes:
that share among the group's threads, between 1024 and 65 536 a lane.
Up to 4096 lanes nothing changes; at 16 x 16 x 16 groups of 64 threads
one entry of a loop ends after 1024 passes. The lane's budget of 65 536
for all its loops stays, so loops inside one another are not cut to one
loop's share: only a loop that runs away on its own is ended early. A
slot of 0 (an indirect dispatch, the test runner) leaves 65 536, and
programs without a loop, other stages and the direct translator emit
what they did.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
(cherry picked from commit 4bad50562d)

Conflicts resolved in: crates/xcl/src/hle/d3d12x/bind.rs (bind_abi takes
the PR's groups argument and keeps the tree's heap_bound check; the
indirect path keeps skip_named_cs and indirect_guard::check and passes
None; translated_dispatch keeps skip_named_cs and the gpu_profile span
and passes Some([x, y, z])).
The direct DXIL translator's compute programs are to count each entry of
a loop against the dispatch's share, as the HLSL path does since the
previous commit. An inner loop's count has to start afresh each time the
loop is entered, and the translator lowers blocks one by one with no
idea of which loop holds which: Cfg only knows the loop headers.

cfg::loop_parents gives, for each loop header of the (reducible) Cfg, the
header of the loop directly around it, or none. A loop is its header and
every block that reaches one of its back edges (an edge into the header
from a block at or after it in the reverse post-order) without passing
the header; the loop around it is the smallest other loop that holds its
header. Nothing calls it yet.

Tested (software adapter, the tests are CFG-only):
  agentcargo.ps1 ... 'test','--release','-p','xcl','--lib','--',
  '--test-threads=4','loop_parents': 5 passed, 0 failed, 0 ignored
  (one loop, two in a row, a loop in a loop, three deep, two back edges
  to one header, an inner loop entered from two blocks, a loop whose
  header is the entry block).
Not run: the 54 tests that open the hardware GPU themselves.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The previous commits made the HLSL path's compute loops end an entry
after the dispatch's share of passes for a thread (IO_LOOP_BUDGET), so
that a large dispatch whose loop count never comes does not outlast the
time Windows gives the GPU before it resets the driver. Compute programs
run through the direct DXIL translator here, and it kept only the lane's
budget of 65 536 passes for all its loops, which a retail title's program
dispatched as 16 x 16 x 16 groups turns into about 31 s of GPU time.

The plain form of a compute program with a loop now loads the slot once
in the entry block and makes cap = slot == 0 ? 65 536 : clamp(slot /
threads per group, DISPATCH_LOOP_PASSES_MIN, 65 536), the HLSL path's
xcl_cap. Each loop header b has a variable VAR_LOOP_PASSES + b (1 << 30
and up: above the temporaries and the reload variables), set to cap at
the entry; a loop's head, before the lane's budget, leaves to the
program's end when its count is 0, else counts it down, and sets the
counts of the loops directly inside it (cfg::loop_parents) back to cap.
In a reducible CFG every path that enters a loop passes the head of the
loop around it, so that is a fresh count on every entry. A loop that
runs out ends the lane's program, where the HLSL path goes on after the
loop; both only end a loop that ran away. The lane's budget stays as it
was. Programs without a loop and every other entry emit what they did;
the compact form and the per-lane form keep the lane's budget alone.

Tested (software adapter):
  agentcargo.ps1 ... 'test','--release','-p','xcl','--lib','--',
  '--test-threads=4','direct_compute_loops_count_each_entry': 1 passed
  (ran: one load of the slot and two decrements for one loop; for the
  loop entered three times one count set at the entry and the inner one
  set back on the outer head's path – the test fails with the reset
  taken out; a loop-free compute program and a kernel with the loop have
  neither; wave32 and split wave64)
  ... 'gpu::dxil::': 158 passed, 0 failed, 3 ignored
  ... 'gpu::recomp::': 373 passed, 0 failed, 18 ignored
Not run: gpu_direct_compute_loop_passes_follow_the_dispatch (65 536,
5000, 1024 and 65 536 passes for the four shares, three entries of 1024
under a share of 1024, a 1025th pass ending the program, wave32 and split
wave64) printed SKIPPED (no wave32 on the software adapter); and the 54
tests that open the hardware GPU themselves.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A switch to compare with the loop bound of before: with
XCL_DISPATCH_LOOP_BUDGET=0 (read once, recomp::dispatch_loop_budget_wanted)
a direct dispatch (bind.rs) and a dispatch of a console command list
(console_list.rs) leave IO_LOOP_BUDGET at 0, the value an indirect
dispatch already passes. Both translators then give every loop of a
compute program the lane's 65 536 passes, as before the dispatch's share
(the translated code is the same: only the slot changes). The README's
list of switches says so.

Tested (software adapter, the whole library suite on this commit):
  agentcargo.ps1 ... 'test','--release','-p','xcl','--lib','--',
  '--test-threads=4': 1350 passed, 0 failed, 24 ignored; 179 GPU tests
  of those passed printed SKIPPED (no wave32 / wave64 on the software
  adapter), among them gpu_compute_loop_passes_follow_the_dispatch and
  gpu_direct_compute_loop_passes_follow_the_dispatch
  ... 'hle::d3d12x::': 350 passed, 0 failed, 1 ignored
Not run: the 54 tests that open the hardware GPU themselves; the switch
itself on a title (it changes only what the runtime writes to the slot).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
dispatch_loop_budget_wanted only decides what a dispatch writes to
IO_LOOP_BUDGET, but it sat in gpu/recomp/mod.rs, which build.rs hashes
into XCL_TRANSLATOR_SOURCE_ID; the direct translator's cache identity is
built on that ID too. So any later edit of the switch, even of its doc
comment, would throw away every translated shader of both translators
while no translated code changed. It now lives in hle/d3d12x/bind.rs
(pub(super)), beside bind_abi, its one caller there, and
console_list.rs calls it through super::bind. Behaviour is unchanged.
This commit itself changes recomp/mod.rs once more (the removal), so
the translator source ID changes with it, as it already did in this
series (the picked upstream commit edits mod.rs and emit.rs; the direct
translator's commit d9a247b changes XCL_DIRECT_DXIL_SOURCE_ID, which
its message did not say): every cached translation of both translators
is made again once.

Tested on the software adapter, release, the tree with all of this
series' follow-up commits (agentcargo.ps1 -Key w5pages):
  'test','--release','-p','xcl','--lib','--','--test-threads=4',
  'hle::d3d12x::': 350 passed, 0 failed, 1 ignored
  ... the whole library suite: 1352 passed, 0 failed, 24 ignored;
  179 GPU tests of those passed printed SKIPPED (no wave32 / wave64)
Not run: the 54 tests that open the hardware GPU themselves; the switch
on a title.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The switch's line said every loop of a translated compute program ends
an entry after its dispatch's share. Not so for an ExecuteIndirect
dispatch (its group counts are in a GPU buffer: the slot stays 0), for
the direct translator's compact form (20 000 instructions and more) and
for XCL_PER_LANE, which keep only the thread's 65 536 passes; and the
direct translator ends the thread's program where the HLSL path only
ends the loop. Someone comparing with XCL_DISPATCH_LOOP_BUDGET=0 could
take a runaway loop on one of those paths for a bug in the bound.

Docs only; no test. Not run: anything on the hardware GPU.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
loop_parents_of_a_loop_with_two_back_edges only half guarded what it is
named for: the inner loop lay on the path of the back edge that comes
first in the header's preds, so a body built from that edge alone
(find instead of filter) still held it and the test passed; its comment
also named the wrong edge. Now each of the two back edges (3 -> 1,
5 -> 1) has an inner loop of its own (2, 4), so dropping either edge
leaves one inner loop outermost. Checked: with the body taken from the
first back edge only, the test fails (and passes again without).

loop_parents_of_a_split_loop adds the one shape make_reducible actually
splits (a loop entered in the middle): loop_parents on the final graph
gives the single loop at 3, with no parent.

cfg.rs is hashed into XCL_DIRECT_DXIL_SOURCE_ID with its tests, so this
commit makes the direct translator's cache entries again once.

Tested on the software adapter, release (agentcargo.ps1 -Key w5pages):
  'test','--release','-p','xcl','--lib','--','--test-threads=4','loop':
  42 passed, 0 failed, 0 ignored (all six loop_parents_* tests ran)
  ... 'gpu::dxil::': 159 passed, 0 failed, 3 ignored
  ... the whole library suite: 1352 passed, 0 failed, 24 ignored;
  179 GPU tests of those passed printed SKIPPED (no wave32 / wave64)
Not run: the 54 tests that open the hardware GPU themselves.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
direct_compute_loops_count_each_entry is the only test of the direct
translator's per-entry loop counts that runs off the hardware (the GPU
test prints SKIPPED there). It counted the slot's load, the decrements
and the count phis, but never that a count of 0 leaves the loop: a
check that branched the wrong way would still pass it. Now, for the
one loop and for both loops of the nested program, the count phi feeds
an icmp eq ..., 0 whose br i1 takes the block that returns.

Checked: with the count's branch inverted (cond_br(none, cont, end))
the test fails at the new assertion, and passes again without. (Taking
the branch out altogether already failed the old test: the count is
then dead and leaves the module with the cap's computation, so
loop_counts finds no extractvalue of the load.)

Tested on the software adapter, release (agentcargo.ps1 -Key w5pages):
  'test','--release','-p','xcl','--lib','--','--test-threads=4',
  'gpu::dxil::': 159 passed, 0 failed, 3 ignored;
  direct_compute_loops_count_each_entry ran (no SKIPPED), wave32 and
  split wave64; gpu_direct_compute_loop_passes_follow_the_dispatch
  printed SKIPPED (no wave32)
  ... the whole library suite: 1352 passed, 0 failed, 24 ignored;
  179 GPU tests of those passed printed SKIPPED (no wave32 / wave64)
Not run: the 54 tests that open the hardware GPU themselves.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
No test that runs without a GPU compiled the HLSL path's new loop
counts (xcl_gb, xcl_cap, uint xcl_n<k> = xcl_cap;):
gpu_compute_loop_passes_follow_the_dispatch returns before its DXC
compile when no GPU is ready. compute_loop_counts_compile compiles
endless_loop_program and endless_loop_entered_three_times as compute
programs, wave32 and wave64, with cs_6_6 whenever DXC is there
(SKIPPED "no DXC" otherwise, as the file's other DXC checks gate).

Tested on the software adapter, release (agentcargo.ps1 -Key w5pages):
  'test','--release','-p','xcl','--lib','--','--test-threads=4',
  'gpu::recomp::': 374 passed, 0 failed, 18 ignored;
  compute_loop_counts_compile ran (no SKIPPED)
  ... the whole library suite: 1352 passed, 0 failed, 24 ignored;
  179 GPU tests of those passed printed SKIPPED (no wave32 / wave64)
Not run: the 54 tests that open the hardware GPU themselves.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Upstream pull request #2291 (its commit cherry-picked, author kept) gives
every entry of a loop in a compute program its own count of passes: the
dispatch's share of 2^28 passes for a thread group among the group's
threads, between 1024 and 65 536. The lane's budget of 65 536 for all its
loops is per lane, so the GPU time it allows grows with the dispatch: a
retail title's program of 4 x 4 x 4 threads dispatched as 16 x 16 x 16
groups with a loop count that never comes was measured upstream at about
31 s on a mid-range GPU, past the time Windows gives a GPU before it
resets the driver.

That commit covers the HLSL path. Compute programs here run through the
direct DXIL translator, so its plain form gets the same bound: the loop
directly around each loop of the CFG (cfg::loop_parents), a count for
each loop set at the program's entry and set back at the head of the loop
around it, from the same io slot. A loop that runs out ends the thread's
program there. ExecuteIndirect dispatches, the compact form and the
per-lane form keep the lane's budget alone.
XCL_DISPATCH_LOOP_BUDGET=0 leaves the slot empty: as before.

Software adapter, whole library suite on the branch: 1352 passed, 0
failed, 24 ignored; 54 tests that open the hardware GPU not run; the GPU
tests of the bound (gpu_direct_compute_loop_passes_follow_the_dispatch,
gpu_compute_loop_passes_follow_the_dispatch) printed SKIPPED there and
have not run on this tree.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Conflicts:
- gpu/recomp/runner.rs (dispatch_with): every memory window u2..u5 is
  bound to mem as before, and the chain's scratch buffer is made after
  them; record_dispatch_chain or Dispatch runs as upstream has it.
- hle/d3d12x/bind.rs, execute_indirect: upstream's switch to the whole
  pipeline of a split program runs after bind_abi, before the ei_work
  RAN note; when the whole pipeline cannot be built the dispatch is
  noted SKIPPED in ei_work as well as counted.
- hle/d3d12x/bind.rs, translated_dispatch: named programs are still
  skipped, bind_abi still gets the group counts (the loop budget's io
  slot), and one gpu_profile span (one watch ring note) is around the
  whole dispatch_chain::dispatch; the span is closed before its error
  is returned.
- hle/d3d12x/console_list.rs: the same span around
  dispatch_chain::dispatch, closed before an error is returned.
- hle/d3d12x/pso_async.rs, submit_as: the lanes of the backlog
  (push(p, known), ahead_cap) are kept; a sent pipeline goes to the
  workers through upstream's enqueue.
- hle/d3d12x/pso_async.rs, resolve_spared: send_spared is kept (the
  spared lane of the backlog).
- hle/d3d12x/real.rs, forget_pso: dispatch_chain::forget is added
  before the sharded TRANSLATED_COMPUTE.remove.
- hle/d3d12x/real.rs, compute pipeline creation: upstream's
  compute_container returns (hr, time, reused) and the caller finishes
  the pipeline. The huge-program refusal log, the DRED label,
  PSO_USER_SGPRS (in its sharded form), PSO_SHADERS and the GPU
  profile's note_compute are in the caller, and the chain path records
  the same PSO_USER_SGPRS, PSO_SHADERS and profile note for its first
  piece.
- hle/d3d12x/title_list.rs: both sides' tests are kept.

Changed after the textual merge:
- pso_async.rs send_spared: its fallback without a backlog sent an
  Arc<Pending> to the worker queue, which now takes closures; it goes
  through enqueue.
- real.rs: upstream's chain path wrote PSO_USER_SGPRS through the old
  Mutex<Option<HashMap>> form; it uses the sharded map's insert.

Tested (software adapter, release; the tests that open the hardware
GPU themselves are not run by the test wrapper):
- check -p xcl --tests: builds, no new warnings
- test --lib gpu::dxil::     168 passed, 0 failed, 3 ignored
- test --lib gpu::recomp::   374 passed, 0 failed, 18 ignored
- test --lib hle::d3d12x::   352 passed, 0 failed, 1 ignored
- test --lib dispatch_chain  8 passed, 0 failed; 7 of them printed
  SKIPPED (no wave32 GPU / no wave64) before their GPU part
- test --lib title_list      5 passed, 0 failed
- test --lib (whole library) 1363 passed, 0 failed, 24 ignored;
  186 tests printed SKIPPED
Not run: the 54 tests that open the hardware GPU themselves, every
GPU part of the dispatch chain tests, a retail title, smoke runs.

Not settled here: a single split wave64 compute group sets up the
spin exchange's xcl_xc counters (and uses group-shared atomics when it
exchanges), which split_compute refuses, so such a program is never
split and stays whole. The wave64 cases of
dispatch_chain_wave64_live_loops_and_exchange,
dispatch_chain_oversized_loop_matches_whole and
dispatch_chain_divergent_forward_edges_3d expect a chain and would
fail on a GPU with wave32 support.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
After the merge of upstream's dispatch chains, a single split wave64 of a
compute group (64 threads, two hardware wave32 halves) meets its other half
through group-shared counters its entry zeroes (Partner::Spin, #1741), and the
exchange's running number (VAR_XK) counts from the program's start. A later
piece of a chain is a new dispatch: its prefix zeroes the counters again, so
its first exchange waits for a count they never reach, stalls for 2^20 polls
and then reads 0 for the other half. split_compute refused every such program
only by accident (the xcl_xc global, the atomics and the TGSM fences), and
upstream's wave64 chain tests still expected a chain: on a GPU with wave32
they panic at chain.expect(...).

- kernel.rs finish_dispatch: a program with a split thread id and the spin
  exchange is not given to split_compute at all; it is built whole as before
  (optimize + finish_optimized, the same output as try_finish), with a log
  line when it is above XCL_DIRECT_SPLIT_INSTRUCTIONS saying why.
- split.rs tests: compare() and dispatch_chain_divergent_forward_edges_3d now
  build and check the program on the CPU before the wave32 skip. At 64 threads
  they assert that split_compute keeps the program whole and run only the
  whole program on the GPU; at 32 threads they still require a chain of at
  least 3 pieces and compare it with the whole one. On the merged tree the
  64-thread case fails on the software adapter this way (chain None where the
  test expected a chain). compare()'s loop blocks register their edges with
  the translator's SSA (lw.block / lw.br / lw.cond_br): the spin exchange
  reads VAR_XK / VAR_XDEAD through it, and with raw blocks the 64-thread whole
  program failed validation (a PHI with no entries).
- kernel.rs test a_split_wave64_compute_program_stays_whole: a 64-thread
  split program with exchanges before and after 40 cuttable blocks goes
  through finish_dispatch with a piece limit and comes out whole and valid.

Tested (agentcargo wrapper, software adapter, release):
  test --release -p xcl --lib -- --test-threads=4 gpu::dxil::
  169 passed, 0 failed, 3 ignored. The CPU halves of the chain tests ran;
  their GPU halves printed SKIPPED (no wave32 GPU): dispatch_chain_wave32_live_loops,
  dispatch_chain_wave64_live_loops_and_exchange, dispatch_chain_oversized_loop_matches_whole,
  dispatch_chain_divergent_forward_edges_3d, dispatch_chain_payload_*.
Not run: the 54 tests that open the hardware GPU themselves (the wrapper skips
them); no GPU run of the whole 64-thread fixtures.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
build_pieces (upstream's dispatch chains) sent up to compile_threads()-1
helper jobs to queue(), the workers that build what a bind waits for, from
whatever thread called it. When the caller is a backlog worker building a
compute pipeline ahead of its first use (the "new compute, one at a time"
lane, or a spared image-only build), those helpers ran its piece driver
compiles at normal priority on the bind workers, and a pipeline a bind then
sent with enqueue waited behind the pieces of one nobody uses yet. That is
what the backlog lanes exist to prevent, and it also broke the lane's one at
a time rule.

A backlog worker's build that nobody waits for (Demand: preload_thread set,
no waiters) now drains every piece on its own thread. A build a title's
thread waits for, a bind worker's build and a title thread's own build fan
out as before.

Test: pso_async::used_tests::a_build_ahead_keeps_its_pieces_on_its_own_thread
(six 20 ms pieces under a backlog build nobody waits for all run on the
caller). Without the change it fails: [0, 0, 0, 0, 0, 1].

Tested (agentcargo wrapper, software adapter, release):
  test --release -p xcl --lib -- --test-threads=4 pso_async
  30 passed, 0 failed, 0 ignored.
Not run: the 54 tests that open the hardware GPU themselves; no title run.
Not changed: helpers still lose JOB_START / JOB_HUGE / PRELOAD_STEP, and a
title thread's own build gives its helpers no "wanted" status (review notes).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
build_pieces collects one result per piece from a channel. When a piece job
panicked on a helper (a bind worker of queue()), that worker thread died
without sending its result; the caller's own drain still holds a Sender, so
recv().iter().take(count) never ended: a title thread building the program
hung for ever and the pool lost a worker for good. On the caller's thread the
panic went up through the whole build.

Each piece now runs under catch_unwind; a panic gives 0 (a failed piece), so
dispatch_chain::build gets every result, sees the failure and the program is
built whole as for any other failed piece.

Test: pso_async::used_tests::a_piece_that_panics_fails_and_the_others_are_built
(eight pieces, every second one panics, on the caller or on helpers: the
results are [1, 0, 3, 0, 5, 0, 7, 0]).

Tested (agentcargo wrapper, software adapter, release):
  test --release -p xcl --lib -- --test-threads=4 pso_async
  31 passed, 0 failed, 0 ignored.
Not run: the 54 tests that open the hardware GPU themselves; no title run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Upstream's chain set its tail pieces (record_dispatch_chain), the whole form
of a split program in a Dispatch fallback, and the whole form before an
ExecuteIndirect with list.SetPipelineState on the title's list. On a list XCL
adopted that call reaches XCL's own hook (cl_set_pipeline_state), which this
branch keeps for the title's calls: bind_abi binds a dispatch's compute
pipeline past it with list_x::set_compute_pipeline. Through the hook each
piece:
- became list_x's bound pipeline, so a Wait64 mid-list split or KickoffX
  started the next segment with the last tail piece as its first pipeline;
- pushed a DRED marker (XCL_DRED=1) with no label (only the first piece is
  labelled), so a fault in piece 2..n or in the whole form was reported as
  "a stand-in, or not translated" instead of the program.

record_dispatch_chain now takes the setter. dispatch_chain::dispatch binds
pieces and the whole form past the hook on an adopted list, and with the
plain call on a list XCL did not adopt; execute_indirect binds the whole form
with list_x::set_compute_pipeline. The test runner keeps the plain call.
With the hook out of the way the tail pieces need no DRED labels: the marker
of the title's own SetPipelineState names the program for the whole chain.

No test fails without this: seeing it needs an adopted list with a chain of
real pipelines recorded on it, and the software adapter cannot create the
pieces (WaveSize 32).

Tested (agentcargo wrapper, software adapter, release):
  test --release -p xcl --lib -- --test-threads=4 dispatch_chain
  8 passed, 0 failed, 0 ignored (the GPU halves printed SKIPPED, no wave32 GPU).
  test --release -p xcl --lib -- --test-threads=4 hle::d3d12x::
  354 passed, 0 failed, 1 ignored.
Not run: the 54 tests that open the hardware GPU themselves; no title run,
no DRED run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A split compute program's whole (unsplit) form is built on first need in the
calling thread: the first ExecuteIndirect of the program, a Dispatch in a
bundle, one with no backing allocator, or one whose scratch is too large or
cannot be made. That is a driver compile of a program above
XCL_DIRECT_SPLIT_INSTRUCTIONS, the size class splitting exists for, on one of
the title's threads, outside pso_async: no Held, so title_held() stayed false
and kernelx Sleep and the frame clock counted the seconds against the title.

Chain::whole now runs its build (and the wait for another thread's build of
the same form) inside pso_async::pc_call(), the guard every other long PC call
of the title uses, so the title is held while it lasts.

Left as it was: the whole form is still built synchronously and outside the
compute pipeline wait budget (XCL_CS_PSO_WAIT_MS); building it on the PSO
workers when the chain is built and skipping the ExecuteIndirect while it
builds is a larger change.

No test fails without this: it needs a chain of real pipelines, which the
software adapter cannot create (WaveSize 32).

Tested (agentcargo wrapper, software adapter, release):
  test --release -p xcl --lib -- --test-threads=4 dispatch_chain
  8 passed, 0 failed, 0 ignored (the GPU halves printed SKIPPED, no wave32 GPU).
Not run: the 54 tests that open the hardware GPU themselves; no title run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
translated_compute_pso_once logs a huge compute program the driver refuses
(record, DXIL size, driver cache name, HRESULT, time in the driver), because
note_translation_error alone does not reach the log. Upstream's chain builds
its pieces and the whole form through compute_container directly, so a
refused huge piece or whole form left no such line: a refused whole form
before an ExecuteIndirect logged only "ExecuteIndirect whole compute PSO:
whole compute pipeline".

PipelineBuilder::pipeline now logs the same warning for a program of
huge_pso_bytes() or more. Logging only: no test.

Tested (agentcargo wrapper, software adapter, release):
  test --release -p xcl --lib -- --test-threads=4 dispatch_chain
  8 passed, 0 failed, 0 ignored (the GPU halves printed SKIPPED, no wave32 GPU).
Not run: the 54 tests that open the hardware GPU themselves; no title run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Every chained Dispatch of upstream's split programs creates its own committed
scratch buffer (DEFAULT heap, zero-filled), of groups x dwords_per_group x 4
bytes, and keeps it until its allocator is reset or released. dwords_per_group
is the stride (1 + the words of every value live across any cut) times the
group's threads, so a 16x16x16 grid of 32-thread groups takes stride x 512 KiB;
at stride 100 that is 50 MB for one dispatch, and the only limit was 4 GiB per
dispatch. Fifty such dispatches a frame with three frames in flight would hold
about 7.5 GB.

The bytes every not yet released chained dispatch holds are now counted
(SCRATCH_HELD: taken before the buffer is made, given back when it cannot be
made and when its Recording is dropped at the allocator's Reset or Release).
A dispatch that would take them past XCL_DIRECT_SPLIT_SCRATCH_MB (default
1024 MiB) runs the whole program instead, as one whose scratch could not be
made, with a log line (the first four, then powers of two). The periodic
"compute split" line also gives the MiB held. README: the variable.

Left as it was: one buffer per dispatch, zero-filled, made on the title's
thread. Keeping one buffer per recording, grown to the largest size asked,
needs a key per recording (two recordings on one allocator may run at once)
and is a larger change.

Test: dispatch_chain::tests::scratch_is_taken_up_to_its_cap (the budget takes
what fits, refuses what would pass the cap without taking anything, takes
again what was given back, and does not overflow).

Tested (agentcargo wrapper, software adapter, release):
  test --release -p xcl --lib -- --test-threads=4 dispatch_chain
  9 passed, 0 failed, 0 ignored (the GPU halves printed SKIPPED, no wave32 GPU).
Not run: the 54 tests that open the hardware GPU themselves; no title run, so
the default cap was not measured against a title's real use.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The xcl-split-counts thread starts in every run and logged "compute split: 0
programs split, ..." every 10 s, also in runs that split nothing. Each line
also takes the log lock from a thread end_title suspends with the others.
log_counts now writes its line only when a count (or the scratch held) has
changed since the last one. Logging only: no test.

Tested (agentcargo wrapper, software adapter, release):
  test --release -p xcl --lib -- --test-threads=4 dispatch_chain
  9 passed, 0 failed, 0 ignored (the GPU halves printed SKIPPED, no wave32 GPU).
Not run: the 54 tests that open the hardware GPU themselves; no title run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
class_for asks an adopted object for its most derived interface and
releases the result with the Release of the object it asked. Without the
debug layer both are the same object. With it (XCL_D3D12_DEBUG=1)
QueryInterface gives another object, and the first object's Release on it
read a null pointer in D3D12Core 1.5 s into a retail title's start: the
debug layer could not be used on that title at all.

The result is released through the vtable it has itself.

Tested: a retail title with XCL_D3D12_DEBUG=1 on an NVIDIA RTX 5090
(driver 621.14): before, an access violation in D3D12Core at 1.46 s; after,
442 s with the layer's messages in the log. No unit test: the path needs
the debug layer's wrapping objects.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
On the PC a command list must not be executed again before its previous
execution is done (debug layer id 553). A console lets a title do it, and
a retail title submits the same recording again about once a second in
its world. XCL only noted it (note_resubmits). In a run on an NVIDIA RTX
5090 that had done it 128 times the device was removed with shader memory
faults (nvlddmkm: "Graphics SM Warp Exception: MMU Fault", 0x887a0006)
2 min 40 s into the world, with DRED inside an ExecuteIndirect of a small
compute program that reads nothing by an address of its own. A run of the
same build with the debug layer on, which slows the submits enough that
no list was ever submitted again while still on the GPU, ended after
442 s without a fault. That is one run each: the link is not proven.

A submit now waits for the previous submits of its lists that the GPU has
not finished, 2 s at most for all of them (XCL_RESUBMIT_WAIT_MS; 0: as
before), polling XCL's own fence of that submit; past the limit the lists
go as they are, logged.

Tested: cargo test --release -p xcl --lib alloc_pool on the software
adapter: 8 passed, 0 failed (new: a_resubmit_waits_for_the_previous_submit:
the limit ends a wait for a submit that never finishes, no limit means no
wait, a submit that finishes ends the wait). Not run on a title yet.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The PC takes at most 65 535 thread groups a dimension in a Dispatch; with
more its behaviour is not defined (the debug layer's warning id 1296). A
retail title dispatches 82 606 x 1 x 1 groups in its world every frame,
which reached the PC call as it was. The first eight such dispatches are
logged with the console compute program, so that the program is known
before such a dispatch is run in parts.

No behaviour change. Not tested beyond the build.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Upstream's 13 commits are merged with the fork's dispatch path (the skip
of named programs, the loop budget's io slot, one profile span and one
ring note for a whole chain), its backlog lanes and its sharded maps.

A single split wave64 of a compute group exchanges through counters in
group-shared memory here; each piece of a chain would zero them again
while the exchange's running number counts from the program's start, so
such programs are kept whole, explicitly. Chains apply to programs of
32 threads a group. Pieces of a build ahead stay on its own worker, a
piece whose build panics fails instead of hanging its caller, the pieces
and the whole form are bound past the list hook, and the scratch chained
dispatches hold together is capped (XCL_DIRECT_SPLIT_SCRATCH_MB).

Software adapter, whole library suite on the branch: 1367 passed, 0
failed, 24 ignored; 54 tests that open the hardware GPU not run. The
chain tests' GPU parts printed SKIPPED there.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
XCL_TRACE_FRAME logs one line for each distinct (VS, PS, render target)
drawn, 160 at most. A busy frame of a retail title fills those with its
first passes within a second, and the passes looked for (the ones that
draw into its lighting target) never got a line.
XCL_TRACE_FORMATS=26,29 (DXGI format numbers) leaves out the draws into
targets of other formats.

Diagnostic only. Tested on a retail title on an NVIDIA RTX 5090: with
XCL_TRACE_FORMATS=26 the trace listed 61 kinds, 35 of them the
stencil-tested passes into the 2560x1440 lighting target.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
A title's menus fill XCL_TRACE_FRAME's list of draw kinds long before its
world draws, so the kinds looked for (the geometry pass into the colour
target) never got a line.

- XCL_TRACE_AFTER_S=<seconds>: no kind is listed before that time of the
  run; each kind listed then also gets its root arguments, and the view
  heaps are counted once at that point.
- XCL_TRACE_SLOTS=<n>: the first n slots of each table instead of 4, all
  eight words of their image descriptors, the image they describe, the
  slot's own index in the shared heap and the resource the T#'s index
  names there (console_heap::named_by_index): a T# the title copied as
  memory carries its source slot's index.
- XCL_TRACE_PROBES=<n>: n texture probes instead of 4; a probe reads every
  level of the first slice, not level 0 only (a streamed texture has only
  its small levels at first).
- XCL_DUMP_SHADERS=ps,<hash>: the dump of only those stages or shaders.

Diagnostics only, all behind their switches. Tested: the dump list's test
(software adapter: 4 passed with the trace tests). On a retail title
(NVIDIA RTX 5090) the trace with XCL_TRACE_SLOTS=8 printed the image and
index of the UI draws' slots. NOT exercised in a run: the probe of every
level and the kinds after XCL_TRACE_AFTER_S (the four runs ended before
the world: three in the driver with frame dumps every 120 presents on,
one in a texture upload that read a page the title had just unmapped).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Twelve files conflicted. What was decided where the two sides did the
same job:

- Split dispatches: upstream's slabs and bounded scratch (e9ddf17,
  0829441) replace the fork's XCL_DIRECT_SPLIT_SCRATCH_MB cap; the fork
  keeps binding each piece past the list hook, one profile span and one
  ring note a chain, the skip of named programs and the loop budget slot.
  A single split wave64 with a counter exchange still stays whole;
  upstream's 64-thread slab case of
  dispatch_chain_divergent_forward_edges_3d is the assertion that it does.
- DirectStorage: upstream's page lists at execution (bb27ed6) with the
  fork's log line.
- Stand-ins (625a0f3): the fork's stands_in is the resolver's
  gave_standin. The shared driver pipeline now goes through the fork's
  late release when its last shell goes (a queued list may still bind it),
  and an ExecuteIndirect of a shell whose compute build failed is skipped
  again (the registered pipeline is the shell, the resolved one the shared
  driver pipeline).
- XCL_TEXTURE_LEVEL_PAGES=1 (3ea5edc): a level that is zero when its pages
  are decided and written before the copy reads it lost its texels and
  kept their hashes; such an item's hashes are forgotten.
- a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier
  (254a058) counts the fork's exchange form: one group sync, the two
  fences of one counter exchange, and no barrier of another mode.

Known and left: upstream widened the compact form (040e46d, e964ad2); a
compact compute program has only the lane budget for its loops, not the
per-entry bound of a large dispatch.

Tested on the merged tree. Software adapter, whole library suite: 1388
passed, 0 failed, 24 ignored; 55 tests that open the hardware GPU not
run there. NVIDIA RTX 5090 (driver 621.14), whole library suite with
XCL_DIRECT_DXIL=1 before the last review fixes: 1435 passed, 4 failed
(gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3, which fail the same
way before the merge), 27 ignored, no driver error.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Console programs keep constant tables after s_endpgm and read them
PC-relative (s_getpc_b64 + s_load_dword* / global_load_dword*). The
translation gave s_getpc_b64 the program offset with high dword 0, so in
a title these loads read memory window 0 at a low offset: zeros. 676 of
the 26503 shader records of a retail title use this, among them all
postfx_aces LUT bakes, whose 64-cube output LUT came out as one constant
texel, so the presented image was flat.

The data blocks after the program (xbox::Fssm::rodata, the new
Options::rodata) now go with the translation:

- HLSL: emit.rs embeds them as `static const uint xcl_rodata[]`, and
  s_load and FLAT / GLOBAL dword loads go through xcl_gload*, which take
  the dwords at a code address inside a block from the table. With
  several memory windows s_getpc_b64's high dword is CODE_ADDRESS_HI
  (0xC0DE, above any user-space address), so a code address is told from
  the title's memory at the same low dword; with one window it is the
  program's offset as before.
- Direct DXIL: the same, as an internal constant array of the module
  (Lw::rodata_loads in lower_window.rs); with windows s_buffer_load reads
  it too. kernel::translate_entry_rodata carries the data. The per-lane
  form (XCL_PER_LANE) has no table and leaves such programs to the
  per-instruction form. TRANSLATOR_VERSION 9 -> 10.
- pso.rs passes the data on the compute, VS / PS and mesh paths (HLSL
  and direct), and `xcl shaders` (precompile, direct sweep) does too.

Not covered: byte / short global loads, MUBUF buffer_load, the legacy
GS path and the per-lane form still read memory at such addresses.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 980eb78bd71077d43056e1d78387d5cce21d1989)
DXC workers otherwise contend on the process heap during parallel cache fills. Give each thread-local compiler a serialized private heap through DxcCreateInstance2, with a compatibility fallback, and add a read-only wrapper for filling the DXIL cache.

Measured on this machine: 19.3-19.5 effective compiler cores with private heaps versus about 2.3 with the shared process heap.

Part of #156.

Assisted-by: Codex (GPT-5)
(cherry picked from commit 760f742b42)
The console runs up to 2^32 - 1 thread groups a dimension; D3D12 takes
65 535, and past that a dispatch is undefined. On an NVIDIA RTX 5060 Ti a
retail game's world loading hung the GPU (DXGI_ERROR_DEVICE_HUNG,
0x887A0006) about 100 s in, every run: the only unfinished work was an
ExecuteIndirect of one loop-free compute program (found with the dispatch
markers of #1323), and its arguments, written by an earlier dispatch, were
72 512 x 1 x 1 and 75 072 x 1 x 1 groups.

A dispatch of more than 65 535 groups in X with 1 in Y now runs as
65 535 x ceil(n / 65 535) groups. The console's count goes into a new io
word (IO_GROUP_LIMIT, in the trap-temp range like IO_UMA_BASE_HI; 0 when
not folded), and every translated compute program takes
gid.x + gid.y * 65 535 as its group in X when the word is set, its Y as 0,
and returns at once in the groups at or past the count. A dispatch that
cannot be folded (two dimensions past the limit) is clamped and logged.

- Dispatch and console-recorded dispatches: the counts are known on the CPU
  (bind::fold, also in console_list).
- ExecuteIndirect of one dispatch: the counts are only on the GPU. A
  one-thread pass (clamp.rs) reads them, writes the counts to dispatch into
  a slot of XCL's buffer and the console's count into the dispatch's io
  (folding only when the rows stay within 65 535, as bind::fold does),
  then the dispatch reads its arguments from the slot. bind_abi now returns
  what it bound so the binding can be set again after the pass.

The translated compute HLSL changes (a few lines in the prelude), so
cached translations and DXIL of compute programs are made again once.

New tests: a folded dispatch runs each console group once and none past
its count (GPU; fails without the change from group 65 535 on), the
indirect pass folds / clamps / leaves counts as they are (GPU), and the
folding rule (unit). runner::device() gives tests the runner's device: a
test making its own device first left the Agility SDK unappliable and the
GPU tests after it skipped.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 280164a748)
`bind` and `clamp` fold a dispatch of more than 65 535 groups in X into Y for
every translated compute pipeline, but only the HLSL path took its group in X
back from both ids (`IO_GROUP_LIMIT`). The direct translator (`gpu::dxil`,
`compute_init`) and its per-lane form (`recomp::lower`) now do the same: the
group in X from both ids, Y 0, and the groups past the console's count leave
at once (a gate before the program; the per-lane form's skip block).

The folded-dispatch GPU test runs all three: HLSL, direct (wave32, wave64,
split wave64) and per-lane; the native wave64 forms only on a GPU that runs
wave64.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 7dbd80c275)
A worker's compiler was made through DxcCreateInstance2 with a private
heap, and only E_INVALIDARG fell back to plain DxcCreateInstance. Any
other HRESULT (E_NOINTERFACE, REGDB_E_CLASSNOTREG from a different DXC
build), S_OK without an object, or a HeapCreate failure under commit
pressure failed the compile, and every later job on that worker failed
the same way, where the shared process heap had compiled it. Now any
failure of the private path warns once with the reason and makes the
compiler on the process heap; only a failure there too is an error.

The private heap is also no longer destroyed with its allocator. Before
the private heaps all DXC memory came from one heap, so a block DXC
keeps past its compiler (lazily made global state, freed later through
another compiler) could not dangle. With HeapDestroy on the last
release it would, for a thread that exits (the tests' scoped threads do).
Pool workers never exit, so in the runtime the heaps already lived until
the process ends; this costs nothing there.

Tested (release, software adapter): new tests show the fallback for
three failing DxcCreateInstance2 results, that a block outlives its
allocator, and that a private-heap compiler gives byte-identical DXIL
to a process-heap compiler for the same pixel shader. Whole library
suite run on this commit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Three follow-ups to the port of the dispatch fold (fe650b6):

- The ExecuteIndirect group clamp records ResourceBarrier calls, which
  a bundle cannot hold. It now runs only on a direct or compute list XCL
  keeps state for, the same test indirect_guard::check uses; a bundle
  keeps the plain path, as before the port.
- The gpu_profile span of a folded Dispatch recorded the folded grid
  (65535x2x1 for 82606x1x1), which hid that the dispatch was past the
  limit. Both translated_dispatch and the console list's dispatch now
  give the span the console's counts and pass the folded grid only to
  dispatch_chain::dispatch.
- A dispatch fold() can only clamp was warned about twice in
  translated_dispatch: by fold() and by the fork's own line. That path
  now uses fold_counts (fold without its log line) and keeps the fork's
  line, which names the cs id, reworded to say the count was clamped.
  fold() logs as before for its other callers.

Fork notes on the cherry-picks below this commit, whose upstream
messages are kept: 41f1a85 sets TRANSLATOR_VERSION 10 -> 11 (its message
says 9 -> 10) and adds kernel::translate_compute_rodata; fe650b6 puts the
group limit in io slot 114 (113 is IO_LOOP_BUDGET), lets the clamp read
the indirect guard's output slot (Checked::arguments / read), and sets
the clamp's and the rebind's pipelines past the SetPipelineState hook.

Tested: cargo check -p xcl --tests, and the whole xcl library suite in
release on the software adapter (the hardware-GPU tests not run).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The direct translator's TRANSLATOR_VERSION is 11 here (the fork was at 10
already, upstream's commit moves 9 to 10). The group limit of a folded
dispatch takes io slot 114; 113 is the fork's loop budget. The
ExecuteIndirect clamp runs on direct and compute lists only (a bundle
cannot hold its barriers).

Software adapter, whole library suite on the branch: 1393 passed, 0
failed, 24 ignored; 56 tests that open the hardware GPU not run.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
On top of the upstream commit: any failure of the private-heap path falls
back to DxcCreateInstance, and a worker's heap is never destroyed (a block
DXC keeps past its compiler must not dangle).

Software adapter, whole library suite on the branch: 1394 passed, 0
failed, 24 ignored; 55 tests that open the hardware GPU not run.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
No log line said which buffer a draw's depth-stencil view names: the
target dump logs only the depth buffer bound most in a frame, and the
per-draw frame trace lines came from direct draws only, so ExecuteIndirect
draws never got one. Before a stencil plane written through a UAV can be
fed to the draws that test it, a run has to show which buffer those draws
bind and whether indirect draws test the same target.

XCL_TRACE_FRAME only:
- state_summary resolves the bound DSV through the handle map that
  XCL_DUMP_TARGETS keeps and appends " names <resource> <w>x<h> PC format
  <f> flags <resource flags>" after the DSV handle.
- CreateDepthStencilView logs the first 64 views of depth buffers at least
  1920 wide with the resource's PC format, the view format passed to the
  PC and the view flags (1 read-only depth, 2 read-only stencil).
- The translated graphics path of ExecuteIndirect traces its draw as a
  direct draw does, so indirect draws get their "draws vs ... ps ... into"
  line.

Logging only, no test: the existing assertion on state_summary's text
keeps passing (the text is only appended to). cargo check -p xcl --tests
is clean of new warnings; the list_x, bind and real tests: 132 passed,
0 failed, 0 ignored (56 tests that open the hardware GPU not run).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The queue's CopyPageMappingsBatchX names pool addresses, and on the
console a physical page stays mapped at every address the title mapped
it at. XCL keeps a page's bytes in one place: Away::at holds an address
only while the bytes are kept there, and when the title maps the same
page at a second address XCL moves the bytes and move_away drops the
first address - which is the pool address the method names. So the
method could not tell which page a pool address holds.

Away gains title: address -> the page the title mapped there last.
map_pages clears an address's entry first and writes it only once the
page is in place (at home, after a move, at the lazy insert, at the
final insert); a failed map leaves none. FreeTitlePhysicalPages drops
the entries of the freed pages with one retain (page numbers are never
handed out again); the release of a sparse, view-window or graphics
reservation forgets the entries inside it. Bookkeeping only: nothing
reads it yet, no behaviour change.

Tested: cargo check -p xcl --tests (no new warnings);
cargo test --release -p xcl --lib hle::kernelx: 52 passed, 0 failed, 1 ignored, including
the new an_address_keeps_the_page_the_title_mapped_there_last.

Builds on xcl-dev/xcl#1055 by Xeltax (f532d33d69): Away::title,
forget_title_mappings and their insert points, with the fixes made there
after review (write after placement, clear on free, forget on release).
Not taken: Away::freed (the entries of freed pages are removed instead).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The queue's CopyPageMappingsBatchX (#29 of the older layout, #31 in the
newer one) maps pages of the title's pool into GPU views; it is a stub
here. Its arguments are decoded apart from what is done with them, so
the record that follows takes a checked list.

mirrors::decode_batches turns one call into (GPU-view page, pool page or
None for unmapped) in the call's order: batches of 24 bytes (first
destination, number of ranges, pointer to them), ranges of three u32
(kind 0: consecutive pool pages, 1: one pool page repeated, 2: unmapped,
3: left as they are; start; count). The whole call is checked before
anything is returned: an unreadable batch or range, a range leaving the
pool, an unknown kind or more than 1 << 20 pages refuse it. No lock.
Not called yet; mirrors::PAGE names the 64 KiB page.

Tested: cargo check -p xcl --tests (no new warnings);
cargo test --release -p xcl --lib hle::kernelx: 53 passed, 0 failed, 1 ignored, including
the new the_page_mapping_batches_are_decoded_whole.

Builds on xcl-dev/xcl#1055 by Xeltax (f532d33d69): the decoding, its
checks, the Batch test helper and the cases of the test.
Builds on xcl-dev/xcl#2308 by adiologydev (31fe59c037): the decoding
split from the record. The batch layout is a fact #1055 cites; no code
from elsewhere.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The queue's CopyPageMappingsBatchX copies the mapping of a pool page
into a page of a GPU view: from the call on, the view page shows the
physical page the title had mapped at that pool address. XCL keeps a
page's bytes in one place, often not the pool address (the title maps
most streamed pages into the CPU view behind the GPU view too), so the
record keeps, for each view page the method names, the physical page
and where XCL keeps its bytes now.

mirrors::apply_batches decodes a call (decode_batches), resolves each
pool address through Away::title to its page and the page's place
(the address it is mapped at away from home, else its home), and
records it with AWAY held from the lookup to the record, so a page that
moves in between cannot be recorded at the place it left. The record
has a lock of its own (PAGES, an RwLock; STATE -> PAGES where both are
held, readers take PAGES alone): what each page shows (physical page,
place, whether a tile may show the place - unified memory, a graphics
reservation or a home -, the call that last changed it, its log key),
physical page -> view pages, place -> view pages, the 16 MiB blocks of
the places and a log of the last change of each page. A pool page with
no page mapped and an unmapped page show nothing; the same mapping
named again changes nothing. mirrors::released drops the pages of the
views that go. Readers: shows (NoView, Same, Page, Nothing), resolve
(an address per 64 KiB page and four counts), touched, any_mapped,
calls - each one atomic load while nothing is recorded. Still not
called by the runtime: no behaviour change.

Tested: cargo check -p xcl --tests (no new warnings);
cargo test --release -p xcl --lib hle::kernelx: 54 passed, 0 failed, 1 ignored, including
the new gpu_view_pages_record_the_physical_page_mapped_into_them (a
call made after the page moved into the CPU view, the unchanged mapping
named again, a remap, the tile flag of a page kept in plain memory, the
release of the view).

Builds on xcl-dev/xcl#1055 by Xeltax (f532d33d69): the recorded
physical page, Mapped, the record step with its in-view check, the
released hunk and the cases of its tests.
Builds on xcl-dev/xcl#2308 by adiologydev (64ad64ce6b): a pool page
with nothing mapped shows nothing and is counted.
Fork: the place kept eagerly (in place of page_now, which locks AWAY),
the lock of its own, the tile flag.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The console lets shaders write a depth buffer through a UAV
(ALLOW_DEPTH_STENCIL | ALLOW_UNORDERED_ACCESS). The PC refuses the pair,
so pc_resource_desc keeps the depth buffer and every UAV of it is a null
view: what a compute program stores there, such as the stencil codes the
lighting draws test, is lost. Giving those UAVs a texture of their own
needs to know, from the view and the DSV, which buffer they name and in
which PC state it was made. This commit only keeps that, behind
XCL_DEPTH_UAV_TWIN=1; with the switch off (the default) nothing is
registered and every hook stops at one atomic load.

New module depth_uav:
- the switch (enabled, on: "0" off, "1" on, else the default, off);
- note_created at the creation paths with the PC state of the call that
  succeeded: CreatePlacedResourceX's three texture returns (with the
  title address), CreateCommittedResource, the PC's way of
  CreatePlacedResource and its memory of its own (0 after its retry). A
  single-sample 2D buffer with flags 6 and PC format 19/39/44/53 is kept;
  objects at one title address and shape share a Cell (on the PC they
  share texels), a buffer without a title address is a Cell of its own;
- note_dsv at CreateDepthStencilView, and DSV descriptor copies
  (CopyDescriptorsSimple, CopyDescriptors range by range) followed: the
  destination names what the source names, or nothing;
- forget at the last release: the object leaves its Cell, the last one
  takes the Cell with it. Returns at once when nothing is registered.
vram::canonical_va becomes pub(super) for the key.

Tests: the_switch_reads_0_and_1,
only_depth_buffers_that_allow_unordered_access_are_kept,
depth_buffers_at_one_title_address_share_a_cell_until_the_last_is_released,
a_copied_dsv_names_what_its_source_names (no GPU).
cargo check -p xcl --tests: no new warnings. cargo test --release -p xcl --lib on the software adapter, the depth_uav, real, device_x and vram tests: 108 passed, 0 failed, 0 ignored (56 tests that open the hardware GPU not run).

Builds on xcl-dev/xcl#1989 by raylitebull (51ee197c)
Builds on xcl-dev/xcl#1063 by IvyNotFound (21aa52cc)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A depth buffer the console lets shaders write keeps no ALLOW_UNORDERED_ACCESS
on the PC, so every UAV of it was a null view: a compute program that
stores stencil codes through it writes nothing, and the draws that test
the stencil plane see zeros. Behind XCL_DEPTH_UAV_TWIN=1 (off by default:
then nothing changes but the log lines), a UAV that names the stencil
plane of a kept two-plane depth buffer (plane slice 1, or a stencil or
8-bit view format) is now made on a twin of the plane: an R8_TYPELESS
texture of the buffer's size with unordered access, resting in
UNORDERED_ACCESS, made at the first such UAV through
real::dev_create_committed_resource (adopted, never in title memory) and
kept with the buffer's Cell until its last object is released.

dev_create_uav_x reads the resource description once and asks
depth_uav::resolve_uav with the title's view as it came. For a twin it
calls dev_create_uav_checked_x on the twin with the title's view on
plane 0 in R8_UINT (or the R8 UNORM / SNORM / SINT class asked for), so
the PC UAV, the published name, the companion SRV and the T# (GFX10
format 5, uint) come by the ordinary path of a texture with unordered
access. A UAV of the depth plane, of a buffer XCL did not see created,
or with the switch off stays a null view, counted with its reason.
Nothing copies between the twin and the plane yet.

Log lines: "depth UAV twins are off (XCL_DEPTH_UAV_TWIN)" once; each twin
made (first 8, then powers of two); "a UAV of a depth buffer stays a null
view (<why>): <n> so far" (first 4, then powers of two), in place of the
old warning for depth buffers.

Tests: a_view_names_the_stencil_plane_by_format_or_plane_slice,
the_twins_view_keeps_the_slices_and_the_r8_class_asked_for (no GPU);
gpu_a_stencil_uav_of_a_console_depth_buffer_is_a_view_of_its_twin on WARP
in a child process with the switch and the shared view heap: a 16x16
console D24S8 buffer with flags 6 made through
CreateCommittedResource, its DSV, two stencil UAVs and a depth UAV made
through the device calls; one twin, R8_TYPELESS with unordered access
and no title address; both stencil slots name it for UAV and SRV with an
R8_UINT T#; the depth slot is a null view counted with its reason; the
DSV is known; the twin goes with the buffer.
cargo check -p xcl --tests: no new warnings. cargo test --release -p xcl
--lib on the software adapter, the depth_uav, real, device_x and vram
tests: 111 passed, 0 failed, 0 ignored (56 tests that open the hardware
GPU not run).

Builds on xcl-dev/xcl#1989 by raylitebull (51ee197c)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The record of the queue's page-mapping method keeps, for each GPU-view
page it named, where XCL keeps the shown physical page's bytes. XCL
moves those bytes whenever the title maps the page at another address
or unmaps it (one place per page), so the place has to follow, on the
moving thread and before the memory the page leaves can go: otherwise a
reader of the record (and, later, a tile linked to the place) reads an
address that was decommitted under it.

mirrors::page_at(page, at, tile) moves the place of every GPU-view page
that shows the physical page (the reverse index by_page), with by_at
and the 16 MiB block counts; its call and its place in the log stay - a
move is no change of what the page shows - unless the page gets its
first place or loses it (its bytes appear or go). One atomic load while
nothing is recorded, and a read-locked lookup before the write lock.
mirrors::page_freed(page): the pages that showed a freed page show
nothing (a change). kernelx::page_placed calls page_at with the tile
flag (a home, unified memory or a graphics reservation) and notes a
moved page as a known write at its new address
(title_textures::note_known_write): a CPU write made just before the
move went with the page. Called, with AWAY held: in move_away after the
copy and before release_at, in unmap_away in both branches (before the
release), in map_pages at the lazy insert, after the copy from home
(before move_home_away can give the home back) and in the zero branch;
FreeTitlePhysicalPages calls page_freed for every page of the call.
Still not reached by the runtime: the record stays empty until the
queue method is turned on.

Tested: cargo check -p xcl --tests (no new warnings);
cargo test --release -p xcl --lib hle::kernelx: 55 passed, 0 failed, 1 ignored, including
the new a_gpu_view_page_follows_its_physical_page (mapped elsewhere,
unmapped home with its bytes, mapped at the CPU view's same offset, a
page never used mapped elsewhere, a move keeping call and log entry,
freed pages showing nothing).

Builds on xcl-dev/xcl#1102 by Xeltax (c387de21fa): the reverse index
physical page -> GPU-view pages and its hook points (unmap_away,
FreeTitlePhysicalPages, map_pages).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
What the textures need from the record of the queue's page-mapping
method, ahead of their use: which GPU-view pages show something else
now, and which GPU-view pages a CPU write reaches.

mirrors::changes_since(seen, lo, hi, most) walks the record's log from
a reader's cursor: each GPU-view page in [lo, hi) whose content changed
(a mapping, an unmap, a free, a page that gets or loses its place),
once, with the call that changed it last, in the order of the last
change, at most `most`, and the next cursor. Nothing is drained, so each
reader keeps its own cursor; one atomic compare when nothing changed. A
move is not in it. The changes do not go through GPU_VIEW_MAP_LOG: a
change there bumps gpu_view_map_gen, which empties every recording
thread's ask cache at every call of the method, and its 4096 entries
overflow into a recheck of every texture, each with a VirtualQuery.

mirrors::views_of_written(dirty, out): for each written 64 KiB page,
the written 4 KiB pages at every GPU-view page that shows the page kept
there (the place index by_at), and, for the CPU view of a pair, at the
GPU-view page of the same offset when the method never named that page
(it shows the CPU view, and keeps today's write tracking); a mapped or
unmapped GPU-view page gets nothing from the CPU view under it. One
STATE take to copy the pairs, then one PAGES read. shown_blocks (the
16 MiB blocks that hold a place), shown_gen and moved_pages. Not called
yet.

Tested: cargo check -p xcl --tests (no new warnings);
cargo test --release -p xcl --lib hle::kernelx: 57 passed, 0 failed, 1 ignored, including
the new changed_gpu_view_pages_are_told_once_in_order (a call of three
pages, a remap told again last with its new call, a move told not at
all, a page changed twice told once, one at a time, the range, a
released view) and
a_write_where_a_page_is_kept_is_a_write_to_the_views_showing_it (one
page at two view pages, nothing at the address it left, the CPU view
under a page never named, mapped or unmapped, the blocks).

Builds on xcl-dev/xcl#1102 by Xeltax (c387de21fa): the idea of a list
of changed pages that the textures read.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
With the fold of over-limit dispatches (upstream PR #1428) a retail
title's first world frames ended in a device removal on an NVIDIA GPU:
0x887A0006 eight seconds after the indirect clamp pass first ran, the
driver's breadcrumbs inside a Dispatch. A run of the same build with
XCL_CLAMP_INDIRECT=0 had none. Arguments that are not counts reach the
pass there (the log has 0 x 1 065 353 216 x 16, the bits of 1.0f), and
the pass and bind::fold turn such a count into work: 1 065 353 216 x 1
x 1 folds into 16 257 rows of 65 535 groups, 70 000 x 70 000 x 16 clamps
to 65 535 x 65 535 x 16. Before the fold the PC was handed the counts as
they were and ran nothing of them.

- bind::fold_counts_within: a dispatch that needs folding or clamping
  and would still run more groups in all than indirect_guard's bound
  (XCL_INDIRECT_MAX_GROUPS, 2^22; one row more for the fold's padding)
  gets no groups. Counts D3D12 takes pass as they are, whatever their
  product.
- clamp.rs: the pass applies the same bound on the GPU (a second root
  constant; the product of two counts fits 32 bits there), counts what
  it left out in its header and logs it.
- The pass is opt-in for now (XCL_CLAMP_INDIRECT=1): the bound closes
  the mechanism above, but no run of the title has shown yet that it was
  all of it.

Tests: a_dispatch_past_the_limit_with_more_groups_than_any_title_asks_for_is_left_out
(the CPU's decision), and the pass's GPU test with the new cases (2^22
folded; 2^22 + 65 536, 65 535^2, the bits of 1.0f and 70 000 x 70 000 x 16
left out; 70 000 x 70 000 x 0 as the CPU gives it). Software adapter,
filters fold, clamp, left_out, indirect: 29 passed. NVIDIA RTX 5090
(driver 621.14), filters indirect_group_counts, fold, clamp, left_out:
18 passed, 0 failed, the GPU test among them. Not run yet: the title with
the pass on.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Since the previous commit a stencil UAV of a depth buffer with unordered
access is a view of the buffer's R8 twin, but the title still clears it
with the depth buffer as the resource. The PC clear then gets a view and a
resource that differ, an invalid pair, and the twin keeps what it held.

list_x::clear_uav takes the GPU slot once, before uav_clear_handles. Behind
depth_uav::any() (one atomic load: no twin alive, nothing changes), it asks
depth_uav::clear_target with what the slot's UAV names in the shared heap
(console_heap::names_of; None when the slot has no place there):
- the view names a twin of the buffer: the PC clear gets the twin as its
  resource, counted as a clear of a twin;
- the slot is not in the shared heap, or the handles are PC handles: what
  the view names is not known, so the clear is not done, and counted;
- a null view, another resource, a buffer without a twin, or a resource
  XCL does not keep: as before.
The decision is a pure function (clear_choice) over the Cell's twins.
Console-recorded lists are not changed (a later commit).

Tests: the_resource_of_a_uav_clear_is_what_the_view_names (no GPU: twin
named, null view, another resource, slot outside the shared heap, buffer
without a twin, a buffer not kept); gpu_clear_uav_of_a_stencil_uav_clears_
the_twin on WARP in a child process with XCL_DEPTH_UAV_TWIN=1 and the shared
heap: a stencil UAV of a 16x16 console D24S8 buffer, then
clear_uav_uint_x with the slot's console handles and the depth buffer as
resource on an adopted list; one clear is counted on the twin and all 256
texels of the twin read back 0x5A. The child was also run directly: it
made twin #1 and printed no SKIPPED. The child-process launcher and the
device / heap / buffer / DSV setup of G1 became a shared fixture; G1's
assertions are unchanged.
cargo check -p xcl --tests: no new warnings. cargo test --release -p xcl
--lib on the software adapter: depth_uav 9 passed, list_x 29 passed,
real 80 passed, 0 failed, 0 ignored (56 tests that open the hardware GPU
not run).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A submit reads a tile's source with raw pointers under the sparse
state's lock (the scan and the copies). Today only a paired CPU view is
a source, and source_part tells sparse about the decommits and releases
of those alone. Once tiles show the pages the queue's page-mapping
method mapped, a source is wherever such a page is kept - the pool, a
home, any address the title mapped the page at - and a decommit there
that sparse does not hear of faults the next scan. Some of those
decommits did not go through source_going at all: give_back_homes, the
release of a block's home, the placeholder decommits.

source_part keeps the pair case as it is (SOURCES_GOING keeps meaning
paired CPU views) and, while any page is recorded
(mirrors::any_mapped), answers the whole range: sparse decides by its
own index of tile sources whether a tile shows it, so the cost while
pages are mapped is two takes of the SOURCES lock a decommit; one atomic
load more while nothing is. give_back_homes, the release of a home block
(sparse::free, unified memory or VirtualFree) and the two placeholder
decommits now go through source_going. A release of a graphics
reservation with size 0 passes the reservation's size (the pair case
gives the same range as before). When a graphics reservation or a
sparse reservation is released, the shown pages kept there have no place
from then on (mirrors::place_gone: they show nothing, a change of what
they show), and for a sparse one the tiles over it are forgotten while
pages are mapped. Still not reached by the runtime while the record is
empty.

Tested: cargo check -p xcl --tests (no new warnings);
cargo test --release -p xcl --lib hle::kernelx: 58 passed, 0 failed, 1 ignored, including
the new memory_under_a_shown_page_is_told_to_sparse_before_it_goes (a
thread-local hook, KEPT_GOING: the address a page leaves, told while
still committed; the home given back; the release of the home block;
the release of the pool leaving its page showing nothing). The two
existing tests of source_going pass unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Before any code copies a twin into its plane, one run has to show that the
compute program really stores stencil codes through the redirected UAV:
if the twin stays all zero, the store does not reach it (or is mistyped)
and the copies would only spread zeros over the plane.

Diagnostic, XCL_DUMP_TARGETS only, and nothing unless a twin is alive. In a
dumped frame, after the render targets, present.rs copies each twin
(depth_uav::twins_to_dump: tag "twin<n> <plane>", n as in the line that
said the twin was made) to a readback buffer on the present list, with a
barrier UNORDERED_ACCESS -> COPY_SOURCE before and back after. When the
dump is drained, such a tag goes to depth_uav::log_values instead of a
picture: the eight most frequent byte values with their counts, the number
of distinct values and the share of zero texels, counted row by row by the
footprint's row pitch. The Twin keeps its number for this.

Test: the_values_of_a_twin_are_counted_by_row_pitch (no GPU: row padding
is not counted, a short buffer counts the rows it has, the order is by
count and then by value, eight values at most, the zero share).
cargo check -p xcl --tests: no new warnings. cargo test --release -p xcl
--lib on the software adapter: depth_uav 10 passed, present 10 passed,
0 failed, 0 ignored; the whole library suite: 1408 passed, 0 failed,
24 ignored (56 tests that open the hardware GPU not run).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Three paths take a range of a GPU view to the CPU view behind it from its
first address alone: cpu_writes::write_now writes all its dwords from one
translated address, bind.rs draw_rects translates the vertex buffer's
start and adds the first vertex, and DirectStorage's cpu_range_in checks
only the first and the last byte. That is right while every page of a
GPU view shows the CPU view at the same offset. Once the queue's page
mappings put the pages of a view in other places, a range over two pages
kept apart would be read or written in the bytes of another page (the
case of issue #697: a buffer across two pages that are not side by side
read wrong when rebased to its first page).

view_want::cpu_run(va, len) gives the CPU address of a range only when
every later 64 KiB page lies right behind the first there, None when its
pages are kept apart or one lies outside the view. write_now writes a
range that is not one piece in two calls, split at the page boundary
(write_now_in takes the resolver, for the test); draw_rects translates
the range of its vertices and falls back to the caller's draw when it is
in pieces; cpu_range_in checks every page, so such a DirectStorage
destination or source is refused instead of written into another page.
Preparation: no behaviour change while every view page shows the same
offset (nothing maps pages into a view yet).

Tested: cargo check -p xcl --tests (no new warnings);
cargo test --release -p xcl --lib hle::d3d12x::view_want
hle::d3d12x::cpu_writes hle::dstorage hle::d3d12x::bind: 65 passed,
0 failed, 0 ignored, including the new
a_range_in_a_gpu_view_is_one_piece_only_while_its_pages_are and
a_write_over_pages_kept_apart_is_made_page_by_page; the existing
cpu_range test of DirectStorage passes unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The record of the queue's page-mapping method (kernelx::mirrors) says
what each GPU-view page shows; the tiles of the view windows still
showed the CPU view at the same offset, so a streamed page the title
mapped into its GPU view never reached the GPU there.

A tile now shows what the record says (tile_shows, behind
mirror_source_tile and cpu_of): the CPU view's tile for a page never
named, the place a mapped page is kept when a tile may show it there,
nothing for an unmapped page, one with no page or one kept where
kernelx does not see the memory go. cpu_of gives the place whatever its
tile flag (the CPU reads and writes any). With an empty record every
tile resolves as before.

When what a page shows changes, kernelx tells sparse::remapped (from
apply_batches for the pages whose entry changed, page_freed, place_gone,
and page_placed for a page that gets or loses its place); it queues the
tiles that were asked for (REMAPS, a lock of its own, no state's lock).
The next submit links them again (remap_mirrors, at most 4096, after the
finished copies back land and before map_mirrors): video memory over
the new place is cleared and filled from its committed pages ahead of
the older asks; a tile that shows nothing gives its video memory back
and stays asked for. A placed buffer's tile keeps its pool tile, cleared,
over no_source (64 KiB of XCL's own, reserved, never committed), because
the buffer maps its tiles once. take_asks leaves a tile that shows
nothing asked for (a later mapping finds it); buffer_tiles links one
over no_source. unlink_kept and park, the halves of unlink_mirror and
drop_mirror, keep the ask: forgetting it would empty every recording
thread's memory of its asks at every change. Still not reached by the
runtime: the record stays empty until the queue method is turned on.

Tested: cargo check -p xcl --tests (no new warnings);
cargo test --release -p xcl --lib hle::d3d12x::sparse hle::kernelx
hle::d3d12x::view_want: 111 passed, 0 failed, 2 ignored, on the
software adapter, including the new
a_tile_of_a_gpu_view_shows_the_page_mapped_there (a mapped, an
unmapped and an untouched tile; a later write to the pool page; a remap;
a page mapped where nothing was, with no new ask; an unmap; no ask
forgotten; a range over two pages kept apart is not one piece) and
a_buffer_over_a_remapped_tile_reads_the_new_page (remap on the same
pool tile, unmap to zeros, a buffer placed over an unmapped page shows
it once mapped). Two existing sparse tests skip there (no GPU).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The line that announces a depth UAV twin says which PC state the buffer
was made in, and the first run with the twins on reads it to learn that
state. It gave the state of the object the UAV was made on. A UAV made
by address (device #71) is made on XCL's own object for that memory,
which resource_at creates in COMMON, so the line read 0x0 for a buffer
the title made in another state.

resource_at now marks the objects it makes (depth_uav::by_address). A
Cell keeps the PC state of the first object a title's creation call
made, and the line gives that one; when the title made no object at
that address, it gives the state of the UAV's own object as before.
The copies that come later take the state of the DSV's object and are
not affected.

Tested: depth_uav::tests::the_state_a_buffer_was_made_in_is_that_of_the_titles_object
(new, no GPU).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ClearUnorderedAccessView* of a depth buffer whose Cell has a twin went
to the PC as it came when the slot's UAV in the shared heap named 0 or
GONE, taken as a null view. But 0 also means "not known": a descriptor
copy from a slot that has no place in the shared heap notes 0 while it
may copy the twin's view. The PC clear then got the depth buffer as its
resource with a view of the twin, the invalid pair the clear's rule is
there to avoid. Such a clear is now not done and counted, as one through
a slot outside the shared heap; a clear through a real null view does
nothing either.

The test of the decision now covers 0 and GONE, and the half that went
through clear_target, which stopped at the "no twin alive" gate before
its lookup, now gives a registered buffer a stand-in twin (a COM object
that only counts references), so the lookup, the Cell's twins and the
counters are reached: the twin named, not known, a buffer XCL does not
keep, a kept buffer without a twin.

Tested: depth_uav::tests::the_resource_of_a_uav_clear_is_what_the_view_names
(no GPU).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
XCL keeps a physical page's bytes in one place and moves them whenever
the title maps the page elsewhere or unmaps it; the record of the queue's
page mappings follows the page (mirrors::page_at), and the place it left
is decommitted or released right after. A tile linked over the old place
would then be given back and filled again at the new one, or, worse,
read memory that is going. A move is no remap: the bytes are the same.

sparse::moved(tiles, from, to, whole), called by kernelx::page_placed on
the moving thread with AWAY held and before the old place can go, takes
the state's lock only when a tile shows `from` (SOURCES), giving way to
submits. State::retarget moves the link of each tile linked over `from`:
with video memory and the page's 64 KiB copied (`whole`) the entry keeps
its pool tile, gen and sent hashes, and nothing is cleared or filled -
the known write kernelx notes at the new place brings its pages to the
next scan, which sends only what differs, and a copy back recorded
before the move lands at the new place. A page never used (not
committed at the new place) gives its video memory up and waits there
like any linked tile. A page that moves to a place no tile may show (plain
memory) is queued with remapped instead, and shows nothing from the next
submit; the old place is told to sparse when it goes. Counted in
page_tiles()[1]. Still not reached by the runtime while the record is
empty.

Tested: cargo check -p xcl --tests (no new warnings);
cargo test --release -p xcl --lib hle::d3d12x::sparse hle::kernelx:
108 passed, 0 failed, 2 ignored, on the software adapter, including the
new a_tile_follows_its_page_without_being_filled_again (pool tile, gen
and sent hashes kept, nothing cleared or filled, a tile linked elsewhere
left; the new place's pages scanned: nothing sent when equal, the chunk
written when not; a copy back recorded before the move lands at the new
place; a page never used gives its video memory up). Two existing sparse
tests skip there (no GPU).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A ClearUnorderedAccessView* recorded on a console-recorded list
(XCL_CONSOLE_LISTS) is replayed into the PC list when the list closes.
The replay passed the title's resource, the depth buffer, together with
the slot's PC UAV, which with XCL_DEPTH_UAV_TWIN=1 is a view of the
buffer's twin: the invalid view/resource pair the direct list's clear
no longer makes. The first run with the twins on would have met it on
such a list, and the twin would have kept stale values.

The direct list's rule moves into list_x::uav_clear_resource and the
replay uses it as well: the twin when the slot's view names it, nothing
(counted as skipped) when what the view names is not known. The plan
left this to a later commit; it is taken now because that run uses the
switch.

The GPU test of the clear also checks what the PC method receives: it
calls the console method on a stand-in of the list whose PC #49 notes
its resource and goes on to the list's own. Before, it counted XCL's
decision only, and the readback would pass with the depth buffer as the
resource too, because the clear goes through the slot's descriptor. A
clear through the buffer's depth-plane UAV, a null view, is not done
and reaches nothing.

Tested: real::depth_uav_twin_tests::gpu_clear_uav_of_a_stencil_uav_clears_the_twin
(WARP, child process; run on its own it made twin #1 and printed no
SKIPPED line). The replay itself is not driven by a test: a console
list closes only with unified memory open on a GPU.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The two GPU tests of depth UAV twins run again in a child process (the
switch and the shared heap are the process's). When the child cannot
run them (no unified memory, no WARP device), skip_test prints its
SKIPPED line on the child's stderr, which the parent dropped on
success: a whole-suite run counted the test as passed and showed no
skip, and AGENTS.md asks for skips to be reported. The parent now
copies the child's SKIPPED lines to its own stderr.

Tested: the depth_uav tests (11 passed, 0 failed); on WARP both children
ran and no SKIPPED line was printed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The tests of depth UAV twins made their buffer with CreateCommittedResource,
which on WARP gave a committed PC resource with no title address. The
path a console depth buffer most likely takes was not covered:
CreatePlacedResourceX at a title address (the registration hooks in
device_x::create_placed_resource_x, the key by vram::canonical_va) and a
stencil UAV made by address (device #71), which is made on XCL's own
object at that memory. Nor was it asserted in the library's process that
with the switch off nothing is registered and a UAV stays a null view.

- gpu_a_stencil_uav_by_address_is_a_view_of_the_placed_buffers_twin (WARP,
  child process): the title places a 16x16 D24S8 buffer with
  ALLOW_DEPTH_STENCIL | ALLOW_UNORDERED_ACCESS at an address in unified
  memory, in DEPTH_WRITE. It is kept under that address with that state;
  a #71 stencil UAV of the same memory, on a second object there, names
  the placed buffer's twin in the shared heap, and the state stays the
  title's. Run on its own, the buffer went to a video-memory arena, the
  view's object aliased it, and twin #1's line gave state 0x10.
- the_switch_decides_whether_a_buffer_is_kept_and_its_uavs_redirected
  (no GPU): note_created keeps the buffer only when the switch is on;
  off, resolve_uav gives a null view with the reason "XCL_DEPTH_UAV_TWIN
  is off".

Tested: the depth_uav tests, 13 passed, 0 failed, no SKIPPED line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
state_summary took the resource a bound DSV names from present's handle
map as a plain address and called GetDesc on it after the map's lock
was released. A CreateDepthStencilView at the same handle on another
thread replaces the entry and releases the old resource, so the call
could read a destroyed object. It now takes the resource through
present::view_resource, which checks the map and adds a reference under
its lock.

The flags in that text are the resource's (ALLOW_DEPTH_STENCIL, 0x2 for
every depth buffer), so the line could not say whether the DSV is
read-only for stencil, which the first run is to answer. When depth_uav
keeps the DSV (XCL_DEPTH_UAV_TWIN=1, a buffer with unordered access) the
view's D3D12_DSV_FLAGS follow as ", view flags {f:#x}"; otherwise the
CreateDepthStencilView line of the same handle gives them.

Tested: logging only (XCL_TRACE_FRAME with XCL_DUMP_TARGETS); the
existing assertion on state_summary's text in list_x's tests keeps
passing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ExecuteIndirect draws now go through trace_ui_draw, but their lines read
like a direct draw's, and the draw kinds are listed once per (vertex
shader, pixel shader, target shape): an indirect draw with the shaders
and target of a direct draw already listed got no line at all. The
first run is to tell whether indirect lighting draws exist against the
lighting target, so the two have to be told apart. The kind's key and
text now carry "(ExecuteIndirect)", and the UI draw line ", ExecuteIndirect".

The "… that draw: {args}" lines read DRAW_ARGS, which only the direct
draw paths set: for an indirect draw they gave the previous direct
draw's arguments on that thread as this draw's. They are left out for
indirect draws, whose arguments are in GPU memory.

Tested: logging only (XCL_TRACE_FRAME); the crate builds with the same
warnings as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A texture placed in a GPU view whose pages the queue's page mappings
named was read at the CPU view's same offset (or, with a page mapped at
the address itself, after a VirtualQuery there). The pages the title
mapped into the view are kept elsewhere: in the pool, at their home, or
wherever the title mapped them last.

Such a texture now keeps its own address as its source (Entry::paged,
found by mirrors::touched with no AWAY and no VirtualQuery) and every
upload carries a table of where its 64 KiB pages are kept
(texture_upload::PageMap, from mirrors::resolve once per due texture).
A read takes no lock: one ReadProcessMemory per 64 KiB piece for a
mapped page (copy_or_zeros: a physical page is committed whole or not
at all), zeros for a page that shows nothing, and today's read for a
page the method never named. The comparison of written pages, the
detile of the upload, the level-pages check, the frame trace sample and
the probe read through such a table; a paged texture counts as watched
for the streamed recheck and skips written_pages; a source in a view
window adds no coarse watch block. The kinds of the pages read are
counted (page_counts). A texture over pages the method never touched
takes today's calls unchanged.

Tested (cargo test --release -p xcl --lib, software adapter):
new texture_upload::tests::an_upload_reads_pages_kept_apart and
title_textures::tests::a_texture_over_mapped_pages_is_read_where_they_are_kept;
gpu_mirror_upload_follows_cpu_writes_and_later_mapping_changes gains a
texture registered over a page the queue's page mappings put in the
GPU view, which reads the pool page (ran on WARP). Modules
texture_upload and title_textures: 42 passed, 0 failed, 0 ignored.

Builds on xcl-dev/xcl#1102 by Xeltax (c387de21fa)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The first five steps of the plan for depth and stencil planes that
shaders write through UAVs, with the review's fixes: nothing changes
unless XCL_DEPTH_UAV_TWIN=1 is set, and nothing is copied between a twin
and its plane yet.

Software adapter, whole library suite on the branch: reported by its last
pass (see the commits); hardware suite not run on the branch.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
When the queue's page mappings put another page under a texture read
through its pages, nothing was written: no write watch fires for a
clean, already filled pool page that is newly mapped, so the texture
kept the bytes of the page that was there before.

recheck_gpu_view_sources now also reads the GPU-view pages whose
mapping changed (mirrors::changes_since, 512 a submit: one upload
batch; the rest at the next), with one atomic compare when nothing
changed. It does not go through GPU_VIEW_MAP_LOG: that bumps the
generation that empties every recording thread's ask cache, and its
log of 4096 entries overflows into a recheck of every texture. A
texture becomes paged when a page under it is first named (pending, as
on today's source changes). For a paged texture that is not pending
the changed pages' bytes are stale: texture_upload::stale joins them
into what goes up again, and the existing AGAIN path sends them with no
comparison; the page hashes come to what went up. A shadowed texture is
made pending instead.

The GPU's write of a texture is noted per PC list as it is recorded
(note_gpu_write gains the list) and stamped when the list is submitted
(Entry::written_call = mirrors::calls()). A mapping changed by a later
call clears gpu_written and sends its pages; one changed before the
submit leaves the texture the GPU's. A list submitted again is stamped
again; a reset list writes nothing more. Textures read again are
counted (rereads).

Tested (cargo test --release -p xcl --lib, software adapter): new
title_textures::tests::a_gpu_write_counts_from_the_submit_of_its_list;
gpu_mirror_upload_follows_cpu_writes_and_later_mapping_changes extended
with a clean pool page newly mapped, a remap to equal bytes, an unmap
and a mapping again (ran on WARP). Modules texture_upload and
title_textures: 43 passed, 0 failed, 0 ignored; list_x: 29 passed,
0 failed, 0 ignored.

Builds on xcl-dev/xcl#1102 by Xeltax (c387de21fa)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A texture read through its pages is found by its own range in the GPU
view, which no write watch covers: a CPU write to the pool, to the CPU
view the page moved into, a DirectStorage write by page number or
XCL's own copy at a move is reported at the place the page is kept,
and no texture lay under that address.

refresh_parts now adds the GPU-view pages a write reaches
(mirrors::views_of_written) to the dirty pages, after sparse had the
real ones: each written page of a place where a mapped page is kept at
every view page that shows it, and a page of a CPU view at the view
page the method never named above it. The existing selection then
finds the paged textures by their own range and compares those pages
through their table; only what differs goes up (a moved page costs a
compare). The watched ranges take the 16 MiB blocks where shown pages
are kept (mirrors::shown_blocks, with shown_gen in the cache key), so
the pool and the CPU view are watched wherever such a page lies. One
atomic load more a submit while nothing is mapped.

Tested (cargo test --release -p xcl --lib, software adapter): new
title_textures::tests::an_untouched_page_of_a_paged_texture_is_found_written;
gpu_mirror_upload_follows_cpu_writes_and_later_mapping_changes extended
with a CPU write to the pool page, a write just before the page moves
into the CPU view with no look in between, a write there after the
move, write_physical_pages by page number, and a submitted GPU write
that stays over a CPU write, gives way to a later mapping, after which
a CPU write goes up (ran on WARP). Modules texture_upload and
title_textures: 44 passed, 0 failed, 0 ignored.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Queue method #29 (#31 in the newer layout) is how a title maps the pages
its texture streaming fills into the GPU views its textures are in. It
was a stub: every mapping was dropped, a GPU-view page kept showing its
CPU view at the same offset, and streamed textures uploaded as zeros.

Its arm now goes to q_copy_page_mappings, which hands the call to
kernelx::mirrors::apply_batches (the record, the tiles, the textures and
the writes of the commits before this one) and sums what it did. A call
the decoder refuses records nothing and logs one warning. The result is
S_OK either way, as the stub's was. The fifth argument does not reach
queue_dispatch and is ignored. This is the only commit of the series
that changes what a title sees.

XCL_PAGE_MAPPINGS=0 (mirrors::page_mappings, parsed by the pure
page_mappings_on) leaves slot 29 to the stub and logs that once; the
record then stays empty and every new path is behind one atomic load.
README names the switch.

Tested: the_queue_page_mapping_method_records_and_can_be_switched_off
(new): a call over a pair of views of the test's own records a named
pool page with no page and an unmapped page as showing nothing, leaves an
untouched page on its CPU view, and returns S_OK; a call with a range of
an unknown kind records nothing and returns S_OK; the switch parses.
Modules queue_tests + hle::kernelx: 61 passed, 0 failed, 1 ignored
(release, software adapter).

Builds on xcl-dev/xcl#1055 by Xeltax (f532d33d69): the queue arm, the
totals and the warning text.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
title_bytes hands the detile the title's memory in place when all of it
is readable. A page the title unmaps while the detile reads it ends the
process: an access violation in Chain::detile_level under
title_textures::subresources, the page's history showing "page unmapped
(copied home)" 2 to 3 ms before. Seen in two runs with XCL_TRACE_FRAME=1,
whose slower submits widen the window; not seen without it so far.

The switch takes the copy (read_committed: through the kernel, zeros for
a page that is gone) for every read. It is slower and off by default; the
race itself is to be closed where the upload reads (in work on the page
mappings).

Tested on a retail title (NVIDIA RTX 5090): a run with XCL_TRACE_FRAME=1
and the switch on went 161 s into the world without the fault; the run
before it, without the switch, ended in it at 78 s. The existing test of
title_bytes (in place when all is readable) is unchanged.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
One info line at the first recorded call of CopyPageMappingsBatchX, at
powers of two and when 10 s have passed since the last one: the calls;
the GPU-view pages mapped, unmapped, named with a pool page that had no
page mapped there (must stay 0: above 0, Away::title misses a path by
which the title maps pages) and elsewhere; the view pages that moved
with their physical page; the textures read again for a mapping changed
under them and the pages of their uploads by where they were read; the
tiles shown anew and the tiles that followed their page. This is what a
run needs to tell whether the page mappings reach the textures and
tiles. Diagnostics only; the text comes from a pure function, and the
counters are atomics read with the totals' lock dropped.

Tested: the_page_mapping_line (new) checks the exact text. Module
queue_tests: 4 passed, 0 failed, 0 ignored (release, software adapter);
the run printed the line for the test's own call.

Builds on xcl-dev/xcl#1055 by Xeltax (f532d33d69): the first half of the
line. The count of pool pages with nothing mapped follows
xcl-dev/xcl#2308 by adiologydev (64ad64ce6b).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Three lines for the question a run could not answer: which depth buffer
a lighting draw tests, and whether shaders write it.

- A depth buffer with unordered access at least 1920 wide gets a line
  when it is kept: object, size, PC and console format, its title
  address (two buffers at one address are one memory on the console) and
  the PC state it was made in.
- A UAV of such a buffer gets a line with its view format and the plane
  it names.
- With XCL_TRACE_FORMATS the pipeline lines keep to pipelines that draw
  into a target of those formats: a title's menus made the first 400
  pipelines, so the ones of its world never got their depth and stencil
  state logged.

XCL_TRACE_FRAME only; nothing changes without it. bind::trace_formats is
the list both the draw kinds and the pipeline lines read.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
When a shown physical page moved, page_placed decided once for all its
GPU-view pages: linked again (sparse::remapped) when the page had no place
before or has none now, or is now kept where no tile may show it; else
the tiles follow it (sparse::moved) from the first old place found.

That missed a page moving from plain memory (tile flag false) to memory a
tile may show (a graphics reservation, unified memory, its home). While
it sat in plain memory its tiles showed nothing and were left unlinked
but still asked for. sparse::moved returns at once when no tile is linked
over the old place, and nothing queued a relink, so the tiles kept
showing nothing until some later mapping change touched those pages. The
single `from` also sent view pages with a different old place (none
after a release, say) to moved, which does nothing for them.

mirrors::page_at now returns each moved view page with its old place and
old tile flag. page_placed has the tiles follow only for the view pages
kept where a tile could show them, at the place they leave, when the new
place may be shown too; all others are linked again at the next submit.

Tested: new test
hle::kernelx::tests::a_page_leaving_plain_memory_has_the_tiles_over_it_linked_again
(a test hook records what page_placed passes to sparse: plain memory,
then a graphics reservation, then another, then home). Module
hle::kernelx: 59 passed, 0 failed, 1 ignored.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The release of a block of unified memory (the title's MEM_GRAPHICS
allocations) told sparse nothing while GPU views show mapped pages: it
called source_going with size 0, which source_part only answers for a
paired CPU view. Yet unified memory counts as memory whose release
kernelx sees (freeing_is_seen), so tiles are linked over pages kept
there, and physical pages can be mapped into such blocks. The record
kept the place and Away::title kept the mapping, so once the block was
handed out again the tiles and paged textures showed the new owner's
bytes, and a later queue call naming a pool address in the block
resolved to the old page.

The release now takes the block's size (Uma::block_len, new), forgets
the title's mappings in it, leaves the shown pages kept there without a
place (mirrors::place_gone), tells sparse of the whole block, and has
their tiles linked again – all before Uma::free hands the block back.

The release of a sparse-window reservation did place_gone after the
address space was given back: a submit in between could link a tile
over the released range, and one reserved and committed again meanwhile
would fill it with unrelated bytes. The record is cleared before the
release now; sparse forgets the tiles over it and relinks the asked
ones after, as before.

forget_title_mappings removes the entries of each page of a range when
the range has fewer pages than there are entries, instead of a pass
over all of them: it now runs on every release of a block of unified
memory.

Tested: new test
hle::kernelx::tests::the_release_of_unified_memory_under_a_shown_page_leaves_it_showing_nothing
(the whole block told to sparse while committed, the page shows
nothing, the title's mapping is forgotten). Module hle::kernelx: 60
passed, 0 failed, 1 ignored. The first run had two failures from the
existing a_page_whose_move_fails_stays_mapped_where_it_was, which
releases an address and expects nobody to reserve it again; a parallel
test reserved it. The rerun passed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
sparse::remapped appends every asked tile of every mapping change to
REMAPS, and each submit appends REMAPS to the state's queue, of which
remap_mirrors takes MIRROR_ASKS_MAX (4096) a submit and removes
duplicates only inside that batch. A view page changed at every frame,
or by several calls, was queued once per change: above 4096 changes a
submit the queue grew without bound and a tile waited behind stale
copies of itself.

take_remaps (new) joins the queue and, once it is longer than
MIRROR_ASKS_MAX, sorts it and keeps each tile once, so the backlog is
bounded by the tiles asked for. The order of a short queue is kept; a
long one goes in address order, which remap_mirrors used within its
batch already.

Tested: new test
hle::d3d12x::sparse::tests::a_tile_remapped_again_and_again_waits_once
(100 tiles changed at each of 100 submits never queue more than
MIRROR_ASKS_MAX + 100). Modules kernelx, sparse, cpu_writes, dstorage,
title_textures, texture_upload, view_want, list_x: 213 passed, 0
failed, 2 ignored (2 SKIPPED: no GPU, existing).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
XCL's own CPU writes for the GPU (immediate writes after a fence, the
64-bit readback copies and maxima) into a GPU-view page go where
view_want::cpu says. Since the tiles of a GPU view show the pages mapped
into them, that is the place of the mapped page, which can be its home.
A home in plain memory is not write-watched (the plan relies on XCL's
own writes there being known writes), so neither the tile nor the
textures over the page saw such a write. Before, the same write went to
the write-watched CPU view.

cpu_writes now tells such a write as XCL's own
(title_textures::note_known_write) when the address it was asked for
shows a mapped page and the write landed elsewhere: write_now (each
part of a split write), write_u64_now and max_u64_now. One atomic load
more while nothing is mapped; a write into a page never named is not
told, as before.

Tested: new test
hle::d3d12x::cpu_writes::tests::a_write_where_a_mapped_page_is_kept_is_a_known_write
(a write through a mapped GPU-view page lands at the page's home and is
a known write there; one through a page never named lands in the CPU
view and is not). Modules kernelx, sparse, cpu_writes, dstorage,
title_textures, texture_upload, view_want, list_x: 213 passed, 0
failed, 2 ignored.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
note_gpu_write noted every GPU-written texture per PC list (LIST_WRITES)
for the stamp that orders a GPU write against the queue's page mappings,
and submitted() then took LIST_WRITES and TEXTURES at every submit of
such a list – also with XCL_PAGE_MAPPINGS=0, where nothing reads the
stamp. That switch is to give back the path from before the page
mappings.

The writes are noted only while mirrors::page_mappings() is on; with it
off, submitted() returns early again when no transition is noted.

Tested: no new test (the switch is read once per process from the
environment). Modules kernelx, sparse, cpu_writes, dstorage,
title_textures, texture_upload, view_want, list_x: 213 passed, 0
failed, 2 ignored; a_gpu_write_counts_from_the_submit_of_its_list
covers the stamp with the switch on.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Four gaps in the tests of the queue's page mappings:

- gpu_view_pages_record_the_physical_page_mapped_into_them paired a CPU
  view of 43 pages, the size an existing sparse test pairs too. GPU
  views pair by size with the most recent unpaired CPU view, so the two
  could pair across each other when run in parallel. It takes 199 pages
  now, a size no other test uses.
- The kernelx and title_textures tests of this work returned silently
  without unified memory, so a skip looked like a pass. They call
  skip_test("no unified memory") now, as the sparse ones do.
- The step "equal bytes in the old and the new page" of
  gpu_mirror_upload_follows_cpu_writes_and_later_mapping_changes could
  not tell an upload from none by its readback; it now also checks that
  the texture was read again for the mapping (title_textures::rereads).
- A range over GPU-view pages kept apart was refused only in a test
  that skips without reserved buffers. New no-GPU test
  hle::dstorage::tests::a_range_over_gpu_view_pages_kept_apart_is_refused:
  view_want::cpu_run over two pages kept apart is None, DirectStorage's
  cpu_range refuses a range across them, reaches a range inside one
  where its page is kept, and one over pages never named at the CPU
  view.

Tested: modules kernelx, sparse, cpu_writes, dstorage, title_textures,
texture_upload, view_want, list_x: 213 passed, 0 failed, 2 ignored;
the GPU test ran on the software adapter (not skipped).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A driver reset three seconds into a retail title's world left a report
that could not name the pass: DRED's count stood at a Dispatch whose
pipeline had no label ("a stand-in, or not translated"), and of the 25
operations the list had left only four pipeline labels were given. DRED's
count can lag behind the GPU, so the operation that faulted is any of
those not done.

- For a list the GPU was in, the report now gives the 16 operations before
  the first one not done and every one after it (160 at most) by name,
  XCL's markers as the label of the pipeline bound from there (dred::ops).
- A bound pipeline with no label of its own is named by what its stand-in
  is built from: the compute program's record, or the shader key of a
  graphics pipeline, and whether it is built (pso_async::describe).
- The DRED 1.2 device state is logged (hung, fault, page fault, or none),
  and a removal without breadcrumbs says so: two removals with reason
  0x887a0005 left no line at all about what was in flight.

Diagnostics only (XCL_DRED=1 for the labels). The test of the labels also
checks the new operation list.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
A retail title's world lost the device with reason 0x887A0005 (no driver
error, DRED state 0, no list in flight) at 23 to 26 GB of video memory
and 46 to 49 GB of process memory, on a PC whose other programs held
71 GB of commit under a 147 GB limit. The sum looked like the limit;
nothing in the log could say.

- The memory line ends with "system commit N of M MB", and a removal
  reports it too. Measured with it: 30.8 GB were left at the removal, and
  the system's commit follows the process's own memory, not its video
  memory - the commit limit is not what removes the device (it is the
  driver's 512 MiB range for the code of pipelines in use,
  xcl-dev/xcl#2403).
- A warning when less than 8 GB of commit are left (once, then at each
  halving): there allocations start to fail for every program.

Tests: the rule of the warning; the commit is known and under its limit.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Twenty commits: the fourteen of the plan (kernelx keeps the page the title
mapped at an address, decodes the method's batches, records which physical
page each GPU-view page shows and follows it when it moves; the tiles of a
GPU view and the textures over it show and read the pages mapped there;
queue method #29 / #31 does it, XCL_PAGE_MAPPINGS=0 for the stub) and six
from two reviews (a page that leaves plain memory has its tiles linked
again, a released block of unified memory leaves no shown page, the queue
of tiles to link again is bounded, XCL's own writes where a page is kept
are known writes, GPU writes are noted per list only while the mappings
are on, the tests own their pairs and report skips).

No conflicts with the depth-buffer registry, the fold bound, the safe
texture read or the trace and device-removal lines on world-main.

Left by the reviews, not fixed: a release runs forget_mirrors on the title
thread (a cost, to be measured); a free and a GPU write of the same call
number are ordered by the call, not by the change. The race of an upload
with the title unmapping the texture's pages is not closed here:
XCL_TEXTURE_SAFE_READ=1 stays the workaround.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
A run with XCL_TRACE_FRAME that also dumped frames or targets ended in an
access violation under present_now (d3d12.dll, GetDesc; earlier in the
driver, on the clone): busiest_rt read every address in USES, which keeps
addresses and no references, and a retail title's world releases transient
render targets all the time. This is what made trace runs need frame
dumps off.

- busiest_rt gives a reference, and only of a target an RTV still names
  (view_resource: the RTV map holds it); most bound first. Followed
  targets go through the same check.
- The DSV line says the depth buffer's title address (two buffers at one
  address are one memory on the console).
- XCL_TRACE_DSV_FORMATS=53,55: the trace also lists draws whose depth
  buffer (2560 wide or more) has one of those PC formats, and pipelines
  with one of them as DSV format: the passes that write or test a depth
  buffer without drawing into a target of XCL_TRACE_FORMATS. The cap on
  pipeline lines is 1500.

Measured with it on a retail title: the 30 pipelines of its lighting pass
draw with depth EQUAL, depth write off and no stencil against a D16
depth-stencil view (RTs R11G11B10_FLOAT and R32_UINT).

Diagnostics only; nothing changes without XCL_TRACE_FRAME.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
A retail title's world ended three times in a device removal with
DEVICE_HUNG (0x887A0006, an nvlddmkm 153, no time-out: two to six
seconds into the world). Each report had one list in flight, and its
first operation not done was the same one: after two barriers and a
pipeline marker, the Dispatch of the pass that rewrites the arguments of
an ExecuteIndirect(DispatchMesh) for its two passes (SCALE_ARGS_HLSL),
at the first such draw of that list.

That pass sets XCL's ABI root signature and then root views 0, 2 and 3;
view 4 (the count buffer) only when the title gave one, which this title
never does. The program declares u4 and reads it under a test of a
constant, so a driver may load from it ahead of the test - and on a list
where nothing set that slot before, the load is at GPU address 0. A read
of GPU address 0 on a graphics node is also what a kernel trace of this
removal showed on another card (xcl-dev/xcl#1452).

scale_views gives every view the program declares an address: without a
count buffer u4 names the constants.

Test: the views with and without a count buffer, none of them 0, and
the registers the program declares. Not shown yet: that the removal is
gone - it came in three of about twelve world starts.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
A diagnostic. An NVIDIA driver keeps the code of the pipelines in use in
512 MiB and removes the device past that (xcl-dev/xcl#2403); a retail
title's world got there 16 to 28 s in, before the passes a trace was
after had run. The biggest compute programs are most of that code:
XCL_SKIP_CS_KB=<n> gives a program with n KiB of DXIL or more no pipeline,
so its dispatches are skipped as those of a program whose build failed,
and a run lives longer at the price of what those programs draw.

Off unless set. Test: the size is in KiB and off unless a positive number.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The console compiler places a root signature's static samplers as S#
words built from constants in the code, and constant_samplers turns an
S# whose four words were all set that way into a static sampler. It
knew s_mov_b32, s_movk_i32 and s_mov_b64. A word with only high bits
set is written bit-reversed instead (`s_brev_b32 s66, 40` for
0x14000000, the filter word of a point sampler with a mip filter), so
such an S# was not recognised and its image instruction looked up the
sampler-heap entry that word 3 names – entry 0 for a constant S#, a
sampler the title made for something else.

In a seeded sample of 1244 programs of a retail title, 534 use a
sampler in 4951 instructions; 482 of those instructions, in 203
programs, have an S# that is constant but for one s_brev_b32 word.
They get their own static sampler now, in the HLSL and the direct
translator alike (both use constant_samplers).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
(cherry picked from commit 253bc79d0b)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:34:06 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 23:28 UTC · original

Verification on RTX 3060 Ti (Windows 11): merge conflict with current main (many files, e.g. crates/xcl/src/gpu/recomp/pso.rs, crates/xcl/src/hle/d3d12x/real.rs, crates/xcl/src/shaders.rs) — needs a rebase before it can be tested.

**@⁠DavidM1911** on GitHub · 2026-11-25 23:28 UTC · [original](https://github.com/xcl-dev/xcl/pull/2572#issuecomment-7177618292) Verification on RTX 3060 Ti (Windows 11): **merge conflict with current `main`** (many files, e.g. `crates/xcl/src/gpu/recomp/pso.rs`, `crates/xcl/src/hle/d3d12x/real.rs`, `crates/xcl/src/shaders.rs`) — needs a rebase before it can be tested.
Author
Owner

@⁠KOLESNiii on GitHub · 2026-11-25 23:42 UTC · original

What is wanted for this?

**@⁠KOLESNiii** on GitHub · 2026-11-25 23:42 UTC · [original](https://github.com/xcl-dev/xcl/pull/2572#issuecomment-7177941553) What is wanted for this?
Author
Owner

@⁠nnonno91 on GitHub · 2026-11-25 23:45 UTC · original

Tested xcl-dev:nvidia-dev at c044dc6, which is included in this PR. Release build with Rust 1.100.0 and DXC 1.8.2502.11. Retail title 1.0.2.1 on an RTX 5090 (driver 617.42), Ryzen 7 9800X3D, Windows 11 build 26200.

Two launches reached the menus at about 30 FPS, then hit DXGI_ERROR_DEVICE_HUNG (0x887A0006) during world loading at 103.4 s and 156.2 s after launch. The second run had 11,205 MB of system commit headroom at device removal. Windows logged nvlddmkm event 153 around both failures.

Common flags were XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_UMA_SHADOW=1 XCL_COHERENT_HEAPS=sparse:16 XCL_LOOK_SKIP=1 XCL_NETWORK=0.

Timed follow-up Last interval with presents Timed exit
XCL_DRED=1 62 s 240 s
DRED + XCL_SKIP_CS_KB=256 62 s 180 s
DRED + XCL_PSO_WAIT_MS=50 60 s 150 s
XCL_PAGE_MAPPINGS=0 60 s 180 s

All four follow-ups stopped presenting during world loading and showed zero presents through their scheduled cutoffs. Gameplay was not reached. Related world-loading reports are in #505.

Tests and log analysis by Codex (GPT-6).

**@⁠nnonno91** on GitHub · 2026-11-25 23:45 UTC · [original](https://github.com/xcl-dev/xcl/pull/2572#issuecomment-7177999785) Tested `xcl-dev:nvidia-dev` at `c044dc6`, which is included in this PR. Release build with Rust 1.100.0 and DXC 1.8.2502.11. Retail title 1.0.2.1 on an RTX 5090 (driver 617.42), Ryzen 7 9800X3D, Windows 11 build 26200. Two launches reached the menus at about 30 FPS, then hit `DXGI_ERROR_DEVICE_HUNG` (`0x887A0006`) during world loading at **103.4 s** and **156.2 s** after launch. The second run had **11,205 MB of system commit headroom** at device removal. Windows logged `nvlddmkm` event 153 around both failures. Common flags were `XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_UMA_SHADOW=1 XCL_COHERENT_HEAPS=sparse:16 XCL_LOOK_SKIP=1 XCL_NETWORK=0`. | Timed follow-up | Last interval with presents | Timed exit | | --- | ---: | ---: | | `XCL_DRED=1` | 62 s | 240 s | | DRED + `XCL_SKIP_CS_KB=256` | 62 s | 180 s | | DRED + `XCL_PSO_WAIT_MS=50` | 60 s | 150 s | | `XCL_PAGE_MAPPINGS=0` | 60 s | 180 s | All four follow-ups stopped presenting during world loading and showed zero presents through their scheduled cutoffs. Gameplay was not reached. Related world-loading reports are in #505. Tests and log analysis by Codex (GPT-6).
Author
Owner

@⁠pr1sm-dev on GitHub · 2026-11-25 23:48 UTC · original · edited 2026-11-26 00:05 UTC

Linux / RTX 3070 8 GB, nvidia-dev at c044dc6: a 600 s run crashed at 374.8 s in xcl::hle::xg::copy_from (xg.rs:713), the CopyFromSubresource crash of #662. The branch has none of its open fixes (#684, #976, #992, #1435). One run, so a data point; the head of this PR is one recompiler commit past c044dc6 and does not touch xg.rs.

Setup: RTX 3070 8 GB, NVIDIA 595.91.07 (Linux), Ryzen 7 5800X, 62 GB RAM; Wine 11.22 + vkd3d-proton master 30b0eb9b with #257's patch; x86_64-pc-windows-gnu release build of c044dc6, no local changes. The retail title, VKD3D_CONFIG=ignore_shared_fence,pipeline_library_log,no_descriptor_heap,retain_psos, XCL_SHORT_MOVIES=1, XCL_NETWORK=0, XCL_PSO_WAIT_MS unset, A / DOWN pressed by XCL_PRESS_AT; compute driver blobs mostly warm (129 compute pipelines from kept blobs, 36 built in the run).

What happened

  • No world: the screen captures (every 5 s up to 328 s) show loading art and dark frames. The three compute programs over 600 KB of DXIL built in the run took 120 s on average (215 s the longest); presents averaged 1–35 per 2 s over each 30 s from 90 s to the crash.
  • At 374.8 s: 0xc0000005, a write inside msvcrt memcpy on a title thread that records command lists, called from xcl::hle::xg::copy_from at xg.rs:713 (resolved from this build's debug info) – the 2D row loop, writing row_pitch apart.

#684 on top

  • #684 (e56dbc3) cherry-picks onto c044dc6 without conflicts and builds.
  • One run with it, same settings and length: no crash, but presents stopped at 375 s while the title's threads waited for compute pipelines still being built (the driver had just started on one of about 1 MB of DXIL with no blob yet). So that run does not show whether the copy was reached; it is not a confirmation of #684 here. @⁠spicbully-star's report on #662 (RDNA4, Windows) is the one that shows a #684-like change removing the crash.

Edit: with the switches from #2057 (XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_UMA_SHADOW=1 XCL_COHERENT_HEAPS=sparse:16 XCL_LOOK_SKIP=1, otherwise as above), c044dc6 ends at 43.8 s and 17.4 s in two runs: status 0x3 with a winevulkan ← d3d12core stack, in the traced run during a compute pipeline's driver compile that never finished. It has the signature of the Linux NVIDIA crash on #2229's constant tables (that program's SPIR-V holds such tables), though I have not shown it is the same cause on this branch; @⁠MacieGx's v2 of #2229 removes it on its own branch here (#2229), but does not cherry-pick onto this branch (conflicts in 3 files), so it would need his rebase or a merge here.

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

**@⁠pr1sm-dev** on GitHub · 2026-11-25 23:48 UTC · [original](https://github.com/xcl-dev/xcl/pull/2572#issuecomment-7178084101) · edited 2026-11-26 00:05 UTC **Linux / RTX 3070 8 GB, `nvidia-dev` at `c044dc6`: a 600 s run crashed at 374.8 s in `xcl::hle::xg::copy_from` (`xg.rs:713`), the `CopyFromSubresource` crash of #662. The branch has none of its open fixes (#684, #976, #992, #1435).** One run, so a data point; the head of this PR is one recompiler commit past `c044dc6` and does not touch `xg.rs`. **Setup:** RTX 3070 8 GB, NVIDIA 595.91.07 (Linux), Ryzen 7 5800X, 62 GB RAM; Wine 11.22 + vkd3d-proton master `30b0eb9b` with #257's patch; `x86_64-pc-windows-gnu` release build of `c044dc6`, no local changes. The retail title, `VKD3D_CONFIG=ignore_shared_fence,pipeline_library_log,no_descriptor_heap,retain_psos`, `XCL_SHORT_MOVIES=1`, `XCL_NETWORK=0`, `XCL_PSO_WAIT_MS` unset, A / DOWN pressed by `XCL_PRESS_AT`; compute driver blobs mostly warm (129 compute pipelines from kept blobs, 36 built in the run). **What happened** - No world: the screen captures (every 5 s up to 328 s) show loading art and dark frames. The three compute programs over 600 KB of DXIL built in the run took 120 s on average (215 s the longest); presents averaged 1–35 per 2 s over each 30 s from 90 s to the crash. - At 374.8 s: `0xc0000005`, a write inside `msvcrt` `memcpy` on a title thread that records command lists, called from `xcl::hle::xg::copy_from` at `xg.rs:713` (resolved from this build's debug info) – the 2D row loop, writing `row_pitch` apart. **#684 on top** - #684 (`e56dbc3`) cherry-picks onto `c044dc6` without conflicts and builds. - One run with it, same settings and length: no crash, but presents stopped at 375 s while the title's threads waited for compute pipelines still being built (the driver had just started on one of about 1 MB of DXIL with no blob yet). So that run does not show whether the copy was reached; it is not a confirmation of #684 here. @⁠spicbully-star's report on #662 (RDNA4, Windows) is the one that shows a #684-like change removing the crash. **Edit: with the switches from #2057** (`XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_UMA_SHADOW=1 XCL_COHERENT_HEAPS=sparse:16 XCL_LOOK_SKIP=1`, otherwise as above), `c044dc6` ends at 43.8 s and 17.4 s in two runs: status `0x3` with a `winevulkan` ← `d3d12core` stack, in the traced run during a compute pipeline's driver compile that never finished. It has the signature of the Linux NVIDIA crash on #2229's constant tables (that program's SPIR-V holds such tables), though I have not shown it is the same cause on this branch; @⁠MacieGx's v2 of #2229 removes it on its own branch here (https://git.gtahub.st/github/xcl-dev--xcl/pulls/2229), but does not cherry-pick onto this branch (conflicts in 3 files), so it would need his rebase or a merge here. AI use: Claude Code (Claude Opus 5.5) made the runs and wrote this comment.
Author
Owner

@⁠GodlyBDS on GitHub · 2026-11-26 02:30 UTC · original

RTX 3090 Ti / Windows 10 — two CPU blockers and repeatable ExecuteIndirect TDR

Tested release 22eb6f211dc1256c202e8df9dfaffff4211d61ba on RTX 3090 Ti 24 GB, driver 621.40, Windows 10 19045, Ryzen 9 5950X, 32 GiB RAM and DXC 1.8.2502.11. The patched runs used the 1 GiB app profile, four heap windows, direct DXIL, UMA shadows, DRED and unlimited PSO waits.

  1. The unmodified build reported that a valid host XCL_D3D12_DIR on another drive had no D3D12Core.dll, fell back to inbox D3D12, rejected root flags and exited at 7.594 s with the +0xb5a5f8 null-read signature from #598. Scoping Agility initialization to native host path resolution loaded SDK v620 and passed that point. The path-scope regression passed.
  2. The Agility-fixed build reached 74.398 s and faulted in xg::copy_from on a destination write. The failing call uses the extra argument before the source pointer, as in #662. Using the extra-argument wrapper and checked row copies from our local baseline cleared this failure. Five XG tests passed, including argument ordering and the unmapped destination case.
  3. With both compatibility fixes, two runs reached DXGI_ERROR_DEVICE_HUNG (0x887a0006) at ~86 and ~96 s. Both recorded nvlddmkm 153 and Display 4101. DRED reported 16 of 7,339 operations complete in the affected list. The first outstanding operation was ExecuteIndirect. In the run with DRED pipeline names, the label was VS d2a238740e50f037, PS e2bcc91e569d6d13. VA was 0, with no associated allocations. The second run reproduced the breadcrumb with the CPU D3D12 debug layer and targeted binding tracing enabled.

The same shader pair drew the UI earlier. The breadcrumb helps locate the execution failure, and more evidence is needed to identify the faulty resource or producer. No verified world geometry in either run.

AI use: OpenAI Codex (GPT-6) integrated the focused local backports, ran the tests, and analyzed the logs.

**@⁠GodlyBDS** on GitHub · 2026-11-26 02:30 UTC · [original](https://github.com/xcl-dev/xcl/pull/2572#issuecomment-7180865764) **RTX 3090 Ti / Windows 10 — two CPU blockers and repeatable ExecuteIndirect TDR** Tested release `22eb6f211dc1256c202e8df9dfaffff4211d61ba` on RTX 3090 Ti 24 GB, driver 621.40, Windows 10 19045, Ryzen 9 5950X, 32 GiB RAM and DXC 1.8.2502.11. The patched runs used the 1 GiB app profile, four heap windows, direct DXIL, UMA shadows, DRED and unlimited PSO waits. 1. The unmodified build reported that a valid host `XCL_D3D12_DIR` on another drive had no `D3D12Core.dll`, fell back to inbox D3D12, rejected root flags and exited at 7.594 s with the `+0xb5a5f8` null-read signature from #598. Scoping Agility initialization to native host path resolution loaded SDK v620 and passed that point. The path-scope regression passed. 2. The Agility-fixed build reached 74.398 s and faulted in `xg::copy_from` on a destination write. The failing call uses the extra argument before the source pointer, as in #662. Using the extra-argument wrapper and checked row copies from our local baseline cleared this failure. Five XG tests passed, including argument ordering and the unmapped destination case. 3. With both compatibility fixes, two runs reached `DXGI_ERROR_DEVICE_HUNG` (`0x887a0006`) at ~86 and ~96 s. Both recorded `nvlddmkm` 153 and Display 4101. DRED reported 16 of 7,339 operations complete in the affected list. The first outstanding operation was `ExecuteIndirect`. In the run with DRED pipeline names, the label was VS `d2a238740e50f037`, PS `e2bcc91e569d6d13`. VA was 0, with no associated allocations. The second run reproduced the breadcrumb with the CPU D3D12 debug layer and targeted binding tracing enabled. The same shader pair drew the UI earlier. The breadcrumb helps locate the execution failure, and more evidence is needed to identify the faulty resource or producer. No verified world geometry in either run. AI use: OpenAI Codex (GPT-6) integrated the focused local backports, ran the tests, and analyzed the logs.
In the HLSL split-wave64 form a group of one console wave (64 threads or
fewer) is just the two 32-lane halves, and they take the same branches
(on exchanged, wave-uniform state), so both reach every exchange. Since
#798 they met through the bounded counter spin there too, which costs
about 2.3x the group barrier per exchange on Ampere (#1244: 13.2 ms vs
5.7 ms on an RTX 3080 in bench_split_wave64, 64-thread groups, one
exchange per iteration; 3.6x vs 1.55x wave32 on an RTX 3070).

x64_spin_for picks the form: groups of more than one console wave keep
the counters (a barrier would wait for other console waves); one-wave
groups now get the barrier, as the direct DXIL translator does
(Partner::Present, #1426). XCL_WAVE64_SPIN=1 forces the counters
everywhere, for debugging a desynchronised pair (wrong output instead
of a hang); =0 keeps the barrier, as before.

Assisted-by: Claude Code (Claude Opus 5.5)
When the device's local video memory passes 75 % of its budget, a new sampled
title texture gets no pool tiles for its largest mips (the largest side kept:
2048 from 75 %, 1024 from 85 %, 512 from 92 %). Those tiles stay unmapped and
every view of the texture is clamped to the first mip that has memory
(ResourceMinLODClamp, which counts from the resource's first mip). With lazy
levels (XCL_TEXTURE_LEVEL_PAGES=1) those levels never get pages.
XCL_TEXTURE_BUDGET=0 turns it off; XCL_TEXTURE_MAX caps every new texture.

Part of #1773.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Once any buffer mirror exists, sync_title_buffers runs on every draw and
nothing reported what it costs. With XCL_ACTIVITY=1 it now logs, every 2 s
in which it ran: draws synced and those with a mirror, copies (whole
buffers), bytes copied, indices scanned for the vertex range, readable()
calls (those over 16 pages, which can take the VirtualQuery walk), the time
in readable() and its slowest call, and the time in the function.

The slowest readable() is not in #2391's list: measuring on #2389 found
single calls of 16 pages or fewer taking 1-9 ms, which the other counters
average away.

The counters cost nothing without XCL_ACTIVITY: host_main turns them on
(enable_sync_activity) before it starts the activity thread, and until then
sync_title_buffers, sync_readable() and sync_count() check one relaxed
bool and take no time stamps and touch no shared counter.

No change in behaviour: the old body is sync_mirrors, unchanged apart
from the counters, and sync_title_buffers still returns first when no
mirror exists.

Fixes #2391. Part of #2389.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
With XCL_PSO_WAIT_MS set, a Dispatch or dispatching ExecuteIndirect put
off to the submit (#2118) was recorded through resolve_wait, with the same
budget a bind has as the title records. A pipeline a bind had already
found late got the stand-in at once, one still building got it after the
budget, and the dispatch was counted as skipped and left out. Its segment
lies between the list's other work, so the list's Write64 labels, EOP
writes and fence signals still fired: the title saw the work as done
while its UAV outputs, counters and indirect argument buffers were never
written.

record_deferred now waits for the segment's compute pipeline
(pso_async::wait_for_submit) before it records the call, whether a bind
found it late or not. Without the budget this is the wait the submit
already made. With it, the submit leaves the build to the workers for
the budget first, as a bind does, so big compiles keep their turns on
the workers; one no worker has started by then is built on the
submitting thread, so a submit never waits for a free worker. One a
worker builds is waited for at most 30 s (SUBMIT_WAIT_MOST, the time a
retail title's watchdog lets its main thread stand still, #891):
title_held stops kernelx::Sleep and the GPU-wait watchdog, not every
clock a title reads. Past that the call goes on with the stand-in as
before, with a WARN ("deferred dispatch skipped after waiting 30 s for
its pipeline") and a count of its own.

A worker's build that panics now ends as a failed build (catch_unwind
around the job), so whoever waits for it goes on instead of waiting for
a done flag nobody sets.

Tests: a put-off dispatch of a translated console program whose build
ends 400 ms into the submit, with a 50 ms budget and the pipeline already
late, has its store and the Write64 after it in the list reach memory
(without the change the label is written and the store is not); a
submit's wait for a late pipeline no worker can start builds it itself;
a submit waits for a worker's build no longer than its bound and counts
it; a panicking build ends as failed.
sync_title_buffers checked every copy's source, and the indices it scans,
with gpu::shader::readable. For a range with a page that is not resident,
or over 16 pages, that walks the region with VirtualQuery. Measured on
#2389, in 18 of 43 two-second windows one such call took 1.1-8.8 ms on
the render thread inside a draw.

The copy now uses title_textures::copy_committed_region (ReadProcessMemory,
which cannot fault), so a page the title freed or protected since keeps
what the mirror had. The indices are scanned from the index buffer's
mirror once copied there; an index buffer without a mirror is still
checked.

#2392 proposed checking once per mirror and again after kernelx frees or
reprotects memory. kernelx does not see HeapFree, which releases large
heap blocks inside ntdll, so that still needed a copy that cannot fault,
and with one the check has nothing left to protect.

Fixes #2392. Part of #2389.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Count completed records in the offline shader path and display progress while the launcher waits for the worker. Warm both pieces and the whole compute fallback for split records. A cancelled or unsuccessful pass leaves the host unstarted.
Keep the guest behind the preparation gate in the host. The presenter owns its window throughout warm-up and swap-chain creation. Let its message thread draw progress and handle cancellation until the guest is ready. Leave the runtime clock and input timing anchored to title startup.
The host starts the measured title interval only after the shader gate succeeds. Let a full-pack run specify a longer launcher deadline and record that setting in the evidence manifest. Keep the default timeout and regression block unchanged.
76 upstream commits; 15 files with conflicts, resolved keeping the fork's
fixes with upstream's new code. Where upstream's #2118 text replaced the
fork's port of it, the port's fixes are carried: the own allocator of a
recording stays on its primary list, a put-off segment's blocks are held
for the PC allocator it records on, alloc_pool asks its own fences
through real::fence_completed. Two upstream geometry tests meet the
fork's refusal of the split ES form and take the native form by default.

Software adapter: cargo test --release -p xcl --lib: 1519 passed,
0 failed, 24 ignored; 58 tests that open the hardware GPU not run.
Integration tests: d3d12_mesh_stream's
console_ms_in_as_slot_and_ms_with_as_are_refused_cleanly fails here and
on world-main before the merge alike (the fork translates that case);
the three e2e tests were not run (the test title was not built).
Not run on a title yet.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Taken as it is at 5bec5877 for a test on a title. One conflict in
shaders.rs: the fork's slice of the shader list and its rodata option
are kept with the pull request's counting of records and errors.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Seven upstream commits. Conflicts in four files: the README keeps both
bullets; dxc.rs keeps the fork's compile_with (a compiler on a private
heap) under upstream's compile_whole and linked form; a dispatch chain's
refusal warning stays, with ComputeBuild::Chain; the split fixture keeps
the fork's optional chain with upstream's timing block inside it.
driver_cache::path is back: upstream's new test calls it.

Software adapter: cargo test --release -p xcl --lib: 1531 passed,
1 failed, 25 ignored; 59 tests that open the hardware GPU not run. The
failure, sparse's flush_parked_does_not_free_or_reuse_tiles_while_unmap_
is_in_flight, passed three times of three run alone (it reads the clock;
a shader build was using the machine). Not run on a title yet.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Taken as it is for a test on a title.

Co-Authored-By: Claude Fable 5.2 <[email protected]>

# Conflicts:
#	crates/xcl/src/hle/d3d12x/list_x.rs
#	crates/xcl/src/host.rs
Taken as it is for a test on a title. The memory line keeps the fork's
budget and commit text after the pull request's count of thinned textures.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The driver builds about two pipelines at a time for one process, so the
preparation before a title (#2555) stood for minutes on each stretch of
large compute programs. The stages are still translated in the host;
the compute pipelines are built by worker processes of the same program,
each on its own slice of the records: the processors less two, 16 at
most, 3 GB of the commit left for each (XCL_PREPARE_WORKERS; 1: as
before). With a list of the pipelines an earlier run used, only those
are built before the title starts. A worker that fails is logged and the
title starts; a worker ends when the host does. A worker reports every
record while a title waits on it, and the host logs its progress every
5 s.

Measured on a retail title, RTX 5090, 32 threads: the first 92 % of the
steps in 85 s (one process: 84 % of one pass after several minutes).

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Taken as it is for a test on a title.

Co-Authored-By: Claude Fable 5.2 <[email protected]>

# Conflicts:
#	crates/xcl/src/gpu/recomp/emit.rs
From #2547: pso_async::wait_for_submit, called by record_deferred
(bind::wait_for_bound) before each put-off call is recorded; the
SUBMIT_WAIT_MOST bound with its WARN and SUBMIT_GAVE_UP count; the test
switches for the wait budget and the submit bound; catch_unwind around a
worker's build; the four tests.

Kept from the fork: Demand's waiters/by_submit/ahead counting (the submit
counts once among the waiters through `ahead`, also for a late pipeline,
and leaves with unwant_ahead when it gives up), waits_for/need_by_submit,
the split LISTS locks (no lock held across the wait), the own allocator on
the primary list, run_job (the panic catch wraps it and clears its
thread-locals), the Wait struct (submit wait counters, 1 s logs, title
held), BUILT_HERE/BUILT_AT_SUBMIT for a build the submit runs itself, the
dred pipeline mark (now after the wait, so it names the built pipeline)
and bound_pso. XCL_CS_PSO_WAIT_MS keeps its precedence: with it set,
wait_for_submit leaves the wait to the call's resolve_wait as before.
Without XCL_PSO_WAIT_MS and XCL_CS_PSO_WAIT_MS the submit's wait is the
unbounded resolve_wait_for it already made.

The list_x GPU test makes the pipeline late after the dispatch is put
off, since the fork does not put off a late pipeline.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The two passes were added up (twice the records), and a worker's count
moved every 200 records, so the screen stood on one number for many
minutes. The workers' pass has its own heading and count, a worker
reports every record, and the line under the bar says a large pipeline
is compiling. Workers: the logical processors less four.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
A shader whose S# is taken for a heap entry it is not samples through
entry 0: point, wrap, mip 0 only. With the switch that entry is linear,
clamp, every mip, so a picture that changes with it shows such shaders.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This reverts commit 4eb70f0fe3, reversing
changes made to 626459dbe7.
A program's S# constants were known only inside the block that set them.
The console compiler sets an S# before a loop or an if and samples
inside it; those samples went through sampler-heap entry 0 (point, wrap,
mip 0): banded gradients, stepped glows, a lookup that wraps. The
constants are followed through the program's branches: a register is a
constant at a block's start when every block that leads there leaves it
with the same one.

On a retail title, RTX 5090: with entry 0 made linear
(XCL_ZERO_SAMPLER_LINEAR=1) the bands and steps went, which showed the
samples went through it.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This reverts commit 52590832bb, reversing
changes made to 2870e1007c.
This reverts commit 2870e1007c, reversing
changes made to 6aa80e3c80.
A run keeps the shaders of the pipelines it uses, each by its own key
(used-shaders.txt beside the DXIL cache). With that list the preparation
before a title translates only those records; the title translates
another when it first uses it. XCL_PREPARE_ALL=1: every record, as
without the list. XCL_PREPARE=0: no preparation, the title builds what
it uses as it goes.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This reverts commit fbfac4d06d.
A program's S# constants were known only inside the block that set them.
The console compiler sets an S# before a loop or an if and samples
inside it; those samples went through sampler-heap entry 0 (point, wrap,
mip 0): banded gradients, stepped glows, a lookup that wraps. In vertex
and pixel programs the constants are followed through the branches: a
register is a constant at a block's start when every block that leads
there leaves it with the same one.

Not in the other programs: read this way on a retail title, compute
programs gave ExecuteIndirect 2 055 counts out of range in 75 s (none
before) and the device hung after 140 s. Why is not known yet.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
A console title may make a UAV of a depth buffer and have compute passes
read and write its depth plane. The PC buffer has no unordered access, so
behind XCL_DEPTH_UAV_TWIN=1 the depth plane of a D32, D16 or D32S8 buffer
gets a twin (R32_TYPELESS, R16_TYPELESS) that must hold what the plane
holds while shaders use it, and give back what they wrote.

The title says when that is: it moves the buffer into UNORDERED_ACCESS
before its shaders use the UAV and out of it before the next depth test or
sampling, and each transition names the state it leaves and the one it
enters. So, in ResourceBarrier:

- The PC buffer cannot be in UNORDERED_ACCESS: where the title has it
  there it rests in COPY_SOURCE (depth_uav::PARK), on every list (also the
  console-shaped ones), from its creation on, so its states agree wherever
  the title moves it. An object the title made in UNORDERED_ACCESS keeps
  the title's states, and gets no copies.
- After a transition into UNORDERED_ACCESS on a DIRECT list, the depth
  plane is copied into the twin (the twin made then when there is none):
  what was drawn reaches the shaders.
- Before a transition out of it, the twin is copied into the plane, which
  goes PARK -> COPY_DEST, and the title's transition goes on from there:
  what the shaders wrote reaches the next draw.
- A copy into the twin is not done while the two hold the same: after a
  copy on this recording with no transition to a state that writes the
  plane since (in_step, per list, cleared by Reset and KickoffX; a split
  segment starts without it). Record order is execution order only within
  one list, so nothing is carried across lists.
- A twin whose last way in was not copied (a compute list, a twin that
  could not be made) is not copied back: it does not hold the plane.
- A split transition is done whole at its end.

D3D12 rules relied on: copies of whole subresources between a depth
plane and a texture of the same format family (R32_TYPELESS and
R16_TYPELESS on both sides; plane 0 of R32G8X24_TYPELESS copies as
R32_TYPELESS); a depth-stencil resource may be in COPY_SOURCE / COPY_DEST;
the twin rests in UNORDERED_ACCESS and goes to COPY_* and back around each
copy. Copies only on DIRECT lists.

The UAV itself still names nothing here; the next commit makes it a view
of the twin.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
With XCL_DEPTH_UAV_TWIN=1 a UAV of the depth plane of a D32, D16 or D32S8
buffer was still a null view ("its depth plane has no twin yet"): on a
retail title 11 of them in the first seconds of its 3D world, so its
compute lighting read nothing and wrote nowhere. It is now a view of the
plane's twin, made at the first such UAV or transition into
UNORDERED_ACCESS, the way the stencil plane's UAV is a view of its R8
twin: the slot's UAV, companion SRV and T# name the twin.

The view keeps the title's dimension, mip and slices on plane 0; its
format is R32_FLOAT (D32, D32S8) or R16_UNORM (D16), the depth as a
shader reads it, unless the title asked for another class of that size
(R32_UINT, R16_UINT ...). A D24S8's depth plane stays a null view (no UAV
format reads it as the depth), as does that of a buffer made in
UNORDERED_ACCESS (its states stay the title's, the twin would never be
copied). The stencil plane goes as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A dumped frame's render targets show where a picture goes wrong (the
first tone-mapped target of a world frame comes out as a negative of
the HDR scene it reads), but not which pass drew it.

With XCL_DUMP_TARGETS set, every graphics pipeline made through
CreateGraphicsPipelineState (or a stream of console VS / PS) is noted
by the address the title holds: its shader set key, each stage's
shader key and dump hash, render target 0's blend state (with the
logic op) and the RT formats, and a copy of its shaders (512 MiB of
them at most, deduplicated by key). Each draw counts per (target,
pipeline); the first draw with a pipeline in a frame notes what its
descriptor tables name.

For each target written, the dump logs the 12 pipelines with most
draws into it: draws, translated or not, keys, formats and blend, the
written targets it reads, and one line for each other resource it
reads (dimension, size, mips, format). A thread of its own then writes
target<k>_<stage>_<key>.hlsl (the VS and PS translated again from the
kept console shader, as the pipeline translates them, the PS's static
samplers after the VS's) and .rdna2.txt (the disassembly) next to the
pictures.

Nothing of this runs without the switch: the hooks return at once.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A title's tone map reads colour-grading lookup tables (3D textures) whose
contents come out wrong. Nothing logged how XCL made, filled or viewed a
3D texture, nor what one holds on the PC.

With XCL_DUMP_TARGETS set (lut3d.rs; nothing is done without it):
- each 3D texture made through CreatePlacedResourceX (and the views by
  address that go through it), CreateCommittedResource, CreatePlacedResource
  in a heap of the title's or CreateReservedResource gets a line and a name
  (lut<n>): size, mips, PC and console format, flags, whether it is kept in
  step with the title's memory, its title address;
- the writes XCL sees are logged: CopyTextureRegion / CopyResource into it,
  a render target view made, drawn into or cleared, an unordered access
  view made, an upload from the title's memory, WriteToSubresource;
- a shader resource view of one in a console slot: its T# index, view
  format, mips, clamp and component mapping; and when a slot that held one
  gets another view (a T# the title copied out before then names that one
  on the PC, while on the console it still names the 3D texture's memory);
- at a dumped frame each live one of at most 64 on a side is read back in
  the state the title's submitted transitions left it in (noted beside
  title_textures'; one copied into from COMMON is not read back): the
  texels at its corners and centre and each channel's range over mip 0,
  and its first, middle and last depth slices as
  lut<n>_<w>x<h>x<d>_f<format>_slice<k>.bmp.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A title makes over two hundred of them; the ones a pass reads were past
the first 32.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The size of a 3D render target on the console is not modelled, and
without a size every PC tile of the reserved texture went on the
title's pages from its address on. The PC's texture has more tiles than
the console's takes (18 for 33x33x33 texels of 8 bytes), so the last
ones were the first pages of the texture the title placed behind it
(512 KiB on): two such textures wrote over each other.

A title's run-time colour-grading volumes are placed like that. Two of
the three the tone-mapping pass reads held slabs of their neighbours:
the picture came out teal and close to a negative. With the texels of
the first level as the least the texture takes, it has those pages at
its address and its own tiles for the rest.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
A dumped frame shows which graphics pipelines drew into each target,
but a scene lit per screen tile by compute passes leaves no trace
there: the dispatches are counted as work and nothing more.

With XCL_DUMP_TARGETS set, every compute pipeline made through
CreateComputePipelineState (or a stream of a console CS) is noted as
the graphics ones are (its CS kept, within the same 512 MiB). Each
Dispatch and each ExecuteIndirect of a dispatch signature counts for
the pipeline the title bound; an indirect one reads its first command's
arguments (and the count) when they are in unified memory at record
time.

The dump logs each compute pipeline of the frame in order of first use:
its CS key and dump hash, its direct and indirect dispatches, the
groups of the first direct one and of the largest, the first indirect
one's arguments (or that they are on the GPU), and whether it runs
translated. The first 400 get compute<k>_cs_<key>.hlsl and .rdna2.txt
on the dump's shader thread, translated through HLSL even when the
pipeline runs direct DXIL; the file names the path that made the
running DXIL (pso::compute_path: HLSL, direct DXIL for XCL_DIRECT_DXIL
or for enormous HLSL, or from the translated cache). HLSL above 8 MB
is not written, with a log line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
XCL_DEBUG_PS_SUB probes inside one pixel shader; a pass done by
compute shaders had nothing alike.

XCL_DEBUG_CS_SUB=<dump hash>:from=>to||from=>to does the same for the
compute shader of that dump hash, with one [SHADER] line per
substitution giving the occurrences replaced. The two switches share
their parsing (debug_subs) and their replacement (apply_debug_subs).

That shader is translated through HLSL: not by the direct DXIL
translator, neither for XCL_DIRECT_DXIL nor for enormous HLSL. It takes
none of the caches kept by its console bytes, which hold it unchanged:
console_to_dxil_in skips the shader cache in memory and the translated
cache on disk for it, and keeps the substituted result in neither. So a
shader preparation that built the original (in this process or in its
worker processes, which also go through console_to_dxil_in) does not
stand in for it. The caches after that are keyed by what changed: the
DXC cache by the HLSL text, the driver's blobs by the DXIL. Every other
compute shader keeps its path and its caches.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Shaders that read zeros where data should be (vertices of prepared meshes
collapsing to a point, tile light lists read as empty) may be reading tiles
of the memory windows with no video memory: never filled, given back, or
asked for at a submit that ran before their fill. Nothing told these apart.
Three switches do, all off unless set:

- XCL_VIEW_KEEP=1: a tile over a CPU view keeps its video memory once
  filled. Where it would go back (its CPU view decommitted, its view gone,
  its page remapped or moved) it stays mapped in `kept` and is taken back
  from there as a parked tile is. Tiles kept count against XCL_MIRROR_MB;
  at the cap tiles are refused as before (warned once).
- XCL_VIEW_POISON=1 (or =0x<pattern>): every tile of the windows without
  video memory is mapped onto one shared tile filled with 0x7fc0dead
  (REUSE_SINGLE_TILE), and an unmapped tile goes back to it instead of
  NULL; a buffer placed in a window starts on it too. The tile is filled
  again at most every 16 ms, as shaders may write there.
- XCL_VIEW_STATS=1 (on with either of the others): a line every 2 s of the
  tiles asked for, filled, given back and kept, how many submits after
  going a tile got video memory again (0-1, 2-8, 9-64, more) and the bytes
  filled again for those, and the submits that left asked tiles waiting
  for a later submit (the fill budget and ask limit of a submit).

Which windows a pipeline's shaders reach is not known (the window comes
from each address at run time), so submits are not matched to the
windows their lists read.

Tests: the switches' pattern, the keep decision, the buckets and the line;
a kept tile stays mapped over a submit and comes back with its count; a
tile without video memory reads the pattern, filled reads its data, given
back reads the pattern again (on the software adapter).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Records with the same program are in several workers' slices. Each
worker found no driver blob and built the pipeline: the driver's
compile of one took about twice as long in each of four workers that
built it at once, and a worker that had waited for its turn built what
another had written to the cache meanwhile.

A worker claims a pipeline with a file beside the blob it will write
(<blob>.claim) and removes it when the build ends; a worker that finds
the claim leaves the pipeline, and the cache is read again after the
wait. A claim left by a process that died is taken over after 30
minutes. The count of pipelines left to another process is printed
with the others.

Reported by a tester who logged what each worker compiled.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
The shader preparation before a title starts builds the compute pipelines
earlier runs used, but no graphics pipeline: what is kept between runs is
not enough to make one again. used-pipelines.txt holds only the key of a
pipeline's shader set, and the driver cache holds blobs named after the
translated DXIL and the description's hash. A retail title then builds
~6 000 graphics pipelines in its first minutes, with thousands of
stand-ins that draw nothing meanwhile.

A lazy graphics pipeline's description is now written down at its first
use in a run (pso_async::on_first_use, told once, as used::note is):
every field of the description but its pointers, its input layout, and
the keys of its console shaders, ~200 bytes, under the key
used-pipelines.txt has. The entry is made when the pipeline is (no
shader copy is kept for it after its build) and written by a thread of
its own, each description once, to used-graphics-pipelines.bin beside
the DXIL cache (gfx_records: the format is in the module's comment). The
file is versioned (another version reads as none and is started again),
an entry cut short or damaged ends it, and it stops at XCL_GFX_RECORDS_MB
(64) with a line in the log. No shader code is kept: the preparation
finds the shaders in the title's shader files by key, as it does for
used-shaders.txt.

Mesh pipeline streams are not recorded.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
After the compute pass, the shader preparation now reads the graphics
pipeline records of earlier runs (used-graphics-pipelines.bin), finds
their console shaders in the title's shader files by key, and builds each
pipeline in worker processes, the way the title's background build makes
it (real::prepare_graphics calls translated_graphics_pso, as
build_graphics does): the translation, DXC and driver blob caches on disk
then hold exactly what the title asks for, and the title makes these
pipelines from the kept blob in milliseconds instead of compiling them
while it draws stand-ins.

Worker processes, as for the compute pipelines: the driver builds about
two pipelines at a time for one process, and a driver that ends a worker
ends no title. Nothing of the title's device is needed: a translated
pipeline gets XCL's root signature, and what else its build reads of the
process is the title's memory windows (given with --windows, no memory
reserved: uma::leave_out, pso::set_title_windows) and the adapter
(XCL_ADAPTER from the title's setting). Each worker gets a file of its
part with the shaders it needs (gfx_records' format) in the temporary
folder, removed after.

The title did not keep the blob of most graphics pipelines: none of under
16 KB of DXIL and none built in under 250 ms (XCL_PSO_DISK_CACHE_MIN_MS),
so most were compiled again in every run. A preparation worker keeps
every blob, on disk only. The blob's file name is made of the
description's state, the DXIL, the adapter and driver and the window
count, no address, so the title's lookup finds the worker's file.

The screen shows "Building graphics pipelines" with its own count, the
5 s line counts graphics pipelines, a failure is logged and skipped and
the title starts regardless. XCL_PREPARE=0 skips it with the rest,
XCL_PREPARE_GRAPHICS=0 skips this pass only.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Its one commit (an S# word written with s_brev_b32 is a constant) is
in the branch already, inside the follow-the-branches form of
constant_samplers; its tests are kept.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Author
Owner

@⁠Royalflamejlh on GitHub · 2026-11-26 05:18 UTC · original

On Linux + NVIDIA, c044dc6 with #684 lost the device in 14 of 17 runs, at 95 to 207 s, with Xid 109 (CTX SWITCH TIMEOUT) in the kernel log in 11 of them and in one run without a removal: probably the DXGI_ERROR_DEVICE_HUNG with event 153 reported above on the RTX 5090 and the RTX 3090 Ti (a guess). In 1 of the 2 runs with breadcrumbs_sync (a barrier after each command), the one queue vkd3d-proton could read had stopped in a Dispatch(320, 180, 1) of cs 3cd7bbae40a84030; the other skipped that program and placed no list. Skipping that program, or taking out 1be95b1b's spin exchange, did not stop the hang. main b49be18 with #684, #751, #1599, #1860, #2082, #2404, #2615 and #2598 (XCL_DIRECT_DXIL=1 of the four; two of the four plain runs on vkd3d-proton's standard dxil-spirv) hit Xid 109 in the 4 runs without breadcrumbs_sync (106 to 159 s), but not in the 2 with it (stopped by our memory guard at 167 and 188 s), so it may be a different hang.

Setup: RTX 4060 Ti 16 GB (NVIDIA 615.71.09), Wine 11.21 Staging, vkd3d-proton v3.1-90-g30b0eb9b with dxil-spirv 694cc674 and three local patches to it, unless named. XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_UMA_SHADOW=1 XCL_CS_PSO_WAIT_MS=50 unless named; first-run screens completed once, no story progress; 300 s asked (1,050 s in three runs).

changed from the setup runs device removed at
none 1 – (Xid 109 at 98.9 s, no removal reported; no present after 94.5 s)
breadcrumbs (the kit built with its trace option; 3 runs on a bench-only tree that waits 10 s at a removal) 5 95.3, 102.7, 104.5, 132.8 s; 94.9 s with breadcrumbs_sync
no XCL_CS_PSO_WAIT_MS 2 147.6 s; – (no present after 94.2 s)
no XCL_HEAP_WINDOWS, no XCL_UMA_SHADOW 2 207.4 s; – (no present after 94.2 s)
HLSL path (no XCL_DIRECT_DXIL) 1 177.0 s
vkd3d-proton's standard dxil-spirv, + #1860 1 132.3 s
XCL_TWO_PASS_MB=1: no two-pass ExecuteIndirect ran (the second with breadcrumbs) 2 130.8, 103.1 s
XCL_SKIP_CS=3cd7bbae40a84030 (the second with breadcrumbs_sync) 2 106.4, 99.6 s
kernel.rs:684 back to main's barrier (33..=64 => Partner::Present) 1 103.8 s
  • Read: that program (64 threads a group) has one loop, the counter spin 1be95b1b gives a 33–64-thread compute group (lanes.rs, up to 1,048,576 tries per wait), where main has the group barrier #1727 found hanging; the hang came with either (last row).
  • With XCL_TWO_PASS_MB=1 no two-pass ExecuteIndirect ran and the device was lost all the same, so the ExecuteIndirect that DRED left outstanding on the RTX 3090 Ti may be a list that waited, not the cause (a guess).

Not tested: Windows; the head 22eb6f2 (one commit past c044dc6, on static samplers; it touches neither ExecuteIndirect nor the wave exchange); main without the eight pull requests; more than one run in most rows.

AI use: Claude Code (Claude Opus 5.5) made the runs, read the logs, the breadcrumbs and the translated programs, and wrote this.

Posted without review by a person: the account owner was away and reads replies later.

**@⁠Royalflamejlh** on GitHub · 2026-11-26 05:18 UTC · [original](https://github.com/xcl-dev/xcl/pull/2572#issuecomment-7183368441) On Linux + NVIDIA, `c044dc6` with #684 lost the device in 14 of 17 runs, at 95 to 207 s, with Xid 109 (`CTX SWITCH TIMEOUT`) in the kernel log in 11 of them and in one run without a removal: probably the `DXGI_ERROR_DEVICE_HUNG` with event 153 reported above on the RTX 5090 and the RTX 3090 Ti (a guess). In 1 of the 2 runs with `breadcrumbs_sync` (a barrier after each command), the one queue vkd3d-proton could read had stopped in a `Dispatch(320, 180, 1)` of `cs 3cd7bbae40a84030`; the other skipped that program and placed no list. Skipping that program, or taking out `1be95b1b`'s spin exchange, did not stop the hang. `main` `b49be18` with #684, #751, #1599, #1860, #2082, #2404, #2615 and #2598 (`XCL_DIRECT_DXIL=1` of the four; two of the four plain runs on vkd3d-proton's standard dxil-spirv) hit Xid 109 in the 4 runs without `breadcrumbs_sync` (106 to 159 s), but not in the 2 with it (stopped by our memory guard at 167 and 188 s), so it may be a different hang. **Setup:** RTX 4060 Ti 16 GB (NVIDIA 615.71.09), Wine 11.21 Staging, vkd3d-proton `v3.1-90-g30b0eb9b` with dxil-spirv `694cc674` and three local patches to it, unless named. `XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_UMA_SHADOW=1 XCL_CS_PSO_WAIT_MS=50` unless named; first-run screens completed once, no story progress; 300 s asked (1,050 s in three runs). | changed from the setup | runs | device removed at | |---|---|---| | none | 1 | – (Xid 109 at 98.9 s, no removal reported; no present after 94.5 s) | | breadcrumbs (the kit built with its trace option; 3 runs on a bench-only tree that waits 10 s at a removal) | 5 | 95.3, 102.7, 104.5, 132.8 s; 94.9 s with `breadcrumbs_sync` | | no `XCL_CS_PSO_WAIT_MS` | 2 | 147.6 s; – (no present after 94.2 s) | | no `XCL_HEAP_WINDOWS`, no `XCL_UMA_SHADOW` | 2 | 207.4 s; – (no present after 94.2 s) | | HLSL path (no `XCL_DIRECT_DXIL`) | 1 | 177.0 s | | vkd3d-proton's standard dxil-spirv, + #1860 | 1 | 132.3 s | | `XCL_TWO_PASS_MB=1`: no two-pass `ExecuteIndirect` ran (the second with breadcrumbs) | 2 | 130.8, 103.1 s | | `XCL_SKIP_CS=3cd7bbae40a84030` (the second with `breadcrumbs_sync`) | 2 | 106.4, 99.6 s | | `kernel.rs:684` back to `main`'s barrier (`33..=64 => Partner::Present`) | 1 | 103.8 s | - **Read:** that program (64 threads a group) has one loop, the counter spin `1be95b1b` gives a 33–64-thread compute group (`lanes.rs`, up to 1,048,576 tries per wait), where `main` has the group barrier #1727 found hanging; the hang came with either (last row). - With `XCL_TWO_PASS_MB=1` no two-pass `ExecuteIndirect` ran and the device was lost all the same, so the `ExecuteIndirect` that DRED left outstanding on the RTX 3090 Ti may be a list that waited, not the cause (a guess). **Not tested:** Windows; the head `22eb6f2` (one commit past `c044dc6`, on static samplers; it touches neither `ExecuteIndirect` nor the wave exchange); `main` without the eight pull requests; more than one run in most rows. **AI use:** Claude Code (Claude Opus 5.5) made the runs, read the logs, the breadcrumbs and the translated programs, and wrote this. Posted without review by a person: the account owner was away and reads replies later.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2572/head:github-bot/gh-2572'
git switch 'github-bot/gh-2572'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2572'
git switch 'github-bot/gh-2572'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2572'
git switch 'github-bot/gh-2572'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2572'
git switch 'main'
git merge --squash 'github-bot/gh-2572'
git switch 'main'
git merge --ff-only 'github-bot/gh-2572'
git switch 'main'
git merge 'github-bot/gh-2572'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.