Repository navigation
Description
Findings
-
HANDOFF's "sparse simultaneous-access errors (1047)" come at least partly from XCL. A sparse window is one 4 GiB reserved buffer.
sparse::before_executecopies the CPU's writes into it on XCL's upload queue at once, while the submitting title queue may still have writes into the same buffer in flight. D3D12 allows a buffer many reading queues but one writing queue at a time. The debug layer reportsOBJECT_ACCESSED_WHILE_STILL_IN_USE(1047): "Simultaneous-access or Buffer Resource … is still referenced by write GPU operations in-flight on another Command Queue". -
Evidence: a synthetic test under the debug layer, in its own process like
tests/texture_states.rs. A title queue copies 200 × 32 MiB into one half of a sparse allocation while the CPU's write to the other half is uploaded. It gets one 1047 per run, 3/3 runs on7a033c8(RTX 5070 Ti, NVIDIA 610.74). In the same process, a texture written on two queues and a plain buffer written on two queues give the same 1047. -
The obvious fix deadlocks. I tried making XCL's upload queue wait for the submitting queue's earlier work, with a fence per title queue. That removes the 1047 (3/3), but the upload queue is one serial queue that every title queue waits on:
- queue A GPU-waits for a fence F that queue B signals only in a later submit (legal; async compute does it);
- A's next submit makes the upload queue wait for A;
- B's upload sits behind that, and B waits for its upload, so B never signals F.
A test of exactly this, with a 5 s timeout, passes on main and hangs with that change. It's a good regression test for any fix.
A plan that avoids both
- Record the CPU-write uploads and tile clears in a list of the submitting queue's type and run it on that queue just before the title's lists. Queue order then puts them after its earlier writes, with no cross-queue wait. They are all
CopyBufferRegion, which direct, compute and copy queues accept. - Track ring and slot reuse by each queue's own fence. The ring reclaims oldest first.
- Keep tile mappings on XCL's queue. It then never waits for a title queue, so title queues can still wait for it.
- Copies back of GPU writes (
readback_after_execute) also go on the title queue, landed by a worker thread. This part is a separate small PR. - Tests: the 1047 test, the A/B wait test, and a test that B sees a CPU write while A is blocked.
Question: today every title queue waits for the upload queue, so queue B sees CPU writes uploaded at A's earlier submit. With uploads on A's queue, B's work can run before A's upload and read the old bytes. Which do you prefer?
- (a) B uploads again any chunk whose upload on A hasn't completed. That means two writers of the same bytes, the same data, and it may overwrite a GPU write made in between.
- (b) Accept that window.
- (c) Keep a cross-queue wait for B, with the deadlock above.
Not covered: writes in flight on other title queues into the same window still conflict under any design, because a window is one buffer. No retail run, no AMD.
🤖 Claude Opus 5.5
Activity
iliassgm commentedon Nov 23, 2026
Taking this on (items 1–3 & 5 of the plan, keeping
readback_after_executeseparate as suggested):CopyBufferRegionuploads into per-queue command lists matching the submitting queue's type (DIRECT/COMPUTE/COPY) and submit them directly on that queue (bypassing title-queue hooks viaown_work), while keepingUpdateTileMappingson XCL's own queue (queue.Wait(&s.fence)runs before the upload list).q_release), falling back to a temporary upload buffer if a different blocked queue holds the front of the 64 MiB ring so cross-queue waits cannot deadlock even under ring pressure.Kalmarv commentedon Nov 23, 2026
@iliassgm thanks, good. Item 4 (
readback_after_executeon the title queue, landed by a worker) is ours, a separate PR touchingsparse.rsandreal.rs(Waitnoting). We'll keep it apart from your lines and rebase onto yours if yours lands first. When your PR is up we'll run it against the synthetic tests from the issue (the 1047 under the debug layer and the A/B wait with a 5 s timeout) and post the results there.Both tests are on a tests-only branch on
main4017f8f, if you want them in your PR:test/sparse-1047-cross-queue(615c267, onlycrates/xcl/tests/sparse_queues.rsandsparse_queue_waits.rs; GPL-2.0 like the rest). Onmainthe 1047 test fails (3/3 runs, one 1047 each, RTX 5070 Ti) and the A/B wait test passes; the A/B test hangs on an upload fix that waits for the submitting queue. Not checked yet on CI without a GPU: they skip when the device or the debug layer cannot be created, and may run on WARP.🤖 Claude Opus 5.5
Cattn commentedon Nov 24, 2026
A related case on the title-texture side, in case it affects your per-queue plan:
Setup: RTX 4070 12 GB, Ryzen 7 7800X3D, 32 GB RAM, Windows 11, a retail title,
XCL_NETWORK=0.What blocks: while the title streams its world, thread dumps every 30 s show its submit thread blocked in XCL in
title_textures::refresh→texture::upload_batch→texture::wait→gpu::fence::wait.What changed it: a local change submits title-texture uploads on the submitting queue itself, when it is a DIRECT queue on the same device.
Result: the title got past its loading screen for the first time on this machine, twice: main
3516080+ this change, and the same with #335. Afterwards the world draws black and the watchdog ends it, which is a separate problem.It's the same direction as your item 1 for sparse uploads. To avoid touching the same lines, I'm planning a separate PR limited to
title_textures.rs/gpu/texture.rs, unless you'd rather fold title textures into yours.(Analysis and change by Claude Code, Claude Opus 5.5; I ran the builds and game runs on the hardware above.)
Tests: a wait for a later signal on another queue gets past sparse up…
Tests: a wait for a later signal on another queue gets past sparse up…
Kalmarv commentedon Nov 24, 2026
@iliassgm one data point for your fix. We first tried having XCL's upload queue wait on the GPU for a fence that the submitting queue signals (local commit
bfd37fc, not pushed as a PR). It removes the 1047, but the A/B wait test fails 3 of 3: queue A does not finish in 5 s. Onmainthe test passes 3 of 3 (RTX 5070 Ti, NVIDIA 610.74). That test is now its own tests-only PR, #603 (crates/xcl/tests/sparse_queue_waits.rs); the 1047 test stays with the fix.🤖 Claude Opus 5.5
Tests: a wait for a later signal on another queue gets past sparse up…
wondercrash commentedon Nov 24, 2026
A retail run for the issue's Not covered ("No retail run"). The retail title produces the 1047 in the issue's shape, in the reverse direction, and also from
UpdateTileMappings.Setup: RTX 5090 32 GB, NVIDIA 621.14, Ryzen 7 9800X3D, 62 GB RAM, Windows 11 23H2 (10.0.22631), release build. Retail title (GTA VI 1.0.2.1, Series X package),
XCL_NETWORK=0, D3D12 debug layer on,XCL_DRED=1. Run 33 is on5dd057dand run 34 on72d2386(run 34 also has 3 GB of VRAM ballast). Both are from our integration branchwondercrash/xcl: upstreammainplus other open upstream PRs plus our own changes, not plainmain. Itssparse.rssplits the sparse state's lock (our change) but keeps main's queue structure: title queues wait for the sparse queue's fence inbefore_execute(main689f2dbsparse.rs:1540), the sparse queue waits for a title queue only for readbacks (readback_after_execute,sparse.rs:1234), andUpdateTileMappingsruns on the sparse queue (sparse.rs:706,744). XCL logs only the first 8 messages of each debug-layer id, so these counts are a floor.Run 33: all 8 logged id-1047 messages come by 50.6 s. They involve one title queue and three buffers.
run33.log:1228, 4.49 s, the issue's case:ExecuteCommandListson'xcl sparse queue'while the buffer "is still referenced by read|write GPU operations in-flight on another Command Queue" (the title queue).run33.log:22961-22971, 43.0-43.6 s, both directions. The title queue starts writes while the sparse queue haswriteorwrite|tilemappingin flight (22961, 22962, 22969). The sparse queue starts writes while the title queue hasread|writeorwritein flight (22970, 22971).run33.log:23034-23035, 50.55 s:UpdateTileMappingson'xcl sparse queue'while the title queue haswritein flight on the buffer: "not safe to start tilemapping GPU operations now".Run 34: the first 1047 is at 4.54 s (
run34.log:1214, the upload shape), and the 8th is logged at 30.75 s (run34.log:12421).@iliassgm, on keeping tile mappings on XCL's queue (plan item 3): the last shape above is a mapping change on XCL's queue while the title queue's write to the same buffer is still in flight. Moving uploads to the submitting queue does not change that ordering. Item 3 keeps XCL's queue from ever waiting for a title queue, so we expect this 1047 to remain after the fix [inference]. It may be worth listing next to the issue's Not covered item. Our runs say nothing about the (a)/(b)/(c) question.
Device removal: both runs ended in a device removal with no DRED page fault (
run33.log:23411, 81.26 s;run34.log:23510, 87.67 s). When the device is removed, XCL logs the last 64 debug-layer messages. In run 34, 56 of those 64 are 1047 (48 fromUpdateTileMappings), 9-68 ms before the removal. The 1047s start about 77 s before either removal and keep coming in between, so we don't read them as the cause. These two runs don't rule it out either.Not tested
mainin a title run.AI use: omp with Claude Opus 5.5 read the run logs and the code, and Claude Opus 5.5 wrote this; the runs are ours on the machine above.
throny commentedon Nov 25, 2026
A retail data point for this issue's plan, from the world load on NVIDIA (RTX 4080, 177cd40 + #2160/#2163, D3D12 debug layer). I logged each 1047 up to the 8th and then at each power of two:
ExecuteCommandLists(this issue's upload case) are 4 of the logged lines, all before 9 s.UpdateTileMappingson XCL's sparse queue, "still referenced by write GPU operations in-flight on another Command Queue". There were 128 by 9.9 s and 512 by 61 s, then 1 024 at 81.5 s and 16 384 by 85.9 s, in the seconds before the world-load device removal at 92 s (details on [OFFICIAL] Looking for PRs with shaders optimization #1269).So in the world load, the case that dominates is item 3 of the plan ("keep tile mappings on XCL's queue"), not the uploads. If the removal is tied to those remaps, the per-queue uploads alone won't touch it. The mappings themselves would need ordering against the writing queue, e.g. putting off unmaps and remaps of tiles until the title queues have passed their last submit, or mapping fresh tiles only, never reused ones, while a queue still writes there.
@iliassgm, are you still on items 1–3? I don't see a PR yet. If not, I'd take the mapping side (a test that reproduces the 1047 from
UpdateTileMappings, then a fix) and leave the uploads to whoever picks them up.AI use: Claude Code (Claude Opus 5.5).
throny commentedon Nov 25, 2026
Correction to my comment above: in the world load, those
UpdateTileMappings1047s are mostly fresh mappings of new tiles into the window, not remaps of reused ones. A run that never unmaps or reuses a tile still had the device removed at the same point, and its pools grew the same. So mapping a new tile while a title queue writes elsewhere in the buffer is flagged per resource, but I can't tie it to the removal. Data on #1269.