Skip to content

D3D12.X: preserve used-pipeline key on RT-gated compute stand-ins - #2755

Open
Saksukella wants to merge 202 commits into
xcl-dev:amd-devfrom
Saksukella:fix/rt-gated-used-pipeline-key
Open

Saksukella wants to merge 202 commits into
xcl-dev:amd-devfrom
Saksukella:fix/rt-gated-used-pipeline-key

Conversation

@Saksukella

@Saksukella Saksukella commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

What is in it

  • crates/xcl/src/hle/d3d12x/pso_async.rs:
    • Pass key: u64 into submit_gated(standin, driver, key) instead of hardcoding key: 0.
    • When a title binds an RT-gated compute stand-in under default XCL_RT_GATE=hold, resolve() / resolve_for_bind() already call p.note_use() (used::note(p.key)), so storing the real pipeline key lets used-pipelines.txt record bound RT compute pipelines for targeted offline xcl shaders ... --precompile --pipelines --used-only --only cs runs before switching to XCL_RT_GATE=auto. Prerequisite: this capture path applies when shared stand-in shells are enabled (default standin::enabled() == true; disabled under XCL_SHARED_STANDINS=0 or console-shaped lists, where maybe_rt_gated_compute_pso takes the raw standin_compute branch without a pso_async entry).
    • Extend submit_gated_maps_driver_without_pending_or_enqueue to assert non-zero key preservation via entry() without touching the on-disk used-pipelines.txt cache.
  • crates/xcl/src/hle/d3d12x/real.rs:
    • Add zero-allocation single_shader_key(hash) (matching shaders_key(&[blob]) without cloning the shader bytes) and pass single_shader_key(record) in maybe_rt_gated_compute_pso.
    • Extend a_key_follows_the_shaders_and_their_order_and_is_never_zero to verify single_shader_key(fnv64(&a)) == shaders_key(&[a]).
  • Target branch: amd-dev (where submit_gated / XCL_RT_GATE live).

Tested

  • Hardware: AMD Radeon RX 9070 XT (driver 32.0.32029.2010), 24-thread x86_64 CPU, 32 GB RAM, Windows; rustc 1.100.0 (0ef1bc386 2026-11-09); debug (tests) and release (xcl.exe).
  • cargo test -p xcl --lib submit_gated_maps_driver_without_pending_or_enqueue: 1 passed, 0 failed (0.00s).
  • cargo test -p xcl --lib a_key_follows_the_shaders_and_their_order_and_is_never_zero: 1 passed, 0 failed (0.00s).

Regression run

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: AMD Radeon RX 9070 XT
title: b8db18c2
seconds: 60
exit: 0x0
frames shown: 1624 (PresentX 1624)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 19700 MB
xcl-smoke v1
commit: 4bb6b30fc5b19e5dbcec8818134af47e39a68a31
gpu: AMD Radeon RX 9070 XT
title: b8db18c2
seconds: 60
exit: 0x0
frames shown: 1674 (PresentX 1674)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15090 MB

Not tested

  • NVIDIA and Intel GPU adapters (tested on AMD Radeon RX 9070 XT only).

AI use

  • Antigravity (Google Gemini): assisted with auditing pso_async::submit_gated / used::note reachability, writing the zero-allocation key helper and unit tests, and running local tests and smoke verification. All diffs and measurements were verified locally on hardware.

isaacwingate and others added 30 commits November 25, 2026 07:22
pso_async means a graphics pipeline still being built to go on with its
stand-in, which draws nothing, while a worker builds it; only compute
pipelines are waited for (a skipped dispatch would leave its outputs
unwritten). But graphics_bound and ExecuteIndirect called resolve_wait,
which waits for the build - and builds it on the title's thread when no
worker has started it. With lazy pipelines that is every graphics
pipeline's first draw.

