Repository navigation
D3D12.X: copy out-of-window two-pass indirect arguments into the window - #3079
RodrigoTorreao wants to merge 287 commits into
Conversation
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)
…shaders On AMD RDNA4, GroupMemoryBarrierWithGroupSync (barrier::GROUP_SYNC) flushes only LDS/TGSM, not L0/L1 global device memory. Shaders that perform global or image UAV stores, atomics, or GLC=1 coherent loads and synchronize with s_barrier can otherwise observe stale cache lines across waves/workgroups, causing infinite spin-wait loops (0x887A0006 TDR) or corrupted buffers. Pre-scan shaders via has_uav_write_or_glc and upgrade s_barrier to barrier::ALL_SYNC (Direct DXIL) and AllMemoryBarrierWithGroupSync / AllMemoryBarrier (HLSL) when the program writes/atomics global or image UAVs or uses GLC=1, leaving pure-LDS/ALU shaders on GROUP_SYNC. Assisted-by: Antigravity (Gemini 4 Neon High)
|
Help wanted: test reports from any AMD or NVIDIA card with a smaller coherent window.
AI-assisted (Claude Code with Claude Opus 5.5). |
|
PortBridge reproduced the two-recorder allocation case at PortBridge also surfaced Xbox2Windows #2332. Their synthetic WARP fixture distinguishes writer ordering (8/8 pixels with the queue wait versus 4/8 without) from consumer retirement (no slot reuse until completion). Your staging allocator differs, but these two controls map directly to its two remaining questions. Same-offset allocation at wrap and reuse of an in-flight slice need separate checks. Would you prefer to enforce a single-recorder/queue scope here, or have PortBridge help check a queue-owned retirement variant? The synthetic Lab request has the exact pin and asks for generated inputs only. |
|
On head
Please distinguish unbacked/outside the window from tracked but out of range, reject the latter before recording any copy or barrier, and validate the effective PC offset and buffer width for the former. Resolve both args and count, plus bundle eligibility, before emitting either copy. A regression should cover those invalid ranges, an exact-end valid range, a non-buffer resource, and the error path where the args are valid but the count is invalid. For the ring issue, a single atomic wrap fix would still allow a slot to be reused before another list or queue finishes reading it. One lifetime-safe direction is to stage into the existing recording-owned argument scratch, using disjoint spans for outputs and staged inputs, then feed the inline scaling pass; retain the source's actual D3D12 state and restore it after the copy. This is a design suggestion, not a tested patch. On Windows 11 build 26300 with an RTX 3080 Ti (driver 621.35), I ran |
|
Two-lane data at head Hardware
Context: on rig2, Tested: the four test groups above at |
|
I’m preparing a narrow nvidia-dev follow-up and will link its draft here, preserving attribution to this existing indirect-argument work. The first supported standalone path is UPLOAD-heap arguments/counts: their invariant GENERIC_READ permits copies without guessing source transitions. It will validate both sources before recording, use recording-owned scratch, and require established resource retirement. DEFAULT-heap/GPU-produced arguments remain unsupported until their exact state and lifetime are proved; this is not yet a fix for the whole missing-world symptom. The first checks cover mixed sources, count/bounds failures, output values and lifetime. No new test results are claimed here. Implementation and review use Codex (GPT-6). Optional temporary Discord for coordinating contributor work, helping test and comparing results: https://discord.gg/gK3y7WRRY |
|
I ran the five tests reported failing on the GTX 1070 / Wine lane above against head All five passed with zero skips: This is a native-host control for the reported lane, not a diagnosis of the Wine failure. GPU generation, driver, and operating system all differ; no retail title or full suite was tested. AI use: OpenAI Codex with GPT-6.2 Astra ran the checks; Codex reviewed and prepared this report. |
|
Test report for Tested
In these 200 s the title is still loading: the first two-pass amd-dev: this PR:
Not tested
AI use: Claude Code, model Claude Opus 5.5. It built both commits, ran the runs and the suites on the machine above, read the logs and wrote this. The person running these tests asked for this post. |
Review of the first version found two problems: - The shared 4 MiB ring could hand two recorders the same slot at the wrap. A slot could also be reused before an earlier list that read it had run on the GPU. - A tracked console buffer with an out-of-range offset fell through to the GPU copy instead of being refused. Arguments and the count are now resolved first. A tracked buffer the range does not fit is refused. Only untracked PC buffers outside a bundle are copied, after their buffer width is checked. The copy goes into the recording's own unified memory (ListState::arena), which is retired with the recording at its allocator's reset. Nothing is recorded unless every range fits and all space is taken. New tests cover the range checks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
One more lifetime case on head Reproducible reservation and GPU order
Please keep both inputs in disjoint spans of one recording-owned allocation and retain them through the consuming submission. Reserving the two inputs together would prevent this particular self-alias; it would not by itself prevent reuse by another in-flight list. A focused regression can force the reservation order above, submit only A, and assert that the scaled X remains This is a source-level execution trace; I did not run that GPU regression. AI use: Codex (GPT-6.2 Astra) found the schedule; Codex (GPT-6.2 Sol) checked the ring, call sites, and shader reads and wrote this review. |
|
Thanks @akimfomin and @thehollowedone, both findings were right.
The same A/B on the RX 6750 XT (Series S, @Prime1997: thanks, glad to see it carried over to AI-assisted (Claude Code with Claude Opus 5.5); run by me on the hardware above. |
|
Thanks for the quick update. I checked new head
Please add a debug-layer/GPU case for an UPLOAD source and another for two staged draws in one list, checking both scaled outputs and the info queue. On a Windows 11 build 26300 host with an RTX 3080 Ti / 621.35, AI use: Codex (GPT-6.2 Astra) traced the lifetime and state paths; Codex (GPT-6.2 Sol) checked the current source against D3D12's state rules, ran the focused tests, and wrote this review. |
|
Tested (native Windows AMD RDNA3 data point; no native Windows AMD report was in the thread yet)
Both ended on 65536 draws with translated pipelines, 0 skipped, 0 dispatches skipped. The "two-pass ExecuteIndirect skipped" line, the "indirect arguments outside the memory windows copied" line and "out of range, not run" never appeared on either arm.
Not tested
AI use Claude Code, Claude Sonnet 5.5, ran the builds, tests and paired runs and wrote this report. |
|
merge-check claim |
|
merge-check |
|
Follow-up to my resource-state review on unchanged head
These are source-level execution traces, not GPU failures I measured. The existing review's UPLOAD and shared-window state issues remain separate. AI use: Codex (GPT-6.2 Astra) traced these paths; Codex (GPT-6.2 Sol) checked the current source and D3D12 state rules and wrote this follow-up. |
|
I exercised the reservation consequence from the state/lifetime review on e2d7249. The distinction between a new block and an existing block matters for a rollback. The bounded CPU harness compiled this head's exact Arena::take, used the staging loop's len.max(16) and 256-byte alignment, and supplied a one-block (64 KiB) allocation provider. No GPU command was recorded. In both rows, reserving arguments succeeded, reserving the four-byte count failed, then an arguments-only retry on the same arena was attempted:
Releasing only newly acquired blocks misses the second case. Restoring only the cursor misses the first. The checkpoint must cover both fields and the block-list length, with exclusive access to the recording until commit or rollback; failures in destination-window resolution also need rollback before emitting barriers. This is an exact allocator-method control with a bounded provider, not an end-to-end ExecuteIndirect test or a claim about source-state barriers. OpenAI Codex prepared and ran the controls and drafted this note. |
|
I confirmed the combined DEFAULT-buffer state review on exact head
The fixture established the incoming mask with a transition after a GPU copy into the DEFAULT argument buffer and asserted that mask before entering staging. On the stock combined-state path, Close itself returned success despite the debug-layer diagnostics. This gives a bounded regression check for both the incoming barrier and outgoing state without submitting an invalid list. The explicit transitions were a matched control in a fixture that knew the full mask; production would need that information from its caller/tracker. This tested the actual staging helper and its bytes, not mesh execution or title performance. AI-assisted fixture and verification. |
|
Targets amd-dev, but the branch is based on an older amd-dev history (amd-dev was rewritten), so it shows ~300 base commits and conflicts; only AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human. |
|
Review (head e2d7249, description read; base
AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
What is in it
A two-pass ExecuteIndirect (DispatchMesh) whose arguments or count are in a PC buffer outside the memory windows was skipped (
its arguments are not in a console buffer in unified memory). The scale prelude reads arguments only through the windows. With a smaller coherent window (XCL_COHERENT_CAP_MB, and the RAM-based cap from #3068 onmain), that is about 3 % of a retail world's draws. Reported in #2996 (lane 5).arg_source). A tracked console buffer whose range does not fit is refused, as before. Only an untracked PC buffer outside a bundle is copied.stage_args_in_windowchecks each PC buffer's dimension and width first (pc_range_fits). It then takes space in the recording's own unified memory (ListState::arena, which is retired with the recording at its allocator's reset), and only after that records the copies. It records nothing unless every range fits and all space is taken.CopyBufferRegion, with the source moved INDIRECT_ARGUMENT → COPY_SOURCE → back, and the window buffer moved back to COMMON after its implicit promotion. A draw with staged arguments does not hoist its prelude.stage_args_tests(tracked out-of-range and overflow cases are refused, untracked buffers in a bundle are refused, a PC copy must fit its buffer).Tested
RX 6750 XT 12 GB, 16 GB RAM, Windows 11 26200, driver 32.0.21045.29003. The retail title ran on Series S (
lockhart) with a warm cache,XCL_PREPARE=0,XCL_COHERENT_CAP_MB=2048,XCL_TEXTURE_LEVEL_PAGES=1and A pressed automatically.0x887a00070x887a0007Both runs end at #2619, which on this machine ends every Series S run between 215 and 318 s. An earlier run with the RT programs precompiled and
XCL_RT_GATE=missgave the same picture: skipped draws fell from 23,804 to 180, and the run still ended at #2619 (VA 0x0, 241 s).Regression run
Same title,
XCL_PREPARE=0, separate empty caches, run one after the other. Each side ran with its ownscripts/smoke.ps1.main b937fba:
This PR:
Full suite (
cargo test --workspace --no-fail-fast -- --test-threads=4):All 18 PR failures also fail on amd-dev.
Not tested
AI use
Code, measurements and text were made with Claude Code (Claude Opus 5.5). I reviewed the change and ran every test on the hardware above.
🤖 Generated with Claude Code