Skip to content

Nvidia dev - #2572

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

bmjask wants to merge 330 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 00:54
…f the uploads)

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the uploads)

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

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

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

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cal diagnostic)

How many of a look's pages the looks before it had found too, in how many
runs they lie, how many of the scanned pages changed, and how long before
its submit the youngest list was closed: the figures that say whether a
look ahead of the submit, or leaving always written pages out of the
write watch, would pay.

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

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

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

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

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

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

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

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ry calls (local diagnostic)

XCL_ACTIVITY logs every 2 s how many placed textures and buffers, page
mapping calls, memory calls and pipelines the title's threads made and
the milliseconds XCL took for them: where the time of a loading screen
goes.

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

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

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

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

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

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

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

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

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… slot 129)

Conflict: NEWER_LIST_SLOTS keeps the tree's (69, 67) and adds the PR's
(129, 126): 23 pairs. The older slot it names gets its handler from the
two-pass merge that follows, which settles the pair.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
theaustinayers and others added 24 commits November 25, 2026 15:35
…tch off

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

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

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

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

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

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

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

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

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

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

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

A texture placed in a GPU view whose pages the queue's page mappings
named was read at the CPU view's same offset (or, with a page mapped at
the address itself, after a VirtualQuery there). The pages the title
mapped into the view are kept elsewhere: in the pool, at their home, or
wherever the title mapped them last.

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

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

Builds on xcl-dev#1102 by Xeltax (c387de2)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ered access: the frame trace of DSVs, the registry, a stencil twin behind XCL_DEPTH_UAV_TWIN=1)

The first five steps of the plan for depth and stencil planes that
shaders write through UAVs, with the review's fixes: nothing changes
unless XCL_DEPTH_UAV_TWIN=1 is set, and nothing is copied between a twin
and its plane yet.

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

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

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

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

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

Builds on xcl-dev#1102 by Xeltax (c387de2)

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

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

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…dev#1031)

Queue method xcl-dev#29 (xcl-dev#31 in the newer layout) is how a title maps the pages
its texture streaming fills into the GPU views its textures are in. It
was a stub: every mapping was dropped, a GPU-view page kept showing its
CPU view at the same offset, and streamed textures uploaded as zeros.

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

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

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

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… it is read

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Four gaps in the tests of the queue's page mappings:

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

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

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

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

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

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

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

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

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…gsBatchX maps pages into GPU views)

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

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

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

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

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

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

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

Diagnostics only; nothing changes without XCL_TRACE_FRAME.

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

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

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

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

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

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

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

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

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

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
(cherry picked from commit 253bc79)
@DavidM1911

Copy link
Copy Markdown
Contributor

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

@KOLESNiii

Copy link
Copy Markdown

What is wanted for this?

@nnonno91

Copy link
Copy Markdown

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

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

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

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

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

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

@pr1sm-dev

pr1sm-dev commented Nov 25, 2026 •

Copy link
Copy Markdown

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

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

What happened

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

#684 on top

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

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

@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.

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.