D3D12.X: same-window copies skip the scratch buffer while a list's last submission runs #1408
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl#1408
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@pvfreis on GitHub · 2026-11-24 15:41 UTC · original
On
main(930e8b4), once a list has a scratch buffer, aCopyMemoryToMemoryXwithin one unified-memory window reads through it only when it is idle or already used by the current recording (CopyScratchCache::acquire,list_x.rs:2054-2058, from392dc0c). AfterKickoffXof a recording that made such a copy (list_x.rs:2979-2980, thenreset_copy_scratchat:3038), or afterResetof a list whose last submission made one and has not finished on the GPU (reset_x,:3591), the scratch has a pending fence mark and is no longer recorded, soacquirereturnsNoneeven when the 64 MiB budget has room.copy_memory_xthen takes its fallback, the copy within one buffer in COPY_DEST (:1978-1982), which is the copy #958 reported (debug layer id 538) and #993 replaced, and nothing is logged.Run on
main(RTX 3060, a local unit test, not for upstream): a real DIRECT list callscopy_scratch(list, 256), then KickoffX's steps by hand (Close,ExecuteCommandListsbehind a fence the GPU waits on,copy_scratch_submitted, nativeReset,reset_copy_scratch). The nextcopy_scratch(list, 256)returnsNonewith 64 KiB of the 64 MiB budget in use and nothing moved toreleased; after the GPU passes the fence the same call returns the same buffer. The test does not callkickoff_xorcopy_memory_xitself, and the debug layer was not run; the rest follows from the code.Effect: as in #958; not measured here.
Expected: the second copy also reads through a scratch in COPY_SOURCE. Refusing to reuse a busy scratch is deliberate (the comment at
:2055); the busy one could move toreleased, where it stays charged to the budget until its marks pass, and a new one be made within the budget, with a log line when the budget forces the fallback.Suggested test:
copy_scratch_budget_counts_resources_until_gpu_completionchecks the refusal only for a request of the full budget; the same setup with a small request should get a buffer other than the busy one.Not tested: the debug layer on this path,
kickoff_xend to end, the split-list case, AMD and Intel, a retail title.Found by reading the code and confirmed with a local unit test on
mainby Claude Code (Claude Opus 5.5), checked by Claude Fable 5.2; checked by a person before posting.@coenflict on GitHub · 2026-11-24 18:05 UTC · original
I reproduced this on
9e3831e1f570d3646e53ab753b19ec07eb8f1485by extendingcopy_scratch_budget_counts_resources_until_gpu_completion. In the fixture, one 64 KiB scratch buffer is marked in flight and another 64 KiB request for the same list returnsNone. The synthetic fence makes the test independent of queue timing.A local patch gives the new recording a different buffer when there is room, holds the old allocation against the 64 MiB budget until the fence passes, and starts the existing reaper. The regression failed on the old code and passed with the patch. It also checks that an over-budget request is refused and that completion returns the retired bytes to the budget.
Tested
32.0.16.2140, Rust 1.97.1 MSVC, DXC and DXIL 1.9.2602.17, debug.cargo test -p xcl --lib copy_scratch -- --nocapture: 2 passed, 0 failed, 0 ignored, 0 skips with the patch.scripts/test.ps1 --nocaptureon the uncommitted patch at the base commit above: 776 reported passed, 0 failed, 41 ignored. The pass count includes three GPU skips (two no wave64, one no heap windows).XCL_SAMPLE_*inputs were unset.Not tested
KickoffXon this path, the D3D12 debug layer, and retail-title regression runs.AI use
gpt-6.2-sol) wrote the local patch and regression test, ran the tests, and drafted this report.@Anon64 on GitHub · 2026-11-25 02:46 UTC · original
@coenflict are you opening your patch as a PR? Your report lists the retail-title regression runs as not tested. I can make the
scripts/smoke.ps1pair for it: the PR's head and itsmainbase, on a retail title, RTX 3060 12 GB. Push it or link a branch and I'll post both blocks. If you'd rather not open it, say so and I'll write the change myself from your description (a new buffer for the new recording when the budget has room, the old allocation held against the 64 MiB until its fence passes, the reaper started), with the failing-first test, and credit you.Written with Claude Code (Claude Opus 5.5).