Repository navigation
D3D12.X: enable DXGI ALLOW_TEARING for VRR displays and add XCL_VSYNC - #2756
Saksukella wants to merge 202 commits into
Conversation
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>
… bit is read Since xcl-dev#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 xcl-dev#2083; the driver time grew with it (+28 % to +81 % on an RTX 4060, measured in xcl-dev#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 xcl-dev#2083), all validate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A retail title's world pixel shaders (xcl-dev#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 xcl-dev#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 xcl-dev#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 xcl-dev#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 (xcl-dev#408) and eliminate per-draw CPU lock contention and heap allocations across command-list recording and descriptor lookups (xcl-dev#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 (xcl-dev#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)
…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)
|
Code review (no title run: this head conflicts with the current
Not tested: any run of this head (conflict); tearing visually on a fixed-refresh or VRR display. RX 6800, Windows 11 Pro 26200. AI use: Claude Code (Claude Opus 5.5) read the diff against |
|
Native Windows DXGI check of the presentation helpers from To cover the retry, a test-only variant gave the first flagged native create an invalid one-buffer flip descriptor, which DXGI rejected with OpenAI Codex (6.2sol) assisted with verification. |
|
This PR targets AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human. |
What is in it
crates/xcl/src/hle/d3d12x/present.rs:IDXGIFactory5::CheckFeatureSupport(DXGI_FEATURE_PRESENT_ALLOW_TEARING)and create the windowed flip-discard swap chain withDXGI_SWAP_CHAIN_FLAG_ALLOW_TEARINGwhen supported (preserving the flag acrossResizeBuffersand retrying once withFlags: 0ifCreateSwapChainForHwndfails on WARP/RDP/headless adapters).XCL_VSYNCenvironment control (tearing/autodefault when supported ->Present(0, DXGI_PRESENT_ALLOW_TEARING)for VRR/FreeSync/G-Sync displays;0/off/mailbox->Present(0, 0);1/on/vsync->Present(1, 0)).MakeWindowAssociation(hwnd, DXGI_MWA_NO_ALT_ENTER)so the swap chain stays windowed/borderless as required by DXGI tearing rules.present_mode_and_tearing_params_match_expected_flags.amd-dev.Tested
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 present_mode_and_tearing_params_match_expected_flags: 1 passed, 0 failed (0.00s).Regression run
Not tested
AI use
ALLOW_TEARING/ResizeBuffersinvariants, writing the patch and unit test, and running local tests and smoke verification. All diffs and measurements were verified locally on hardware.