gpu: back slot 133 linear buffers by sharing or a submit-time copy (opt-in) #2210

Merged
MasterDomino merged 19 commits from upstream-pr/2218 into main 2026-11-25 23:02:55 +00:00
MasterDomino commented 2026-11-25 05:42:09 +00:00 (Migrated from github.com)

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 state COMMON. This is the narrowest production kind that is linear, CPU-written and GPU-read:

  • Its desktop backing is what production GPU work actually reads: ExecuteIndirect argument and index buffers, alias SRVs in translated draws, and desktop views.
  • Today it is silently wrong outside private memory. Over XMem pages, or on an adapter without existing heaps (the Gen9 row), slot 133 returns S_OK with a zero-filled buffer that does not alias the title memory.

Buffers in UNORDERED_ACCESS or acceleration-structure state, textures and command-list slot 148 keep their current paths.

X2W_D3D12_LINEAR_BUFFERS=1 (or =copy) opts in. Unset or 0, none of the new code runs.

Rebase onto main (ff06794b) and follow-ups

The branch is rebased onto ff06794b as a series. Main had changed slot 133, release() and queue_execute substantially.

Integration with main:

  • release(): main's budget end_use calls, drop_mesh_lease_owner and the list-kind discard_mesh_lease_recording are kept. The linear retire runs after retire_placement, under the opt-in.
  • queue_execute: main's submit lambda (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 consumer Wait run 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 fences red_producers adds and each split mesh submission, and leaves red_producers semantics as they are.
  • Slot 133 publish: publish_placed_buffer carries main's tail: the index_resource callback in publish_placement, x2w_budget::resource(..., placed) plus the heap's backing_budget with begin_use when aliased, and x2w_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:

  • Budgets (gpu: count linear-buffer backings in the D3D12 budget).
    • A shared buffer counts as placed memory, and its heap (opened once per private range) gets a backing-heap ticket that is in use while a buffer on it is held.
    • A copied buffer counts as a committed DEFAULT buffer.
    • Staging buffers count as upload memory when created; they live for the process.
    • New fixture case 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.
  • No double ownership with the XMem lease path (gpu: defer slot 133 linear buffers to the XMem lease path).
    • #2280's mesh lease path (X2W_MESH86_XMEM_SRV or X2W_MESH_INDIRECT_XMEM) takes the default copied placements of XMem pages whose console flags are 0. note_mesh_xmem_write requires Placement::copied_buffer and console.Flags == NONE, then mirrors GPU writes into a leased view and publishes it to mesh readers.
    • Those are exactly the GPU-read XMem buffers the linear copy path would back, so both could claim one placement.
    • While the lease path is on, slot 133 now keeps the default backing for such a placement and records 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.
    • New fixture path lease: the XMem buffer keeps the default backing (reads zero, as before) with the deferral reported, and a private one is still copied.
  • Buffers a list copy writes (gpu: stop refreshing a copied linear buffer that a list copy writes).
    • Main now forwards CopyBufferRegion and CopyResource into 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.
    • Such a buffer now keeps the GPU's bytes from the recording on and is no longer refreshed, as the default backing behaves. It is reported as gpu_written in the info and totals.
    • New case gpuw (copy path): a list CopyBufferRegion writes G, the title changes the words on both sides, and the read still sees G.
    • New mutant refresh-gpu-written keeps refreshing; it reads A instead, and fails 2 of 2.
  • Docs for all of the above.

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 uploaded was updated at enqueue. Queue 2's diff therefore saw no change and skipped its refresh.

Fix (src/startup_stubs/linear_buffer_backing.h):

  • One internal COPY queue per device runs every refresh. It never waits on a title fence. Each refresh (staging → backing) is executed there and signals an internal fence value V. Each copied buffer remembers the V of its last refresh. ExecuteCommandLists and Signal on 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 or ExecuteCommandLists.
  • Every consumer orders behind pending refreshes. Every submission through a queue wrapper, of any type, first makes its queue 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. Recording uploaded at enqueue is now correct, because every later consumer waits for the copy to land.
  • No title queue ever waits on another title queue. A refresh never sits behind the title's own waits, so title-owned cross-queue fences (queue 1 waits on a fence that queue 2 signals after its lists) cannot form a cycle with it.
  • Staging reuse is gated on the internal fence. Only the copy reads staging, so title fences don't matter. after_submit, the per-title-queue fences and linear_submitted are gone.
  • Simultaneous access. The internal queue may write a backing while an earlier submission that reads it still waits on its queue. Buffers allow simultaneous access across queues, so this is valid D3D12. It is also what unified memory does on the console: a read that executes later sees the CPU's latest writes. This rationale is now in the header and in docs/startup-runtime.md.
  • Fallback. If the internal queue or its fence cannot be created, copied placements keep the default backing and record that HRESULT in the log line, the info and the totals. X2W_TEST_SUBMIT_FENCE_FAIL=1 still gives E_NOT_VALID_STATE. Nothing returns stale data silently.
  • Fixture seam. x2w_d3d12_linear_buffer_internal_queue returns the internal queue, so a fixture can hold refreshes in flight behind a fence of its own. Cases c, contention and gate2q.held use 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.
  • Mutant skip-consumer-wait: submissions no longer wait. gate2q.held then has queue 2 read A before the held refresh lands (2 of 2), and case c reads zeros.
  • Kept and adapted:
    • contention now 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.
    • Case c holds the internal queue on the copy paths, so reuse-early still fails it.
    • q.comp and q.copy still pass: the consumers on COMPUTE and COPY queues wait for the internal fence.
  • Fixture capacity: the private pool grows from 4 to 8 MiB for the extra allocations.