On an NVIDIA GPU the retail title of xcl-dev#505 had its threads held 1 - 5 s
per draw in the driver's compiler as its world loaded: 25 graphics binds,
33.2 s in all within 25 s (counted with xcl-dev#899's log), and its hang
watchdog ended the run. A test report on xcl-dev#889 (RTX 4080) found a title
thread held in bind::execute_indirect -> resolve_wait at the abort.

Draws and ExecuteIndirect now take their pipeline with resolve_for_bind:
a graphics one still being built goes to the workers and the draw uses
its stand-in (ExecuteIndirect skips, as it already did for a pending
one); a compute one is waited for as before. With this, the same world
load logged no graphics wait.

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

On the console a physical page mapped at several addresses is one page. XCL
keeps a page at one address at a time and copies it when the title maps it
elsewhere (`move_away`), so the other addresses go stale; a retail title maps
its streamed pages into a pool, into the CPU view of a 24 GB reservation and
into that reservation's GPU view (xcl-dev#1031).

`kernelx::sections` is the base for real aliasing: a block of physical pages
is one pagefile-backed SEC_RESERVE section, and a page is mapped as a view of
its 64 KiB slice into a placeholder (MapViewOfFile3 with
MEM_REPLACE_PLACEHOLDER). Every view of a slice is the same memory and a page
takes commit once, when it is committed through any view. Unmapping leaves a
placeholder for the next view. Ordinary reserved memory (write-watched if
asked) can replace part of a placeholder and go back to one.

Nothing calls it yet. Measured in a standalone program on Windows 11 26200
over 200 000 pages: map 2.2 us, unmap 2.75 us, commit 0.9 us a page.
GetWriteWatch refuses a range that holds a view (error 87), and one call
cannot span two neighbouring reservations either.
The upload of title memory to video memory (`d3d12x::sparse`) and the
textures kept in step with title memory learn what the CPU wrote from the
write watch, and a view of a section (`kernelx::sections`) cannot be
write-watched: GetWriteWatch refuses any range that holds one.

`kernelx::guards` keeps the views of a physical page read-only. The first
write through any of them faults; a vectored handler makes that view
writable, notes the page and lets the write go on. `take_dirty` hands over
the pages of every view of each page written – a write through one view is
a write to all of them – and guards those views again before their bytes are
read, so a later write is caught again and an earlier one is in what is read.

Kernel calls do not fault into the handler, they fail: `lazy::ensure`, which
XCL already calls before a kernel call or its own code writes title memory,
opens the guards there first and counts the write. A view committed by the
lazy handler is writable and counts as written. Both take no lock until a
view has been watched.

Nothing watches a view yet.
… fault

A guarded view of a physical page (`kernelx::guards`) is read-only until it
is written. Code of XCL's own that writes there faults into the guard and
goes on, but a kernel call does not fault: ReadFile into such a view fails.
`lazy::ensure` opened the views first, yet the submit thread's `take_dirty`
could guard them again before the write – between DirectStorage's check of
its destination and the copy, or before the kernel wrote a ReadFile buffer.

`guards::open` now returns `Opened`, which keeps its views writable until it
is dropped; `take_dirty` uploads a pinned view but does not guard it again,
and the end of the write counts as a write. `lazy::ensure` returns it and its
callers hold it across their write: the routed ReadFile for a synchronous
read, and the destination checks of DirectStorage and the CPU-side
bottom-of-pipe writes. An overlapped ReadFile writes after the call returns:
its views stay open until its OVERLAPPED is no longer STATUS_PENDING, which
`take_dirty` reads without faulting (the title may free it once done). A
retail title reads 271 MB that way into the CPU view of its 24 GB
reservation 8.5 s after start.

`guards::written` counts a page as written through all its views when XCL
writes it by page number.

Nothing watches a view yet, so nothing changes without views.
…s mapped at

Without it XCL keeps a physical page at one address at a time and copies it
when the title maps it elsewhere; the console shows the page at every
address it is mapped at. A retail title maps its streamed pages into a pool,
into the CPU view of a 24 GB reservation and into that reservation's GPU
view (xcl-dev#1031).

With `XCL_PAGE_ALIAS=1` (`kernelx::alias`):
- a block of physical pages is a section (`kernelx::sections`) with a view
  of its own, through which XCL reads and writes pages by number
  (DirectStorage); the title never maps a page there;
- the title's reservations of 64 KiB pages with no commit (its CPU view, GPU
  view and pool) are placeholders, and a page mapped there is a view of its
  slice, guarded (`kernelx::guards`) so that a write through one view is
  uploaded at all of them; `title_textures` adds those pages to what the
  write watch found;
- a page mapped anywhere else (a placeholder region the title made in a
  sparse window) is moved there and back with its bytes, as before.

Pages are committed on first use as before (`kernelx::lazy`); whether a page
is committed is a bit per page: asking Windows walked the rest of a fresh
block, and a title mapping 100 000 new pages one at a time took 20 s longer
to its first frame.

Measured in a traced run of a retail title: 3 blocks (11 360, 2 960 and
99 776 pages), 131 072 map calls in 150 s, nearly all single pages into its
plain reservations, none at a page's home, no commit inside them.
…GPU-view page shows

Queue method xcl-dev#31 (xcl-dev#29 of the older layout) maps pages of the title's
memory into GPU views; it was a stub. Its batches are now decoded and
checked against the batch count and the pool, and each 64 KiB page of
a GPU view records the pool page it was given and the physical page the
title had mapped there (kernelx::mirrors). A bad call records nothing;
releasing a view drops its pages.

XCL keeps a physical page's data where it was mapped last, and the
title maps most streamed pages into the CPU view behind the GPU view
too, so `mapped_source` answers where that page is now (`page_now`),
else the pool page itself. Each title mapping is remembered per address
(Away::title), written once the page is in place and forgotten when the
reservation goes; a page freed while its allocation lives is no longer
looked for (Away::freed).

Nothing reads the record yet: textures are unchanged; the queue logs its
counts. (xcl-dev#1031)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`mirrors::decode_batches` checks and decodes one call of the queue's
CopyPageMappingsBatchX into (GPU-view page, pool page or unmapped) pairs;
`apply_batches` records them as before. No change in behaviour: the next
commit maps the decoded pages for real when physical pages alias.
The queue's CopyPageMappingsBatchX maps pool pages into GPU views; on the
console a GPU-view page then shows the physical page mapped at its pool page
at the time of the call. xcl-dev#1055 decodes the calls and keeps a record of them;
with physical pages aliasing (`kernelx::alias`) the GPU view is a reservation
of views, so the decoded mappings are made for real: each GPU-view page
becomes a view of the physical page mapped at its pool page now, or is
unmapped (kind 2, or nothing mapped at the pool page). Textures in the GPU
view then read the page at their own address (`title_textures` prefers an
address with a physical page mapped), and a write through any view of the
page is uploaded at all of them.

Without the switch nothing changes: the call is recorded as in xcl-dev#1055.
Each chained dispatch made a scratch buffer for all its groups and kept it until the allocator's reset. A retail title's 176 split programs need 187 KB a group (median), 3 GB for 960x540 pixels in groups of 8x4. At most XCL_SPLIT_SCRATCH_MB (256) of groups now run at once, each piece adding the slab's origin to the group ids, and the chains recorded on one list share the buffer.
In a pixel shader EXEC holds helper lanes (s_wqm), and on a primitive's
edge the first lane of EXEC is often one. v_readfirstlane read that lane.
An RDNA2 driver (RX 6700 XT, 32.0.21045) gives 0 for everything a helper
lane holds once a WaveReadLaneAt ran inside a loop, quad reads included.
A loop whose state the console's compiler carries in a vector register
(v_mov v, s ... v_readfirstlane s, v) then read 0 back on each pass and
ran to the loop budget: a retail title's volumetric light pass took
seconds per draw at its world start and Windows reset the GPU (xcl-dev#675).

v_readfirstlane now reads the first lane of EXEC that is live
(ballot(true), per half in the wave32-in-64 form) when EXEC has one, and
the first lane of EXEC as before when it has none. The value is the same:
the console's compiler reads the first lane of a value equal in every
lane, or of a lane it then removes from EXEC (a waterfall loop).

The new GPU test draws that title's list-loop shape on two triangles
sharing a diagonal. Without the change, on the RX 6700 XT, 69 of 1024
pixels run the loop 65 536 times (the budget) with wrong results; with
it, none, and at most 16 passes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
raylitebull and others added 12 commits November 26, 2026 01:06
…ze deferred submits

Give graphics and compute pipelines independent 12 s per-frame wait windows (XCL_PSO_FRAME_BUDGET_MS, default 12000 ms; 0 = skip immediately, off = disabled). Builds run on prioritized wanted xcl-pso-* workers so title threads always wake when a frame's window expires; once spent, remaining unready draws or dispatches for that kind return the stand-in for the current frame and retry with a fresh window on the next frame instead of stalling PresentX into title render watchdogs or dropping fast cold graphics draws permanently. Also mark deferred submits wanted immediately in need_by_submit so DXC/big-compile gates and preload workers prioritize them right away.

Assisted-by: Antigravity (Gemini 4 Neon High)
…ed texture caches (xcl-dev#2578)

Adapt two cache-safe stability fixes cleanly onto origin/amd-dev (bf02341):
- xcl-dev#2577 (real.rs, shaders.rs): record the chosen adapter's PCI vendor ID
  in driver_cache::note_vendor() and disable on-disk .pso driver blobs on
  AMD (0x1002) unless XCL_PSO_DISK_CACHE=1, avoiding device removals from
  stale 954-byte driver cache stubs written before a crash/kill (xcl-dev#2512).
  Adds driver_cache::tests::blobs_are_kept_on_disk_unless_they_are_references.
- xcl-dev#2578 (title_textures.rs): return all retired resource pointers from
  Table::retire_range() so retire_overlapping() evicts LAST_CONTENT and
  STREAM_RECHECK for every retired texture (not only placed unmap targets).

Assisted-by: Antigravity (Gemini 4 Neon High)
…access (xcl-dev#2582)

Fix xcl-dev#2582 (0xc0000005 CPU write AV inside sparse UMA windows on buffers
backed by OutsideBufferTable / sparse::alloc_vram_only):
- place_at_title_address stored alloc_vram_only's uncommitted sparse VA
  (holes = 0xFFFF, MEM_RESERVE only) in UMA_BUFFERS, so GetGPUVirtualAddress
  and Map handed that uncommitted VA back to the title. When the title later
  CPU-wrote through it (e.g. clearing a 128x0x5c0 table), Windows raised
  0xc0000005.
- Mark alloc_vram_only 64 KiB pages with kernelx::lazy::mark (0 upfront CPU
  commit, GPU-only buffers keep holes = 0xFFFF and never clobber UAV writes)
  and unmark + MEM_DECOMMIT them cleanly in free_vram_only.
- When the title first CPU-touches a page, kernelx::lazy::commit commits it
  and queues it via sparse::note_lazy_commit (without locking sparse::STATE
  inside the VEH); before_execute, readback_now, readback_after_execute, and
  decommit_range drain LAZY_COMMITS to clear entry.holes without touching
  to_zero so only CPU-written 4 KiB pages upload to VRAM.
- In real::res_map, call kernelx::lazy::ensure(p, bytes) before readback_now
  so Map() on a lazy sparse buffer commits pages before VRAM->CPU copy.
- Add regression test lazy_commit_clears_vram_only_holes_without_clobbering_to_zero.

Assisted-by: Antigravity (Gemini 4 Neon High)
…ts, and keep split whole builds async

Eliminate the remaining multi-second stalls observed past the 12 s per-frame pipeline wait window on cold/warm world frames:
- Track in-flight wall-clock waits (`active_waiters` / `active_since`) in `pso_async::FrameWaitBudget` so staggered concurrent title threads share one hard wall-clock ceiling per kind per frame instead of each getting a fresh 12 s window (applied to both `FRAME_BUDGET_GFX`/`FRAME_BUDGET_CS` and `FRAME_WAIT`).
- Skip deferring pending compute dispatches to submit in `list_x::defer` when `XCL_PSO_WAIT_MS` is set (xcl-dev#2581), when the current frame's compute wait window is already spent, or once 16 deferred segments have already been allocated on the current frame (prevents 512+ deferred segments and command-allocator/RAM churn).
- Never compile `Chain::whole()` synchronously on a title/submit thread inside `dispatch_chain::dispatch` when scratch allocation fails under memory pressure or missing backing allocator: kick off `start_whole_async()` and return an error so the dispatch is skipped cleanly until the background whole build finishes, matching `whole_nonblocking`.

Assisted-by: Antigravity (Gemini 4 Neon High)
…#505/xcl-dev#1833)

Track recycled (previously returned/cooled) 64 KiB tiles in vram::TilePool
via a per-heap bitmap (freshly allocated D3D12 heaps remain clean with zero
extra GPU work) and asynchronously zero recycled tiles in one coalesced
CopyBufferRegion batch on Pages::queue before flushing Pages::fence in
before_execute (default ON, XCL_ZERO_TARGET_PAGES=0 disables):
- PoolHeaps caches a 0-extra-VRAM aliased 64 MiB placed BUFFER per pool heap
  (D3D12_HEAP_FLAG_NONE Tier 2) and ZeroRing reuses a 4-slot DIRECT command
  ring + 1 MiB pre-zeroed UPLOAD source with D3D12_RESOURCE_BARRIER_TYPE_ALIASING
  so stale render-target/depth/UAV bytes never bleed into newly mapped targets
  (e.g., 2560x1440 R9G9B9E5 lighting blocks/white-outs).
- Add unit tests tile_pool_tracks_dirty_bits_only_for_recycled_tiles and
  coalesce_tile_runs_merges_adjacent_tiles_per_heap.

Assisted-by: Antigravity (Gemini 4 Neon High)
Agility SDK 1.620+ allocates some D3D12 COM vtables on the heap rather than inside a loaded module. If a COM object is freed and a different object reuses the same heap address for its vtable, caching Class solely by (orig, kind) can dispatch through stale methods from the previous object.

Snapshot the copied runtime method pointers on Class when module_of(orig) == 0, compare them against the live vtable before reusing a cached Class, and double-check under CLASSES.write() before leaking a new extended vtable. DLL-resident vtables keep copied = None with zero extra overhead.

Verified with cargo check -p xcl --lib and class_for_rebuilds_when_heap_vtable_reused_with_different_methods (1 passed, 0 failed).

Assisted-by: Antigravity (Gemini 4 Neon High)
placed_srv_resource and placed_uav_resource returned uncounted raw ID3D12Resource pointers after dropping TABLE.lock(), and on a concurrent cache-miss race entry(key).or_insert(res) dropped the losing resource inside TABLE.lock() (risking res_release -> format_alias::forget deadlock) while still returning the dropped loser pointer. Furthermore, concurrent eviction via evict_stale_internal_at -> defer_drop_resources -> late_release::hold could synchronously run drain_known(true) and release the PC COM object while dev_create_srv_x was mid-call before r.GetDesc() (crashing inside amdxc64.dll).

Fix all three lifetime bugs:

- Return owned Option<ID3D12Resource> cloned inside TABLE.lock() from placed_srv_resource and placed_uav_resource (via cache_insert_or_clone), dropping any race loser outside TABLE.lock(), and hold the owned reference across dev_create_srv_x / dev_create_uav_x.

- Pin internal PlacedUav/PlacedSrv resources across sync_pair in on_uav_barrier and sync_title_writers.

- Drop adopted evicted resources normally in defer_drop_resources (outside TABLE.lock()) so real::res_release cleans up title_textures/vram/format_alias maps on the final ref before deferring the PC Release via late_release::hold.

- Reuse a single r.GetDesc() call across dev_create_srv_x.

Verified with cargo check -p xcl --lib and cargo test -p xcl --lib -- hle::d3d12x::format_alias::tests --test-threads=1 (5 passed, 0 failed).

Assisted-by: Antigravity (Gemini 4 Neon High)
…patch

In live world runs ambient.rs tracked TemporalResolve / ReflectionHistory PSOs and captured the 128x128 sky dome, yet ambient_fill_cs and reflect_clamp_cs never dispatched because find_dispatch_views missed the output UAV:

- SM 6.6 directly-indexed bindless heaps bind the view heap via SetDescriptorHeaps (s.heaps[0]) rather than Param::Table, leaving tables empty.

- ExecuteIndirect compute dispatches (both chained split and direct) never called ambient::after_compute_dispatch, and matches_dispatch_target rejected indirect/1D dispatches.

- matches_dispatch_target checked the resource format (often R16G16B16A16_TYPELESS) instead of the concrete UAV view format (R16G16B16A16_FLOAT / R11G11B10_FLOAT / R32G32B32A32_FLOAT).

- VIEW_SLOTS was keyed only by slot.index, colliding across CPU-only view heaps before CopyDescriptors copied them to the >1.24M-slot shader-visible heap, while the 1<<20 index cap and 256-byte CBV scan truncated high slots and larger pass CBVs.

Pass s.heaps[0] into find_dispatch_views, hook ExecuteIndirect compute dispatches, index ViewSlots by both unique slot.at and hosted GLOBAL index, raise the slot cap to 2_000_000 and CBV scan to 2048 B, match by concrete UAV view format with DepthOrArraySize == 1 guard, rank candidates by dispatch grid match, and log first-4 diagnostic misses.

Verified with cargo check -p xcl --lib and hle::d3d12x::ambient::tests (5 passed, 0 failed).

Assisted-by: Antigravity (Gemini 4 Neon High)
…adbacks

Two defensive memory/resource-lifetime fixes:

- kernelx.rs / uma.rs: clean up AWAY physical-page mappings, mirrors, and
  title mapping records on coherent UMA VirtualFree (MEM_DECOMMIT and
  MEM_RELEASE), matching sparse and plain VirtualFree so freed/reused
  coherent blocks never retain dangling AWAY entries. Add Uma::allocation_at
  and extend virtual_free_unmaps_away_pages_in_plain_and_sparse_reservations
  to cover coherent UMA MEM_DECOMMIT and MEM_RELEASE.
- real.rs: call cpu_writes::unregister_water_readback in res_release so
  released or recycled placed textures never retain stale water-readback
  entries.

Assisted-by: Antigravity (Gemini 4 Neon High)
…raphics once, and guard unbuilt ExecuteIndirect

- Keep non-spared memory-writing producer compute pipelines (`!spared && !bvh_traversal`)
  exempt from the per-frame `XCL_PSO_FRAME_BUDGET_MS` skip cutoff so world-entry dispatches
  never leave title memory/tables uninitialized; prioritize wanted producer compute ahead of
  wanted graphics in `PsoQueue::pop`, and run non-deprioritized producer compute inline when
  no worker has started it yet.
- Restrict `XCL_PSO_FRAME_BUDGET_MS` skipping to graphics pipelines and stamp `waited_frame`
  on `Pending` so an unready slow graphics PSO stalls at most one frame while workers finish
  compiling it in the background.
- Skip `list_x::defer` for `spared`/`bvh_traversal` compute PSOs and make `FrameDeferCap`
  slot reservation atomic (`try_reserve`/`release`) so concurrent threads cannot overshoot
  the per-frame deferred segment cap (producer dispatches past the cap fall through to
  `resolve_wait` instead of being dropped).
- Add `pso_async::bound_unbuilt(raw_pso, pso)` for `execute_indirect` and `dispatch_mesh`
  so a pipeline that finishes building right after `resolve_for_bind` returned the stand-in
  cannot slip into the raw PC call with a mismatched root signature.

Assisted-by: Antigravity (Gemini 4 Neon High)
…8x4 grids in ambient

Wave 16e diagnostics showed both TemporalResolve ([320, 360, 1]) and ReflectionHistory ([0, 0, 0]) reached ambient::after_compute_dispatch with tables=3, view_heap=0x4c610000, indices=16 (meaning zero root constants/CBVs and all bindings inside the two Param::Table descriptor tables).

Fix all four remaining lookup gaps:

- Decode CBV V# buffer descriptors (w3 >> 28 < 8, dst_sel 0xFAC) in slots 0..32 of every bound Param::Table and scan their readable constant-buffer bytes (up to 2048 B) for bindless view-heap indices.

- Probe direct image T# descriptors across slots 0..64 of every bound Param::Table (previously capped at 0..16).

- Resolve DXGI_FORMAT_UNKNOWN (0) in dev_create_uav_x and dev_create_srv_x to rd.Format.0 before calling ambient::note_descriptor so views that inherit the resource format are never dropped.

- Score Wave32 [8, 4, 1] and [4, 2, 1] dispatch grids alongside [8, 8, 1] and lower min_w/min_h to (groups/2).max(64) so [320, 360, 1] matches 2560x1440, 1280x720, and half-res probe targets.

Verified with cargo check -p xcl --lib and hle::d3d12x::ambient::tests (5 passed, 0 failed).

Assisted-by: Antigravity (Gemini 4 Neon High)

@luckyteagirl luckyteagirl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The used-pipelines.txt capture path described here requires shared stand-in shells. At 4bb6b30, maybe_rt_gated_compute_pso calls submit_gated(..., key) only when standin::shell returned a nonzero driver; with XCL_SHARED_STANDINS=0 or console-shaped lists enabled, standin::enabled() is false and creation takes the raw standin_compute branch instead. A successful bind then has no pending key for resolve() to record. This is a scope limitation of the proposed workflow, not a new regression introduced by this patch; the new tests inject a key directly and do not cover creation with shells disabled.

Could the PR description name the shared-standin prerequisite for the XCL_RT_GATE=hold → --used-only workflow? That would keep users from treating a capture in either non-shell configuration as complete. Exact-head source review assisted by Codex (GPT-6.2 Sol and GPT-6.2 Astra); I did not run a non-shell title capture.

@Saksukella

Copy link
Copy Markdown
Contributor Author

Good point @luckyteagirl — updated the PR description to state explicitly that the XCL_RT_GATE=hold -> --used-only capture path applies when shared stand-in shells are enabled (default standin::enabled() == true, not under XCL_SHARED_STANDINS=0 or console-shaped lists).

@Prime1997 Prime1997 mentioned this pull request Nov 26, 2026
@vibryxcx

vibryxcx commented Nov 27, 2026 •

Copy link
Copy Markdown

I tried to see the new behaviour on a retail title on Windows / RDNA2. No RT-gated key reached used-pipelines.txt in either tree. Nothing regressed, but I could not confirm the change works in a real run either.

Setup: RX 6800 (driver 32.0.21045.5002), Windows 11 Pro 26200, release. This head sits on b5c0275f, where my shader cache is cold (about an hour of recompile), so I merged it onto the current amd-dev bf7c82ee (no conflicts) and compared that merge (adafbeb) with bf7c82ee. Default XCL_RT_GATE (hold), shared stand-ins on (the log has pipelines whose shaders are not compiled yet get a stand-in…).

Method: each run started from an empty used-pipelines.txt, with XCL_PREPARE=0 so that the title starts at once and A pressed every 10 s. Each run lasted 120 s. The log names each held pipeline as RT-gated compute PSO <record> held back without compiling, and <record> is the same fnv64(cs) this PR passes to single_shader_key. So for each logged record I computed single_shader_key(record) and looked for it in the file afterwards.

tree RT-gated PSOs held their keys in used-pipelines.txt lines written frames / crashes
bf7c82ee 15 0 18 1887 / 0
bf7c82ee + this PR 15 0 14 2055 / 0

With a full file (1,892 lines from earlier runs) neither tree added a line, so that comparison says nothing.

Reading: submit_gated stores the key and resolve / resolve_for_bind call note_use, which looks right. My guess is that in these 120 s the title creates the 15 RT PSOs (at about 25 s) but never binds them, so note_use never runs. I could not check this, because binds are not logged. If there is a scene or switch that makes the title dispatch these (or a log line for a gated stand-in's first bind), I can rerun it.

Tests on the merge, debug: submit_gated_maps_driver_without_pending_or_enqueue and a_key_follows_the_shaders_and_their_order_and_is_never_zero pass (2 passed, 0 failed). I did not run the full suite.

Not tested: this exact head on its own base (b5c0275f); XCL_SHARED_STANDINS=0; runs longer than 120 s; NVIDIA.

AI use: Claude Code (Claude Opus 5.5) merged and built the trees, ran the title, computed the keys from the logs and wrote this comment.


Update: full lib suite on this exact head (4bb6b30f, on its own base b5c0275f; RX 6800, debug, cargo test -p xcl --lib -- --test-threads=1, with the tests skipped that hang or abort only inside the full amd-dev run and xgameruntime::gamesave::tests run on their own, see #42): 1519 passed, 11 failed, 27 ignored, and gamesave 11/11. The 11 failures are the set b5c0275f already has on this card (#2757): fuzz_validate_and_gpu_1, dispatch_chain_native_wave64_builds_whole, a_bridged_mask_write_where_one_half_is_elsewhere_meets_no_barrier, f32_programs_on_the_gpu, two_pass_binds_set_the_shared_view_heap, a_dispatch_with_a_pipeline_still_building_waits_at_the_submit, a_put_off_dispatch_runs_at_the_submit_when_its_build_outlasts_the_wait_budget, bitset_runs_emit_exact_contiguous_page_ranges, giant_driver_compiles_have_their_own_lane, title_bytes_are_used_in_place_when_all_are_readable, physical_home_without_sparse_windows_uses_coherent_window. Both tests this PR changes pass.

@andrewDoing

Copy link
Copy Markdown
Contributor

I checked the first actual bind of a gated compute pipeline on head 4bb6b30f and its parent b5c0275f, with the same synthetic shader and test-only fixture. Both builds created a shared held pipeline shell and had no entry for the expected key immediately after creation. The fixture then created a real direct command list and called SetPipelineState; it did not call submit_gated or the resolve helper directly.

On the parent, the key remained absent after the bind and the assertion failed. On the PR head, the expected key appeared in used-pipelines.txt and the test passed with no reported skip. Both runs logged the same held shader and expected key. This verifies capture on the tested shared-shell bind path; it does not establish whether any of the 15 held retail pipelines were bound or measure cold compilation savings.

AI use: OpenAI Codex with GPT-6.2 Astra constructed and ran the synthetic parent/head comparison; Codex coordinated and prepared this report.

@thehollowedone

thehollowedone commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

merge-check
base: 7c795f5 (amd-dev)
head: 4bb6b30
merge: clean (2 files)
build: cargo build --offline --locked -j 4 --workspace -> ok on the merged tree
tests: cargo test --offline --locked -j 4 --workspace --no-fail-fast -- --test-threads=4 -> merged tree 1,801 passed, 19 failed, 48 ignored; 30 GPU skip notices. The exact base did not produce a complete count: its lib process aborted twice in the pso_async worker-test area (0xc0000409), then the other targets ran; do not compare its partial totals with the merged total. The merged tree's two changed key tests each passed 1/0/0. Its failing d3d12_mesh_stream, e2e, and gpu_compute_e2e targets failed on the base too. Of the five lib failures absent before the base aborted, three also failed when run individually on the base; the other two passed individually on both trees, indicating a suite interaction rather than an isolated #2755 regression. This comparison cannot prove all 19 failures are inherited.
review: I read the complete two-file diff on this merge. The key handed to submit_gated matches the existing single-shader key formula; resolve_wait_for calls note_use, which records that key when a shared gated stand-in is bound. The focused test covers key storage, and the prior synthetic parent/head bind report covers the actual SetPipelineState path. The existing limitation is explicit: the capture path needs a shared stand-in shell; a title-created gated pipeline that is never bound records nothing. I found no source-level blocker in this diff.
performance: No new work per present. On the gated creation path, the shader hash was already computed for logging; this change also derives the one-shader used key from that hash without cloning the shader bytes. The benefit is enabling later targeted precompile; I did not measure title startup or frame time.
verdict: safe to merge: no change-specific blocker found on the exact merged tree. The current AMD branch's suite abort and existing test failures still need separate repair; this verdict does not claim the full suite is green or that this Windows NVIDIA run establishes AMD title behavior.
hardware / tool and model: Windows 11 build 26300, Ryzen 7 9800X3D, NVIDIA RTX 3080 Ti 12 GiB (621.35), Rust 1.99.1, DXC 1.8.2502.11; Codex (GPT-6.2 Sol) reviewed the merged source, built it, and ran the tests.

@akimfomin

Copy link
Copy Markdown
Contributor

AnyXboxX #575 is a useful warm-list consumer: it prewarms used keys after translating shaders. A synthetic producer-side test here could emit a gated compute variant and a normal variant with distinct keys, then replay the used list. Check that the exact gated key survives recording and that the cache stays quiet for a key never referenced. No need for another scene run.

@Saksukella

Copy link
Copy Markdown
Contributor Author

Thanks @luckyteagirl and @thehollowedone! Confirmed: the used-pipelines.txt capture path here applies to the default shared stand-in shell path (standin::enabled()), and is intentionally a no-op under XCL_SHARED_STANDINS=0 or console-shaped lists where raw stand-in creation bypasses submit_gated.

Queued on #3041 for a second independent merge-check against amd-dev 7c795f5e (head 4bb6b30).

AI use: drafted with AI assistance.

@JJAutoCompare

Copy link
Copy Markdown

Tested

Exact 4bb6b30fc5b19e5dbcec8818134af47e39a68a31 on the amd-dev PR, Windows 11 x64 build 26200.9974, Ryzen 7 3800X, Rust 1.100.1 MSVC. I reran the pinned standalone CPU harness after verifying five production source slices against four Git blobs.

gated_keys.exe --exact shaders::recorded_gated_and_ordinary_compute_keys_select_exactly_their_blobs --test-threads=1 --nocapture exited 0. 1 passed, 0 failed, 0 ignored, 0 runtime skips, 0 filtered.

The harness serialized two synthetic compute keys as lowercase hexadecimal rows. The production parser and membership helper selected the gated blob (991cf9e386f8243d) and ordinary blob (32f326e60444adbb) and excluded the unrelated blob (c74ad2297bbf5a69). Selection was [true, true, false]. An empty list excluded all three.

Not tested

Production pipeline bind or journal, CLI integration, cache writes, GPU execution, retail smoke, and the workspace suite.

AI use

T3 Code through the Codex harness (gpt-6.2-sol) verified the source and executable, reran the synthetic test, and wrote this report.

@throny

throny commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

merge-check claim
head: 4bb6b30

@throny

throny commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

merge-check
base: 7c795f5 (amd-dev)
head: 4bb6b30
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> no full count on this card: in both of my runs of this tree the library test binary ended early with 0xc0000409, as it also did today for a tree identical to the base, so that is the branch on this NVIDIA card and not this PR. Up to that point nothing failed that does not also fail, or come and go, on the base (base alone, in the one run that completed: 1804 passed, 16 failed, 48 ignored; two tests there fail in some runs and not in others). The other test binaries: 121 passed, 6 failed, 20 ignored, the base's failures.
review: none blocking. The key recorded for a gated stand-in equals the normal compute set key, so note_use records what an ungated pipeline would; submit_gated has no caller the PR leaves unchanged. Small: single_shader_key duplicates the existing shader_set_key([hash]) and could reuse it. Known limit: the key is set only on the shared-shell path.
performance: none; the hash was already computed for the log line, one note per gated pipeline at its first bind. No translator source changes.
verdict: safe to merge (from the code and the build; the suite cannot be completed on this card today, see tests)
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read). An NVIDIA card: it says nothing about AMD driver behaviour, so a check from an AMD tester is the one that counts for that.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head 4bb6b30

This PR targets amd-dev. Only the top commit (4bb6b30) is its own. The other ~217 commits (+34.9k lines) come from the old base b5c0275, which is shared with #2754, #2756, #2727, #2726, #2738 and #2710. That is where the shared added lines come from.
The commit gives pso_async::submit_gated a used-pipeline key from real.rs:maybe_rt_gated_compute_pso. Neither function exists on current amd-dev or main: the RT-gated compute stand-in came in with 123ef32 in that base, and amd-dev's XCL_RT_GATE=hold only turns BVH traversal off (bvh_traversal_allowed). So the fix cannot be rebased onto the target, and merging the branch as it is would bring in all 217 base commits.
Recommendation: close (superseded: the code it patches no longer exists on amd-dev or main).

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

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.