Repository navigation
D3D12.X: coalesce sparse UpdateTileMappings fence signals until execute/wait (companion to #3010) - #3024
D3D12.X: coalesce sparse UpdateTileMappings fence signals until execute/wait (companion to #3010)#3024Saksukella wants to merge 286 commits into
Conversation
…esent in flight)
A retail game unmaps addresses while it streams its world with
XMemMapPhysicalPagesScatter(addresses, n, NULL); it checks the result
and runs into its own int3 when the call fails (+0xb18de7, then its
crash reporter). XCL refused a NULL page array with
ERROR_INVALID_PARAMETER. Page 0 already means "unmap this address" in a
scatter, so no array is taken as page 0 for every address.
Test scatter_without_pages_unmaps: two pages mapped and written, unmapped
with no array (the call succeeds, the addresses are no longer committed),
mapped again they read what was written. It fails without the change
("refused").
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A retail title keeps its destination page lists in slots of its own table and writes a slot's pages after EnqueueRequest. At enqueue such a slot can still name the pages of the slot's previous request, and the snapshot taken then is what execute() wrote to (xcl-dev#289 rereads only the entries that are 0). Over 16 000 requests a run were written into pages the title had since reused: its objects got garbage pointers and it crashed about 20 s into world loading; when the old pages were freed, the request failed with E_ACCESS_VIOLATION. The console reads the list when it runs the request. execute() now reads it again (through read_own, as the snapshot) and takes it when it differs and every page in it is allocated (kernelx::physical_pages_live). A list that was on the enqueuing thread's stack keeps the snapshot: that memory is reused once the call returns, and a page ID written there since can belong to another live allocation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…heir pages with their texels A retail title places its streamed textures at full size and has memory behind their levels only as it loads them, the small ones first. vram::place_pages gives a sampled texture a 64 KiB page of video memory for every tile at once: when that title's world is set up about 92 % of those pages have nothing behind them (80 690 pages, 6 809 committed, on one card). With the switch (off by default) a sampled 2D texture of one slice is placed with no tile mapped. Its tiling is kept as groups of tiles, one for each level with tiles of its own and one for the packed levels, and a group gets its pages before the first upload that has texels for it - the same pages by address as before, so textures placed at one address still share them. A texture the GPU writes gets all its pages. Part of xcl-dev#1773. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
… done When the GPU-wait watchdog releases a wait (xcl-dev#505), its lines say which queues wait on which, but not what the GPU is running. With XCL_GPU_CULPRIT=1 every dispatch XCL records (title lists, console-recorded lists, ExecuteIndirect of a translated compute pipeline) is wrapped in WriteBufferImmediate markers, in before and out after, one pair of words per PC list in a readback buffer. At a release the lists whose marker in is above their marker out are logged with the dispatches between the two: console CS (fnv64 of the title's bytecode), PC pipeline and groups. On the retail title of xcl-dev#505 (RTX 5080) this named, at each stall, one list with a run of 1-D dispatches of one CS whose first never finished; not the same CS from run to run. DRED breadcrumbs were tried first: they change the driver's pipeline cache keys, so every pipeline was built again and the title never got past its start. Off by default; without the variable nothing is recorded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This reverts commit bd4584d.
Bring in 36 upstream PRs from origin/main (xcl-dev#2310..xcl-dev#587) onto amd-dev (c7a18d8) while preserving all local AMD RDNA4 work (xcl-dev#615 pipelined presenter SRVs, xcl-dev#495/xcl-dev#1405 XCL_PAGE_ALIAS=1 hooks, xcl-dev#2306 level tiling timers, xcl-dev#1989 vtable fix, mesh user SGPRs). Resolved 4 conflicts: - console_list.rs: kept both mesh_arguments_go_in_user_sgprs_from_s16 and xcl-dev#2323 dispatch-heap tests - real.rs: kept both effective_st depth-UAV tracking and xcl-dev#2280 pc_clear_for_desc - vram.rs: kept Step::Tiling timer around level_tiling - kernelx.rs: kept XCL_PAGE_ALIAS=1 hooks in physical_pages_live and XMemMapPhysicalPagesScatter Assisted-by: Antigravity (Gemini 4 Neon High)
Both internal indirect-argument rewrite passes in bind.rs (guard_dispatch_args and make_scaled_args_buffer) emitted the exact DRED breadcrumb pattern (barrier, barrier, marker, Dispatch, barrier, marker) with an unlabeled pipeline and had root-binding and alignment hazards on AMD RDNA4: 1. Neither guard_indirect_pipeline nor scale_indirect_pipeline called dred::label_text (or SetName), so DRED printed the fallback stand-in label. 2. Both reused abi_root_signature (6 root UAVs + directly-indexed heap flags) while leaving slots unbound; SCALE_ARGS_HLSL statically references cnt (u4) via a ternary even when no count buffer is bound. 3. src_va and count_va were passed directly to SetComputeRootUnorderedAccessView even when args_off or count_off was not 16-byte aligned (e.g. 12-byte Dispatch argument strides or 4-byte count offsets). Fix all three: label both pipelines for DRED, give args_pipeline a minimal root signature with every parameter unconditionally bound (binding u4 to consts_va when count is None and guarding cnt.Load with an if), align root UAV bases down to 256 bytes and pass the byte offset via io, guard GUARD_ARGS_HLSL divisions, and validate bundle/stride/offset bounds. Assisted-by: Antigravity (Gemini 4 Neon High)
Console D16_UNORM_S8_UINT (118..=120) depth+UAV twins used R16_UNORM SRVs and a float fullscreen pass. Because 2^24-1 is not a multiple of 65535, hardware R16_UNORM conversion can differ by 1 ULP from float(k) * asfloat(0x37800080) computed by tiled-lighting DepthFunc = EQUAL vertex shaders, rejecting lighting draws on AMD RDNA4. Read the R16_TYPELESS twin as R16_UINT in a dedicated fullscreen PSO returning float(val) * asfloat(0x37800080) for console formats 118..=120, and update the twin-plan unit test. Assisted-by: Antigravity (Gemini 4 Neon High)
…olves Command list xcl-dev#146 (uav_barrier_x) synced depth+UAV enhanced barriers and PlacedUav format-alias pairs, but never checked D3D12_BARRIER_TYPE_TEXTURE transitions on TitlePlaced format-alias writers (such as R9G9B9E5 lighting targets), leaving aliased SRVs stale under enhanced barriers. Add format_alias::filter_enhanced_barriers and call sync_title_writers in uav_barrier_x. Also translate console target formats in resolve_subresource_x and resolve_subresource_region_x via device_x::pc_target_format. Assisted-by: Antigravity (Gemini 4 Neon High)
buffer_view (used by CreateShaderResourceView and CreateUnorderedAccessView on buffer resources) returned empty V# descriptors for placed GPU-view buffers, and dev_create_cbv_x / buffer_words_at only fell back to read-only sparse::gpu_view mirrors (requiring XCL_GPU_VIEW_BUFFERS=1 and skipping UAVs). Add real::resolve_uma_va(va, len) consulting kernelx::mirrors::mapped_source and mirrors::source with per-64-KiB-page contiguity verification inside UMA, wire it ahead of sparse::gpu_view::base_for in buffer_view, dev_create_cbv_x, and buffer_words_at, and add read-only sparse fallback to buffer_view. Assisted-by: Antigravity (Gemini 4 Neon High)
Keep amd-dev 0 commits behind origin/main (xcl-dev#573, xcl-dev#2083, xcl-dev#2345, xcl-dev#2342). Resolved 1 conflict in bind.rs: kept pso_for_draw(raw_pso) and bounds-checked commands_at/count_at while taking xcl-dev#2342 failed shared compute stand-in check. Assisted-by: Antigravity (Gemini 4 Neon High)
map_pages and move_away previously called sparse::committed(at, PHYS_PAGE) inside the per-page loop. When a large physical-page allocation (~2+ GB) lands in a sparse UMA window (such as Series S / lockhart TileHeap), this issued ~34,000 separate 64 KiB UpdateTileMappings + queue.Signal calls (>31 s at ~64 MB/s), tripping the title's 30 s init watchdog. Coalesce contiguous 64 KiB sparse-window commits in SparseCommitBatch across map_pages, move_away_batched, MapTitlePhysicalPages, and XMemMapPhysicalPagesScatter, flushing early on any overlapping decommit/unmap. Reduces ~34,000 UpdateTileMappings calls to one batched commit per contiguous run (~34 pool-heap calls, <100 ms). Assisted-by: Antigravity (Gemini 4 Neon High)
Titles can enqueue DirectStorage requests with heap-backed DestinationPageArray pointers, populate/map the physical page lists, and then call Submit(). Auto-submitting the queue at half capacity let worker threads run mid-batch against unpopulated page entries, dropping streamed geometry. When the pending queue contains any non-stack DestinationPageArray request, suppress the half-capacity auto-submit and wait for explicit Submit() (or full queue capacity), while keeping normal half-capacity auto-submit for memory, file, and stack-backed page-list requests. Assisted-by: Antigravity (Gemini 4 Neon High)
VOP3 v_interp_p1ll_f16, v_interp_p1lv_f16, and v_interp_p2_f16 encode (high << 8) | (chan << 6) | attr in SRC0 (OPR_ATTR). For attr63.w (attr=63, chan=3, high=0), SRC0 == 0xFF == 255, which rdna2::decode's VALU fallback literal scan mistook for a 32-bit inline literal and consumed the following instruction word. Skip fields explicitly typed as non-source operands (!is_src_type) during the VALU fallback literal scan while keeping v_nop's empty-operand hidden shader hash literals intact. Assisted-by: Antigravity (Gemini 4 Neon High)
Use the ambient stand-in when the raytracing gate forces misses. Assisted-by: Codex (exact model identifier unavailable)
Most recordings need only a few argument records. Grow to the regular block size when a slot fills. Assisted-by: Codex (exact model identifier unavailable)
Release recyclable scratch for the device when the system is short on commit. Assisted-by: Codex (exact model identifier unavailable)
Use an explicit aliasing barrier for the overlapping placed resources. Keep native-driver execution available by adapter selection. Assisted-by: Codex (exact model identifier unavailable)
Share identical shader bytes from different title addresses and check byte equality before reusing a hash match. Assisted-by: Codex (exact model identifier unavailable)
Port the mapping and retirement changes from xcl-dev#2981. Seal only the unmaps covered by the queue signals and keep zero-buffer aliases alive through retirement. Assisted-by: Codex (exact model identifier unavailable)
Adapt xcl-dev#2821 to bound fence waits and retry unsent writes when a slot is still busy. Use smaller upload and readback staging buffers with chunked transfers. Assisted-by: Codex (exact model identifier unavailable)
Port xcl-dev#2912 so finished staging allocations are reaped even when the originating queue goes quiet. Assisted-by: Codex (exact model identifier unavailable)
Port xcl-dev#2985 so supported fallback resources can share backing heaps and reuse the decoded layout. Assisted-by: Codex (exact model identifier unavailable)
Sample process pages to distinguish unified, sparse, and other resident memory in the diagnostic report. Assisted-by: Codex (exact model identifier unavailable)
Track the latest submitted work along with missing completion markers. Assisted-by: Codex (exact model identifier unavailable)
Port the GPU timestamp profiler from nvidia-dev ea22791, including submission and pipeline identification hooks. Assisted-by: Codex (exact model identifier unavailable)
XCL moves from GPL-2.0-only to GPL-3.0-or-later so that code can move between XCL and GPL-3.0 projects (VIctory and its forks) in both directions. - LICENSE: the GPL-3.0 text from gnu.org; Cargo.toml: GPL-3.0-or-later. - README, CONTRIBUTING, AGENTS, SECURITY: the new licence and the GPL-3.0 compatibility rule for dependencies. - THIRD_PARTY.md: the GPL-3.0-compatible licence list; VIctory is used under its own GPL-3.0; AnyPS5 is listed as a reference only. - AnyPS5 was read as a description of the hardware behaviour (MIMG A16 address layout, 16-bit VALU halves), no code was taken from it: the two comments in recomp/emit.rs that said "ported" now say so. - Headers of the VIctory and FFmpeg ports no longer name GPL-2.0-only. No code change. (cherry picked from commit 06f90c1)
Avoid signalling the sparse command queue fence after every `ensure_mapped` (`map_tiles`) call. `map_tiles` already marks `mapping_queued = true`, and `before_execute` / `wait_pending_mappings` flush a single `queue.Signal` before the next title submit, matching the batched signalling pattern used for texture page mappings (`XCL_SPARSE_SIGNAL_EACH=1` restores immediate per-commit signalling). Add `commit_range_coalesces_tile_mapping_signals_until_flush` verifying multiple `commit_range` calls coalesce into one fence signal on flush.
|
Title A/B on an RX 6800 (RDNA2). No clear gain or loss from this head in 4 runs; on this card every run ends in a device loss or a title crash first, so the sparse path's own cost decides little here. Setup: RX 6800 16 GB, driver 32.0.21045.5002, i5-10600KF, 32 GB, Windows 11 Pro 26200, release builds of base
Not tested: more runs; the timing of AI use: Claude Code (Claude Opus 5.5) ran the A/B through a local test runner, read the logs and wrote this comment. |
|
Test report for this PR applied together with #3025 (one comment, so it is not repeated here): #3025 (comment) AI use: Claude Code, Claude Sonnet 5.5. |
|
Two-batch native control on
With CPU waits off, a marker on each consumer remained pending behind the gated mapping queue in both batches before release. With CPU waits enabled, the mapping fence had reached the expected value by the time both helpers returned. For data validation I separately ordered the initialization copy before both readers; after batch two, both queues recovered the first pair and the newly mapped pair ( Four fresh-process runs passed, zero skips. This exercises sparse-buffer commits and explicit mapping waits on native Windows. It does not exercise #3010’s separate texture page pool or measure vkd3d batching or title performance. AI use: OpenAI Codex extended the sparse test fixture, ran the four native controls, and drafted this report. |
|
Only the top commit (b7fc3b4) belongs to this PR. The branch also carries about 235 commits of an older amd-dev lineage (7c795f5 and below) that are not on AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human. |
Companion to #3010: coalesce sparse
UpdateTileMappingsfence signals until command-list submission or explicit wait.Summary
self.signal()call at the end ofState::ensure_mapped.map_tilesalready marksmapping_queued = true, andflush_pending_mappings()(called once inbefore_executeandwait_pending_mappings) emits a singlequeue.Signalcovering all queued tile mappings before the next title submit.XCL_SPARSE_SIGNAL_EACH=1escape hatch to restore immediate per-commit signalling for debugging.7952987A, coalescing per-commit signals cutssparse queuefence signals from ~41k down to ~700–1k.commit_range_coalesces_tile_mapping_signals_until_flushverifying that consecutivecommit_rangecalls coalesce into a single fence signal on flush and complete on the GPU.Verification
(
commit_range_coalesces_tile_mapping_signals_until_flush ... ok; the 1 ignored test is the pre-existingearly_commit_timingbenchmark.)