Review changes (tedin7)

  • P1, merge conflict: resolved by the rebase onto b0669e06. In queue_execute, #2216's retire_address_uploads(queue, ready) and linear_submitted(queue, linear) are both kept, in that order. Main's "Command-list upload allocation (slot 148)" section precedes this one in docs/startup-runtime.md.
  • P2, the lock: before_submit no longer holds mutex_ across a fence wait or ExecuteCommandLists.
    • Under the lock it snapshots the work: which buffers changed and which span of each.
    • Without the lock it takes staging (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 runs ExecuteCommandLists.
    • Under the lock again it publishes the results: the uploaded bytes and counters, the staging the submission holds, or a stale mark for each buffer whose staging failed.
    • Copied state is held by shared_ptr, so a snapshot outlives a concurrent discard.
    • after_submit still signals the queue fence under the lock. That keeps fence values monotonic across threads; Signal does not wait.
    • The guarantees are unchanged: a staging buffer is chosen only when its fence has completed or it is new; the refresh still happens at submit; a failed staging still marks the buffer stale and the submission still runs.
    • In render mode, queue_execute now refreshes before it takes draw_lock and allocator_lock, so a staging wait no longer stalls list recording either. linear_submitted runs after the ready check, so an executed refresh always gets its fence value.
    • New contention path (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.
    • New mutant hold-lock keeps 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.
    • A second queue's submission that needs a refresh of its own still waits when the pool is full. That is a wait for a staging buffer, not for the lock, so the probe submission refreshes nothing.
  • P2, non-direct queues: new rows q.comp and q.copy on the copy path. The buffer is read by a dispatch on a COMPUTE queue and by CopyBufferRegion on a COPY queue, each through its queue wrapper. The refresh runs on that queue: the buffer is promoted from COMMON to COPY_DEST there 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.
  • Nit: x2w_d3d12_linear_buffer_info returns false for a wrapper whose own().real is null. The totals export takes no wrapper.
  • Superseded by R0Y00's review: refreshes moved to the internal queue, so after_submit, linear_submitted and 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_HEAPS reports 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, reports E_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.

    • Only bytes that changed since the last upload are copied, through upload staging buffers.
    • The copy runs on the internal COPY queue (see Review changes (R0Y00)), and each submission waits for the pending refreshes of live copied buffers.
    • A staging buffer is reused only after its copy's internal fence value has completed.
  • 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:

    • a GPU-written use (ALLOW_UNORDERED_ACCESS) that cannot be shared has no copy-back point: the sharing HRESULT, or DXGI_ERROR_UNSUPPORTED when sharing was not attempted;
    • no internal refresh queue or fence: E_NOT_VALID_STATE under X2W_TEST_SUBMIT_FENCE_FAIL=1, else the creation HRESULT;
    • the copy's default buffer cannot be created: that HRESULT.

    Each refusal is recorded three ways:

    • the slot 133 log line, with (kept default backing: linear refusal 0x..., use=... type=... existing-heaps=... share=...) appended;
    • x2w_d3d12_linear_buffer_info, as path 3 with refusal_hr;
    • the totals, as kept_default and last_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_failures and last_refresh_hr in the info, and refresh_failures and last_refresh_hr in the totals.

d3d12_xs_device.cpp changes in four places:

  • slot 133 takes the new path for the eligible kind, and otherwise falls through to the unchanged default code. The wrap and publish tail moves unchanged into publish_placed_buffer. With the switch off, the default log line gets an empty suffix.
  • release retires a copied buffer.
  • queue_execute refreshes and inserts the consumer wait before the title's lists. In render mode this happens before the wrapper's locks.
  • three fixture exports: x2w_d3d12_linear_buffer_info, x2w_d3d12_linear_buffer_totals (layouts in linear_buffer_report.h) and x2w_d3d12_linear_buffer_internal_queue.

Fixture-only switches:

  • X2W_TEST_EXISTING_HEAPS_UNSUPPORTED=1
  • X2W_TEST_LINEAR_REFRESH_FAIL=<n> (staging requests 2, 2 + n, ... fail with E_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 32 and 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:

  • Switch off: unchanged behaviour. The run stopped at 294 s at the slot 148 builder.
  • X2W_D3D12_LINEAR_BUFFERS=1: the title faulted at 1.76 s, reading address 0x18. Its first eligible slot 133 placement was width=0xae00000 flags=0x20004 type=0x40000 (MEM_MAPPED) use=gpu-written share=0x80070057, and slot 133 returned 0x80070057. On the console CreatePlacedResourceX does not fail, so the title used the null object.
  • Slot 133 mix in the switch-off run (count, size, default outcome):
    • 2,987 GPU-read buffers, 14.2 MiB, not aliased;
    • 506 GPU-written buffers, 856 MiB, not aliased;
    • 61 GPU-written buffers, 167 MiB, aliased (private).

That is why every refusal now keeps the default backing and is only recorded.

This revision (14769462), matched pair on one build:

Switch off X2W_D3D12_LINEAR_BUFFERS=1
End slot 148 builder stop at 290.1 s slot 148 builder stop at 294.1 s (same stop)
Frames presented in 285 s 8,487 (29.8 fps) 8,451 (29.6 fps)
Executes / translated draws (not drawn) 8,400 / 256,460 (0) 8,400 / 256,265 (3)
Pipelines translated / missing 18 / 0 18 / 2
Slot 133 linear-buffer placements default path 3,094 copied at submit, 64 shared, 507 kept the default backing with the refusal recorded (463 0x80070057 split or unaligned GPU-written, 44 0x80070032 XMem view)
Refresh failures (stale) n/a none logged
Peak commit 12,056 MiB 16,479 MiB

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 onto ff06794b)

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 with NtQuerySystemInformation before each arm and 10 s after it exited.

X2W_D3D12_LINEAR_BUFFERS=1 Switch off
End 420 s limit, no stop 420 s limit, no stop
Frames 11,787 in 411 s (28.7 fps) 11,456 in 413 s (27.8 fps)
Executes 11,700 11,400
Pipelines translated / missing 11 / 3 14 / 0
Translated draws (not drawn) 382,346 (27,004) 409,670 (0)
Slot 133 linear buffers 2,848 copied at submit, 56 shared, 496 kept the default backing with the refusal recorded (452 0x80070057, 44 0x80070032) default path
Shared commit before → after 3.55 → 3.53 GiB 3.53 → 3.64 GiB
  • Frame rate: the internal-queue refresh and the consumer waits cost no measurable frame rate.
  • Shared commit: the opt-in arm left none behind.
  • Pipelines: the opt-in arm's 3 missing pipelines and 27,004 undrawn draws are most likely ordering. It ran first, so it translated new pipelines that the switch-off arm then found in the cache. I haven't verified that.

Test

tests/linear_buffer_backing_check.cpp drives the production entry points, not a model:

  • slot 133 on the device wrapper;
  • list Reset (139) and Close (9) on wrapper lists recorded on their desktop lists;
  • 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.dll physical 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:

  • return S_OK with an object;
  • behave as before: an XMem view not aliased, a private range aliased on an adapter with existing heaps;
  • carry the refusal HRESULT in the info, the totals and its own slot 133 log line. The fixture reads that line back from X2W_TRAP_LOG, written next to the executable as linear_buffer_backing_<path>_<adapter>.log.

The cases:

  • a, a2: A to B before submit, then a 16-word change that must copy 64 bytes.
  • b: GPU write, fence, alias readback.
  • c: three held submissions, then backing reuse only after completion.
  • d1: missing refresh, by executing past the wrapper.
  • d2: readback before the fence, ordered by a queue Wait on a gate.
  • split, gate, off: a buffer across two XMem views; no heap open when the feature query reports no support; no linear-buffer code with the switch off.
  • kept: the kept-default total equals the number of refusals.
  • stale: a failed refresh still runs and completes, reads the last upload and is reported stale; the next refresh clears it.
  • q.comp, q.copy: the refresh on a COMPUTE and a COPY queue.
  • contention: the info export, release() and another queue's submission finish while a refresh waits for the only staging buffer, whose copy is held on the internal queue.
  • gate2q, gate2q.held, xq: one buffer read on two queues after one CPU write: both see it, also with the refresh held, and with a title-owned cross-queue fence (no deadlock).

Results

Environment:

  • Commit: the series on ff06794b (head 9b8c36fe), Windows 11 build 26300.9974.
  • Adapters: in-box WARP (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 report D3D12_FEATURE_EXISTING_HEAPS.
  • Debug layer off and on (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.

Path Pool Backing Slot 133 / sharing / refusal Bytes copied Results
default XMem committed buffer, not aliased (old behaviour) S_OK / not attempted / none 0 a reads zero in all words; b leaves P (asserted as before)
default private aliased through the cached heap (old behaviour) S_OK / not attempted / none 0 a B; b G ^ key; totals all zero (no linear-buffer code ran)
real sharing private title memory, 1 heap open, 7 cache hits, generation 1 S_OK / S_OK / none 0 a B; a2 E; b G ^ key; c B, C, D held, then E at X's address on the same heap; d1 B both ways; d2 P before the fence, G ^ key after
real sharing XMem copied (view not shared); b and d2 kept default S_OK / 0x80070032, split 0x80070057 / b, d2 0x80070032 a 131,072; a2 64; split 131,072; c 4 × 131,072; d1 131,072 + 4,096 as forced copying; b and d2 leave P as before; 2 kept defaults counted
forced copying XMem, private committed buffer refreshed at submit; b and d2 kept default S_OK / not attempted / b, d2 0x887A0004 a 131,072; a2 64; c 4 × 131,072; d1 131,072 + 4,096 a B; a2 E; c B, C, D on staging 1, 2, 3, then staging 1 reused after the fence; d1 stale A past the wrapper, B through it; b and d2 as before (XMem P, private G ^ key); 4 kept
host sharing refusal XMem, private as forced copying S_OK / 0x887A0004 from the feature gate / b, d2 0x887A0004 as forced copying as forced copying; gate: 1 feature query, 0 heap opens; 4 kept
copy without a submit fence XMem, private kept default for every placement S_OK / not attempted / a 0x8007139F (E_NOT_VALID_STATE), b and d2 0x887A0004 0 a: XMem zero, private B; b and d2: XMem P, private G ^ key (all as before); 6 kept
forced copying, other queues (q.comp, q.copy) XMem, private copied, refreshed on the COMPUTE or COPY queue S_OK / not attempted / none 131,072, then 64 B in every word, then 16 E; no refresh failure
two queues, one buffer (gate2q, gate2q.held, xq) XMem, private copied S_OK / not attempted / none 131,072 for A, then 4,096 for B queue 2 completes with queue 1 still gated and reads B, queue 1 then reads B; .held: queue 2 waits for the held refresh; xq: both complete and read B
contention (one staging buffer) XMem, private copied S_OK / not attempted / none 540,672 for the run probes 0 ms each while S2 waited about 310 ms for the held copy; S1 C, S2 C; staging created 1; no refresh failure
forced copying (budget, gpuw) XMem, private copied S_OK / not attempted / none 131,072; gpuw then 0 budget: buffer objects live 0 -> 1 -> 0 after release, retained +1, unmeasured +0; gpuw: G after the title's writes around it, gpu_written 1
real sharing (budget) private shared S_OK / S_OK / none 0 placed objects live 0 -> 1 -> 0, retained +1, heap live 1
lease path on XMem kept default, deferred S_OK / not attempted / 0x800700AA 0 reads zero, as before; deferral in info, totals and the log
lease path on private copied S_OK / not attempted / none 131,072 B
failed refresh XMem, private copied S_OK / not attempted / none 131,072 + 4,096 per pool; 0 for the failed refresh the failed submission completes and reads A (last upload), stale reported with 0x8007000E in info and log; next submission reads B, stale cleared; 2 refresh failures in totals

Totals per run:

  • share: 19 placements: 9 shared, 8 copied, 2 kept default. 1,052,736 bytes copied.
  • copy: 30 placements: 26 copied, 4 kept default. 3,441,024 bytes copied. 3 staging buffers created and 37 reused.
  • refusal: 16 placements: 12 copied, 4 kept default. 1,581,184 bytes copied. 3 staging buffers created and 13 reused.
  • contention: 4 placements copied. 540,672 bytes copied. 1 staging buffer created and 7 reused.
  • untracked: 6 placements, all 6 kept default.
  • stale: 2 placements copied. 270,336 bytes copied. 2 refresh failures.
  • lease: 1 placement copied (private) and 1 kept default (XMem, deferred). 131,072 bytes copied.

Measured, not asserted (share path, XMem): on both adapters OpenExistingHeapFromAddress on the five-page view and a placed buffer at +0x30000 return S_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 inside d3d12_xs.dll. Each must fail its case in both pools, and in all four configurations each does:

Mutant (path) Guarantee removed Result
skip-refresh (copy) copy at submit; the copy is taken at placement (bind) a reads A, 2 of 2 failed
reuse-early (copy) staging reuse waits for the copy's fence with the internal queue held, the held refreshes all take staging 1; X, Y and Z read D; c 2 of 2 failed
copy-gpu-writes (copy) GPU-written use not taken by the copy b and d2 leave P and report no refusal; b 2 of 2 failed
ignore-feature (refusal) feature gate before any open 1 heap opened under EXISTING_HEAPS = 0; gate 1 of 1 failed
refusal-silent (copy) a kept default is reported no refusal in the info and no log line; b 2 of 2 failed, kept total 0
hold-lock (contention) no lock held across the staging wait the info probe blocks 4.7 s; S2's wait times out, it goes stale and reads B; contention 2 of 2 failed
skip-consumer-wait (copy) consumers wait for pending refreshes 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) a buffer a list copy wrote is no longer refreshed gpuw: the refresh of the title's two changed words spans the written region and copies A over G; 2 of 2 failed

Inside the run there are also these oracle controls:

  • d1 executes past the wrapper and must see the stale A.
  • The default path must show the old zero stand-in over XMem.
  • d2 must see P before the gate opens.
  • The failed refresh must still read A.

Commands

.\tools\dev.ps1
cmake --preset release
cmake --build --preset release
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 4
# one path by hand, debug layer on:
$env:X2W_TEST_DEBUG_LAYER = '1'; .\out\build\release\linear_buffer_backing_check.exe hardware stale
  • Release, this revision (series on ff06794b):
    • The build is clean; main's generated CPU translation sources still print C4805 warnings, none from this series.
    • 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 4 passed 53/53, covering WARP and hardware. That is 24 linear_buffer_backing (8 paths on 2 adapters, plus 8 controls), 5 unified_buffer_paths, 6 xmem_section_lease, 8 startup_list_resubmit, 6 startup_address_console, 2 startup_upload_arena and 2 startup_upload_lifetime.
    • With X2W_TEST_DEBUG_LAYER=1, -R '^linear_buffer_backing' passed 24/24.
    • linear_buffer_backing_check was 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.
    • System commit (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.
  • Previous revision (52d779d9), environmental failure: one earlier debug-layer ctest attempt failed unified_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, and git itself failed with 0xC000012D. The same binaries then failed identically without the debug layer. Once commit was free again, the same command passed 25/25.
  • Dev, previous revision (14769462); not rerun for this one: ctest --preset dev --no-tests=error -R '^(vm_|era_|xmem|unified_buffer_paths|startup_|linear_buffer_backing)' -j 6 selected 513 tests:
    • 508 passed, including all 17 linear_buffer_backing_* and 5 unified_buffer_paths_* tests.
    • 4 skipped (77): startup_view_heap_{warp,hardware} and startup_logical_view_{warp,hardware}.
    • 1 failed: startup_run_ps1. It compares the translator's --watch path 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.
  • The 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_hardware returns 77 on an adapter without existing-heap support, and refusal covers that case there. On a Gen9 adapter the share run would skip while the other paths run. That has not been measured here.

Not covered

  • Table SRVs of copied buffers in translated draws still take frame_copy at record, and graphics root SRVs still take upload_from_title at bind. Neither reads the slot 133 backing; moving them to the submit copy point is a separate change.
  • GPU-written buffers that cannot be shared keep the default backing. In the switch-off title run, 506 of them (856 MiB) were not aliased, and that backing neither aliases nor copies. This slice records them but does not fix them. They need a copy-back point or a releasable shared backing.
  • Shared buffers and their heaps live for the process, as every wrapper does. A private range under one cannot be released, as with the default backing. Releasing the backing after the title's release and its last fence, which sharing XMem views would also need, is follow-up work. One option is a heap per XMem section (OpenExistingHeapFromFileMapping) with section and offset from XMem.
  • The copy compares every live copied buffer's bytes on each submit. That costs CPU time proportional to the copied bytes while the switch is on (14.2 MiB of GPU-read buffers in the title run). It has not been measured.
  • One matched title pair only (above). A passing fixture and that pair do not establish full-game startup; the per-submit compare cost was not profiled beyond the frame rate.
  • A copied buffer that a list copy wrote stops following its title memory, as the default backing does. Merging the GPU's bytes with later title writes would need a copy-back point.
  • Sharing XMem views through #2280's section lease instead of copying them (follow-up).
  • Unsynchronized concurrent CPU and GPU writes, textures, render targets, acceleration structures and slot 148 are outside this slice.
  • Not run on a Gen9 adapter; the Gen9 case is simulated with X2W_TEST_EXISTING_HEAPS_UNSUPPORTED=1.

Refs #1914
Refs #874

🤖 Generated with Claude Code

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6598057330 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2218). Originally posted by [MasterDomino](https://github.com/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 state `COMMON`. This is the narrowest production kind that is linear, CPU-written and GPU-read: - Its desktop backing is what production GPU work actually reads: ExecuteIndirect argument and index buffers, alias SRVs in translated draws, and desktop views. - Today it is silently wrong outside private memory. Over XMem pages, or on an adapter without existing heaps (the Gen9 row), slot 133 returns `S_OK` with a zero-filled buffer that does not alias the title memory. Buffers in `UNORDERED_ACCESS` or acceleration-structure state, textures and command-list slot 148 keep their current paths. `X2W_D3D12_LINEAR_BUFFERS=1` (or `=copy`) opts in. Unset or `0`, none of the new code runs. ## Rebase onto main (`ff06794b`) and follow-ups The branch is rebased onto `ff06794b` as a series. Main had changed slot 133, `release()` and `queue_execute` substantially. **Integration with main:** - **`release()`:** main's budget `end_use` calls, `drop_mesh_lease_owner` and the list-kind `discard_mesh_lease_recording` are kept. The linear `retire` runs after `retire_placement`, under the opt-in. - **`queue_execute`:** main's `submit` lambda (`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 consumer `Wait` run 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 fences `red_producers` adds and each split mesh submission, and leaves `red_producers` semantics as they are. - **Slot 133 publish:** `publish_placed_buffer` carries main's tail: the `index_resource` callback in `publish_placement`, `x2w_budget::resource(..., placed)` plus the heap's `backing_budget` with `begin_use` when aliased, and `x2w_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:** - **Budgets** (`gpu: count linear-buffer backings in the D3D12 budget`). - A shared buffer counts as placed memory, and its heap (opened once per private range) gets a backing-heap ticket that is in use while a buffer on it is held. - A copied buffer counts as a committed DEFAULT buffer. - Staging buffers count as upload memory when created; they live for the process. - New fixture case `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. - **No double ownership with the XMem lease path** (`gpu: defer slot 133 linear buffers to the XMem lease path`). - #2280's mesh lease path (`X2W_MESH86_XMEM_SRV` or `X2W_MESH_INDIRECT_XMEM`) takes the default copied placements of XMem pages whose console flags are 0. `note_mesh_xmem_write` requires `Placement::copied_buffer` and `console.Flags == NONE`, then mirrors GPU writes into a leased view and publishes it to mesh readers. - Those are exactly the GPU-read XMem buffers the linear copy path would back, so both could claim one placement. - While the lease path is on, slot 133 now keeps the default backing for such a placement and records `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. - New fixture path `lease`: the XMem buffer keeps the default backing (reads zero, as before) with the deferral reported, and a private one is still copied. - **Buffers a list copy writes** (`gpu: stop refreshing a copied linear buffer that a list copy writes`). - Main now forwards `CopyBufferRegion` and `CopyResource` into 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. - Such a buffer now keeps the GPU's bytes from the recording on and is no longer refreshed, as the default backing behaves. It is reported as `gpu_written` in the info and totals. - New case `gpuw` (copy path): a list `CopyBufferRegion` writes G, the title changes the words on both sides, and the read still sees G. - New mutant `refresh-gpu-written` keeps refreshing; it reads A instead, and fails 2 of 2. - **Docs** for all of the above. **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 `uploaded` was updated at enqueue. Queue 2's diff therefore saw no change and skipped its refresh. **Fix** (`src/startup_stubs/linear_buffer_backing.h`): - **One internal COPY queue per device runs every refresh.** It never waits on a title fence. Each refresh (staging → backing) is executed there and signals an internal fence value V. Each copied buffer remembers the V of its last refresh. `ExecuteCommandLists` and `Signal` on 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 or `ExecuteCommandLists`. - **Every consumer orders behind pending refreshes.** Every submission through a queue wrapper, of any type, first makes its queue `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. Recording `uploaded` at enqueue is now correct, because every later consumer waits for the copy to land. - **No title queue ever waits on another title queue.** A refresh never sits behind the title's own waits, so title-owned cross-queue fences (queue 1 waits on a fence that queue 2 signals after its lists) cannot form a cycle with it. - **Staging reuse is gated on the internal fence.** Only the copy reads staging, so title fences don't matter. `after_submit`, the per-title-queue fences and `linear_submitted` are gone. - **Simultaneous access.** The internal queue may write a backing while an earlier submission that reads it still waits on its queue. Buffers allow simultaneous access across queues, so this is valid D3D12. It is also what unified memory does on the console: a read that executes later sees the CPU's latest writes. This rationale is now in the header and in `docs/startup-runtime.md`. - **Fallback.** If the internal queue or its fence cannot be created, copied placements keep the default backing and record that HRESULT in the log line, the info and the totals. `X2W_TEST_SUBMIT_FENCE_FAIL=1` still gives `E_NOT_VALID_STATE`. Nothing returns stale data silently. - **Fixture seam.** `x2w_d3d12_linear_buffer_internal_queue` returns the internal queue, so a fixture can hold refreshes in flight behind a fence of its own. Cases c, contention and `gate2q.held` use 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. - **Mutant `skip-consumer-wait`:** submissions no longer wait. `gate2q.held` then has queue 2 read A before the held refresh lands (2 of 2), and case c reads zeros. - **Kept and adapted:** - `contention` now 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. - Case c holds the internal queue on the copy paths, so `reuse-early` still fails it. - `q.comp` and `q.copy` still pass: the consumers on COMPUTE and COPY queues wait for the internal fence. - **Fixture capacity:** the private pool grows from 4 to 8 MiB for the extra allocations. ## Review changes (tedin7) - **P1, merge conflict:** resolved by the rebase onto `b0669e06`. In `queue_execute`, #2216's `retire_address_uploads(queue, ready)` and `linear_submitted(queue, linear)` are both kept, in that order. Main's "Command-list upload allocation (slot 148)" section precedes this one in `docs/startup-runtime.md`. - **P2, the lock:** `before_submit` no longer holds `mutex_` across a fence wait or `ExecuteCommandLists`. - Under the lock it snapshots the work: which buffers changed and which span of each. - Without the lock it takes staging (`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 runs `ExecuteCommandLists`. - Under the lock again it publishes the results: the uploaded bytes and counters, the staging the submission holds, or a stale mark for each buffer whose staging failed. - Copied state is held by `shared_ptr`, so a snapshot outlives a concurrent `discard`. - `after_submit` still signals the queue fence under the lock. That keeps fence values monotonic across threads; `Signal` does not wait. - The guarantees are unchanged: a staging buffer is chosen only when its fence has completed or it is new; the refresh still happens at submit; a failed staging still marks the buffer stale and the submission still runs. - In render mode, `queue_execute` now refreshes before it takes `draw_lock` and `allocator_lock`, so a staging wait no longer stalls list recording either. `linear_submitted` runs after the ready check, so an executed refresh always gets its fence value. - New `contention` path (`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. - New mutant `hold-lock` keeps 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. - A second queue's submission that needs a refresh of its own still waits when the pool is full. That is a wait for a staging buffer, not for the lock, so the probe submission refreshes nothing. - **P2, non-direct queues:** new rows `q.comp` and `q.copy` on the copy path. The buffer is read by a dispatch on a COMPUTE queue and by `CopyBufferRegion` on a COPY queue, each through its queue wrapper. The refresh runs on that queue: the buffer is promoted from `COMMON` to `COPY_DEST` there 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. - **Nit:** `x2w_d3d12_linear_buffer_info` returns false for a wrapper whose `own().real` is null. The totals export takes no wrapper. - **Superseded by R0Y00's review:** refreshes moved to the internal queue, so `after_submit`, `linear_submitted` and 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_HEAPS` reports 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, reports `E_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. - Only bytes that changed since the last upload are copied, through upload staging buffers. - The copy runs on the internal COPY queue (see Review changes (R0Y00)), and each submission waits for the pending refreshes of live copied buffers. - A staging buffer is reused only after its copy's internal fence value has completed. - **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: - a GPU-written use (`ALLOW_UNORDERED_ACCESS`) that cannot be shared has no copy-back point: the sharing HRESULT, or `DXGI_ERROR_UNSUPPORTED` when sharing was not attempted; - no internal refresh queue or fence: `E_NOT_VALID_STATE` under `X2W_TEST_SUBMIT_FENCE_FAIL=1`, else the creation HRESULT; - the copy's default buffer cannot be created: that HRESULT. Each refusal is recorded three ways: - the slot 133 log line, with `(kept default backing: linear refusal 0x..., use=... type=... existing-heaps=... share=...)` appended; - `x2w_d3d12_linear_buffer_info`, as path 3 with `refusal_hr`; - the totals, as `kept_default` and `last_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_failures` and `last_refresh_hr` in the info, and `refresh_failures` and `last_refresh_hr` in the totals. `d3d12_xs_device.cpp` changes in four places: - slot 133 takes the new path for the eligible kind, and otherwise falls through to the unchanged default code. The wrap and publish tail moves unchanged into `publish_placed_buffer`. With the switch off, the default log line gets an empty suffix. - `release` retires a copied buffer. - `queue_execute` refreshes and inserts the consumer wait before the title's lists. In render mode this happens before the wrapper's locks. - three fixture exports: `x2w_d3d12_linear_buffer_info`, `x2w_d3d12_linear_buffer_totals` (layouts in `linear_buffer_report.h`) and `x2w_d3d12_linear_buffer_internal_queue`. Fixture-only switches: - `X2W_TEST_EXISTING_HEAPS_UNSUPPORTED=1` - `X2W_TEST_LINEAR_REFRESH_FAIL=<n>` (staging requests 2, 2 + n, ... fail with `E_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 32` and 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:** - **Switch off:** unchanged behaviour. The run stopped at 294 s at the slot 148 builder. - **`X2W_D3D12_LINEAR_BUFFERS=1`:** the title faulted at **1.76 s**, reading address `0x18`. Its first eligible slot 133 placement was `width=0xae00000 flags=0x20004 type=0x40000 (MEM_MAPPED) use=gpu-written share=0x80070057`, and slot 133 returned `0x80070057`. On the console `CreatePlacedResourceX` does not fail, so the title used the null object. - **Slot 133 mix in the switch-off run** (count, size, default outcome): - 2,987 GPU-read buffers, 14.2 MiB, not aliased; - 506 GPU-written buffers, 856 MiB, not aliased; - 61 GPU-written buffers, 167 MiB, aliased (private). That is why every refusal now keeps the default backing and is only recorded. **This revision (`14769462`), matched pair on one build:** | | Switch off | `X2W_D3D12_LINEAR_BUFFERS=1` | |---|---|---| | End | slot 148 builder stop at 290.1 s | slot 148 builder stop at **294.1 s** (same stop) | | Frames presented in 285 s | 8,487 (29.8 fps) | 8,451 (29.6 fps) | | Executes / translated draws (not drawn) | 8,400 / 256,460 (0) | 8,400 / 256,265 (3) | | Pipelines translated / missing | 18 / 0 | 18 / 2 | | Slot 133 linear-buffer placements | default path | 3,094 copied at submit, 64 shared, 507 kept the default backing with the refusal recorded (463 `0x80070057` split or unaligned GPU-written, 44 `0x80070032` XMem view) | | Refresh failures (stale) | n/a | none logged | | Peak commit | 12,056 MiB | 16,479 MiB | 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 onto `ff06794b`) **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 with `NtQuerySystemInformation` before each arm and 10 s after it exited. | | `X2W_D3D12_LINEAR_BUFFERS=1` | Switch off | |---|---|---| | End | 420 s limit, no stop | 420 s limit, no stop | | Frames | 11,787 in 411 s (28.7 fps) | 11,456 in 413 s (27.8 fps) | | Executes | 11,700 | 11,400 | | Pipelines translated / missing | 11 / 3 | 14 / 0 | | Translated draws (not drawn) | 382,346 (27,004) | 409,670 (0) | | Slot 133 linear buffers | 2,848 copied at submit, 56 shared, 496 kept the default backing with the refusal recorded (452 `0x80070057`, 44 `0x80070032`) | default path | | Shared commit before → after | 3.55 → 3.53 GiB | 3.53 → 3.64 GiB | - **Frame rate:** the internal-queue refresh and the consumer waits cost no measurable frame rate. - **Shared commit:** the opt-in arm left none behind. - **Pipelines:** the opt-in arm's 3 missing pipelines and 27,004 undrawn draws are most likely ordering. It ran first, so it translated new pipelines that the switch-off arm then found in the cache. I haven't verified that. ## Test `tests/linear_buffer_backing_check.cpp` drives the production entry points, not a model: - slot 133 on the device wrapper; - list Reset (139) and Close (9) on wrapper lists recorded on their desktop lists; - `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.dll` physical 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: - return `S_OK` with an object; - behave as before: an XMem view not aliased, a private range aliased on an adapter with existing heaps; - carry the refusal HRESULT in the info, the totals and its own slot 133 log line. The fixture reads that line back from `X2W_TRAP_LOG`, written next to the executable as `linear_buffer_backing_<path>_<adapter>.log`. The cases: - **a, a2:** A to B before submit, then a 16-word change that must copy 64 bytes. - **b:** GPU write, fence, alias readback. - **c:** three held submissions, then backing reuse only after completion. - **d1:** missing refresh, by executing past the wrapper. - **d2:** readback before the fence, ordered by a queue `Wait` on a gate. - **split, gate, off:** a buffer across two XMem views; no heap open when the feature query reports no support; no linear-buffer code with the switch off. - **kept:** the kept-default total equals the number of refusals. - **stale:** a failed refresh still runs and completes, reads the last upload and is reported stale; the next refresh clears it. - **q.comp, q.copy:** the refresh on a COMPUTE and a COPY queue. - **contention:** the info export, `release()` and another queue's submission finish while a refresh waits for the only staging buffer, whose copy is held on the internal queue. - **gate2q, gate2q.held, xq:** one buffer read on two queues after one CPU write: both see it, also with the refresh held, and with a title-owned cross-queue fence (no deadlock). ## Results Environment: - Commit: the series on `ff06794b` (head `9b8c36fe`), Windows 11 build 26300.9974. - Adapters: in-box WARP (`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 report `D3D12_FEATURE_EXISTING_HEAPS`. - Debug layer off and on (`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. | Path | Pool | Backing | Slot 133 / sharing / refusal | Bytes copied | Results | |---|---|---|---|---|---| | default | XMem | committed buffer, not aliased (old behaviour) | `S_OK` / not attempted / none | 0 | a reads zero in all words; b leaves P (asserted as before) | | default | private | aliased through the cached heap (old behaviour) | `S_OK` / not attempted / none | 0 | a B; b G ^ key; totals all zero (no linear-buffer code ran) | | **real sharing** | private | title memory, 1 heap open, 7 cache hits, generation 1 | `S_OK` / `S_OK` / none | 0 | a B; a2 E; b G ^ key; c B, C, D held, then E at X's address on the same heap; d1 B both ways; d2 P before the fence, G ^ key after | | real sharing | XMem | copied (view not shared); b and d2 kept default | `S_OK` / `0x80070032`, split `0x80070057` / b, d2 `0x80070032` | a 131,072; a2 64; split 131,072; c 4 × 131,072; d1 131,072 + 4,096 | as forced copying; b and d2 leave P as before; 2 kept defaults counted | | **forced copying** | XMem, private | committed buffer refreshed at submit; b and d2 kept default | `S_OK` / not attempted / b, d2 `0x887A0004` | a 131,072; a2 64; c 4 × 131,072; d1 131,072 + 4,096 | a B; a2 E; c B, C, D on staging 1, 2, 3, then staging 1 reused after the fence; d1 stale A past the wrapper, B through it; b and d2 as before (XMem P, private G ^ key); 4 kept | | **host sharing refusal** | XMem, private | as forced copying | `S_OK` / `0x887A0004` from the feature gate / b, d2 `0x887A0004` | as forced copying | as forced copying; gate: 1 feature query, 0 heap opens; 4 kept | | copy without a submit fence | XMem, private | kept default for every placement | `S_OK` / not attempted / a `0x8007139F` (`E_NOT_VALID_STATE`), b and d2 `0x887A0004` | 0 | a: XMem zero, private B; b and d2: XMem P, private G ^ key (all as before); 6 kept | | forced copying, other queues (q.comp, q.copy) | XMem, private | copied, refreshed on the COMPUTE or COPY queue | `S_OK` / not attempted / none | 131,072, then 64 | B in every word, then 16 E; no refresh failure | | two queues, one buffer (gate2q, gate2q.held, xq) | XMem, private | copied | `S_OK` / not attempted / none | 131,072 for A, then 4,096 for B | queue 2 completes with queue 1 still gated and reads B, queue 1 then reads B; `.held`: queue 2 waits for the held refresh; xq: both complete and read B | | contention (one staging buffer) | XMem, private | copied | `S_OK` / not attempted / none | 540,672 for the run | probes 0 ms each while S2 waited about 310 ms for the held copy; S1 C, S2 C; staging created 1; no refresh failure | | forced copying (budget, gpuw) | XMem, private | copied | `S_OK` / not attempted / none | 131,072; gpuw then 0 | budget: buffer objects live 0 -> 1 -> 0 after release, retained +1, unmeasured +0; gpuw: G after the title's writes around it, `gpu_written` 1 | | real sharing (budget) | private | shared | `S_OK` / `S_OK` / none | 0 | placed objects live 0 -> 1 -> 0, retained +1, heap live 1 | | lease path on | XMem | kept default, deferred | `S_OK` / not attempted / `0x800700AA` | 0 | reads zero, as before; deferral in info, totals and the log | | lease path on | private | copied | `S_OK` / not attempted / none | 131,072 | B | | failed refresh | XMem, private | copied | `S_OK` / not attempted / none | 131,072 + 4,096 per pool; 0 for the failed refresh | the failed submission completes and reads A (last upload), stale reported with `0x8007000E` in info and log; next submission reads B, stale cleared; 2 refresh failures in totals | Totals per run: - **share:** 19 placements: 9 shared, 8 copied, 2 kept default. 1,052,736 bytes copied. - **copy:** 30 placements: 26 copied, 4 kept default. 3,441,024 bytes copied. 3 staging buffers created and 37 reused. - **refusal:** 16 placements: 12 copied, 4 kept default. 1,581,184 bytes copied. 3 staging buffers created and 13 reused. - **contention:** 4 placements copied. 540,672 bytes copied. 1 staging buffer created and 7 reused. - **untracked:** 6 placements, all 6 kept default. - **stale:** 2 placements copied. 270,336 bytes copied. 2 refresh failures. - **lease:** 1 placement copied (private) and 1 kept default (XMem, deferred). 131,072 bytes copied. Measured, not asserted (share path, XMem): on both adapters `OpenExistingHeapFromAddress` on the five-page view and a placed buffer at `+0x30000` return `S_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 inside `d3d12_xs.dll`. Each must fail its case in both pools, and in all four configurations each does: | Mutant (path) | Guarantee removed | Result | |---|---|---| | `skip-refresh` (copy) | copy at submit; the copy is taken at placement (bind) | a reads A, 2 of 2 failed | | `reuse-early` (copy) | staging reuse waits for the copy's fence | with the internal queue held, the held refreshes all take staging 1; X, Y and Z read D; c 2 of 2 failed | | `copy-gpu-writes` (copy) | GPU-written use not taken by the copy | b and d2 leave P and report no refusal; b 2 of 2 failed | | `ignore-feature` (refusal) | feature gate before any open | 1 heap opened under `EXISTING_HEAPS = 0`; gate 1 of 1 failed | | `refusal-silent` (copy) | a kept default is reported | no refusal in the info and no log line; b 2 of 2 failed, kept total 0 | | `hold-lock` (contention) | no lock held across the staging wait | the info probe blocks 4.7 s; S2's wait times out, it goes stale and reads B; contention 2 of 2 failed | | `skip-consumer-wait` (copy) | consumers wait for pending refreshes | `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) | a buffer a list copy wrote is no longer refreshed | `gpuw`: the refresh of the title's two changed words spans the written region and copies A over G; 2 of 2 failed | Inside the run there are also these oracle controls: - d1 executes past the wrapper and must see the stale A. - The default path must show the old zero stand-in over XMem. - d2 must see P before the gate opens. - The failed refresh must still read A. ## Commands ```powershell .\tools\dev.ps1 cmake --preset release cmake --build --preset release 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 4 # one path by hand, debug layer on: $env:X2W_TEST_DEBUG_LAYER = '1'; .\out\build\release\linear_buffer_backing_check.exe hardware stale ``` - **Release, this revision (series on `ff06794b`):** - The build is clean; main's generated CPU translation sources still print C4805 warnings, none from this series. - `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 4` passed 53/53, covering WARP and hardware. That is 24 `linear_buffer_backing` (8 paths on 2 adapters, plus 8 controls), 5 `unified_buffer_paths`, 6 `xmem_section_lease`, 8 `startup_list_resubmit`, 6 `startup_address_console`, 2 `startup_upload_arena` and 2 `startup_upload_lifetime`. - With `X2W_TEST_DEBUG_LAYER=1`, `-R '^linear_buffer_backing'` passed 24/24. - `linear_buffer_backing_check` was 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. - **System commit (`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. - **Previous revision (`52d779d9`), environmental failure:** one earlier debug-layer `ctest` attempt failed `unified_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, and `git` itself failed with `0xC000012D`. The same binaries then failed identically without the debug layer. Once commit was free again, the same command passed 25/25. - **Dev, previous revision (`14769462`); not rerun for this one:** `ctest --preset dev --no-tests=error -R '^(vm_|era_|xmem|unified_buffer_paths|startup_|linear_buffer_backing)' -j 6` selected 513 tests: - 508 passed, including all 17 `linear_buffer_backing_*` and 5 `unified_buffer_paths_*` tests. - 4 skipped (77): `startup_view_heap_{warp,hardware}` and `startup_logical_view_{warp,hardware}`. - 1 failed: `startup_run_ps1`. It compares the translator's `--watch` path 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. - The `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_hardware` returns 77 on an adapter without existing-heap support, and `refusal` covers that case there. On a Gen9 adapter the `share` run would skip while the other paths run. That has not been measured here. ## Not covered - Table SRVs of copied buffers in translated draws still take `frame_copy` at record, and graphics root SRVs still take `upload_from_title` at bind. Neither reads the slot 133 backing; moving them to the submit copy point is a separate change. - GPU-written buffers that cannot be shared keep the default backing. In the switch-off title run, 506 of them (856 MiB) were not aliased, and that backing neither aliases nor copies. This slice records them but does not fix them. They need a copy-back point or a releasable shared backing. - Shared buffers and their heaps live for the process, as every wrapper does. A private range under one cannot be released, as with the default backing. Releasing the backing after the title's release and its last fence, which sharing XMem views would also need, is follow-up work. One option is a heap per XMem section (`OpenExistingHeapFromFileMapping`) with section and offset from XMem. - The copy compares every live copied buffer's bytes on each submit. That costs CPU time proportional to the copied bytes while the switch is on (14.2 MiB of GPU-read buffers in the title run). It has not been measured. - One matched title pair only (above). A passing fixture and that pair do not establish full-game startup; the per-submit compare cost was not profiled beyond the frame rate. - A copied buffer that a list copy wrote stops following its title memory, as the default backing does. Merging the GPU's bytes with later title writes would need a copy-back point. - Sharing XMem views through #2280's section lease instead of copying them (follow-up). - Unsynchronized concurrent CPU and GPU writes, textures, render targets, acceleration structures and slot 148 are outside this slice. - Not run on a Gen9 adapter; the Gen9 case is simulated with `X2W_TEST_EXISTING_HEAPS_UNSUPPORTED=1`. Refs #1914 Refs #874 🤖 Generated with [Claude Code](https://claude.com/claude-code)
tedin7 commented 2026-11-25 06:01:32 +00:00 (Migrated from github.com)

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 in docs/startup-runtime.md and src/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 --mutate controls (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. The hardware variants 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

  • The PR is CONFLICTING with main (files above). It needs a rebase, and the Win2025 result must be repeated on the rebased head, because the conflict is inside d3d12_xs_device.cpp (the device_place_resource_x / queue_execute hunks this PR rewrites).

P2

  • src/startup_stubs/linear_buffer_backing.h before_submit (about L315-405) holds mutex_ while it calls take_staging (waits up to 5000 ms on WaitForSingleObject) and queue->ExecuteCommandLists. Another queue's submission, or a release() of a placed resource calling retire, blocks behind it. Opt-in only, but consider dropping the lock around the wait, or documenting it in docs/experiments.md.
  • before_submit refreshes 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_info reads w->own().real after the kind check only. That is fine, but a nullptr guard on real would match the sibling exports.
  • Hardware-adapter variants are registered, but only WARP evidence is attached.

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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6052478230 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2218#pullrequestreview-6052478230). Originally posted by [tedin7](https://github.com/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 in `docs/startup-runtime.md` and `src/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 `--mutate` controls (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. The `hardware` variants 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** - The PR is `CONFLICTING` with main (files above). It needs a rebase, and the Win2025 result must be repeated on the rebased head, because the conflict is inside `d3d12_xs_device.cpp` (the `device_place_resource_x` / `queue_execute` hunks this PR rewrites). **P2** - `src/startup_stubs/linear_buffer_backing.h` `before_submit` (about L315-405) holds `mutex_` while it calls `take_staging` (waits up to 5000 ms on `WaitForSingleObject`) and `queue->ExecuteCommandLists`. Another queue's submission, or a `release()` of a placed resource calling `retire`, blocks behind it. Opt-in only, but consider dropping the lock around the wait, or documenting it in `docs/experiments.md`. - `before_submit` refreshes 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_info` reads `w->own().real` after the `kind` check only. That is fine, but a `nullptr` guard on `real` would match the sibling exports. - Hardware-adapter variants are registered, but only WARP evidence is attached. 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.
tedin7 commented 2026-11-25 06:01:32 +00:00 (Migrated from github.com)

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 to 60220de68a948cf66ff96e66c6ac2b1323595800 while 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6052480487 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2218#pullrequestreview-6052480487). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T05:48:37Z. **Review:** COMMENTED --- Note on my review above: it covers the earlier head `14769462719628f1ce3bfd871eb43738d2c073aa`. The branch was updated to `60220de68a948cf66ff96e66c6ac2b1323595800` while 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.
tedin7 commented 2026-11-25 07:01:03 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T06:12:55Z.

Review: COMMENTED


Re-review of head 52d779d9dea7b2127393bdcc095e30995917321b (earlier review covered 14769462).

Previous findings

  • P1 (merge conflict with main): resolved. gh pr view reports MERGEABLE; git diff --stat origin/main...HEAD is 7 files, +2321/-22.
  • P2 (lock held across fence wait and ExecuteCommandLists in before_submit): resolved. src/startup_stubs/linear_buffer_backing.h now snapshots work under mutex_, stages/records/executes without it, and publishes under it again (L318-L430). retire() during a flight is safe: publish re-checks copy.live. A new contention case plus a hold-lock mutant cover it.
  • P2 (no test on a non-direct queue): resolved. The copy path now has a q.comp/q.copy case (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.
  • Nit (real null guard on the info export): resolved, d3d12_xs_device.cpp:1349 checks !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 including hold_lock and the new queue case, all killed as expected). The release phase failed twice at compile of d3d12_xs_device.cpp with sccache: 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.
  • Mutation: the PR's built-in mutants (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

  • none.

P2

  • Release-phase WARP result is missing on this head (sccache failure above). Please re-run the release phase before Ready.

Nit

  • In before_submit, two threads submitting at once can each snapshot the same uploaded diff and publish out of order, so uploaded may 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.
  • The hardware variants 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6052689621 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2218#pullrequestreview-6052689621). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T06:12:55Z. **Review:** COMMENTED --- Re-review of head `52d779d9dea7b2127393bdcc095e30995917321b` (earlier review covered `14769462`). **Previous findings** - P1 (merge conflict with main): resolved. `gh pr view` reports MERGEABLE; `git diff --stat origin/main...HEAD` is 7 files, +2321/-22. - P2 (lock held across fence wait and `ExecuteCommandLists` in `before_submit`): resolved. `src/startup_stubs/linear_buffer_backing.h` now snapshots work under `mutex_`, stages/records/executes without it, and publishes under it again (L318-L430). `retire()` during a flight is safe: publish re-checks `copy.live`. A new `contention` case plus a `hold-lock` mutant cover it. - P2 (no test on a non-direct queue): resolved. The `copy` path now has a `q.comp`/`q.copy` case (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. - Nit (`real` null guard on the info export): resolved, `d3d12_xs_device.cpp:1349` checks `!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 including `hold_lock` and the new queue case, all killed as expected). The release phase failed twice at compile of `d3d12_xs_device.cpp` with `sccache: 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. - Mutation: the PR's built-in mutants (`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** - none. **P2** - Release-phase WARP result is missing on this head (sccache failure above). Please re-run the release phase before Ready. **Nit** - In `before_submit`, two threads submitting at once can each snapshot the same `uploaded` diff and publish out of order, so `uploaded` may 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. - The `hardware` variants 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.
R0Y00 commented 2026-11-25 07:01:03 +00:00 (Migrated from github.com)

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 52d779d9 after 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_submit records the new bytes in uploaded when 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6053026731 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2218#pullrequestreview-6053026731). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T06:44:49Z. **Review:** CHANGES_REQUESTED --- I reproduced a copy-path ordering failure on `52d779d9` after 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_submit` records the new bytes in `uploaded` when 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.
tedin7 commented 2026-11-25 07:01:03 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T06:54:10Z.

Review: COMMENTED


Re-review of head 793b52b5fa2ea08ecbe739b3ac540a4a194cf162 (previous review covered 52d779d9).

Previous findings

  • P2 (release-phase WARP result missing on the earlier head): resolved. I re-ran it on this head, see below: release /O2 20/20 passed.
  • Nit (concurrent publishes may leave uploaded lagging): resolved. The only change since 52d779d9 is a comment in src/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 under mutex_).
  • Nit (hardware variants 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, including contention_warp, contention_hardware and the hold_lock control.
  • Mutation: the PR's built-in mutants (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 still pending; Linux Python checks passed. Please wait for those to turn green before Ready.
  • PR is MERGEABLE; the title is neutral; the new code is original in-repo work, so clean-room is intact.

P1

  • none.

P2

  • none. The previous P2 is resolved.

Nit

  • The hardware ctest 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6053113864 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2218#pullrequestreview-6053113864). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T06:54:10Z. **Review:** COMMENTED --- Re-review of head `793b52b5fa2ea08ecbe739b3ac540a4a194cf162` (previous review covered `52d779d9`). **Previous findings** - P2 (release-phase WARP result missing on the earlier head): resolved. I re-ran it on this head, see below: release `/O2` 20/20 passed. - Nit (concurrent publishes may leave `uploaded` lagging): resolved. The only change since `52d779d9` is a comment in `src/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 under `mutex_`). - Nit (`hardware` variants 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**, including `contention_warp`, `contention_hardware` and the `hold_lock` control. - Mutation: the PR's built-in mutants (`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 still `pending`; Linux Python checks passed. Please wait for those to turn green before Ready. - PR is MERGEABLE; the title is neutral; the new code is original in-repo work, so clean-room is intact. **P1** - none. **P2** - none. The previous P2 is resolved. **Nit** - The `hardware` ctest 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.
MasterDomino commented 2026-11-25 07:01:12 +00:00 (Migrated from github.com)

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, on 60220de6 (main b0669e06, which includes #2216).

  • P1 (conflict): already resolved by the rebase you noted.
  • P2 (lock): before_submit now takes a snapshot of what changed under mutex_, then releases it while it takes, creates or waits for staging, fills it, records the refresh and runs ExecuteCommandLists. It re-takes the lock to publish. In render mode, queue_execute refreshes before taking draw_lock and allocator_lock. after_submit still signals under the lock, which keeps fence values ordered across threads; Signal doesn't wait.
    • New contention path: the staging pool is limited to one buffer with the test-only X2W_TEST_LINEAR_STAGING_LIMIT=1. S1 holds it behind a gate while S2 waits on another thread. During the wait, the info export, a release() 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.
    • New hold-lock mutant: 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.
  • P2 (queues): new q.comp and q.copy rows read the copied buffer with a dispatch on a COMPUTE queue and a CopyBufferRegion on a COPY queue, each through its wrapper. The refresh runs on that queue and relies on implicit COMMON to COPY_DEST promotion. Both read B with 131,072 bytes copied, then 64 bytes after a 16-word change. The debug layer stays clean on both adapters.
  • Nit: x2w_d3d12_linear_buffer_info returns false when the wrapper's real is null.
  • Hardware: every row ran on the RX 9070 XT as well as WARP.

Results:

  • Release, 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 4 passed 43/43 on WARP and hardware.
  • Debug layer on (X2W_TEST_DEBUG_LAYER=1): linear_buffer_backing|unified_buffer_paths passed 25/25.
  • Mutants: each of the 6 fails all its targeted rows.

One environmental note. On this host, a debug-on run of #1942's unified_buffer_paths_warp failed 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7154392467 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2218#issuecomment-7154392467). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-25T06:03:11Z. --- @tedin7, thanks for the review. All of it is addressed in `52d779d9`, on `60220de6` (`main` `b0669e06`, which includes #2216). - **P1 (conflict):** already resolved by the rebase you noted. - **P2 (lock):** `before_submit` now takes a snapshot of what changed under `mutex_`, then releases it while it takes, creates or waits for staging, fills it, records the refresh and runs `ExecuteCommandLists`. It re-takes the lock to publish. In render mode, `queue_execute` refreshes before taking `draw_lock` and `allocator_lock`. `after_submit` still signals under the lock, which keeps fence values ordered across threads; `Signal` doesn't wait. - **New `contention` path:** the staging pool is limited to one buffer with the test-only `X2W_TEST_LINEAR_STAGING_LIMIT=1`. S1 holds it behind a gate while S2 waits on another thread. During the wait, the info export, a `release()` 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. - **New `hold-lock` mutant:** 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. - **P2 (queues):** new `q.comp` and `q.copy` rows read the copied buffer with a dispatch on a COMPUTE queue and a `CopyBufferRegion` on a COPY queue, each through its wrapper. The refresh runs on that queue and relies on implicit `COMMON` to `COPY_DEST` promotion. Both read B with 131,072 bytes copied, then 64 bytes after a 16-word change. The debug layer stays clean on both adapters. - **Nit:** `x2w_d3d12_linear_buffer_info` returns false when the wrapper's `real` is null. - **Hardware:** every row ran on the RX 9070 XT as well as WARP. Results: - **Release, 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 4` passed 43/43 on WARP and hardware. - **Debug layer on** (`X2W_TEST_DEBUG_LAYER=1`): `linear_buffer_backing|unified_buffer_paths` passed 25/25. - **Mutants:** each of the 6 fails all its targeted rows. One environmental note. On this host, a debug-on run of #1942's `unified_buffer_paths_warp` failed 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.
MasterDomino commented 2026-11-25 07:01:12 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T06:14:23Z.


Thanks for the re-review.

  • Release on this head: I ran the release phase on 52d779d9 locally, 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 4 passed 43/43. The hardware rows there ran on that GPU.
  • Nit (concurrent publish): agreed. I'm adding a comment at the publish step in before_submit. It says that two submissions snapshotting the same buffer can publish uploaded in 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7154585968 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2218#issuecomment-7154585968). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-25T06:14:23Z. --- Thanks for the re-review. - **Release on this head:** I ran the release phase on `52d779d9` locally, 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 4` passed 43/43. The `hardware` rows there ran on that GPU. - **Nit (concurrent publish):** agreed. I'm adding a comment at the publish step in `before_submit`. It says that two submissions snapshotting the same buffer can publish `uploaded` in 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.
tedin7 commented 2026-11-25 13:01:01 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T12:52:51Z.


@MasterDomino could you rebase this branch onto current main and force-push?

GitHub reports head 793b52b5 as conflicting with main, so it cannot be merged as is.

Files that conflict with current main (4aaea119):

  • docs/experiments.md
  • src/startup_stubs/d3d12_xs_device.cpp

Commands run locally:

git fetch origin main pull/2218/head
git merge-tree --write-tree --name-only origin/main FETCH_HEAD
gh pr view 2218 --json mergeable   # CONFLICTING

Once it is rebased and CI is green it will be re-checked right away.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7162984822 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2218#issuecomment-7162984822). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T12:52:51Z. --- @MasterDomino could you rebase this branch onto current `main` and force-push? GitHub reports head `793b52b5` as conflicting with `main`, so it cannot be merged as is. Files that conflict with current `main` (`4aaea119`): - `docs/experiments.md` - `src/startup_stubs/d3d12_xs_device.cpp` Commands run locally: ``` git fetch origin main pull/2218/head git merge-tree --write-tree --name-only origin/main FETCH_HEAD gh pr view 2218 --json mergeable # CONFLICTING ``` Once it is rebased and CI is green it will be re-checked right away. AI-assisted; commands listed were executed locally.
MasterDomino commented 2026-11-25 15:02:01 +00:00 (Migrated from github.com)

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 main ff06794b as tedin7 asked. Head is 9b8c36fe.

The stale read (3bfa3a9d):

  • Every refresh now runs on one internal COPY queue per device, which never waits on a title fence.
  • Every submission through a queue wrapper first does Wait(internal fence, V), where V covers the live copied buffers' latest refreshes. So recording the uploaded bytes at enqueue is correct.
  • Title queues never wait on each other, so the title's own cross-queue fences can't deadlock with a refresh. Buffers allow simultaneous access, so the refresh may land before an earlier gated reader runs, which matches unified memory.
  • New cases: gate2q is your repro: queue 2 completes while queue 1's gate is closed, and both read B. gate2q.held does the same with the internal queue held. xq has queue 1 waiting on a title fence that queue 2 signals: both complete and read B.
  • New mutant: skip-consumer-wait reproduces the stale A.

Rebase onto main's changes:

  • Kept from main: the budgets, the mesh-lease bookkeeping, the red_producers submit wrapper and commit_list_gpu_writes. The refresh and wait run once per guest call, ahead of every list.
  • New commits:
    • 2088e004: linear backings count in the D3D12 budget, with a new budget case.
    • 1330a3dc: while the mesh XMem lease path (#2280) is on, the placements it can claim keep the default backing, and the refusal is recorded as 0x800700aa. New lease case. 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. New gpuw case and a refresh-gpu-written mutant.

Results:

  • Release: 53/53 for 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.
  • Title pair on this head: both arms ran the 420 s limit with no stop, at 28.7 fps with the opt-in against 27.8 fps without, and the opt-in arm left no shared commit behind. The table is in the PR body.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7166139942 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2218#issuecomment-7166139942). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-25T14:59:52Z. --- @R0Y00, your same-buffer cross-queue case is fixed, and the branch is rebased onto `main` `ff06794b` as tedin7 asked. Head is `9b8c36fe`. **The stale read (`3bfa3a9d`):** - Every refresh now runs on one internal COPY queue per device, which never waits on a title fence. - Every submission through a queue wrapper first does `Wait(internal fence, V)`, where V covers the live copied buffers' latest refreshes. So recording the uploaded bytes at enqueue is correct. - Title queues never wait on each other, so the title's own cross-queue fences can't deadlock with a refresh. Buffers allow simultaneous access, so the refresh may land before an earlier gated reader runs, which matches unified memory. - **New cases:** `gate2q` is your repro: queue 2 completes while queue 1's gate is closed, and both read B. `gate2q.held` does the same with the internal queue held. `xq` has queue 1 waiting on a title fence that queue 2 signals: both complete and read B. - **New mutant:** `skip-consumer-wait` reproduces the stale A. **Rebase onto main's changes:** - **Kept from `main`:** the budgets, the mesh-lease bookkeeping, the `red_producers` submit wrapper and `commit_list_gpu_writes`. The refresh and wait run once per guest call, ahead of every list. - **New commits:** - `2088e004`: linear backings count in the D3D12 budget, with a new `budget` case. - `1330a3dc`: while the mesh XMem lease path (#2280) is on, the placements it can claim keep the default backing, and the refusal is recorded as `0x800700aa`. New `lease` case. 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. New `gpuw` case and a `refresh-gpu-written` mutant. **Results:** - **Release:** 53/53 for `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. - **Title pair on this head:** both arms ran the 420 s limit with no stop, at 28.7 fps with the opt-in against 27.8 fps without, and the opt-in arm left no shared commit behind. The table is in the PR body. AI-assisted.
MasterDomino commented 2026-11-25 16:05:22 +00:00 (Migrated from github.com)

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 main they 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7166224257 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2218#issuecomment-7166224257). Originally posted by [MasterDomino](https://github.com/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 `main` they 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.
MasterDomino commented 2026-11-25 16:05:23 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T15:27:32Z.


Title pair rerun on 9b8c36fe, this time past confirmation. On current main the 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=1 Switch off
Past confirmation yes: 13,083 storage requests, 268,582 decompressions, peak commit 31.1 GB yes: 12,387 / 273,475 / 32.5 GB
Last screen the opening credit sequence, rendered the opening credit sequence, rendered
End second-chance access violation in the main executable at 507.2 s second-chance access violation in the main executable at 492.3 s, at a different site
Frames 11,344 in 502 s (22.6 fps) 11,586 in 486 s (23.8 fps)
Executes 158,943 149,322
Pipelines translated / missing 48 / 438 58 / 434
Slot 133 linear buffers 13,890 copied at submit, 59 shared, 562 kept the default backing with the refusal recorded (518 0x80070057, 44 0x80070032) default path
Shared commit before → 10 s after exit 3.65 → 3.92 GiB 3.92 → 3.94 GiB
  • No visible difference. Both arms render the opening credits the same way, up to their crashes. Under the opt-in, about 13,900 GPU-read buffers now hold the title's bytes instead of zero-filled stand-ins, but nothing in this stretch looks different because of it. The frame rate is about 5% lower with the opt-in. That's a single pair, so it could be noise.
  • The crash isn't the opt-in's. The switch-off arm crashes too, at a different site, so it isn't caused by this PR. It's a new stop on current main; c374c7bf ran this input to 600 s without one. I'll report it on #870 separately.
  • About 250 MiB of shared commit stayed after the opt-in arm, still unexplained. It was still there 10 minutes later. I tested the obvious candidate on this host: heaps opened with OpenExistingHeapFromAddress over 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). The linear_buffer_backing fixtures 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7166874083 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2218#issuecomment-7166874083). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-25T15:27:32Z. --- Title pair rerun on `9b8c36fe`, this time past confirmation. On current `main` the 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=1` | Switch off | |---|---|---| | Past confirmation | yes: 13,083 storage requests, 268,582 decompressions, peak commit 31.1 GB | yes: 12,387 / 273,475 / 32.5 GB | | Last screen | the opening credit sequence, rendered | the opening credit sequence, rendered | | End | second-chance access violation in the main executable at 507.2 s | second-chance access violation in the main executable at 492.3 s, at a different site | | Frames | 11,344 in 502 s (22.6 fps) | 11,586 in 486 s (23.8 fps) | | Executes | 158,943 | 149,322 | | Pipelines translated / missing | 48 / 438 | 58 / 434 | | Slot 133 linear buffers | 13,890 copied at submit, 59 shared, 562 kept the default backing with the refusal recorded (518 `0x80070057`, 44 `0x80070032`) | default path | | Shared commit before → 10 s after exit | 3.65 → 3.92 GiB | 3.92 → 3.94 GiB | - **No visible difference.** Both arms render the opening credits the same way, up to their crashes. Under the opt-in, about 13,900 GPU-read buffers now hold the title's bytes instead of zero-filled stand-ins, but nothing in this stretch looks different because of it. The frame rate is about 5% lower with the opt-in. That's a single pair, so it could be noise. - **The crash isn't the opt-in's.** The switch-off arm crashes too, at a different site, so it isn't caused by this PR. It's a new stop on current `main`; `c374c7bf` ran this input to 600 s without one. I'll report it on #870 separately. - **About 250 MiB of shared commit stayed after the opt-in arm, still unexplained.** It was still there 10 minutes later. I tested the obvious candidate on this host: heaps opened with `OpenExistingHeapFromAddress` over 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). The `linear_buffer_backing` fixtures 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.
MasterDomino commented 2026-11-25 19:04:14 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T18:36:04Z.


Rebased onto main at c887a65a (after #2443). The new head is 07455f08, with the same 9 commits. I resolved the conflicts in src/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 to linear_buffers().retire(...).
  • queue_execute order: drain_retired_resources() first. Then linear_refresh(queue), which runs the refreshes on the internal COPY queue and makes the title queue wait on its fence. Then the title's ExecuteCommandLists, then retire_note_submission(...).
  • What that preserves: the consumer wait still comes before the title's lists, and the retire bookkeeping still follows 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-wait still fails gate2q.held with consumer 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_addrlib and run_sh.

Review and merge. Under the updated merge scope, our own PR goes to another maintainer.

  • @tedin7, could you take the review and merge once CI is green?
  • @R0Y00, your change request from 52d779d9 (the cross-queue stale read) was addressed at 9b8c36fe with the internal copy queue and the consumer Wait; 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7171133367 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2218#issuecomment-7171133367). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-25T18:36:04Z. --- Rebased onto `main` at `c887a65a` (after #2443). The new head is `07455f08`, with the same 9 commits. I resolved the conflicts in `src/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 to `linear_buffers().retire(...)`. - **`queue_execute` order:** `drain_retired_resources()` first. Then `linear_refresh(queue)`, which runs the refreshes on the internal COPY queue and makes the title queue wait on its fence. Then the title's `ExecuteCommandLists`, then `retire_note_submission(...)`. - **What that preserves:** the consumer wait still comes before the title's lists, and the retire bookkeeping still follows `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-wait` still fails `gate2q.held` with `consumer 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_addrlib` and `run_sh`. **Review and merge.** Under the updated merge scope, our own PR goes to another maintainer. - @tedin7, could you take the review and merge once CI is green? - @R0Y00, your change request from `52d779d9` (the cross-queue stale read) was addressed at `9b8c36fe` with the internal copy queue and the consumer `Wait`; 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.
R0Y00 commented 2026-11-25 21:00:50 +00:00 (Migrated from github.com)

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, and skip-consumer-wait reproduces the stale read.

Blocking: a discarded copy permanently disables CPU-to-GPU refresh. I added a local source-built case alongside case_gpuw and left the shim unchanged. Place A and complete its first GPU read. On another wrapper list record slot 15 CopyBufferRegion into that buffer, Close, and Reset without submitting the copy. Write B on the CPU, then submit a separate read. The expected read is B with gpu_written=0. Both XMem and private memory returned A in 1,024/1,024 words with gpu_written=1 on WARP and RTX 4060 Laptop.

note_linear_gpu_write changes 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 specification

Commands for the modified fixture:

cmake --build --preset release --target linear_buffer_backing_check
ctest --preset release --no-tests=error -j 1 -R '^linear_buffer_backing_' -V

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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6064650862 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2218#pullrequestreview-6064650862). Originally posted by [R0Y00](https://github.com/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, and `skip-consumer-wait` reproduces the stale read. **Blocking: a discarded copy permanently disables CPU-to-GPU refresh.** I added a local source-built case alongside `case_gpuw` and left the shim unchanged. Place A and complete its first GPU read. On another wrapper list record slot 15 `CopyBufferRegion` into that buffer, Close, and Reset without submitting the copy. Write B on the CPU, then submit a separate read. The expected read is B with `gpu_written=0`. Both XMem and private memory returned A in 1,024/1,024 words with `gpu_written=1` on WARP and RTX 4060 Laptop. `note_linear_gpu_write` changes 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 specification](https://microsoft.github.io/DirectX-Specs/d3d/D3D12EnhancedBarriers.html#single-queue-simultaneous-access) Commands for the modified fixture: ```powershell cmake --build --preset release --target linear_buffer_backing_check ctest --preset release --no-tests=error -j 1 -R '^linear_buffer_backing_' -V ``` 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.
legacy-code-archaeologist commented 2026-11-25 21:00:50 +00:00 (Migrated from github.com)

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 runs ExecuteCommandLists and Signal outside mutex_. The internal queue runs the two copies in internal_mutex_ order, but uploaded is written later in mutex_ order, and the two orders are independent.

Sequence:

  1. Thread A copies the title bytes X into staging.
  2. The CPU writes Y.
  3. Thread B copies Y into staging.
  4. B takes internal_mutex_ first and gets value 1. A follows with value 2, so the backing ends up holding X.
  5. A publishes uploaded = X, then B publishes uploaded = Y.
  6. The next submission compares the title (Y) with 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:

  • Do the staging memcpy and the Execute/Signal in one critical section, per buffer or under internal_mutex_.
  • Or publish uploaded for 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_submit snapshot → refresh() memcpy)

before_submit collects every live copied buffer, not only the ones the submitted lists use, and calls probe_readable under mutex_. refresh() then copies w.source + w.offset without mutex_. 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:

  • Recheck live and readability right before the memcpy, with retire() and the memcpy under the same lock.
  • Or guard the copy with SEH and mark that buffer stale.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6064694737 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2218#pullrequestreview-6064694737). Originally posted by [legacy-code-archaeologist](https://github.com/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 runs `ExecuteCommandLists` and `Signal` outside `mutex_`. The internal queue runs the two copies in `internal_mutex_` order, but `uploaded` is written later in `mutex_` order, and the two orders are independent. Sequence: 1. Thread A copies the title bytes X into staging. 2. The CPU writes Y. 3. Thread B copies Y into staging. 4. B takes `internal_mutex_` first and gets value 1. A follows with value 2, so the backing ends up holding X. 5. A publishes `uploaded = X`, then B publishes `uploaded = Y`. 6. The next submission compares the title (Y) with `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: - Do the staging memcpy and the Execute/Signal in one critical section, per buffer or under `internal_mutex_`. - Or publish `uploaded` for 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_submit` snapshot → `refresh()` memcpy) `before_submit` collects every live copied buffer, not only the ones the submitted lists use, and calls `probe_readable` under `mutex_`. `refresh()` then copies `w.source + w.offset` without `mutex_`. 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: - Recheck `live` and readability right before the memcpy, with `retire()` and the memcpy under the same lock. - Or guard the copy with SEH and mark that buffer stale. AI-assisted (Claude Code).
MasterDomino commented 2026-11-25 21:01:32 +00:00 (Migrated from github.com)

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 bfdd583f on main 2851685e, and it merges cleanly with current main. The set of changed lines is identical to 07455f08 (8 files, +2680/-28); only context lines moved.

Conflicts, both in d3d12_xs_device.cpp, with both sides kept:

  • release(): slice 2's retire_note_title_release runs before our linear_buffers().retire(...). They don't interact: one updates written_textures, and ours uses the pointer only as a map key.
  • queue_execute: #2504's split path is kept. The internal-fence Wait is still queued before every title submission, including each split submission, and the retire bookkeeping still follows ExecuteCommandLists.

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-wait still fails gate2q.held.
  • ^startup_(resource|list_copy|address_srv): 39/39, which includes the slice 1 and slice 2 retire fixtures.
  • Broad ^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 52d779d9 was addressed at 9b8c36fe.

AI-assisted; commands executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7173814236 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2218#issuecomment-7173814236). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-25T20:32:04Z. --- Rebased again after today's merges, including #2468 (slice 2) and #2504. The head is now `bfdd583f` on `main` `2851685e`, and it merges cleanly with current `main`. The set of changed lines is identical to `07455f08` (8 files, +2680/-28); only context lines moved. **Conflicts, both in `d3d12_xs_device.cpp`, with both sides kept:** - **`release()`:** slice 2's `retire_note_title_release` runs before our `linear_buffers().retire(...)`. They don't interact: one updates `written_textures`, and ours uses the pointer only as a map key. - **`queue_execute`:** #2504's `split` path is kept. The internal-fence `Wait` is still queued before every title submission, including each split submission, and the retire bookkeeping still follows `ExecuteCommandLists`. **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-wait` still fails `gate2q.held`. - **`^startup_(resource|list_copy|address_srv)`:** 39/39, which includes the slice 1 and slice 2 retire fixtures. - **Broad `^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 `52d779d9` was addressed at `9b8c36fe`. AI-assisted; commands executed locally.
MasterDomino commented 2026-11-25 21:01:32 +00:00 (Migrated from github.com)

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 head bfdd583f:

your request at bfdd583f
track the pending refresh per backing, and order foreign-queue consumers behind it Refreshes are no longer recorded as uploaded when enqueued on the consumer's queue. They run on one internal COPY queue per device and signal an internal fence, and every title submission that reads the backing queues a Wait on that fence before its lists (queue_execute, before ExecuteCommandLists, including #2504's split submissions).
add this same-buffer gate Case gate2q in tests/linear_buffer_backing_check.cpp:1018 is 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.
both reads should see B gate2q: queue 2 completed with queue 1 still gated and read B 1024/1024; queue 1 then read B 1024/1024. Same for private and xmem, on WARP and the RX 9070 XT.
(stronger) the second consumer must not finish before the refresh lands gate2q.held also holds the internal refresh queue. Queue 2 does not complete until it is released (after waiting for the held refresh), then both read B. The skip-consumer-wait mutant control fails exactly that row (WITHOUT WAITING for the held refresh, consumer waits +0).
keep the different-buffer contention case contention is still there and passes; the hold-lock mutant fails it.

Full run at bfdd583f: ctest --preset dev --no-tests=error -R 'linear_buffer' -V gives 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7173871245 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2218#issuecomment-7173871245). Originally posted by [MasterDomino](https://github.com/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 head `bfdd583f`: | your request | at `bfdd583f` | |---|---| | track the pending refresh per backing, and order foreign-queue consumers behind it | Refreshes are no longer recorded as uploaded when enqueued on the consumer's queue. They run on one internal COPY queue per device and signal an internal fence, and every title submission that reads the backing queues a `Wait` on that fence before its lists (`queue_execute`, before `ExecuteCommandLists`, including #2504's split submissions). | | add this same-buffer gate | Case `gate2q` in `tests/linear_buffer_backing_check.cpp:1018` is 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. | | both reads should see B | `gate2q`: queue 2 completed with queue 1 still gated and read **B 1024/1024**; queue 1 then read **B 1024/1024**. Same for `private` and `xmem`, on WARP and the RX 9070 XT. | | (stronger) the second consumer must not finish before the refresh lands | `gate2q.held` also holds the internal refresh queue. Queue 2 does not complete until it is released (`after waiting for the held refresh`), then both read B. The `skip-consumer-wait` mutant control fails exactly that row (`WITHOUT WAITING for the held refresh`, `consumer waits +0`). | | keep the different-buffer contention case | `contention` is still there and passes; the `hold-lock` mutant fails it. | Full run at `bfdd583f`: `ctest --preset dev --no-tests=error -R 'linear_buffer' -V` gives 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.
tedin7 commented 2026-11-25 21:01:32 +00:00 (Migrated from github.com)

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:

  • Debug (--preset dev):
    • Build (cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim linear_buffer_backing_check -- -j 2): 49.52s (configure 2.70s)
  • Release /O2 (--preset release):
    • Build (cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim linear_buffer_backing_check -- -j 2): 95.40s (configure 4.53s)
  • sccache: 45/257 hits; wall 199.7s

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7173994369 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2218#issuecomment-7173994369). Originally posted by [tedin7](https://github.com/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`: - **Debug (`--preset dev`)**: - Build (`cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim linear_buffer_backing_check -- -j 2`): `49.52s` (configure `2.70s`) - **Release `/O2` (`--preset release`)**: - Build (`cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim linear_buffer_backing_check -- -j 2`): `95.40s` (configure `4.53s`) - `sccache`: 45/257 hits; wall `199.7s` AI-assisted; commands listed were executed locally.
MasterDomino commented 2026-11-25 21:01:33 +00:00 (Migrated from github.com)

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:

  1. Move the GPU-written transition from recording to submission. It will use the same pending-write path that already handles textures: committed when the recording is submitted, and dropped on Reset, destruction or a failed Close. I'll add your discarded-copy case for both the private and XMem paths (expected: B, gpu_written=0), keep the submitted-copy case that preserves G, and add a mutant that restores the recording-time mark.
  2. Order the refresh and the write commit behind earlier overlapping GPU access to the same backing, not only order later consumers behind the refresh. That comes with a case that would read torn data without the wait.

I'll post the new head with the results.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7174024400 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2218#issuecomment-7174024400). Originally posted by [MasterDomino](https://github.com/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: 1. **Move the GPU-written transition from recording to submission.** It will use the same pending-write path that already handles textures: committed when the recording is submitted, and dropped on Reset, destruction or a failed Close. I'll add your discarded-copy case for both the private and XMem paths (expected: B, `gpu_written=0`), keep the submitted-copy case that preserves G, and add a mutant that restores the recording-time mark. 2. **Order the refresh and the write commit behind earlier overlapping GPU access to the same backing,** not only order later consumers behind the refresh. That comes with a case that would read torn data without the wait. I'll post the new head with the results. AI-assisted.
MasterDomino commented 2026-11-25 21:01:33 +00:00 (Migrated from github.com)

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:

  • (A) The staging copy, Execute/Signal and the uploaded publish 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.
  • (B) retire() and the title-memory copy will sit under the same lock, with live rechecked 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7174109378 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2218#issuecomment-7174109378). Originally posted by [MasterDomino](https://github.com/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: - **(A)** The staging copy, Execute/Signal and the `uploaded` publish 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. - **(B)** `retire()` and the title-memory copy will sit under the same lock, with `live` rechecked 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.
R0Y00 commented 2026-11-25 21:01:36 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T20:38:46Z.

Code review location: src/startup_stubs/list_copy.inl; line 230

@@ -218,6 +227,7 @@ void __stdcall list_copy_buffer_region(Wrapper* self, u64 destination, u64 desti
         note_mesh_xmem_write(self, to.wrapper, destination_offset, bytes, 15, source_kind,
                              srv_word || mesh_record ? from.resource : nullptr, source_offset);
     }
+    note_linear_gpu_write(to);

This 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4700592697 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2218#discussion_r4700592697). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T20:38:46Z. **Code review location:** `src/startup_stubs/list_copy.inl`; line 230 ~~~~diff @@ -218,6 +227,7 @@ void __stdcall list_copy_buffer_region(Wrapper* self, u64 destination, u64 desti note_mesh_xmem_write(self, to.wrapper, destination_offset, bytes, 15, source_kind, srv_word || mesh_record ? from.resource : nullptr, source_offset); } + note_linear_gpu_write(to); ~~~~ --- This 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.
MasterDomino commented 2026-11-25 22:02:17 +00:00 (Migrated from github.com)

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 from bfdd583f in six focused commits. One design point needs your decision; it's marked below.

# finding fix (commit) new case / mutant control
1 A discarded copy permanently disables refresh (R0Y00) e880a3cb: note_linear_gpu_write no longer marks the backing at recording. It queues the buffer in a per-list pending map under the same pending_writes_lock as the texture writes. commit_list_gpu_writes commits it after ExecuteCommandLists, and discard_list_gpu_writes drops it on Reset and on a failed Close. gpuw.discard: recorded, closed, reset unsubmitted, then the CPU wrote B. Result: read B 1024/1024, gpu_written 0. Mutant gpuw-at-record: read A, gpu_written 1. gpuw still keeps G.
2 Refresh not ordered behind earlier overlapping access (R0Y00) 07c7a19e: each queue signals a user fence after the title's lists. Just before a refresh executes, the internal queue Waits 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. Mutant skip-producer-wait: queue 1 read B.
A Concurrent refreshes publish out of execution order 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. Mutant publish-out-of-order: read C.
B Title memory read after the lock is dropped 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 as unreadable; 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. Mutant copy-after-retire: the guard catches the fault (0x800703E6), with no crash.

Decision needed: one exception to "wait on all prior users" (fix 2).

  • The deadlock: waiting on every earlier submission deadlocks a common pattern. Queue 1 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.
  • The exception: a queue whose latest submission sits behind a title Wait (slot 17) on an unreached fence is skipped. It's counted as producer_wait_skips and logged.
  • Proof there's no deadlock: case xq.write. Queue 2 completed while queue 1 still waited and read B; queue 1 then read B.
  • The window left open: that skipped submission hasn't started yet, so it reads the newer bytes. If F is reached while the copy is still executing, its read could overlap the copy.
  • Not visible to the shim: a Wait issued 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.
  • A submission now also waits for its own pending refresh even if the title released that buffer in the meantime. Before, a retired buffer's refresh was left out of the consumer wait.

Runs (Windows 11 build 26300; WARP 10.0.26100.9818; AMD Radeon RX 9070 XT, driver 32.0.32029.2010):

command result
ctest --preset dev --no-tests=error -R 'linear_buffer' -V 28/28 (16 path entries + 12 mutant controls, each failing its targeted rows); I reran this one myself at 58971a4a
the same in --preset release (linear_buffer_backing_) 28/28
`ctest --preset dev --no-tests=error -R '^startup_(resource list_copy
`ctest --preset dev --no-tests=error -R '^startup_' -E 'heap_leak mapping

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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7174946467 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2218#issuecomment-7174946467). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-25T21:20:32Z. --- @R0Y00, @legacy-code-archaeologist: all four points are addressed at **`58971a4a`**, a fast-forward from `bfdd583f` in six focused commits. One design point needs your decision; it's marked below. | # | finding | fix (commit) | new case / mutant control | |---|---|---|---| | 1 | **A discarded copy permanently disables refresh** (R0Y00) | `e880a3cb`: `note_linear_gpu_write` no longer marks the backing at recording. It queues the buffer in a per-list pending map under the same `pending_writes_lock` as the texture writes. `commit_list_gpu_writes` commits it after `ExecuteCommandLists`, and `discard_list_gpu_writes` drops it on `Reset` and on a failed `Close`. | `gpuw.discard`: recorded, closed, reset unsubmitted, then the CPU wrote B. Result: **read B 1024/1024, `gpu_written 0`**. Mutant `gpuw-at-record`: read A, `gpu_written 1`. `gpuw` still keeps G. | | 2 | **Refresh not ordered behind earlier overlapping access** (R0Y00) | `07c7a19e`: each queue signals a user fence after the title's lists. Just before a refresh executes, the internal queue `Wait`s 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`. Mutant `skip-producer-wait`: queue 1 read B. | | A | **Concurrent refreshes publish out of execution order** | `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`. Mutant `publish-out-of-order`: read C. | | B | **Title memory read after the lock is dropped** | `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 as `unreadable`; 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. Mutant `copy-after-retire`: the guard catches the fault (`0x800703E6`), with no crash. | **Decision needed: one exception to "wait on all prior users" (fix 2).** - **The deadlock:** waiting on every earlier submission deadlocks a common pattern. Queue 1 `Wait`s 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. - **The exception:** a queue whose latest submission sits behind a title `Wait` (slot 17) on an unreached fence is skipped. It's counted as `producer_wait_skips` and logged. - **Proof there's no deadlock:** case `xq.write`. Queue 2 completed while queue 1 still waited and read B; queue 1 then read B. - **The window left open:** that skipped submission hasn't started yet, so it reads the newer bytes. If F is reached while the copy is still executing, its read could overlap the copy. - **Not visible to the shim:** a `Wait` issued 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. - **A submission now also waits for its own pending refresh** even if the title released that buffer in the meantime. Before, a retired buffer's refresh was left out of the consumer wait. **Runs** (Windows 11 build 26300; WARP 10.0.26100.9818; AMD Radeon RX 9070 XT, driver 32.0.32029.2010): | command | result | |---|---| | `ctest --preset dev --no-tests=error -R 'linear_buffer' -V` | **28/28** (16 path entries + 12 mutant controls, each failing its targeted rows); I reran this one myself at `58971a4a` | | the same in `--preset release` (`linear_buffer_backing_`) | **28/28** | | `ctest --preset dev --no-tests=error -R '^startup_(resource|list_copy|address_srv)'` | **39/39** | | `ctest --preset dev --no-tests=error -R '^startup_' -E 'heap_leak|mapping|OpenExistingHeapFromFileMapping' -j 6` | 723 of 724 passed, 8 capability skips. The one failure is `startup_vertex_fetch_formats_hardware`, which timed out at 120 s under `-j 6` and passes alone in 81.5 s. It never sets `X2W_D3D12_LINEAR_BUFFERS`, so it doesn't run this code. | 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.
tedin7 commented 2026-11-25 22:02:19 +00:00 (Migrated from github.com)

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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7175144975 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2218#issuecomment-7175144975). Originally posted by [tedin7](https://github.com/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.
MasterDomino commented 2026-11-25 22:02:19 +00:00 (Migrated from github.com)

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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7175217054 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2218#issuecomment-7175217054). Originally posted by [MasterDomino](https://github.com/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.
R0Y00 commented 2026-11-25 22:02:20 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T21:36:44Z.


For the xq.write decision, 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7175308846 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2218#issuecomment-7175308846). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T21:36:44Z. --- For the `xq.write` decision, 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.
tedin7 commented 2026-11-25 22:02:20 +00:00 (Migrated from github.com)

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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7175311131 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2218#issuecomment-7175311131). Originally posted by [tedin7](https://github.com/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.
MasterDomino commented 2026-11-25 22:02:20 +00:00 (Migrated from github.com)

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.write I'll drop the skip and keep the conservative ordering:

  • Detect before enqueueing: a submission is checked before any refresh or guest list is enqueued. If it needs an overlapping refresh and an earlier submission on another queue is still behind an unreached title 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.
  • The fence path stays usable: the wrapper's ordinary fence Signal keeps working, so a refused list can't strand the earlier queue.
  • New case: the earlier queue gated, then a second CPU write. Release the gate and check:
    • the earlier read gives A;
    • the refused read's output is unchanged;
    • the queue progresses after the explicit signal;
    • a later safe submission reads B.
  • Controls: the existing gated and ordinary write-after-read controls stay, plus a mutant that accepts the unsafe submission.

New head and results to follow.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7175328846 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2218#issuecomment-7175328846). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-25T21:37:37Z. --- Thanks, @R0Y00: understood, and thanks @tedin7, no harm done. For `xq.write` I'll drop the skip and keep the conservative ordering: - **Detect before enqueueing:** a submission is checked before any refresh or guest list is enqueued. If it needs an overlapping refresh and an earlier submission on another queue is still behind an unreached title `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. - **The fence path stays usable:** the wrapper's ordinary fence `Signal` keeps working, so a refused list can't strand the earlier queue. - **New case:** the earlier queue gated, then a second CPU write. Release the gate and check: - the earlier read gives A; - the refused read's output is unchanged; - the queue progresses after the explicit signal; - a later safe submission reads B. - **Controls:** the existing gated and ordinary write-after-read controls stay, plus a mutant that accepts the unsafe submission. New head and results to follow. AI-assisted.
MasterDomino commented 2026-11-25 22:02:23 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T21:56:17Z.


@R0Y00 Thanks. Your xq.write decision is in at c777de19, a fast-forward from 58971a4a: code in c6a0c8a9, docs in c777de19. The skip exception is gone. A submission whose refresh has no safe completion order is now refused before anything is enqueued.

What changed Detail
Detection Runs in the refresh, under the internal queue lock, right before the copy would be enqueued. It applies when the submission has changed bytes and its refresh would have to wait for an earlier submission that is behind an unreached title 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.
Refusal Nothing is enqueued: no refresh, no consumer Wait, none of the title's lists, no user fence Signal. queue_execute returns before any submission bookkeeping. Counted as unsafe_refresh_refusals, which replaces producer_wait_skips, and the first 8 are logged.
Bookkeeping The staging buffers and refresh list are freed. No upload record, refresh value, stale flag or failure count changes, so the next safe submission copies whatever still differs. A recorded copy's GPU write stays pending on the refused recording, which can still be submitted.
Signal path The title's queue Signal and Wait don't pass through this code. A refused submission adds no user fence value, so it leaves nothing for a later refresh to wait on.
Also A title wait that can't be stored (bad_alloc) now keeps the queue blocked until the first submission behind it completes; before, the next submission cleared it. A queue whose user fence Signal failed is refused instead of skipped. A bad_alloc while listing the producer waits fails the refresh as stale instead of silently dropping a wait.
Case xq.write (copy path, both pools) Queue 1 is gated by a title Wait with 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's Signal through queue 2's wrapper (slot 16) returns S_OK and releases queue 1, which reads A. The same refused recording, resubmitted on queue 2, reads B, with no further refusal and nothing stale.
Mutant accept-unsafe-refresh Restores the skip. Nothing is refused, queue 2 reads B, and queue 1 reads B instead of A. It fails 2 of 2 rows and doesn't hang (about 1 s).
Kept controls war (queue 1 reads A, queue 2 reads B, producer waits +1), gate2q, gate2q.held and xq pass 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):

Command Result
ctest --preset dev --no-tests=error -R 'linear_buffer' -V 29/29: 16 path entries, plus 13 controls that each fail their targeted rows; 0 skips. I reran this one myself at c777de19.
ctest --preset release --no-tests=error -R 'linear_buffer_backing_' -V 29/29, 0 skips
ctest --preset dev --no-tests=error -R '^startup_(resource|list_copy|address_srv)' 39/39
git diff --check, tests/docs_links_check.py, tests/bidi_controls_check.py clean

Not covered:

  • No rerun with the debug layer.
  • A title Wait issued on the desktop queue past the wrapper is still not seen.
  • A refused submission's work doesn't run. ExecuteCommandLists returns void, so the log and the counter are the only signal.
  • Disjoint-resource proofs and immutable per-submission backings aren't implemented.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7175730487 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2218#issuecomment-7175730487). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-25T21:56:17Z. --- @R0Y00 Thanks. Your `xq.write` decision is in at **`c777de19`**, a fast-forward from `58971a4a`: code in `c6a0c8a9`, docs in `c777de19`. The skip exception is gone. A submission whose refresh has no safe completion order is now refused before anything is enqueued. | What changed | Detail | |---|---| | Detection | Runs in the refresh, under the internal queue lock, right before the copy would be enqueued. It applies when the submission has changed bytes and its refresh would have to wait for an earlier submission that is behind an unreached title `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. | | Refusal | Nothing is enqueued: no refresh, no consumer `Wait`, none of the title's lists, no user fence `Signal`. `queue_execute` returns before any submission bookkeeping. Counted as `unsafe_refresh_refusals`, which replaces `producer_wait_skips`, and the first 8 are logged. | | Bookkeeping | The staging buffers and refresh list are freed. No upload record, refresh value, stale flag or failure count changes, so the next safe submission copies whatever still differs. A recorded copy's GPU write stays pending on the refused recording, which can still be submitted. | | Signal path | The title's queue `Signal` and `Wait` don't pass through this code. A refused submission adds no user fence value, so it leaves nothing for a later refresh to wait on. | | Also | A title wait that can't be stored (`bad_alloc`) now keeps the queue blocked until the first submission behind it completes; before, the next submission cleared it. A queue whose user fence `Signal` failed is refused instead of skipped. A `bad_alloc` while listing the producer waits fails the refresh as stale instead of silently dropping a wait. | | Case `xq.write` (copy path, both pools) | Queue 1 is gated by a title `Wait` with 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's `Signal` through queue 2's wrapper (slot 16) returns `S_OK` and releases queue 1, which **reads A**. The same refused recording, resubmitted on queue 2, **reads B**, with no further refusal and nothing stale. | | Mutant `accept-unsafe-refresh` | Restores the skip. Nothing is refused, queue 2 reads B, and queue 1 reads B instead of A. It fails 2 of 2 rows and doesn't hang (about 1 s). | | Kept controls | `war` (queue 1 reads A, queue 2 reads B, producer waits +1), `gate2q`, `gate2q.held` and `xq` pass 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): | Command | Result | |---|---| | `ctest --preset dev --no-tests=error -R 'linear_buffer' -V` | **29/29**: 16 path entries, plus 13 controls that each fail their targeted rows; 0 skips. I reran this one myself at `c777de19`. | | `ctest --preset release --no-tests=error -R 'linear_buffer_backing_' -V` | **29/29**, 0 skips | | `ctest --preset dev --no-tests=error -R '^startup_(resource\|list_copy\|address_srv)'` | 39/39 | | `git diff --check`, `tests/docs_links_check.py`, `tests/bidi_controls_check.py` | clean | **Not covered:** - No rerun with the debug layer. - A title `Wait` issued on the desktop queue past the wrapper is still not seen. - A refused submission's work doesn't run. `ExecuteCommandLists` returns void, so the log and the counter are the only signal. - Disjoint-resource proofs and immutable per-submission backings aren't implemented. AI-assisted; commands listed were executed locally.
MasterDomino commented 2026-11-25 22:02:23 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T21:59:16Z.


Merged current main (fc97ade7) in as 7ecb6cfd, with no rebase, so c777de19 stays reviewable as is.

  • The conflict: a single one in d3d12_xs_device.cpp. main added retire_never = RetireNever::buffer (under X2W_D3D12_RELEASE_RETIRED) to the placed-buffer block that this branch had moved into publish_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 from main.
  • Run at the merge: 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.write refusal described in my previous comment. Since it's my own PR, another maintainer would merge it.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7175792998 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2218#issuecomment-7175792998). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-25T21:59:16Z. --- Merged current `main` (`fc97ade7`) in as **`7ecb6cfd`**, with no rebase, so `c777de19` stays reviewable as is. - **The conflict:** a single one in `d3d12_xs_device.cpp`. `main` added `retire_never = RetireNever::buffer` (under `X2W_D3D12_RELEASE_RETIRED`) to the placed-buffer block that this branch had moved into `publish_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 from `main`. - **Run at the merge:** `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.write` refusal described in my previous comment. Since it's my own PR, another maintainer would merge it. AI-assisted; commands listed were executed locally.
R0Y00 commented 2026-11-25 23:01:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T22:15:00Z.

Review: CHANGES_REQUESTED


I rebuilt 7ecb6cfd in Windows Release. The unmodified ctest --preset release --no-tests=error -R '^linear_buffer_backing_' -V passed 29/29 with zero skips. The serial xq.write refusal and the discarded-copy/reset regression both work.

One reproducible blocker remains when slot 17 and ExecuteCommandLists overlap on the same guest queue. In the source-built xq.write fixture I added a local event pause immediately after the real queue enqueues Wait(F,1) and immediately before note_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 guest Signal(F,1) on queue 2. note_title_wait records user.value + 1 after the unchanged submission already advanced user.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)$' -V failed 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6065729762 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2218#pullrequestreview-6065729762). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T22:15:00Z. **Review:** CHANGES_REQUESTED --- I rebuilt `7ecb6cfd` in Windows Release. The unmodified `ctest --preset release --no-tests=error -R '^linear_buffer_backing_' -V` passed 29/29 with zero skips. The serial `xq.write` refusal and the discarded-copy/reset regression both work. One reproducible blocker remains when slot 17 and `ExecuteCommandLists` overlap on the same guest queue. In the source-built `xq.write` fixture I added a local event pause immediately after the real queue enqueues `Wait(F,1)` and immediately before `note_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 guest `Signal(F,1)` on queue 2. `note_title_wait` records `user.value + 1` after the unchanged submission already advanced `user.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)$' -V` failed 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.
MasterDomino commented 2026-11-25 23:02:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T22:20:03Z.


Thanks, @R0Y00. That interleaving is real: the native Wait and our record of it aren't atomic with respect to a concurrent ExecuteCommandLists on the same queue, so the record can land behind a submission the GPU queued after the wait.

The fix I'm making:

  • One per-queue lock spans both the real Wait together with note_title_wait, and the submission's refresh decision through ExecuteCommandLists and the user-fence Signal. The native queue order and the producer/Wait records can then no longer disagree.
  • A bounded two-thread control alongside the serial xq.write case: your pause point between the real Wait and note_title_wait, a concurrent unchanged read on queue 1, then the write, queue 2's submission and the guest Signal. 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.
  • The discarded-GPU-write case stays.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7176231903 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2218#issuecomment-7176231903). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-25T22:20:03Z. --- Thanks, @R0Y00. That interleaving is real: the native `Wait` and our record of it aren't atomic with respect to a concurrent `ExecuteCommandLists` on the same queue, so the record can land behind a submission the GPU queued after the wait. The fix I'm making: - **One per-queue lock** spans both the real `Wait` together with `note_title_wait`, and the submission's refresh decision through `ExecuteCommandLists` and the user-fence `Signal`. The native queue order and the producer/Wait records can then no longer disagree. - **A bounded two-thread control** alongside the serial `xq.write` case: your pause point between the real `Wait` and `note_title_wait`, a concurrent unchanged read on queue 1, then the write, queue 2's submission and the guest `Signal`. 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. - **The discarded-GPU-write case** stays. AI-assisted.
MasterDomino commented 2026-11-25 23:02:07 +00:00 (Migrated from github.com)

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 Wait and the submission in one order while the producer/Wait records landed in the other. The fix is at ee56e734, a single fast-forward commit on 7ecb6cfd.

The fix: a per-queue order lock in each queue's linear-buffer record.

  • Slot 17 holds it from the desktop Wait(F, v) through note_title_wait.
  • A submission holds it from the title's ExecuteCommandLists through the user-fence Signal in after_submit.
  • Lock order: in render mode it is taken before draw_lock and allocator_lock, with no other lock held. mutex_ is only ever taken under it, never the reverse.
  • No waiting under it: it is not held across the refresh, so the staging waits and the pause points run outside it. Nothing under it waits on the CPU for the GPU.
  • Signal stays free: the title's 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 Wait that 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 that Wait.

New case xq.race, run alongside the serial xq.write in both pools:

  1. Thread W's slot 17 Wait(F,1) on queue 1 is parked at a new test pause point (3), between the desktop Wait and its record.
  2. Thread S submits the unchanged read of A on queue 1, and gets up to 1 s to return before W resumes.
  3. The CPU writes B, queue 2 submits the read, and the guest 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 at ee56e734. Dev gave 30/30 as well.
  • With the fix, in both pools on both adapters:
    • S doesn't return while W is parked.
    • Queue 2's read is refused (refusals +1), and its slot keeps P in all 1,024 words.
    • Queue 2's fence is reached, and the Signal returns S_OK.
    • Queue 1 completes and reads A. The resubmission reads B, with no further refusal.
  • New control 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.
  • Stability: ctest --preset release --no-tests=error -R '^linear_buffer_backing_copy_(warp|hardware)$' --repeat until-fail:20 gave 20/20 runs on each adapter: 80 xq.race rows, none failed.
  • Unchanged: gpuw.discard (a discarded GPU-write recording doesn't suppress the later CPU refresh), xq.write, war and gate2q* all pass.
  • Neighbours: 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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7176747168 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2218#issuecomment-7176747168). Originally posted by [MasterDomino](https://github.com/MasterDomino) on 2026-11-25T22:45:14Z. --- @R0Y00 Thanks for the repro. You're right: the desktop queue could receive the `Wait` and the submission in one order while the producer/Wait records landed in the other. The fix is at **`ee56e734`**, a single fast-forward commit on `7ecb6cfd`. **The fix: a per-queue order lock** in each queue's linear-buffer record. - **Slot 17** holds it from the desktop `Wait(F, v)` through `note_title_wait`. - **A submission** holds it from the title's `ExecuteCommandLists` through the user-fence `Signal` in `after_submit`. - **Lock order:** in render mode it is taken before `draw_lock` and `allocator_lock`, with no other lock held. `mutex_` is only ever taken under it, never the reverse. - **No waiting under it:** it is not held across the refresh, so the staging waits and the pause points run outside it. Nothing under it waits on the CPU for the GPU. - **Signal stays free:** the title's `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 `Wait` that 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 that `Wait`. **New case `xq.race`**, run alongside the serial `xq.write` in both pools: 1. Thread W's slot 17 `Wait(F,1)` on queue 1 is parked at a new test pause point (3), between the desktop `Wait` and its record. 2. Thread S submits the unchanged read of A on queue 1, and gets up to 1 s to return before W resumes. 3. The CPU writes B, queue 2 submits the read, and the guest `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 at `ee56e734`. Dev gave 30/30 as well. - **With the fix,** in both pools on both adapters: - S doesn't return while W is parked. - Queue 2's read is refused (refusals +1), and its slot keeps P in all 1,024 words. - Queue 2's fence is reached, and the `Signal` returns `S_OK`. - Queue 1 completes and reads A. The resubmission reads B, with no further refusal. - **New control `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. - **Stability:** `ctest --preset release --no-tests=error -R '^linear_buffer_backing_copy_(warp|hardware)$' --repeat until-fail:20` gave 20/20 runs on each adapter: 80 `xq.race` rows, none failed. - **Unchanged:** `gpuw.discard` (a discarded GPU-write recording doesn't suppress the later CPU refresh), `xq.write`, `war` and `gate2q*` all pass. - **Neighbours:** `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.
upstream-sync closed this pull request 2026-11-26 00:00:43 +00:00
R0Y00 commented 2026-11-26 00:00:43 +00:00 (Migrated from github.com)

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 ee56e734 and ran ctest --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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6066170114 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2218#pullrequestreview-6066170114). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T23:02:27Z. **Review:** APPROVED --- The per-queue lock resolves my concurrent slot-17 review. I rebuilt `ee56e734` and ran `ctest --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.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!2210
No description provided.