Skip to content

Recompiler: match all VOP3 encoding names in ps_masks - #2605

Open
real-alponzo wants to merge 195 commits into
xcl-dev:amd-devfrom
real-alponzo:amd-dev/fix-ps-masks-vop3
Open

real-alponzo wants to merge 195 commits into
xcl-dev:amd-devfrom
real-alponzo:amd-dev/fix-ps-masks-vop3

Conversation

@real-alponzo

@real-alponzo real-alponzo commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Fixes VOP3 encoding detection in crates/xcl/src/gpu/recomp/ps_masks.rs:

per_lane and forms checked d.enc.name.starts_with("ENC_VOP3"), which misses VOP3_SDST_ENC, VOP3_SDST_ENC_INST_LITERAL, and VOP3_INST_LITERAL. As a result, V_ADD_CO_CI_U32, V_SUB_CO_CI_U32, and V_SUBREV_CO_CI_U32 in VOP3_SDST_ENC fell through to VCC instead of checking their SRC2 carry-in SGPR pair in per_lane(d), allowing diverged SRC2 reads to slip past ps_masks::run.

What is in it

  • Replace d.enc.name.starts_with("ENC_VOP3") with d.enc.name.contains("VOP3") in per_lane and forms (crates/xcl/src/gpu/recomp/ps_masks.rs).
  • Add unit test vop3_sdst_and_literal_encodings_are_recognized verifying VOP3_SDST_ENC (V_ADD_CO_CI_U32 / V_SUB_CO_CI_U32) SRC2 extraction and scalar-vs-literal Form::Uniform.

Tested

  • Hardware: Intel Core i9-9900K, 32 GB RAM, AMD Radeon RX 6800 (16337 MiB VRAM, RDNA2, driver 32.0.21045.29003), Windows 11 Pro build 26300, rustc 1.100.0, DXC 1.9.2602.17.
  • cargo test -p xcl --lib gpu::recomp::ps_masks: 4 passed, 0 failed, 0 ignored, 0 skipped.

Not tested

  • NVIDIA or Intel GPUs or Linux/Wine.

Regression run

xcl-smoke v1
commit: e1d84b7d9153f86a97d2ec5d209d196046fc0bea
gpu: AMD Radeon RX 6800
title: 6ca5cab7
seconds: 60
exit: 0x0
frames shown: 1499 (PresentX 1499)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13951 MB
xcl-smoke v1
commit: 6a0bb5b4f294b0729771ed457af1f96c01f5c06b
gpu: AMD Radeon RX 6800
title: 6ca5cab7
seconds: 60
exit: 0x0
frames shown: 1540 (PresentX 1540)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14734 MB
xcl-smoke v1
commit: 5b4437eea9af0775547529e6e34574992a6a5f7f
gpu: AMD Radeon RX 6800
title: 6ca5cab7
seconds: 60
exit: 0x0
frames shown: 1458 (PresentX 1458)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14766 MB

AI use

  • Antigravity (Gemini 4 Neon): audited amd-dev ps_masks.rs, implemented the fix and unit test, ran the tests and paired scripts/smoke.ps1 runs, and drafted this PR description.

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 #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 #899's log), and its hang
watchdog ended the run. A test report on #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 (#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 (#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 #31 (#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. (#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. #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 #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 (#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>
Kalmarv and others added 16 commits November 26, 2026 00:43
… bit is read

Since #2083 every pixel-shader compare on the direct route rebuilds its quad's four bits
from quad reads of its operands and four WaveActiveBallot passes. On 610 retail PS that
makes the DXIL 1.42x larger than before #2083; the driver time grew with it (+28 % to
+81 % on an RTX 4060, measured in #2083).

