Skip to content

Nvidia dev - #2572

Open
bmjask wants to merge 371 commits into
xcl-dev:mainfrom
theaustinayers:nvidia-dev
Open

bmjask wants to merge 371 commits into
xcl-dev:mainfrom
theaustinayers:nvidia-dev

Conversation

@bmjask

@bmjask bmjask commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

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

theaustinayers and others added 30 commits November 25, 2026 03:33
…ocator

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 xcl-dev#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 <noreply@anthropic.com>
…nion

xcl-dev#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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
…s it

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 <noreply@anthropic.com>
…s driver blobs named after adapter, driver and windows)
…part

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 <noreply@anthropic.com>
…f it

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 <noreply@anthropic.com>
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 xcl-dev#70 / xcl-dev#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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
…of a CPU view against submits; decommits in a window)
…anged

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 <noreply@anthropic.com>
… call

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 <noreply@anthropic.com>
theaustinayers and others added 6 commits November 25, 2026 20:34
…e-wave groups meet at a group barrier by default

Taken as it is for a test on a title.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

# Conflicts:
#	crates/xcl/src/gpu/recomp/emit.rs
…MS set, a put-off dispatch waits for its pipeline at the submit instead of being dropped

From xcl-dev#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 <noreply@anthropic.com>
… record

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 <noreply@anthropic.com>
… fork's put-off dispatches)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…iagnostic)

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 <noreply@anthropic.com>
…on the fork's put-off dispatches)"

This reverts commit 4eb70f0, reversing
changes made to 626459d.
@GodlyBDS

Copy link
Copy Markdown

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 Retail title 1.0.2.1: null read at +0xb5a5f8 right after the auth token refusals – crashes at the account prompt with no input (RTX 3080, Win10 19044) #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 XG CopyFromSubresource: retail title passes one argument more → memcpy AV in copy_from; then null write at game+0x23cf683 at end of loading #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.

theaustinayers and others added 10 commits November 25, 2026 21:35
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 <noreply@anthropic.com>
…xtures go without their top mips while video memory fills up"

This reverts commit 5259083, reversing
changes made to 2870e10.
…aw mirror sync copies without asking readable()"

This reverts commit 2870e10, reversing
changes made to 6aa80e3.
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 <noreply@anthropic.com>
…n the stages that draw

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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
@Royalflamejlh

Copy link
Copy Markdown
Contributor

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

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.

theaustinayers and others added 11 commits November 26, 2026 00:23
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 <noreply@anthropic.com>
…exture

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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.