Skip to content

Nvidia dev - #2572

Merged
Prime1997 merged 429 commits into
xcl-dev:mainfrom
theaustinayers:nvidia-dev
Nov 28, 2026
Merged

Prime1997 merged 429 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 06:28
…LSL path

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

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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
…ges by counters

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

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

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

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

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

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

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

Review of d4624b7: the PC heap behind a shader-visible console sampler heap
now holds 2 048 samplers, and descriptor heap xcl-dev#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 xcl-dev#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 xcl-dev#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 xcl-dev#25 / xcl-dev#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
xcl-dev#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; xcl-dev#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 xcl-dev#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 <noreply@anthropic.com>
…d from what goes into it, free page pool heaps of title textures given back)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…isible sampler heap, the null views for a view slot with no room, the shared heap's fill in the log)

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

throny commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

@ettehn thank you, that is exactly the comparison I needed: under 1 s with a supplied blob on 621.24, against 15-20 s here on 621.40 for the same size class. So the blobs can load fast and something on this machine prevents it.

What differs here besides the driver version: xcl.exe runs in the NVIDIA profile of #2590 (1 GiB shader heap), and the driver's own cache folder for it has grown to 18 GB. Next I time the same preparation under another exe name (no profile; the driver's cache cold at the first launch and warm at the second), which separates "profile" and "driver cache state" from "driver version". If both are slow, the remaining suspect is 621.40 itself and I will say so here. The marker PR offered on #2088 stays useful either way, since it removes the re-creation from every launch.

AI use: Claude Code (Claude Fable 5.2).

Review note on xcl-dev#2927: unmap_levels searched the texture's page keys and
swap_removed one for each key given back, under PAGES: quadratic in the
pages of a large level. remove_once_each counts the keys to drop and
takes one occurrence of each in a single retain.

Test: remove_once_each_takes_one_occurrence_for_each_naming (duplicates,
keys not named, nothing to take); the level-pages GPU test still passes.

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