recomp/ps_masks.rs picks the cheapest form a compare's mask allows: the lane's own bit
when the mask is never read whole, WaveActiveBallot | own bit (HLSL ballot_px_local) when
it is read whole but nothing reads another lane's helper bit, cond ? EXEC : 0 for scalar
operands. In the ballot | own form every lane's copy of the mask has the live lanes' bits
and its own right, so EXEC predication, v_cndmask and carry-ins stay exact in helper lanes
and so do the values derivatives read later. A forward taint analysis refuses it where a
helper bit of another lane is read: a non-bitwise SALU, SCC / VCCZ, a scalar operand,
DPP / ds_swizzle / bpermute / permlane / readfirstlane while EXEC carries it, or values a
branch on such an EXEC lets differ between lanes. A subset of the entry EXEC (a kill's
live-pixel mask) has no helper bits and stays exact. Kept compares OR in their own bit.

610 PS: 43 % own bit, 31 % ballot | own, 4 % cond ? EXEC : 0, 23 % kept; DXIL x0.784
(x1.109 of before #2083), all validate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A retail title's world pixel shaders (#505; 173 of its 362) pack their
float16 interpolants: two components per dword (component c of a
register in dword c / 2, the even one in the low half) and up to two
signature registers per attribute, the second after the dwords the first
one's components take (1 for .xy, 2 for .xyz / .xyzw). The PS reads each
half with v_interp_p2_f16, SRC0 bit 8 choosing the high one.

XCL refused the PS input table of such programs (records [6, reg, mask,
attr, 0, reg2, packed reg, flags]: flag 8 = float16, flag 16 = byte 5
names the second register, byte 6 below byte 1 from the first pair on),
so every attribute, plain ones included, fell back to "the N-th
register" and the ones after a pair read their neighbour. The PS also
converted the raw packed dword as a float, ignored the high bit and
declared the float16 inputs nointerpolation.

Now the table parses, each (dword, half) of a packed attribute maps to
its element and component (f16_registers, ps_f16_slot; a record that
repeats its own register pairs it with the next float16 register no
other attribute names), and the PS reads that component as a float,
interpolated with the attribute's own mode. Both translators (HLSL and
direct DXIL).

The layout was checked on the title's dumped programs: every
v_interp_p2_f16 (dword, half) of 376 of 378 packed attributes in 362 PS
is a declared component (2 read one past a .xy register).

Not covered here: the VS / mesh side still exports the packed dwords
raw (the next commit), so the GPU test feeds the PS from a PC VS that
hands over each component as a float.

register always in dwords 2-3, a repeated register paired with itself -
which does not match the title's programs after a .xy register; both
have since dropped their float16 part in favour of this change.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The other half of the previous commit: the VS and mesh (NGG) programs
that feed those pixel shaders export their float16 interpolants packed
the same way - two components per dword, up to two signature registers
per exp param.

XCL refused the output table of such programs (records [6, reg, param,
reg, 0, 1 | 3]: 1 = float16, 3 = more than one dword) and fell back to
"the N-th register", so every param after a pair went to its
neighbour's register; a packed param went raw into its first register
alone. A mesh program never used its table at all.

Now the table parses for VS and mesh programs (MsInterface::params) and
a packed param is unpacked where it is exported: each half goes as a
float to its own component of its own element, in the VS outputs and in
the mesh record, in both translators. The table does not name the second
register of a pair: the float16 registers pair up in order, so it is the
next one no other param starts with (f16_registers).

Checked on the title's dumped programs: the enable mask of every exp
param of 383 packed params in 442 MS is exactly the predicted dwords.

A mesh program with a table now takes its params' registers from it,
float16 or not, as a VS already did; without one nothing changes.

dwords 2-3 and paired a mesh program's registers without its table; it
has since dropped that part in favour of this change.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RDNA2 scratch_* has three address forms, chosen by SADDR alone: an
SGPR is SS (SGPR + offset), NULL (0x7D) is SV (VADDR + offset) and
0x7F (EXEC_HI) is ST (the offset alone). There is no SGPR + VGPR form
and no SVE bit on RDNA2; both came with GFX11 / GFX940. This is how
LLVM encodes GFX10 scratch (FLAT_Real_gfx10 sets Inst{54-48} to EXEC_HI
for a scratch op without vaddr and to SGPR_NULL otherwise, and Inst{55}
to 0), and its gfx1030 MC tests encode `scratch_load_dword v1, off, off`
with byte 6 = 0x7f.

