gpu: back slot 133 linear buffers by sharing or a submit-time copy (opt-in) #2210
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2218"
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?
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T05:42:09Z.
What and why
This is the first production slice of the #1914 decision, as R0Y00 asked after #1942 merged. It wires #1942's comparison to one ordinary linear buffer that the CPU writes and the GPU reads, and it keeps the current backing as the default.
The buffer kind is device slot 133 (
CreatePlacedResourceX) with a buffer description, row-major or unknown layout, and initial stateCOMMON. This is the narrowest production kind that is linear, CPU-written and GPU-read:S_OKwith a zero-filled buffer that does not alias the title memory.Buffers in
UNORDERED_ACCESSor acceleration-structure state, textures and command-list slot 148 keep their current paths.X2W_D3D12_LINEAR_BUFFERS=1(or=copy) opts in. Unset or0, none of the new code runs.Rebase onto main (
ff06794b) and follow-upsThe branch is rebased onto
ff06794bas a series. Main had changed slot 133,release()andqueue_executesubstantially.Integration with main:
release(): main's budgetend_usecalls,drop_mesh_lease_ownerand the list-kinddiscard_mesh_lease_recordingare kept. The linearretireruns afterretire_placement, under the opt-in.queue_execute: main'ssubmitlambda (red_producers().execute,retire_address_uploads,retire_draw_sampler_heaps,note_submits,commit_list_gpu_writes) and the mesh XMem split path are unchanged. The internal-queue refresh and the consumerWaitrun once per guest call before the wrapper's locks, so they precede every list of the submission in both the render and non-render paths. That covers the producer fencesred_producersadds and each split mesh submission, and leavesred_producerssemantics as they are.publish_placed_buffercarries main's tail: theindex_resourcecallback inpublish_placement,x2w_budget::resource(..., placed)plus the heap'sbacking_budgetwithbegin_usewhen aliased, andx2w_budget::committed(..., DEFAULT)otherwise. Main's default path uses it unchanged.docs/experiments.md: main's "A lease for committed XMem section pages" and "GPU queue handoff to an XMem-backed root SRV" sections come first, then this one.New commits on top:
gpu: count linear-buffer backings in the D3D12 budget).budget(share, copy): one placement goes live in its category (placed with its heap live, or buffer), and the title's release moves it to retained, with nothing unmeasured.gpu: defer slot 133 linear buffers to the XMem lease path).X2W_MESH86_XMEM_SRVorX2W_MESH_INDIRECT_XMEM) takes the default copied placements of XMem pages whose console flags are 0.note_mesh_xmem_writerequiresPlacement::copied_bufferandconsole.Flags == NONE, then mirrors GPU writes into a leased view and publishes it to mesh readers.HRESULT_FROM_WIN32(ERROR_BUSY)(0x800700aa, "deferred to the lease path") in the log line, the info and the totals. Other placements, and everything while the lease path is off, are unchanged.lease: the XMem buffer keeps the default backing (reads zero, as before) with the deferral reported, and a private one is still copied.gpu: stop refreshing a copied linear buffer that a list copy writes).CopyBufferRegionandCopyResourceinto slot 133 placed buffers (list_copy.inl), so a copied linear buffer can be GPU-written. Those bytes never reach title memory, and a refresh whose changed span covered them would have copied older title bytes over them.gpu_writtenin the info and totals.gpuw(copy path): a listCopyBufferRegionwrites G, the title changes the words on both sides, and the read still sees G.refresh-gpu-writtenkeeps refreshing; it reads A instead, and fails 2 of 2.Follow-up, not in this PR: with #2280's section lease (pinned slots mapped as one view, opened as a D3D12 heap and released after GPU completion), XMem views could be shared through a lease instead of copied. This PR keeps copying them; view sharing stays refused (
0x80070032) because an open heap pins the title's own view.Review changes (R0Y00)
The repro. One copied buffer held A, and its first read was complete. Two read-only direct lists were recorded for it, and the CPU wrote B once before submitting either. List 1 went to queue 1 behind an unsignalled gate. List 2 went to queue 2, completed before the gate opened, and read A in 1,024 of 1,024 words; list 1 later read B. No refresh failure was reported.
The cause. Queue 1's submission enqueued the refresh on queue 1 behind the gate, but
uploadedwas updated at enqueue. Queue 2's diff therefore saw no change and skipped its refresh.Fix (
src/startup_stubs/linear_buffer_backing.h):ExecuteCommandListsandSignalon that queue are serialized by a small mutex of their own, so values stay in order. The backing's main lock is still never held across a wait orExecuteCommandLists.Wait(internal_fence, V). V is the highest value among the live copied buffers that has not completed; buffers the title released are not waited for. Recordinguploadedat enqueue is now correct, because every later consumer waits for the copy to land.after_submit, the per-title-queue fences andlinear_submittedare gone.docs/startup-runtime.md.X2W_TEST_SUBMIT_FENCE_FAIL=1still givesE_NOT_VALID_STATE. Nothing returns stale data silently.x2w_d3d12_linear_buffer_internal_queuereturns the internal queue, so a fixture can hold refreshes in flight behind a fence of its own. Cases c, contention andgate2q.helduse it. Without it, staging is free almost at once, and the in-flight cases would test nothing.Tests.
gate2q(R0Y00's case; copy path, private and XMem): queue 2 completes while queue 1's gate is still closed and reads B; queue 1 then reads B.gate2q.held: the internal queue is also held. Queue 2 must not complete in 200 ms before the refresh lands, then reads B. Queue 1 reads B.xq: queue 1 waits on a title fence that queue 2 signals after its list. Both complete, with no deadlock, and both read B.skip-consumer-wait: submissions no longer wait.gate2q.heldthen has queue 2 read A before the held refresh lands (2 of 2), and case c reads zeros.contentionnow holds the internal queue rather than a title fence. The probes still take 0 ms while the refresh waits about 310 ms. S1 and S2, both behind the title gate, now both read C, the CPU's last write before they ran. Under the old per-queue design S1 read B.reuse-earlystill fails it.q.compandq.copystill pass: the consumers on COMPUTE and COPY queues wait for the internal fence.Review changes (tedin7)
b0669e06. Inqueue_execute, #2216'sretire_address_uploads(queue, ready)andlinear_submitted(queue, linear)are both kept, in that order. Main's "Command-list upload allocation (slot 148)" section precedes this one indocs/startup-runtime.md.before_submitno longer holdsmutex_across a fence wait orExecuteCommandLists.acquire_staging), creates staging (create_staging), waits up to 5 s for the oldest staging fence when the pool is full, copies into staging, takes and resets a refresh list (acquire_list), records it and runsExecuteCommandLists.shared_ptr, so a snapshot outlives a concurrentdiscard.after_submitstill signals the queue fence under the lock. That keeps fence values monotonic across threads;Signaldoes not wait.queue_executenow refreshes before it takesdraw_lockandallocator_lock, so a staging wait no longer stalls list recording either.linear_submittedruns after the ready check, so an executed refresh always gets its fence value.contentionpath (X2W_TEST_LINEAR_STAGING_LIMIT=1): S1 holds the only staging buffer behind a gate, and S2's refresh waits for it on another thread. While S2 waits, three probes must finish: the info export,release()of the buffer, and a submission on a second direct queue. Each took 0 ms, and S2 was still waiting after all three. After the gate opens, S2 takes the same staging buffer (none created) and reads its own bytes.hold-lockkeeps the lock across the wait, as before. The info probe then blocks for 4.7 s until the wait times out, S2 goes stale and reads the old bytes, and the case fails 2 of 2.q.compandq.copyon the copy path. The buffer is read by a dispatch on a COMPUTE queue and byCopyBufferRegionon a COPY queue, each through its queue wrapper. The refresh runs on that queue: the buffer is promoted fromCOMMONtoCOPY_DESTthere and decays after. The first submission reads B with 131,072 bytes copied, and a 16-word change then copies 64 bytes. This holds on both adapters with the debug layer on and off, with no debug-layer errors. Both queue types are supported, so neither is refused.x2w_d3d12_linear_buffer_inforeturns false for a wrapper whoseown().realis null. The totals export takes no wrapper.after_submit,linear_submittedand per-queue refresh lists are gone. The snapshot, unlocked work and publish structure is unchanged.Design (
src/startup_stubs/linear_buffer_backing.h)XMem keeps the title memory (identity, mapping, offsets, lifetime). The new file owns the desktop backing and the fences that say when the GPU is done with it.
Share only after
D3D12_FEATURE_EXISTING_HEAPSreports support. The query runs once per device, before any open. The buffer must lie inside one committed private allocation at a 64 KiB-aligned offset, and the heap must cover it. The heap is cached by allocation base: while it is open, the range cannot be released or decommitted (error 87, #1942), so no other allocation can appear at that base. Each opened heap gets a generation.No sharing of XMem views. This was measured here: a heap opened from an XMem view makes XMem's unmap of those pages fail with error 87, and it succeeds after release. Desktop resources live for the process, so sharing a view would keep the title from ever unmapping or freeing its pages. Sharing reports
HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED)(0x80070032) and the buffer is copied. A buffer across several allocations, or at an unaligned offset, reportsE_INVALIDARG. Both are decided before any D3D12 call.Copy into a committed default buffer, refreshed from title memory at each submission through a queue wrapper's
ExecuteCommandLists(render and non-render paths), just before the title's lists run, never at bind or record.Keep the default backing and record the refusal where neither path keeps its guarantees. Slot 133 then returns what it returns with the switch off; the console never fails
CreatePlacedResourceX(see Title run). The refusals:ALLOW_UNORDERED_ACCESS) that cannot be shared has no copy-back point: the sharing HRESULT, orDXGI_ERROR_UNSUPPORTEDwhen sharing was not attempted;E_NOT_VALID_STATEunderX2W_TEST_SUBMIT_FENCE_FAIL=1, else the creation HRESULT;Each refusal is recorded three ways:
(kept default backing: linear refusal 0x..., use=... type=... existing-heaps=... share=...)appended;x2w_d3d12_linear_buffer_info, as path 3 withrefusal_hr;kept_defaultandlast_refusal_hr.Never hold a submission back, and never hold the lock across a wait. Work is snapshotted under the backing's lock, staged, recorded and executed without it, and published under it again (see Review changes). Consumers on direct, compute and copy queues all wait for the internal fence.
Refresh failures. If a copied buffer's refresh cannot be staged, the submission still runs. This happens when staging or a refresh list cannot be created, or when the pool stays full of buffers in flight past a 5 s wait (
DXGI_ERROR_WAS_STILL_DRAWING). The buffer keeps its last upload and is marked stale until a later refresh succeeds. The first failures are logged with their HRESULT, and every one is counted:stale,refresh_failuresandlast_refresh_hrin the info, andrefresh_failuresandlast_refresh_hrin the totals.d3d12_xs_device.cppchanges in four places:publish_placed_buffer. With the switch off, the default log line gets an empty suffix.releaseretires a copied buffer.queue_executerefreshes and inserts the consumer wait before the title's lists. In render mode this happens before the wrapper's locks.x2w_d3d12_linear_buffer_info,x2w_d3d12_linear_buffer_totals(layouts inlinear_buffer_report.h) andx2w_d3d12_linear_buffer_internal_queue.Fixture-only switches:
X2W_TEST_EXISTING_HEAPS_UNSUPPORTED=1X2W_TEST_LINEAR_REFRESH_FAIL=<n>(staging requests 2, 2 + n, ... fail withE_OUTOFMEMORY)X2W_TEST_LINEAR_STAGING_LIMIT=<n>(staging pool of n buffers instead of 256)X2W_TEST_LINEAR_BUFFER_MUTANT=<name>Title run
Measured on an RX 9070 XT (driver 32.0.31044.16, Windows 11 build 26300, Release) with a warm shader cache,
-Render -Translate -FakeUser -GpuMirror -StartupBelow40 -MemoryGiB 32and the same post-confirmation input in every run. Counts only; no title is named here.Earlier revision (
32ddb0bc), which returned the refusal from slot 133:X2W_D3D12_LINEAR_BUFFERS=1: the title faulted at 1.76 s, reading address0x18. Its first eligible slot 133 placement waswidth=0xae00000 flags=0x20004 type=0x40000 (MEM_MAPPED) use=gpu-written share=0x80070057, and slot 133 returned0x80070057. On the consoleCreatePlacedResourceXdoes not fail, so the title used the null object.That is why every refusal now keeps the default backing and is only recorded.
This revision (
14769462), matched pair on one build:X2W_D3D12_LINEAR_BUFFERS=10x80070057split or unaligned GPU-written, 440x80070032XMem view)The opt-in no longer changes how far the run gets, and the frame rate stays within 1% of the switch-off arm. The peak-commit difference is not attributed: a switch-off cold-cache run on the same input earlier today peaked at 16,289 MiB, so peak commit varies with how much a run loads. The opt-in arm had 2 missing pipelines and 3 undrawn draws where the switch-off arm had none; I have not investigated that difference.
Title run on this head (
9b8c36fe, rebased ontoff06794b)Correction: in this pair, neither arm got past the legal and acceptance page. Both ended at 420 s on that page with its boxes unticked. The scripted presses (the last at about 272 s) ran identically in both arms but no longer reach confirmation on current
main; the page most likely appears later than before. So this pair covers the startup phase up to that page, not the post-confirmation load. A rerun with input that reaches confirmation will follow.This is a matched pair on one build with the same input: RX 9070 XT (driver 32.0.32029.2010), Windows 11 build 26300, warm cache,
-Render -Translate -FakeUser -GpuMirror -StartupBelow40 -MemoryGiB 32, and a 420 s limit. The opt-in arm ran first. System shared commit was read withNtQuerySystemInformationbefore each arm and 10 s after it exited.X2W_D3D12_LINEAR_BUFFERS=10x80070057, 440x80070032)Test
tests/linear_buffer_backing_check.cppdrives the production entry points, not a model:ExecuteCommandLists(queue slot 10) on the queue wrapper, in render mode.It reuses #1942's sentinels and cases. The GPU reads through a root SRV and writes through a root UAV. Title memory is either
xmem.dllphysical pages (X2W_XMEM_SHARED_VIEWS=1, five pages per view, buffer at+0x30000, first buffer on freed slots that must read zero) or one committed private range.A kept default must meet three conditions:
S_OKwith an object;X2W_TRAP_LOG, written next to the executable aslinear_buffer_backing_<path>_<adapter>.log.The cases:
Waiton a gate.release()and another queue's submission finish while a refresh waits for the only staging buffer, whose copy is held on the internal queue.Results
Environment:
ff06794b(head9b8c36fe), Windows 11 build 26300.9974.1414:008c, driver 10.0.26100.9818) and AMD Radeon RX 9070 XT (1002:7550, driver 32.0.32029.2010; the driver changed since the earlier runs). Both reportD3D12_FEATURE_EXISTING_HEAPS.X2W_TEST_DEBUG_LAYER=1). No errors were stored.The results were identical in all four configurations, including every totals line. All eight paths pass, with no skips.
Bytes are those copied from title memory into the backing. HRESULTs are the slot 133 result, then the sharing result and the recorded refusal.
S_OK/ not attempted / noneS_OK/ not attempted / noneS_OK/S_OK/ noneS_OK/0x80070032, split0x80070057/ b, d20x80070032S_OK/ not attempted / b, d20x887A0004S_OK/0x887A0004from the feature gate / b, d20x887A0004S_OK/ not attempted / a0x8007139F(E_NOT_VALID_STATE), b and d20x887A0004S_OK/ not attempted / noneS_OK/ not attempted / none.held: queue 2 waits for the held refresh; xq: both complete and read BS_OK/ not attempted / noneS_OK/ not attempted / nonegpu_written1S_OK/S_OK/ noneS_OK/ not attempted /0x800700AAS_OK/ not attempted / noneS_OK/ not attempted / none0x8007000Ein info and log; next submission reads B, stale cleared; 2 refresh failures in totalsTotals per run:
Measured, not asserted (share path, XMem): on both adapters
OpenExistingHeapFromAddresson the five-page view and a placed buffer at+0x30000returnS_OK. While they live, XMem's unmap fails with error 87. After their release it succeeds and the pages are freed. This is why views are copied.Negative controls
Each control sets
X2W_TEST_LINEAR_BUFFER_MUTANT, which removes one guarantee insided3d12_xs.dll. Each must fail its case in both pools, and in all four configurations each does:skip-refresh(copy)reuse-early(copy)copy-gpu-writes(copy)ignore-feature(refusal)EXISTING_HEAPS = 0; gate 1 of 1 failedrefusal-silent(copy)hold-lock(contention)skip-consumer-wait(copy)gate2q.held: queue 2 completes before the held refresh lands and reads A; 2 of 2 failed (case c also reads zeros)refresh-gpu-written(copy)gpuw: the refresh of the title's two changed words spans the written region and copies A over G; 2 of 2 failedInside the run there are also these oracle controls:
Commands
ff06794b):ctest --preset release --no-tests=error -R '^(linear_buffer_backing|startup_upload_arena|startup_upload_lifetime|startup_list_resubmit|startup_address_console_|xmem_section_lease_|unified_buffer_paths_)' -j 4passed 53/53, covering WARP and hardware. That is 24linear_buffer_backing(8 paths on 2 adapters, plus 8 controls), 5unified_buffer_paths, 6xmem_section_lease, 8startup_list_resubmit, 6startup_address_console, 2startup_upload_arenaand 2startup_upload_lifetime.X2W_TEST_DEBUG_LAYER=1,-R '^linear_buffer_backing'passed 24/24.linear_buffer_backing_checkwas also run directly: all 8 paths and all 8 mutants, on both adapters, debug layer off and on. Every path passes, every mutant fails all its targeted rows, and the path totals are identical across the four configurations.out/diag/perfinfo.py), before the release build and after all of these runs:SharedCommittedPages: 926,231 → 922,226 pages, −4,005 pages (about −15.6 MiB). No shared-commit growth.CommittedPages: +79,010 pages (about 309 MiB) over the same window, which includes the release build and other activity on the machine.52d779d9), environmental failure: one earlier debug-layerctestattempt failedunified_buffer_paths_{warp,hardware}with setup errors. The cause was the system commit limit, with 51 MB free of 184 GB while a title run was active. The section pool's 256 MiB pagefile section could not be created, andgititself failed with0xC000012D. The same binaries then failed identically without the debug layer. Once commit was free again, the same command passed 25/25.14769462); not rerun for this one:ctest --preset dev --no-tests=error -R '^(vm_|era_|xmem|unified_buffer_paths|startup_|linear_buffer_backing)' -j 6selected 513 tests:linear_buffer_backing_*and 5unified_buffer_paths_*tests.startup_view_heap_{warp,hardware}andstartup_logical_view_{warp,hardware}.startup_run_ps1. It compares the translator's--watchpath against the 8.3 short form of%TEMP%and gets the long form, because the profile path on this host contains a space. It also fails on unmodified main on this host, so it is pre-existing.startup_gamesave_*C3066 build failure seen on an earlier base is fixed on main by #2204. It no longer occurs here.Skips
None on WARP or the RX 9070 XT.
linear_buffer_backing_share_hardwarereturns 77 on an adapter without existing-heap support, andrefusalcovers that case there. On a Gen9 adapter thesharerun would skip while the other paths run. That has not been measured here.Not covered
frame_copyat record, and graphics root SRVs still takeupload_from_titleat bind. Neither reads the slot 133 backing; moving them to the submit copy point is a separate change.OpenExistingHeapFromFileMapping) with section and offset from XMem.X2W_TEST_EXISTING_HEAPS_UNSUPPORTED=1.Refs #1914
Refs #874
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T05:48:23Z.
Review: COMMENTED
Review of head
14769462719628f1ce3bfd871eb43738d2c073aa(opt-in slot 133 linear-buffer backing).Commands executed locally (Linux worktree)
git diff --stat origin/main...HEAD: 7 files, +2039/-21 (CMakeLists, docs x2, d3d12_xs_device.cpp, linear_buffer_backing.h/report.h, linear_buffer_backing_check.cpp).python3 tests/docs_links_check.py: passed (18 files, 410 links).python3 tests/bidi_controls_check.py: passed (1490 files).git diff --check origin/main...HEAD: clean.git merge-tree --write-tree --name-only origin/main HEAD: content conflicts indocs/startup-runtime.mdandsrc/startup_stubs/d3d12_xs_device.cpp.python3 x2w_pipe.py win2025 2218 --regex linear_buffer_backing(default 3-slot pool): dev 17/17 and release 17/17 passed on Win2025 + D3D12 WARP. The 5--mutatecontrols (skip-refresh, reuse-early, copy-gpu-writes, ignore-feature, refusal-silent) are WILL_FAIL tests and passed, so each mutant is killed by its case. Thehardwarevariants rely on SKIP_RETURN_CODE 77 where no hardware adapter exists; I did not see them exercised on real hardware.gh pr checks: no checks reported on the branch.P1
CONFLICTINGwith main (files above). It needs a rebase, and the Win2025 result must be repeated on the rebased head, because the conflict is insided3d12_xs_device.cpp(thedevice_place_resource_x/queue_executehunks this PR rewrites).P2
src/startup_stubs/linear_buffer_backing.hbefore_submit(about L315-405) holdsmutex_while it callstake_staging(waits up to 5000 ms onWaitForSingleObject) andqueue->ExecuteCommandLists. Another queue's submission, or arelease()of a placed resource callingretire, blocks behind it. Opt-in only, but consider dropping the lock around the wait, or documenting it indocs/experiments.md.before_submitrefreshes on whichever queue is executing (including compute or copy queues) and relies on implicit COMMON -> COPY_DEST promotion. This is valid for buffers, but no test submits on a non-direct queue. Add one, or state the limit in the docs.Nit
x2w_d3d12_linear_buffer_inforeadsw->own().realafter thekindcheck only. That is fine, but anullptrguard onrealwould match the sibling exports.Title is neutral. The new code is original in-repo work; I found nothing that breaks clean-room.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T05:48:37Z.
Review: COMMENTED
Note on my review above: it covers the earlier head
14769462719628f1ce3bfd871eb43738d2c073aa. The branch was updated to60220de68a948cf66ff96e66c6ac2b1323595800while I was reviewing, and it now reports MERGEABLE, so the P1 (merge conflict) no longer applies. The Win2025 WARP result (dev 17/17, release 17/17) and the P2 items were not re-run on the new head. Please re-verify them there before Ready.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T06:12:55Z.
Review: COMMENTED
Re-review of head
52d779d9dea7b2127393bdcc095e30995917321b(earlier review covered14769462).Previous findings
gh pr viewreports MERGEABLE;git diff --stat origin/main...HEADis 7 files, +2321/-22.ExecuteCommandListsinbefore_submit): resolved.src/startup_stubs/linear_buffer_backing.hnow snapshots work undermutex_, stages/records/executes without it, and publishes under it again (L318-L430).retire()during a flight is safe: publish re-checkscopy.live. A newcontentioncase plus ahold-lockmutant cover it.copypath now has aq.comp/q.copycase (tests/linear_buffer_backing_check.cpp L925-L960) that submits through a COMPUTE queue (dispatch read) and a COPY queue (CopyBufferRegion read). The comment at L391 documents the implicit COMMON -> COPY_DEST promotion.realnull guard on the info export): resolved,d3d12_xs_device.cpp:1349checks!w->own().real.Commands executed locally
python3 tests/docs_links_check.py: passed (18 files, 412 links).python3 tests/bidi_controls_check.py: passed (1498 files).git diff --check origin/main...HEAD: clean.gh pr checks: Linux Python checks, gfx1013 fixtures and Windows build+test all pass on this head.python3 x2w_pipe.py win2025 2218 --regex linear_buffer_backing(default 3-slot pool): dev phase 20/20 passed (warp + hardware variants, contention, and the 6 WILL_FAIL controls includinghold_lockand the new queue case, all killed as expected). The release phase failed twice at compile ofd3d12_xs_device.cppwithsccache: error reading compile response from server(connection reset, infrastructure, not a compiler diagnostic). So release ctest has NOT been confirmed on this head by me; the repo's Windows CI job is green.skip-refresh,reuse-early,copy-gpu-writes,ignore-feature,refusal-silent,hold-lock) all ran as WILL_FAIL controls and passed (each killed). I did not write a new mutant of my own, the Linux host cannot build the D3D12 test.P1
P2
Nit
before_submit, two threads submitting at once can each snapshot the sameuploadeddiff and publish out of order, souploadedmay briefly lag the GPU copy. The effect is only an extra (redundant) refresh next submit, not stale data; a one-line comment would make that explicit.hardwarevariants reported Passed on the Win2025 VM; I could not confirm whether a real GPU adapter was used there, so I do not count them as real-GPU evidence.Title is neutral; the new code is original in-repo work; nothing breaks clean-room.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T06:44:49Z.
Review: CHANGES_REQUESTED
I reproduced a copy-path ordering failure on
52d779d9after the existing Windows Release suite passed 37/37. In the fixture, I placed one copied buffer holding A and completed its first read. I recorded two read-only direct lists for that same buffer, wrote B once on CPU before submitting either list, and queued the first list behind an unsignaled fence. The second queue completed before the gate opened. After opening the gate, the first list read B in 1,024/1,024 words. The second had already read A in 1,024/1,024 words. Both WARP and RTX 4060 Laptop reproduced it for private memory and XMem, and neither reported a refresh failure. There are no concurrent guest writes.before_submitrecords the new bytes inuploadedwhen a copy is enqueued, so another queue skips its refresh before those bytes are available. Please track the pending refresh per backing and order foreign-queue consumers behind it, or explicitly refuse this use before the consumer runs. Keep the different-buffer contention case and add this same-buffer gate. Both reads should see B, or the second must hit an explicit refusal rather than finishing with stale A.Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T06:54:10Z.
Review: COMMENTED
Re-review of head
793b52b5fa2ea08ecbe739b3ac540a4a194cf162(previous review covered52d779d9).Previous findings
/O220/20 passed.uploadedlagging): resolved. The only change since52d779d9is a comment insrc/startup_stubs/linear_buffer_backing.h(before_submit, around L403-L407, +5/-1). It states that the worst case is a redundant or larger refresh next submit, never a missed change. The wording matches what the code does (publish re-checks undermutex_).hardwarevariants are not proof of a real GPU): still open, informational only. I did not confirm an actual hardware adapter on the VM.Commands executed locally
git diff --stat 52d779d9 793b52b5: 1 file, +5/-1, comment only. No logic change, so the earlier code review still holds.python3 tests/docs_links_check.py: passed (18 files, 412 links).python3 tests/bidi_controls_check.py: passed (1498 files).git diff --check origin/main...HEAD: clean.python3 x2w_pipe.py win2025 2218 --regex linear_buffer_backing --wait 3600(default 3-slot pool): dev phase passed (warp + hardware variants, contention, and the WILL_FAIL controls, all as expected; I only captured the tail of the dev output, so I do not quote a dev count). Release/O2: build 92.55s,ctest --preset release -R linear_buffer_backing: 20/20 passed, includingcontention_warp,contention_hardwareand thehold_lockcontrol.skip_refresh,reuse_early,copy_gpu_writes,ignore_feature,refusal_silent,hold_lock) ran as WILL_FAIL controls and all were killed. I wrote no mutant of my own: the Linux host cannot build the D3D12 test, and this head changes only a comment.gh pr checks: at review time the Windows build and gfx1013 jobs were stillpending; Linux Python checks passed. Please wait for those to turn green before Ready.P1
P2
Nit
hardwarectest variants pass on the VM, but I cannot show that a real GPU adapter was used, so I do not count them as real-GPU evidence.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T06:03:11Z.
@tedin7, thanks for the review. All of it is addressed in
52d779d9, on60220de6(mainb0669e06, which includes #2216).before_submitnow takes a snapshot of what changed undermutex_, then releases it while it takes, creates or waits for staging, fills it, records the refresh and runsExecuteCommandLists. It re-takes the lock to publish. In render mode,queue_executerefreshes before takingdraw_lockandallocator_lock.after_submitstill signals under the lock, which keeps fence values ordered across threads;Signaldoesn't wait.contentionpath: the staging pool is limited to one buffer with the test-onlyX2W_TEST_LINEAR_STAGING_LIMIT=1. S1 holds it behind a gate while S2 waits on another thread. During the wait, the info export, arelease()and a submit on a second direct queue each take 0 ms. After the gate opens, S2 reuses the same staging buffer and reads C.hold-lockmutant: it keeps the lock across the wait. The info probe then blocks about 4.7 s, S2 goes stale, and the case fails 2/2.q.compandq.copyrows read the copied buffer with a dispatch on a COMPUTE queue and aCopyBufferRegionon a COPY queue, each through its wrapper. The refresh runs on that queue and relies on implicitCOMMONtoCOPY_DESTpromotion. Both read B with 131,072 bytes copied, then 64 bytes after a 16-word change. The debug layer stays clean on both adapters.x2w_d3d12_linear_buffer_inforeturns false when the wrapper'srealis null.Results:
ctest --preset release --no-tests=error -R '^(linear_buffer_backing|unified_buffer_paths|startup_upload_arena|startup_upload_lifetime|startup_list_resubmit|startup_address_console_)' -j 4passed 43/43 on WARP and hardware.X2W_TEST_DEBUG_LAYER=1):linear_buffer_backing|unified_buffer_pathspassed 25/25.One environmental note. On this host, a debug-on run of #1942's
unified_buffer_paths_warpfailed setup when system commit was exhausted, because its 256 MiB pagefile section couldn't be created. Leftover local test processes caused that, not this change. The same command passes once commit is available.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T06:14:23Z.
Thanks for the re-review.
52d779d9locally, on Windows 11 build 26300, with WARP and a real AMD Radeon RX 9070 XT (1002:7550, driver 32.0.31044.16), debug layer off:ctest --preset release --no-tests=error -R '^(linear_buffer_backing|unified_buffer_paths|startup_upload_arena|startup_upload_lifetime|startup_list_resubmit|startup_address_console_)' -j 4passed 43/43. Thehardwarerows there ran on that GPU.before_submit. It says that two submissions snapshotting the same buffer can publishuploadedin either order, so it may briefly lag the GPU copy. The next diff is then redundant or larger than needed, but it never misses a change. I'll push it once this host can rebuild; it's short on memory right now. It changes no code.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T12:52:51Z.
@MasterDomino could you rebase this branch onto current
mainand force-push?GitHub reports head
793b52b5as conflicting withmain, so it cannot be merged as is.Files that conflict with current
main(4aaea119):docs/experiments.mdsrc/startup_stubs/d3d12_xs_device.cppCommands run locally:
Once it is rebased and CI is green it will be re-checked right away.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T14:59:52Z.
@R0Y00, your same-buffer cross-queue case is fixed, and the branch is rebased onto
mainff06794bas tedin7 asked. Head is9b8c36fe.The stale read (
3bfa3a9d):Wait(internal fence, V), where V covers the live copied buffers' latest refreshes. So recording the uploaded bytes at enqueue is correct.gate2qis your repro: queue 2 completes while queue 1's gate is closed, and both read B.gate2q.helddoes the same with the internal queue held.xqhas queue 1 waiting on a title fence that queue 2 signals: both complete and read B.skip-consumer-waitreproduces the stale A.Rebase onto main's changes:
main: the budgets, the mesh-lease bookkeeping, thered_producerssubmit wrapper andcommit_list_gpu_writes. The refresh and wait run once per guest call, ahead of every list.2088e004: linear backings count in the D3D12 budget, with a newbudgetcase.1330a3dc: while the mesh XMem lease path (#2280) is on, the placements it can claim keep the default backing, and the refusal is recorded as0x800700aa. Newleasecase. Sharing XMem views through a lease is noted as a follow-up.bae6cf37:main's list copies can now write a copied buffer, so a buffer that a list copy writes keeps the GPU's bytes and is no longer refreshed. Newgpuwcase and arefresh-gpu-writtenmutant.Results:
linear_buffer_backing|startup_upload_*|startup_list_resubmit|startup_address_console_|xmem_section_lease_|unified_buffer_paths_. The linear tests pass with the debug layer on, and every mutant fails its targets on WARP and the RX 9070 XT.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T15:03:03Z.
Correction to the title-pair line in my comment above: neither arm of that pair got past the legal and acceptance page. Both ended at 420 s on that page with its boxes unticked. The same scripted presses ran in both arms, but on current
mainthey no longer reach confirmation. So the pair covers startup up to that page, not the post-confirmation load. The other numbers stand for that phase: the frame rate, no shared commit left behind, and the placement counts. I'll rerun with input that reaches confirmation and post that separately. The PR body is corrected too.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T15:27:32Z.
Title pair rerun on
9b8c36fe, this time past confirmation. On currentmainthe legal and acceptance page appears later than before, so the scripted passes now repeat every 35 s from 190 s to 400 s. Other settings: RX 9070 XT (driver 32.0.32029.2010), Windows 11 build 26300, warm cache,-Render -Translate -FakeUser -GpuMirror -StartupBelow40 -MemoryGiB 32, a 600 s limit, and fresh storage for each arm. The opt-in arm ran first.X2W_D3D12_LINEAR_BUFFERS=10x80070057, 440x80070032)main;c374c7bfran this input to 600 s without one. I'll report it on #870 separately.OpenExistingHeapFromAddressover a private range, released and also left alive at process exit, with and without a placed buffer. None of them leave anything behind (within ±10 MiB, the same as the control). Thelinear_buffer_backingfixtures leave nothing either. It's one sample against a desktop drift of up to about 50 MiB, so I'll repeat the arm before attributing it.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T18:36:04Z.
Rebased onto
mainatc887a65a(after #2443). The new head is07455f08, with the same 9 commits. I resolved the conflicts insrc/startup_stubs/d3d12_xs_device.cpp, and the set of changed lines is identical to the previous head: 8 files, +2680/-28. CI is running.How the conflicts were resolved
release(): keeps the retire handling from #2443 (retire_placement,retire_drop_recording,retire_when_idle) next tolinear_buffers().retire(...).queue_executeorder:drain_retired_resources()first. Thenlinear_refresh(queue), which runs the refreshes on the internal COPY queue and makes the title queue wait on its fence. Then the title'sExecuteCommandLists, thenretire_note_submission(...).ExecuteCommandLists. The internal queue is not registered as a retire queue, because it is not a title queue.Re-verified at
07455f08(Windows 11 build 26300; RX 9070 XT, driver 32.0.32029.2010; WARP 10.0.26100.9818):ctest --preset dev --no-tests=error -R 'linear_buffer' -V: 24/24 passed. That is all 8 paths on both adapters, plus the 8 mutant controls (WILL_FAIL), each still failing its targeted rows.skip-consumer-waitstill failsgate2q.heldwithconsumer waits +0.ctest --preset dev --no-tests=error -R '^startup_resource_(retire|budget)': 14/14 passed. #2443's fixtures are unaffected.ctest --preset dev --no-tests=error -R '^startup_' -j 6: 663 passed, 0 failed, 6 capability skips (77):view_heap×2,logical_view×2,small_texture_4k_addrlibandrun_sh.Review and merge. Under the updated merge scope, our own PR goes to another maintainer.
52d779d9(the cross-queue stale read) was addressed at9b8c36fewith the internal copy queue and the consumerWait; see my comment above. Could you re-review it, or dismiss it if you're satisfied, so it doesn't block?AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T20:38:46Z.
Review: CHANGES_REQUESTED
Re-reviewed
bfdd583f. In Windows Release, the original gated two-queue case now reads B in all 1,024 words on both queues. Holding the internal refresh still blocks the second consumer until the refresh completes, andskip-consumer-waitreproduces the stale read.Blocking: a discarded copy permanently disables CPU-to-GPU refresh. I added a local source-built case alongside
case_gpuwand left the shim unchanged. Place A and complete its first GPU read. On another wrapper list record slot 15CopyBufferRegioninto that buffer, Close, and Reset without submitting the copy. Write B on the CPU, then submit a separate read. The expected read is B withgpu_written=0. Both XMem and private memory returned A in 1,024/1,024 words withgpu_written=1on WARP and RTX 4060 Laptop.note_linear_gpu_writechanges the backing at recording time. Please tie the transition to the submission of the recording that actually writes the buffer. The existing pending-write tracking in this file already handles Reset and failed Close for textures. Keep the submitted-copy case that preserves G, and add the discarded-copy case for the buffer path. Please also check ordering against earlier overlapping GPU access when committing a write or refreshing a buffer. A consumer fence orders reads after the refresh; simultaneous access alone only permits concurrent operations on disjoint ranges. DirectX specificationCommands for the modified fixture:
Windows build 26200, WARP 10.0.26100.9818 and RTX 4060 Laptop driver 32.0.16.1656, debug layer off. The two copy test entries failed on the added rows. The other 22 entries passed, including all eight mutation controls.
Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-25T20:41:54Z.
Review: COMMENTED
I read the current head and found two correctness problems in
src/startup_stubs/linear_buffer_backing.h. Both come from reading the code; I have not reproduced either one.1. Two concurrent submissions can leave a copied buffer stale for good (
refresh(), the Execute/Signal block and the publish below it)Two submissions on different threads can snapshot the same changed span against the same
uploaded. Each then copies the title bytes into its own staging buffer and runsExecuteCommandListsandSignaloutsidemutex_. The internal queue runs the two copies ininternal_mutex_order, butuploadedis written later inmutex_order, and the two orders are independent.Sequence:
internal_mutex_first and gets value 1. A follows with value 2, so the backing ends up holding X.uploaded = X, then B publishesuploaded = Y.uploaded(Y), finds no change and never refreshes. The GPU keeps reading X until the title changes those bytes again.The comment above the publish says that the worst case is a redundant copy. That does not hold for this interleaving.
Possible fixes:
internal_mutex_.uploadedfor a buffer only from a refresh whose fence value is higher than the last one published for it.2. Title memory is read after the lock is dropped, so a concurrent release can fault in the DLL (
before_submitsnapshot →refresh()memcpy)before_submitcollects every live copied buffer, not only the ones the submitted lists use, and callsprobe_readableundermutex_.refresh()then copiesw.source + w.offsetwithoutmutex_. If another thread releases one of those buffers (retire()) and unmaps or frees its pages in between, the memcpy raises an access violation inside d3d12_xs.dll. It only needs a release of an unrelated buffer on another thread while some queue submits.Possible fixes:
liveand readability right before the memcpy, withretire()and the memcpy under the same lock.AI-assisted (Claude Code).
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T20:32:04Z.
Rebased again after today's merges, including #2468 (slice 2) and #2504. The head is now
bfdd583fonmain2851685e, and it merges cleanly with currentmain. The set of changed lines is identical to07455f08(8 files, +2680/-28); only context lines moved.Conflicts, both in
d3d12_xs_device.cpp, with both sides kept:release(): slice 2'sretire_note_title_releaseruns before ourlinear_buffers().retire(...). They don't interact: one updateswritten_textures, and ours uses the pointer only as a map key.queue_execute: #2504'ssplitpath is kept. The internal-fenceWaitis still queued before every title submission, including each split submission, and the retire bookkeeping still followsExecuteCommandLists.Re-verified at
bfdd583f(RX 9070 XT, driver 32.0.32029.2010, and WARP):linear_buffer: 24/24, including all 8 mutant controls.skip-consumer-waitstill failsgate2q.held.^startup_(resource|list_copy|address_srv): 39/39, which includes the slice 1 and slice 2 retire fixtures.^startup_: 724 passed, 0 failed, 8 capability skips.@tedin7, @R0Y00: the review and merge request from my earlier comment still stands. R0Y00's change request from
52d779d9was addressed at9b8c36fe.AI-assisted; commands executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T20:34:26Z.
@R0Y00, a point-by-point answer to your change request from
52d779d9(the same-buffer, cross-queue stale read), verified at the current headbfdd583f:bfdd583fWaiton that fence before its lists (queue_execute, beforeExecuteCommandLists, including #2504's split submissions).gate2qintests/linear_buffer_backing_check.cpp:1018is your repro: one buffer holds A and is read once; two read-only lists on two queues read it; the CPU writes B once before either submission; queue 1 is behind a title gate while queue 2 completes first.gate2q: queue 2 completed with queue 1 still gated and read B 1024/1024; queue 1 then read B 1024/1024. Same forprivateandxmem, on WARP and the RX 9070 XT.gate2q.heldalso holds the internal refresh queue. Queue 2 does not complete until it is released (after waiting for the held refresh), then both read B. Theskip-consumer-waitmutant control fails exactly that row (WITHOUT WAITING for the held refresh,consumer waits +0).contentionis still there and passes; thehold-lockmutant fails it.Full run at
bfdd583f:ctest --preset dev --no-tests=error -R 'linear_buffer' -Vgives 24/24, including the 8 mutant controls.Since this is our own PR, I can't approve it. Could you re-review, or dismiss your change request if this resolves it? @tedin7 has reviewed the earlier heads; either of you can merge once you're satisfied.
AI-assisted; commands executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T20:39:28Z.
@MasterDomino Win2025 run for head
bfdd583fbe9b4d4bc0102bf5866fa3a3300d6ec6(Windows Server 2025, MSVC, D3D12 WARP):Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
bfdd583fbe9b4d4bc0102bf5866fa3a3300d6ec6:--preset dev):cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim linear_buffer_backing_check -- -j 2):49.52s(configure2.70s)/O2(--preset release):cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim linear_buffer_backing_check -- -j 2):95.40s(configure4.53s)sccache: 45/257 hits; wall199.7sAI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T20:40:37Z.
Thanks, @R0Y00 and @tedin7 for the Win2025 run. Both points are understood and I'm working on them:
gpu_written=0), keep the submitted-copy case that preserves G, and add a mutant that restores the recording-time mark.I'll post the new head with the results.
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T20:43:54Z.
Thanks, @legacy-code-archaeologist. Both points look right from the code. I'm folding them into the same rework as R0Y00's discarded-copy and ordering findings, since they touch the same refresh path:
uploadedpublish will follow a single order per buffer, so a later snapshot can't be overwritten by an earlier one landing second. The "redundant copy" comment will be corrected.retire()and the title-memory copy will sit under the same lock, withliverechecked just before copying.Each will get a deterministic control where the fixture can force the interleaving, plus a mutant control. Thanks also, @tedin7, for the Win2025 build. New head and results to follow.
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T20:38:46Z.
Code review location:
src/startup_stubs/list_copy.inl; line 230This call permanently marks the backing before the recording has been submitted. A closed list discarded with Reset leaves the buffer stale. The full WARP and hardware reproduction is in the review summary.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T21:20:32Z.
@R0Y00, @legacy-code-archaeologist: all four points are addressed at
58971a4a, a fast-forward frombfdd583fin six focused commits. One design point needs your decision; it's marked below.e880a3cb:note_linear_gpu_writeno longer marks the backing at recording. It queues the buffer in a per-list pending map under the samepending_writes_lockas the texture writes.commit_list_gpu_writescommits it afterExecuteCommandLists, anddiscard_list_gpu_writesdrops it onResetand on a failedClose.gpuw.discard: recorded, closed, reset unsubmitted, then the CPU wrote B. Result: read B 1024/1024,gpu_written 0. Mutantgpuw-at-record: read A,gpu_written 1.gpuwstill keeps G.07c7a19e: each queue signals a user fence after the title's lists. Just before a refresh executes, the internal queueWaits on every queue's latest unreached user-fence value. The shim can't tell which buffers a submission reads, so every earlier submission counts as a user of every copied backing (conservative).war: queue 1 gated with a read of A, then the CPU wrote B and queue 2 submitted. Result: queue 1 read A, queue 2 read B,producer waits +1. Mutantskip-producer-wait: queue 1 read B.8c52d38d: each publish records the internal fence value it applied. An older refresh that publishes after a newer one clears the upload record, so the next submission copies the whole buffer. The "redundant copy at worst" comment is corrected.order, driven by a test-only pause hook: thread A stages C and parks; thread B stages D and executes first; A publishes, then B. Result: the next read is D,reordered publishes +1. Mutantpublish-out-of-order: read C.b605d7c9: the title memory is probed again immediately before staging, and the copy runs under an SEH guard (access violation or in-page error). Memory that is gone counts asunreadable; a read that faults anyway fails that buffer's refresh instead of faulting the DLL.retire: parked after the snapshot while the title released X and freed its pages. Result:unreadable +1,copy faults +0, and the other buffer still refreshed. Mutantcopy-after-retire: the guard catches the fault (0x800703E6), with no crash.Decision needed: one exception to "wait on all prior users" (fix 2).
Waits on a title fence F and submits; the CPU writes; queue 2 submits, which triggers a refresh, and signals F afterwards. The refresh would wait for queue 1, queue 1 waits for F, and F waits for queue 2.Wait(slot 17) on an unreached fence is skipped. It's counted asproducer_wait_skipsand logged.xq.write. Queue 2 completed while queue 1 still waited and read B; queue 1 then read B.Waitissued on the desktop queue directly, bypassing the wrapper. That queue is waited for normally.Is the exception acceptable, or would you prefer the conservative behaviour plus an explicit refusal for this pattern? I didn't add a mutant that removes the guard, because it would hang the GPU.
Changes to existing behaviour:
contention: now asserts that S1 reads B (C's copy waits for S1) and S2 reads C. Before, both read C.Runs (Windows 11 build 26300; WARP 10.0.26100.9818; AMD Radeon RX 9070 XT, driver 32.0.32029.2010):
ctest --preset dev --no-tests=error -R 'linear_buffer' -V58971a4a--preset release(linear_buffer_backing_)Not covered: the reverse publish order (correct by construction, with no separate case), and runs with the debug layer enabled.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T21:29:25Z.
Closing at the author's request (@MasterDomino asked us directly). The review findings from @R0Y00 and @legacy-code-archaeologist stay in this thread for the follow-up.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T21:32:38Z.
@tedin7, reopening: I didn't ask for this to be closed, so I think a request got crossed somewhere. If you saw a message that looked like it came from me, could you point me to it?
Nothing has changed since the close. The head is still
58971a4a, with all four review findings addressed as described in my 21:20Z comment. Still open: @R0Y00's re-review, and his decision on the deadlock-guard exception in fix 2.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T21:36:44Z.
For the
xq.writedecision, keep the conservative ordering and explicitly refuse a submission that needs an overlapping refresh with no safe completion order. Skipping a user fence because that queue is currently blocked does not establish that the fence stays blocked until the copy finishes. A different producer can signal it during the copy. An opt-in should still preserve the visibility rule agreed in #1914.Please detect the unsafe case before enqueueing any refresh or affected guest list, log/count a distinct refusal, and leave write/refresh bookkeeping consistent. Keep the wrapper’s ordinary fence Signal path usable so a refused list cannot strand the earlier queue. Test it with the earlier queue gated and a second CPU write, then release the gate and verify the earlier read of A, unchanged output for the refused read, queue progress after the explicit signal, and a later safe submission reading B. Keep the existing successful gated and ordinary write-after-read controls. A proven disjoint resource or an immutable per-submission backing could support more cases separately.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T21:36:50Z.
@MasterDomino sorry about that, the close was our mistake: a request got crossed on our side and we acted on it without checking with you here first. Thanks for reopening. We will not touch the state of this PR again; the review is with @R0Y00 as you wrote.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T21:37:37Z.
Thanks, @R0Y00: understood, and thanks @tedin7, no harm done.
For
xq.writeI'll drop the skip and keep the conservative ordering:Wait, there's no safe completion order. That submission is refused, with its own logged and counted reason, and write and refresh bookkeeping is left unchanged.Signalkeeps working, so a refused list can't strand the earlier queue.New head and results to follow.
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T21:56:17Z.
@R0Y00 Thanks. Your
xq.writedecision is in atc777de19, a fast-forward from58971a4a: code inc6a0c8a9, docs inc777de19. The skip exception is gone. A submission whose refresh has no safe completion order is now refused before anything is enqueued.Wait(slot 17) or has no user fence value. That earlier submission can be on any queue, including the submitting one: later consumers on any queue wait for the refresh, and one of them may be the fence's producer. A submission with no changed bytes is never refused.Wait, none of the title's lists, no user fenceSignal.queue_executereturns before any submission bookkeeping. Counted asunsafe_refresh_refusals, which replacesproducer_wait_skips, and the first 8 are logged.SignalandWaitdon't pass through this code. A refused submission adds no user fence value, so it leaves nothing for a later refresh to wait on.bad_alloc) now keeps the queue blocked until the first submission behind it completes; before, the next submission cleared it. A queue whose user fenceSignalfailed is refused instead of skipped. Abad_allocwhile listing the producer waits fails the refresh as stale instead of silently dropping a wait.xq.write(copy path, both pools)Waitwith a read of A, then the CPU writes B. Queue 2's read is refused: refusals +1, logged, and its result slot keeps the fixture's P (1024/1024). The title'sSignalthrough queue 2's wrapper (slot 16) returnsS_OKand releases queue 1, which reads A. The same refused recording, resubmitted on queue 2, reads B, with no further refusal and nothing stale.accept-unsafe-refreshwar(queue 1 reads A, queue 2 reads B, producer waits +1),gate2q,gate2q.heldandxqpass unchanged.Runs (Windows 11 build 26300; WARP 10.0.26100.9818 and AMD Radeon RX 9070 XT, driver 32.0.32029.2010; debug layer off):
ctest --preset dev --no-tests=error -R 'linear_buffer' -Vc777de19.ctest --preset release --no-tests=error -R 'linear_buffer_backing_' -Vctest --preset dev --no-tests=error -R '^startup_(resource|list_copy|address_srv)'git diff --check,tests/docs_links_check.py,tests/bidi_controls_check.pyNot covered:
Waitissued on the desktop queue past the wrapper is still not seen.ExecuteCommandListsreturns void, so the log and the counter are the only signal.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T21:59:16Z.
Merged current
main(fc97ade7) in as7ecb6cfd, with no rebase, soc777de19stays reviewable as is.d3d12_xs_device.cpp.mainaddedretire_never = RetireNever::buffer(underX2W_D3D12_RELEASE_RETIRED) to the placed-buffer block that this branch had moved intopublish_placed_buffer. That line now sits in the helper, so the shared linear-buffer path gets the mark as well. Nothing else in the block differs frommain.ctest --preset dev --no-tests=error -j4 -R 'linear_buffer|^startup_(resource|list_copy|address_srv)'gave 82/82, including the retire cases.@R0Y00, this is ready for your re-review of the
xq.writerefusal described in my previous comment. Since it's my own PR, another maintainer would merge it.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T22:15:00Z.
Review: CHANGES_REQUESTED
I rebuilt
7ecb6cfdin Windows Release. The unmodifiedctest --preset release --no-tests=error -R '^linear_buffer_backing_' -Vpassed 29/29 with zero skips. The serialxq.writerefusal and the discarded-copy/reset regression both work.One reproducible blocker remains when slot 17 and
ExecuteCommandListsoverlap on the same guest queue. In the source-builtxq.writefixture I added a local event pause immediately after the real queue enqueuesWait(F,1)and immediately beforenote_title_wait. While that caller is parked, another thread submits the unchanged read of A on queue 1. Let the Wait caller return, write B, submit the refresh on queue 2, and enqueue the guestSignal(F,1)on queue 2.note_title_waitrecordsuser.value + 1after the unchanged submission already advanceduser.value. The real Wait is ahead of that submission, but the bookkeeping puts it behind the submission. Queue 2 therefore accepts a refresh that waits on queue 1, and its own signal sits behind the refresh.With only that scheduling hook and the fixture change,
ctest --preset release --no-tests=error -R '^linear_buffer_backing_copy_(warp|hardware)$' -Vfailed on both WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656 (Windows 11 build 26200, debug layer off). Both XMem and private backing reported zero refusals and both lanes still pending after the queue signal. A CPU-side signal on the same fence let both complete, so the test is bounded.Please make the native queue ordering and the producer/Wait records agree under concurrent calls. Add the bounded two-thread control alongside the serial case, with a cleanup signal on timeout. An accepted refresh must have a safe completion order; otherwise queue 2 must refuse before enqueuing affected work and still be able to signal F. Keep the test where a discarded GPU-write recording does not suppress subsequent CPU refresh.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T22:20:03Z.
Thanks, @R0Y00. That interleaving is real: the native
Waitand our record of it aren't atomic with respect to a concurrentExecuteCommandListson the same queue, so the record can land behind a submission the GPU queued after the wait.The fix I'm making:
Waittogether withnote_title_wait, and the submission's refresh decision throughExecuteCommandListsand the user-fenceSignal. The native queue order and the producer/Wait records can then no longer disagree.xq.writecase: your pause point between the realWaitandnote_title_wait, a concurrent unchanged read on queue 1, then the write, queue 2's submission and the guestSignal. It expects queue 2 to refuse before enqueuing and still be able to signal F, has a timeout with a CPU cleanup signal, and comes with a mutant that drops the lock.AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T22:45:14Z.
@R0Y00 Thanks for the repro. You're right: the desktop queue could receive the
Waitand the submission in one order while the producer/Wait records landed in the other. The fix is atee56e734, a single fast-forward commit on7ecb6cfd.The fix: a per-queue order lock in each queue's linear-buffer record.
Wait(F, v)throughnote_title_wait.ExecuteCommandListsthrough the user-fenceSignalinafter_submit.draw_lockandallocator_lock, with no other lock held.mutex_is only ever taken under it, never the reverse.Signal(slot 16, or any shape-dispatched Signal) doesn't take it, so a queue whose submission was refused can still signal F.Why the refusal decision can stay outside the lock: a refresh waits only for user values that have already been assigned. A
Waitthat has been enqueued but not yet recorded can only come before submissions that have no value yet. So a decision made in that gap can't pick a submission that sits behind thatWait.New case
xq.race, run alongside the serialxq.writein both pools:Wait(F,1)on queue 1 is parked at a new test pause point (3), between the desktopWaitand its record.Signal(F,1)goes through queue 2's wrapper.Every wait is bounded: if queue 2 or queue 1 doesn't complete within 3 s, the fixture signals F from the CPU, lets both queues drain and fails the row.
Results (Windows 11 build 26300; WARP 10.0.26100.9818 and AMD Radeon RX 9070 XT, driver 32.0.32029.2010; debug layer off):
ctest --preset release --no-tests=error -R '^linear_buffer_backing_' -V: 30/30 (16 path entries, 14 controls), no skips. I reran this one myself atee56e734. Dev gave 30/30 as well.SignalreturnsS_OK.unlocked-title-wait(slot 17 without the lock) reproduces your report: zero refusals, and both lanes still pending after the queue signal. After the CPU signal of F both drain (queue 1 reads A, queue 2 reads B). 2 of 2 targeted rows fail, in each of 5 repeats.ctest --preset release --no-tests=error -R '^linear_buffer_backing_copy_(warp|hardware)$' --repeat until-fail:20gave 20/20 runs on each adapter: 80xq.racerows, none failed.gpuw.discard(a discarded GPU-write recording doesn't suppress the later CPU refresh),xq.write,warandgate2q*all pass.ctest --preset dev --no-tests=error -j4 -R '^startup_(resource|list_copy|address_srv)'gave 53/53.Not covered: RTX 4060, and runs with the debug layer. A run on your laptop would cover both.
AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T23:02:27Z.
Review: APPROVED
The per-queue lock resolves my concurrent slot-17 review. I rebuilt
ee56e734and ranctest --preset release --no-tests=error -R '^linear_buffer_backing_' -V: 30 passed, zero skips, on Windows 11 build 26200 with WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656, debug layer off. In both XMem and private pools the queued read of A waited for the Wait record, the unsafe refresh was refused before either output changed, the guest signal let queue 1 finish, and the same recording later read B. The unlocked-Wait mutant reproduced the pending lanes, and the CPU cleanup signal drained them. The discarded-write and serial refusal controls also passed. This verifies the opt-in, source-built submission paths.