throny commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Six tests fail on the clean nvidia-dev head ecc0bb57 on this machine (RTX 4080 16 GB, driver 621.40, Windows 11 26300, Rust 1.100.0, debug, no game running; cargo test --workspace --no-fail-fast -- --test-threads=4: 1825 passed, 8 failed counts over 42 test binaries, 48 ignored, 27 SKIPPED lines, most of them "no wave64"). Each was rerun alone on the clean tree with the same result:

  • hle::d3d12x::texture_upload::tests::gpu_parts_of_a_texture_go_up_and_the_rest_stays and …::pieces_hold_the_texels_of_their_levels (both panic at texture_upload.rs:1002)
  • gpu_compute_e2e: split_compute_prefers_the_offline_whole_pipeline (the child's compiled.dispatch_chain.is_some() at line 119) and async_compute_pso_registers_real_pso_and_not_standin (line 535: the released async compute pipeline is still in the translated table)
  • gpu_two_pass_cache_e2e: two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs (line 574)
  • d3d12_mesh_stream: console_ms_in_as_slot_and_ms_with_as_are_refused_cleanly (expects the AS-slot refusal, gets "MS: no NGG hardware variant")

I have not looked into causes; posting so that nobody takes them for regressions of a PR tested on NVIDIA. If they pass for others on this head, tell me and I will dig into what differs here. AI use: Claude Code (Claude Fable 5.2) ran the tests and wrote this.

@throny

throny commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Follow-up on the slow blob loads (RTX 4080, driver 621.40): the 1 GiB profile is not the cause. The same build under another exe name (no profile), second launch, so with the driver's own cache for that name warm: 67 creations from stored blobs at 750 KB-1 MB of DXIL took 19.7 s on average, 13 above 1 MB took 28.2 s (with the profile: 14.9 s and 19.7 s). The first launch under that name, with the driver's cache cold, took 50 s and 74 s for the same size classes, like a compile without a blob.

So on this machine the stored blob never makes creation fast; whatever speed there is comes from the driver's own cache, and for the large programs that is 15-30 s each. @ettehn measured under 1 s on 621.24 and @andrewDoing milliseconds on 616.92 (small synthetic programs, on #2951), which leaves the driver version as the main suspect here. A rollback to 621.24 would settle it; that needs the machine's owner, so it will not happen tonight.

AI use: Claude Code (Claude Fable 5.2) ran the tests and wrote this.

theaustinayers and others added 5 commits November 27, 2026 01:52
Reverts accee0a (mesh stage views reach 1 MiB by default) and 4ac7558
(tiles asked for at a submit are filled within 1024 MB). With both, the scenes
behind a title's full-screen title cards were not drawn at all; with the old
values (XCL_VIEW_REACH_MB=0, XCL_MIRROR_FILL_MB=16) on the same binary they
were. Neither change had fixed the heads it was meant for. Both values stay
reachable through their switches.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A pipeline stream with a console mesh shader returns from translated_mesh_stream
before note_pipeline_for_dump, so a dumped target drawn by mesh pipelines (a
title's whole G-buffer) listed them as "not known" and their pixel shaders were
not written. After the stream is made, its MS (also from the AS slot) and PS,
render target 0's blend and the formats are noted as a graphics desc's are.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A title's G-buffer target is drawn by about 30 pipelines; with 12 the rest were
cut off as "and N more", their shaders not written.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With 16 MB a submit, a close-up of a detailed mesh was drawn while part of the
mesh data it asked for was still unfilled (it reads zero): heads came out as
shards and slabs, on some runs and not others. A/B on one binary as a Series S:
16 MB, shards in 3 of 3 runs that reached the close-ups; 256 MB, none in 5 runs,
the scenes behind full-screen title cards drawn, no change in frame rate. (1024
MB went out with build 16 together with a longer mesh view reach; the reach was
what blanked those scenes, not the fill.)

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

throny commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Bisect result for the black world on our Intel + RTX 4080 machine: it is #2892 (CLZERO loops as native code on a CPU without CLZERO); 71b9f7b2 shows the world, 7e63fc6d and everything after is black. Table and details: #2892 (latest comment). So it is neither the placement switches nor the "dark view" you are chasing; sorry for the detour. A confirmation run with XCL_CLZERO_PATCH=0 on the head is in progress. AI use: Claude Code (Claude Fable 5.2).

@throny

throny commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Correction to my bisect result above: it is wrong. The "visible" builds before #2892 were still on the loading screens when their frame dumps were taken (loading takes 7+ minutes without that PR on this Intel CPU; draw counters confirm it), so #2892 is not shown to blacken anything. Details: #2892 (latest comment). What remains true here: the world is 100 % black in every build that reaches it on this RTX 4080 machine, with any heap placement, with and without #2929, and I have no world frame of any build that is not black. So the question I asked earlier is the open one: does anyone see a lit world on nvidia-dev on NVIDIA? AI use: Claude Code (Claude Fable 5.2).

@throny

throny commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

A second kind of device loss on NVIDIA, with NVIDIA Aftermath dumps: a GPU page fault in the last tile of a freshly created texture, not the shader-heap limit (#2403).

Setup: RTX 4080 16 GB (621.40), 2 GiB shader-heap profile, nvidia-dev d1be8103 + #3003–#3008, #3036, #2951, #2987 (local stack), XCL_UMA_WINDOWS=16 XCL_UMA_DRIVER=mixed:1536:1792 XCL_TEXTURE_LEVEL_PAGES=1 XCL_TWO_PASS_MB=3072.

  • 2 of 7 world runs on this build ended with 0x887a0006 (device hung) at world entry (145 s and 191 s); DRED had no breadcrumbs. The other five ran their full 10–12 minutes.
  • Both have an Aftermath dump, and both say the same thing: device state Error_DMA_PageFault, a read by the graphics engine that "failed to translate the virtual address", inside a resource the driver knows:
    • run A: a BC7 sRGB texture, 512x512, 8 mips, not a placed resource, alive, reported fully resident; the fault is in its tile 6 of 6;
    • run B: a BC1 sRGB texture, 1024x1024, 9 mips, not placed, alive, fully resident; tile 11 of 11.
  • In both the texture was created about 1.9 s before the dump, and the faulting tile is the last 64 KB tile, which is where the small mips are packed.

Reading (not proven): a reserved texture is sampled before the tile that holds its packed mips is mapped, or that tile's mapping is dropped while the texture is in use. XCL_TEXTURE_LEVEL_PAGES=1 is the first suspect on our side because it maps a texture's levels separately; I will run the same build without it and report the hang count. If someone knows the level-pages or the reserved-texture mapping code: does the packed-mip tile get its mapping in the same queue operation as the first level, before the texture's first use?

For others on NVIDIA: with the Nsight Graphics Aftermath monitor running, nv-aftermath-format -j <dump> prints this as text; the page-fault block names the resource without any debug build.

No dump or game data is posted; the numbers above are the driver's description of the resource. AI use: Claude Code (Claude Fable 5.2) ran the runs, decoded the dumps and wrote this.

@claudetools-gh

claudetools-gh commented Nov 27, 2026 •

Copy link
Copy Markdown

Update, same evening: our page-budget path is ruled out. A second dump here (run 313, with a log of every young texture the budget evicts) has the same pattern: a BC7 1024x128 texture, 6 mips, 3 tiles, 2.4 s old, the fault again at offset 0x2A000 in a pixel shader. That texture was never evicted: the last young-texture eviction in that run was 160 s before the hang. So what leaves the tail untranslatable here is still unknown. The level-groups reading for nvidia-dev below still stands as code, and so does the GPU test of a NULL tail.


@throny the same fault here without XCL_TEXTURE_LEVEL_PAGES, so your five runs without it may not make it go away. RTX 5070 Ti 16 GB (621.01), 2 GiB shader-heap profile, our tree on MacieGx's lab line. With the camera moving, about 1 run in 9 hangs here. The second run with Aftermath armed (global mode, resource tracking) gave this dump:

  • Error_DMA_PageFault, a read by a pixel shader, "failed to translate the virtual address";
  • a reserved texture (not placed, alive, "fully resident"), BC1 512x512, 8 mips, 3 tiles, created 2.3 s before the dump;
  • the fault is at offset 0x2A000, so in tile 3 of 3: mip 0 takes tiles 1–2 and the packed mips are tile 3.

So three dumps on two cards, two trees and two setups, all with the same pattern: a texture about 2 s old, its packed-mip tail read by the graphics engine, the address untranslatable.

Your question, read from nvidia-dev d1be8103 (not run): with XCL_TEXTURE_LEVEL_PAGES=1 the packed tail is its own group of levels (level_tiling gives it StartTileIndexInOverallResource / NumTilesForPackedMips). It does not get its pages with the first level. map_levels maps a group only when an upload first has texels for its levels. unmap_levels maps a group back to NULL when the title takes the memory from under all its levels, while the texture lives. So on that path the tail can be NULL when it is sampled. Without level pages, bind maps all of a texture's tiles, the tail included, in one UpdateTileMappings at creation.

Our path: we don't run level pages, but we do run a page budget (XCL_PAGE_BUDGET_MB, which nvidia-dev doesn't have). It was at its cap: 30,609 textures evicted in the run. evict_lru may evict a texture of fewer than 4 tiles that no view heap names 2 s after it was placed. It maps all of its tiles NULL at once, without waiting for work already submitted.

Reading (not proven): both paths leave a texture's packed tail NULL while the title may sample it, and both codes assume, as unmap_levels says, that "tiles without memory read as zeros … (tiled resources tier 2)". That holds for standard tiles. These dumps suggest that on NVIDIA a NULL packed tail faults instead. Next here:

  1. a log of every young texture the budget evicts, to match against the next dump (running now);
  2. a GPU test that samples a reserved texture whose packed tail is NULL. If it removes the device, the fix is to keep a tail mapped (to its own tile, or to one shared zero tile) whenever its levels have no pages, on both paths.
    Your runs without level pages will tell whether your path is the level groups.

AI-assisted.

@throny

throny commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

The hang count I promised, same card, build and switches as in my comment above (RTX 4080 16 GB, XCL_UMA_WINDOWS=16 XCL_UMA_DRIVER=mixed:1536:1792), only XCL_TEXTURE_LEVEL_PAGES changed:

runs past world entry device hung (0x887a0006) Aftermath dumps
with XCL_TEXTURE_LEVEL_PAGES=1 10 2 (at 145 s and 191 s) 2, both the page fault in the last tile of a fresh BC texture
without it 6 (5 minutes each) 0 0
  • The logs confirm the switch: the level-pages lines are present in the first group and absent in the second.
  • This is weak on its own: with a true rate of 2 in 10, six clean runs in a row happen about one time in four. It agrees with @claudetools-gh's reading (a packed-mip tail left unmapped while its levels are sampled), it does not prove it.
  • Cost of running without the switch here: local video memory peaks at about 26 GB against 21.6 GB with it (16 GB card, so more of it is shared memory), and presents per second in the world are about the same (2.0–2.4 against 2.3).

If a fix for the packed-mip tail exists as a commit or PR, name it and I will run ten world entries with the switch on; that is the test that can separate the two cases.

AI use: Claude Code (Claude Fable 5.2) ran the runs and wrote this. No game data posted.

@psuedo-tty

psuedo-tty commented Nov 28, 2026 •

Copy link
Copy Markdown

pr-2572-fix-and-probe.patch
Device removed at world entry with level pages: a list already on the GPU reads a reserved texture made since, before any tile-mapping call has run on it

This is a reading of the two fresh-texture dumps reported above (level pages / page budget), with a standalone reproduction and a fix that held here.

What happens

  • A title makes a streamed texture and points a descriptor at it in one call (CreateShaderResourceViewAtX), while lists that read that descriptor are already submitted.
  • With level pages a placed texture is lazy: place_on_pages makes the reserved resource and records it with no UpdateTileMappings call at all (main e429936c1 vram.rs:2079, under the comment "nothing mapped yet"; nvidia-dev 54225f588 vram.rs:1037). The non-lazy branch maps, but nothing waits for that call: before_execute orders only later submits.
  • On an RTX 5090 (driver 621.40) a read by a list ALREADY SUBMITTED of a reserved texture created since, on which no mapping call has run yet, is a page fault. The device hangs for the Windows GPU time-out and is removed. A reserved texture made earlier and never mapped reads zeros, as documented; only the new one faults.
  • It needs draws in flight at the placement, so the per-operation GPU profile (which serialises) hides it.

Reproduction without a title (descriptor_rewrite_native.rs in the attached patch; cargo test --release -p xcl --test descriptor_rewrite_native -- --nocapture)

One descriptor slot, sampled by a compute and a pixel shader from lists submitted continuously for 6 s, while another thread rewrites the slot:

variant what the slot is pointed at result
still not rewritten alive
mapped / unmapped two older reserved textures in turn, mapped or never mapped (76 million rewrites) alive
new a reserved texture created just now, no mapping call device removed
new-waited same, after another queue passed a fence signalled after the creation device removed
new-list same, after an empty command list ran on another queue device removed
new-null same, after one UpdateTileMappings with a NULL range for the whole texture ran (30,544 textures) alive
new-main same, after the sampling queue passed a fence signalled after the creation alive

Nsight Aftermath on the title and on the probe gives the same picture: the fault address lies in a texture created at the moment of the fault (subtract TdrDelay from the dump time when comparing ticks).

Fix that held here

Before the title can name a new placed texture: one NULL-range UpdateTileMappings for the whole resource on the lazy branch, then Signal on the mapping queue and a bounded wait (250 ms cap) for that fence value, on both branches. About 160 µs per placed texture.

// lazy branch, after pages.targets.insert(..):  pages.null_all(res); pages.settle_new();
// whole-pages branch, after its insert:          pages.settle_new();
unsafe fn null_all(&mut self, res: &ID3D12Resource) {
    let flag = D3D12_TILE_RANGE_FLAG_NULL;
    self.queue.UpdateTileMappings(res, 1, None, None, None, 1, Some(&flag), None, None, D3D12_TILE_MAPPING_FLAG_NONE);
    self.mappings_changed();
}

Tested (RTX 5090 32 GB, driver 621.40, Ryzen 9 9950X3D, Windows 11, release build, Agility 1.722.1 preview)

  • Retail title, world entry, level pages on, no per-operation profile: before the fix 7 of 9 launches lost the device; with it 7 of 7 ran clean, three of them through the whole scene (482–486 s).
  • The probe table above, each variant run on its own.
  • cargo test --release -p xcl --lib hle::d3d12x::vram: 25 passed, 0 failed, 1 ignored.

Not tested

  • AMD and Intel; NVIDIA drivers other than 621.40; the inbox D3D12 runtime.
  • Whether a cheaper remedy than the wait is enough (the probe shows the NULL mapping call must have run; it does not show how little waiting suffices).
  • Other reserved resources made and named at once (placed buffers in the sparse windows).

Related: #3010 orders the tile-mapping fence before the next title work, which covers later submits only, not lists already in flight. #2981 looks like the same family on AMD.

AI use: Claude Code (Claude Fable 5.2) found the cause, wrote the probe and the fix, ran the launches and tests on my hardware, and drafted this comment for human review.

@throny

throny commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

@psuedo-tty thanks, that is the test I offered. Running now on the RTX 4080 16 GB (621.40): nvidia-dev head plus the runtime part of your patch, ten world entries of 5 minutes with XCL_TEXTURE_LEVEL_PAGES=1 (the setup in which 2 of my 10 runs hung), then ten on the same head without the patch as the control. I will post both counts here in one comment, with the Aftermath result of any run that loses the device.

AI use: Claude Code (Claude Fable 5.2).

@throny

throny commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

@psuedo-tty the pair is in, and it agrees with yours: 0 of 10 lost the device with the fix, 4 of 10 without it, same build otherwise.

RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300. nvidia-dev 54225f58 plus three small local patches (the #684 crash fix, input timing, preparation skip); 5-minute world entries with XCL_UMA_WINDOWS=16 XCL_UMA_DRIVER=mixed:1536:1792 XCL_TEXTURE_LEVEL_PAGES=1 XCL_CS_PSO_WAIT_MS=200 XCL_TWO_PASS_MB=3072; all twenty runs back to back this morning.

runs device hung (0x887a0006) when Aftermath
with the fix 10 0 – no dump
without (control) 10 4 134–149 s, at world entry 4 dumps, each Error_DMA_PageFault, a read by the graphics engine in the last tile of a live, non-placed BC1 texture created about 1.8 s before the dump
  • What I ran is a port, not your patch as posted. The attachment does not apply to nvidia-dev, main or this PR's head (its vram.rs hunks expect helpers these trees do not have: mappings_changed, unsignalled, event). I carried null_all and settle_new over by hand with the two calls in place_on_pages (58 lines; the signal is done the way nvidia-dev does it elsewhere in Pages; the probe test and the test hook are left out). So this confirms the idea on a second card and tree; a PR against nvidia-dev from you would be the thing to merge-check, and I will run it the same way.
  • The fix was active in every run with it: more than 131,000 new textures waited per run, 76 µs each on average (you measured about 160 µs). The 250 ms cap was hit once in the ten runs (one warning line).
  • Frame rate in the world is unchanged within the spread: 2.1–2.6 presents/s with the fix, 2.1–2.6 in the six control runs that survived.
  • Statistics, for what twenty runs give: 4 of 10 against 0 of 10 is p = 0.04 one-sided (Fisher). Together with your 7 of 9 against 0 of 7 on another card it is hard to read as chance. Yesterday's 2 of 10 here was the same fault on an older head.
  • The created-before-the-dump time is 1.8 s in all four, which fits your note about subtracting the time-out.

AI use: Claude Code (Claude Fable 5.2) ported the two functions, ran the twenty runs, decoded the dumps and wrote this. Counts and the driver's description of the resource only; no game data posted.

@throny

throny commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

@psuedo-tty since your patch does not apply to nvidia-dev, I opened the remedy there as #3116, with you named as the source of the cause and the fix. After an independent review it differs from what you posted in three ways: the wait is outside the PAGES lock, it yields after half a millisecond, and only the lazy branch gets the NULL mapping and the wait (the other branch would be on every GPU's default path and I have no measurement for it). With that form: 0 of 10 world entries lost the device, 4 of 10 without. If you think the non-lazy branch needs the wait too, say so there; your probe is the evidence that would settle it.

AI use: Claude Code (Claude Fable 5.2).

@Prime1997
Prime1997 merged commit 3f39671 into xcl-dev:main Nov 28, 2026
1 check failed
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.