Both lowerings (direct DXIL lower_mem.rs and the HLSL emitter) took
0x7F for the SV form and added ADDR's VGPR, so an ST access went to a
per-lane address that its value happened to hold. They now use 0 as the
base for 0x7F, so ADDR is read only for 0x7D.

Issue #2400 proposed checking an SVE bit and adding SGPR + VGPR. The
RDNA2 ENC_FLAT_SCRATCH spec has no SVE field (bit 55 is not decoded),
so that half does not apply; the ST case it describes is real and is
the one fixed here.

Tests: an HLSL text check of the three forms and a direct DXIL check
that ST and SS containers do not change with ADDR while SV ones do
(both fail without the fix), a GPU test of the three forms, and the
existing scratch GPU test now encodes the SV form it describes.

Fixes #2400

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After DCE removes unused components from a multi-dword rawBufferLoad
(e.g. a 4-dword load whose y/z/w extracts were dead), narrowing the
contiguous DXIL mask (15/7/3 -> 1/3/7) based on the highest live
ExtractValue index (< 4, never touching loads whose residency status
index 4 or whole struct escapes) reduces memory traffic and avoids
trailing OOB byte reads.

Also supplies early_depth: false in the cherry-picked #2513 f16 PS
interface test initializer.

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

sparse::State::queue is created as D3D12_COMMAND_LIST_TYPE_DIRECT, but
take_readback_job created its pooled command allocator and command list as
D3D12_COMMAND_LIST_TYPE_COPY. Submitting a COPY list to a DIRECT queue
removed the device immediately with DXGI_ERROR_INVALID_CALL (0x887a0001).

Match s.queue by creating ReadbackJob allocators and lists as
D3D12_COMMAND_LIST_TYPE_DIRECT.

Assisted-by: Antigravity (Gemini 4 Neon High)
sparse::State::queue is a D3D12_COMMAND_LIST_TYPE_DIRECT queue, but
take_readback_job created its pooled allocator and command list as
D3D12_COMMAND_LIST_TYPE_COPY. Submitting a COPY command list to a
DIRECT queue immediately triggers DXGI_ERROR_INVALID_CALL (0x887a0001).

Create ReadbackJob allocators/lists as D3D12_COMMAND_LIST_TYPE_DIRECT
matching State::queue, and skip returning/resetting a ReadbackJob if its
fence wait times out so an in-flight allocator is never reused early.

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

Implement indirect Draw/DrawIndexed safety caps (#408) and eliminate
per-draw CPU lock contention and heap allocations across command-list
recording and descriptor lookups (#395):

- Indirect draw caps (device_x.rs, bind.rs): track Draw/DrawIndexed
  command signatures in DRAW_SIGS (RwLock) and guard indirect draw
  argument buffers via hoisted PRELUDE_DRAW_GUARD_* (or inline
  GUARD_DRAW_ARGS_* when prelude hoisting is blocked), zeroing any
  record with verts == 0, instances == 0, verts >= 2^23 (8,388,608),
  or verts * instances > 2^26 (67,108,864) using overflow-safe u32
  arithmetic. Opt-out via XCL_INDIRECT_DRAW_GUARD=0 or
  XCL_INDIRECT_GUARD=0. Indirect dispatch guards already enforce
  <= 2^22 total groups with X > 65,535 folding into Y.
- Lock contention & per-stage bind cache (bind.rs, list_x.rs):
  - Shard bind::STATES across 64 Mutex shards and switch command
    signature tables (ROOT_SIGNATURES, DISPATCH_SIGNATURES,
    DISPATCH_ONLY, DISPATCH_MESH_SIGS, DRAW_SIGS) and list_x::MIRRORS
    to RwLock so parallel recording threads do not serialize.
  - Zero-allocation stack [u32; KERNEL_SGPRS] io builders (fill_io_gfx,
    fill_io_compute, fill_io_two_pass), zero-allocation little-endian
    Set*Root32BitConstants, reusable dummy_table_p when all root args
    fit inline, and idempotent Set*RootSignature preserving io_cache
    and Vec capacity.
  - Cache per-list heaps_ensured, lazily cached vram_io_dev, and
    pso_abi_cache (skipping repeated pso_async/real/list_x/GLOBAL
    lookups on consecutive draws with the same PSO).
  - Fix list_x::skip_redundant_pso_bind so bind_abi re-binding an
    already-active resolved PC PSO hits the cache instead of
    re-emitting SetPipelineState + DRED markers on every async PSO.
- Reusable dirty-page bitset & descriptor lookup (list_x.rs,
  console_heap.rs, real.rs):
  - Replace per-draw Vec<bool> in list_x::copy_written with a reusable
    thread-local Vec<u64> bitset and word-wise run scanning.
  - Keep console_heap::HEAPS sorted for O(log N) partition_point
    lookups, add single-lock slot_pair for copy_console_slots,
    zero-refcount global_*_heap_raw accessors, and smallest_failed
    allocation short-circuiting on full shared heaps.

Assisted-by: Antigravity (Gemini 4 Neon High)
Break any active 256-slot InlineGuardBatch on graphics draws
(DrawInstanced, DrawIndexedInstanced, DispatchMesh, graphics
ExecuteIndirect) and mark prelude_blocked + close inline_guard on
Enhanced/UAV barriers (uav_barrier_x and UAV resource_barrier_x) so
memory-writing graphics shaders never race with a pre-draw indirect
guard batch or hoisted prelude (#424). Also gate test-only indirect
draw limit constants with #[cfg(test)] for zero warnings.

Assisted-by: Antigravity (Gemini 4 Neon High)
Complete Win11 scheduling hardening in kernelx/host/real:
- Export guest SetThreadPriority in kernelx.rs and floor guest priorities
  below THREAD_PRIORITY_BELOW_NORMAL (IDLE / LOWEST) to BELOW_NORMAL
  unless XCL_PRIORITY=0, preventing Windows 11 hybrid E-core starvation
  of title streaming/background threads while leaving internal XCL
  pso_async workers (calling win32 directly) untouched.
- Add winmm timeBeginPeriod(1) alongside NtSetTimerResolution(finest, 1)
  in kernelx::fine_timer(), and add idempotent restore_fine_timer() called
  on normal exit (host.rs) and forced/timed exit (real::end_title) so both
  timer-resolution requests are cleanly released on shutdown.
- Add unit tests covering priority flooring (pure + live guest hook) and
  idempotent timer-resolution restoration.

Assisted-by: Antigravity (Gemini 4 Neon High)
…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)
…ure caches (#2578)

Adapt two cache-safe stability fixes cleanly onto origin/amd-dev (bf02341):
- #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 (#2512).
  Adds driver_cache::tests::blobs_are_kept_on_disk_unless_they_are_references.
- #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 (#2582)

Fix #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 (#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)
Use contains(VOP3) instead of starts_with(ENC_VOP3) in ps_masks so VOP3_SDST_ENC and VOP3*_INST_LITERAL instructions inspect SRC2 properly and scalar-vs-literal compares recognize Form::Uniform.

Assisted-by: Antigravity (Gemini 4 Neon)
@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), head merged with current main:

  • cargo test -p xcl --lib -- --test-threads=1: aborts with 0xc0000409 (STATUS_STACK_BUFFER_OVERRUN) partway through, deterministically:
thread 'xcl-pso-5' panicked at crates\xcl\src\hle\d3d12x\pso_async.rs:1219:43:
a build that panics (test)

thread 'xcl-pso-22' panicked at windows-core-0.62.2\src\interface.rs:41:18:
misaligned pointer dereference: address must be a multiple of 0x8 but is 0xffffffffffffffff
thread caused non-unwinding panic. aborting.

During hle::d3d12x::pso_async::used_tests::a_released_queued_pipeline_is_not_built_by_normal_workers. An injected worker panic is followed by a 0xffffffffffffffff COM-pointer dereference on another worker — the poisoned pointer is not being checked during teardown. Real bug in the merged state.

Note: the branch is a ~212-commit stack on main, so this may belong to an earlier layer (the pso_async frame-wait-window work looks related).

— Devin

@DarkPanda69

Copy link
Copy Markdown

NVIDIA run (listed as untested), plus an RX 9070 XT: the new test passes on both, and nothing else changes against amd-dev in the GPU suite.

Head 5b4437e applied on amd-dev b5c0275, debug, Windows 11 Pro 26200, cargo test -p xcl --lib -- gpu:: --test-threads=4 (default HLSL path) on amd-dev and with the PR, card chosen with XCL_ADAPTER:

amd-dev this PR
RTX 3060 (Ampere, 32-lane waves only, 32.0.16.1088) 749 passed, 3 failed, 20 SKIPPED 750 passed, 3 failed, 20 SKIPPED
RX 9070 XT (RDNA4, 32.0.32029.2010) 748 passed, 4 failed, 4 SKIPPED 749 passed, 4 failed, 4 SKIPPED

On both cards, the only result change is the new vop3_sdst_and_literal_encodings_are_recognized (ok), with no new skips. All the failures are the same on amd-dev without this PR:

Not tested: Intel, Linux / Wine, a title.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.

rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 26, 2026
…2605)

LATER shared-analysis soundness: starts_with ENC_VOP3 missed
VOP3_SDST_ENC and VOP3*_INST_LITERAL (SRC2 never inspected, compare
masks fell back to VCC / missed Form::Uniform). Two-line contains
fix + regression test land verbatim (4 ps_masks tests pass).
koboshchan added a commit to koboshchan/xcl that referenced this pull request Nov 26, 2026
@thehollowedone

thehollowedone commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

merge-check
base: 7c795f5 (amd-dev)
head: 5b4437e
merge: clean, with no tree change on the sole touched file
build: not run; the merge contributes no code to this base
tests: not run; the merge contributes no code to this base
review: The current AMD branch already contains e346b778, Recompiler: match all VOP3 encoding names in ps_masks. Its stable patch ID and this PR's stable patch ID both equal 7868b54d36f1b2576e1ec48a5725c458bfdefce8; git diff --exit-code between the current base and PR head for ps_masks.rs is empty. The local merge had no staged or unstaged changes. The fix and its regression are already present on the target branch.
performance: identical to the current base; this PR adds no behavior when merged now.
verdict: not yet: redundant PR; close it as already integrated by e346b77 rather than merge an empty change.
hardware / tool and model: Read-only Git/tree/patch-ID comparison on Windows 11; Codex (GPT-6.2 Sol) verified the duplicate. No GPU or title run was needed for this identity check.

@throny

throny commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

merge-check claim
head: 5b4437e

@throny

throny commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

merge-check
base: 7c795f5 (amd-dev)
head: 5b4437e
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 on amd-dev 7c795f5 + this PR -> 1802 passed, 17 failed, 48 ignored (21 SKIPPED lines) on an RTX 4080; this is the base's own result, because the merge changes nothing.
review: the whole change is already on amd-dev as e346b77 (same subject); the file is byte-identical on the branch and on this head, as the earlier finding in the thread says.
performance: nothing to add.
verdict: not yet: nothing to merge; already on amd-dev through e346b77, so this PR can be closed.
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; nothing run on the GPU beyond the suite).

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head 5b4437e

Only the top commit (5b4437e, ps_masks.rs) belongs to this PR. The other 211 commits (+34k lines) come from a fork branch shared with #2604. Please rebase onto main as that one commit. The same change appears only inside large fork-merge PRs (e.g. #3547, #2912), not as a separate PR. It is not on main: per_lane and forms still test starts_with("ENC_VOP3").
The per_lane part is a real fix: V_ADD_CO_CI_U32/V_SUB_CO_CI_U32 in VOP3 form decode as VOP3_SDST_ENC, so on main their SRC2 carry-in is taken for VCC. On main, per_lane now takes wave64 (regs(v, if wave64 { 2 } else { 1 })), so the change and test need adapting.
The Form::Uniform half of the test does not exercise the change: V_CMP_LT_F32 with a literal still decodes as ENC_VOP3, which main already matches.
Recommendation: keep open.

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.