Repository navigation
gpu: back slot 133 linear buffers by sharing or a submit-time copy (opt-in) - #2218
MasterDomino wants to merge 15 commits into
Conversation
1476946 to
60220de
Compare
tedin7
left a comment
There was a problem hiding this comment.
Review of head 14769462719628f1ce3bfd871eb43738d2c073aa (opt-in slot 133 linear-buffer backing).
Commands executed locally (Linux worktree)
git diff --stat origin/main...HEAD: 7 files, +2039/-21 (CMakeLists, docs x2, d3d12_xs_device.cpp, linear_buffer_backing.h/report.h, linear_buffer_backing_check.cpp).python3 tests/docs_links_check.py: passed (18 files, 410 links).python3 tests/bidi_controls_check.py: passed (1490 files).git diff --check origin/main...HEAD: clean.git merge-tree --write-tree --name-only origin/main HEAD: content conflicts indocs/startup-runtime.mdandsrc/startup_stubs/d3d12_xs_device.cpp.python3 x2w_pipe.py win2025 2218 --regex linear_buffer_backing(default 3-slot pool): dev 17/17 and release 17/17 passed on Win2025 + D3D12 WARP. The 5--mutatecontrols (skip-refresh, reuse-early, copy-gpu-writes, ignore-feature, refusal-silent) are WILL_FAIL tests and passed, so each mutant is killed by its case. Thehardwarevariants rely on SKIP_RETURN_CODE 77 where no hardware adapter exists; I did not see them exercised on real hardware.gh pr checks: no checks reported on the branch.
P1
- The PR is
CONFLICTINGwith main (files above). It needs a rebase, and the Win2025 result must be repeated on the rebased head, because the conflict is insided3d12_xs_device.cpp(thedevice_place_resource_x/queue_executehunks this PR rewrites).
P2
src/startup_stubs/linear_buffer_backing.hbefore_submit(about L315-405) holdsmutex_while it callstake_staging(waits up to 5000 ms onWaitForSingleObject) andqueue->ExecuteCommandLists. Another queue's submission, or arelease()of a placed resource callingretire, blocks behind it. Opt-in only, but consider dropping the lock around the wait, or documenting it indocs/experiments.md.before_submitrefreshes on whichever queue is executing (including compute or copy queues) and relies on implicit COMMON -> COPY_DEST promotion. This is valid for buffers, but no test submits on a non-direct queue. Add one, or state the limit in the docs.
Nit
x2w_d3d12_linear_buffer_inforeadsw->own().realafter thekindcheck only. That is fine, but anullptrguard onrealwould match the sibling exports.- 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
left a comment
There was a problem hiding this comment.
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.
Review of R0Y00#2218: - before_submit snapshots the copied buffers' work under mutex_, then takes, creates or waits for staging (a full pool waits up to 5 s for the oldest fence), fills it, resets and records a refresh list and runs ExecuteCommandLists without the lock, and publishes the result under it again. A release(), the fixture exports or another queue's submission no longer wait behind a fence wait or ExecuteCommandLists. Staging is still reused only after its fence, the refresh still runs at submit, and a buffer whose staging fails is still marked stale. - In render mode the refresh runs before queue_execute takes draw_lock and allocator_lock, so a staging wait does not stall list recording. - x2w_d3d12_linear_buffer_info returns false for a wrapper without a desktop object. The fixture adds a contention path (X2W_TEST_LINEAR_STAGING_LIMIT=1): while a refresh waits for the only staging buffer behind a gate, the info export, release() and a second queue's submission must finish, and a hold-lock mutant that keeps the lock across the wait must fail. The copy path also refreshes on COMPUTE and COPY queues, read by a dispatch and by CopyBufferRegion. Refs R0Y00#1914 Refs R0Y00#874 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@tedin7, thanks for the review. All of it is addressed in
Results:
One environmental note. On this host, a debug-on run of #1942's AI-assisted. |
tedin7
left a comment
There was a problem hiding this comment.
Re-review of head 52d779d9dea7b2127393bdcc095e30995917321b (earlier review covered 14769462).
Previous findings
- P1 (merge conflict with main): resolved.
gh pr viewreports MERGEABLE;git diff --stat origin/main...HEADis 7 files, +2321/-22. - P2 (lock held across fence wait and
ExecuteCommandListsinbefore_submit): resolved.src/startup_stubs/linear_buffer_backing.hnow snapshots work undermutex_, stages/records/executes without it, and publishes under it again (L318-L430).retire()during a flight is safe: publish re-checkscopy.live. A newcontentioncase plus ahold-lockmutant cover it. - P2 (no test on a non-direct queue): resolved. The
copypath now has aq.comp/q.copycase (tests/linear_buffer_backing_check.cpp L925-L960) that submits through a COMPUTE queue (dispatch read) and a COPY queue (CopyBufferRegion read). The comment at L391 documents the implicit COMMON -> COPY_DEST promotion. - Nit (
realnull guard on the info export): resolved,d3d12_xs_device.cpp:1349checks!w->own().real.
Commands executed locally
python3 tests/docs_links_check.py: passed (18 files, 412 links).python3 tests/bidi_controls_check.py: passed (1498 files).git diff --check origin/main...HEAD: clean.gh pr checks: Linux Python checks, gfx1013 fixtures and Windows build+test all pass on this head.python3 x2w_pipe.py win2025 2218 --regex linear_buffer_backing(default 3-slot pool): dev phase 20/20 passed (warp + hardware variants, contention, and the 6 WILL_FAIL controls includinghold_lockand the new queue case, all killed as expected). The release phase failed twice at compile ofd3d12_xs_device.cppwithsccache: error reading compile response from server(connection reset, infrastructure, not a compiler diagnostic). So release ctest has NOT been confirmed on this head by me; the repo's Windows CI job is green.- 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 sameuploadeddiff and publish out of order, souploadedmay briefly lag the GPU copy. The effect is only an extra (redundant) refresh next submit, not stale data; a one-line comment would make that explicit. - The
hardwarevariants reported Passed on the Win2025 VM; I could not confirm whether a real GPU adapter was used there, so I do not count them as real-GPU evidence.
Title is neutral; the new code is original in-repo work; nothing breaks clean-room.
AI-assisted; commands listed were executed locally.
|
Thanks for the re-review.
AI-assisted. |
R0Y00
left a comment
There was a problem hiding this comment.
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.
Two submissions that snapshot the same copied 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, never one that misses a change. Comment only (tedin7's review nit on R0Y00#2218). Refs R0Y00#1914 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tedin7
left a comment
There was a problem hiding this comment.
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
/O220/20 passed. - Nit (concurrent publishes may leave
uploadedlagging): resolved. The only change since52d779d9is a comment insrc/startup_stubs/linear_buffer_backing.h(before_submit, around L403-L407, +5/-1). It states that the worst case is a redundant or larger refresh next submit, never a missed change. The wording matches what the code does (publish re-checks undermutex_). - Nit (
hardwarevariants are not proof of a real GPU): still open, informational only. I did not confirm an actual hardware adapter on the VM.
Commands executed locally
git diff --stat 52d779d9 793b52b5: 1 file, +5/-1, comment only. No logic change, so the earlier code review still holds.python3 tests/docs_links_check.py: passed (18 files, 412 links).python3 tests/bidi_controls_check.py: passed (1498 files).git diff --check origin/main...HEAD: clean.python3 x2w_pipe.py win2025 2218 --regex linear_buffer_backing --wait 3600(default 3-slot pool): dev phase passed (warp + hardware variants, contention, and the WILL_FAIL controls, all as expected; I only captured the tail of the dev output, so I do not quote a dev count). Release/O2: build 92.55s,ctest --preset release -R linear_buffer_backing: 20/20 passed, includingcontention_warp,contention_hardwareand thehold_lockcontrol.- 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 stillpending; 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
hardwarectest variants pass on the VM, but I cannot show that a real GPU adapter was used, so I do not count them as real-GPU evidence.
AI-assisted; commands listed were executed locally.
|
@MasterDomino could you rebase this branch onto current GitHub reports head Files that conflict with current
Commands run locally: Once it is rebased and CI is green it will be re-checked right away. AI-assisted; commands listed were executed locally. |
793b52b to
9b8c36f
Compare
Review of R0Y00#2218: - before_submit snapshots the copied buffers' work under mutex_, then takes, creates or waits for staging (a full pool waits up to 5 s for the oldest fence), fills it, resets and records a refresh list and runs ExecuteCommandLists without the lock, and publishes the result under it again. A release(), the fixture exports or another queue's submission no longer wait behind a fence wait or ExecuteCommandLists. Staging is still reused only after its fence, the refresh still runs at submit, and a buffer whose staging fails is still marked stale. - In render mode the refresh runs before queue_execute takes draw_lock and allocator_lock, so a staging wait does not stall list recording. - x2w_d3d12_linear_buffer_info returns false for a wrapper without a desktop object. The fixture adds a contention path (X2W_TEST_LINEAR_STAGING_LIMIT=1): while a refresh waits for the only staging buffer behind a gate, the info export, release() and a second queue's submission must finish, and a hold-lock mutant that keeps the lock across the wait must fail. The copy path also refreshes on COMPUTE and COPY queues, read by a dispatch and by CopyBufferRegion. Refs R0Y00#1914 Refs R0Y00#874 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two submissions that snapshot the same copied 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, never one that misses a change. Comment only (tedin7's review nit on R0Y00#2218). Refs R0Y00#1914 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of R0Y00#2218 (R0Y00): one copied buffer, one CPU write, then a list on queue 1 behind an unsignalled gate and a list on queue 2. Queue 2 read the old bytes: queue 1's refresh was enqueued behind its gate but recorded as uploaded, so queue 2 skipped its own. - Every refresh now runs on one internal COPY queue per device, which never waits on a title fence, and signals an internal fence value. Each copied buffer remembers the value of its last refresh. - Every submission through a queue wrapper first makes its queue wait for the highest such value among the live copied buffers that has not completed. A consumer on any queue runs after every refresh enqueued before it, and no title queue waits on another, so title-owned cross-queue fences cannot form a cycle with a refresh. - Staging is reused once its copy's internal fence value completes. The per-title-queue fences, after_submit and linear_submitted go. - If the internal queue or fence cannot be created, copied placements keep the default backing with that HRESULT recorded. - x2w_d3d12_linear_buffer_internal_queue lets fixtures hold refreshes. The fixture adds gate2q (both reads see the CPU write), gate2q.held (the second queue waits for a held refresh), xq (queue 1 waits on a fence queue 2 signals: no deadlock, both read the write) and a skip-consumer-wait mutant that must fail gate2q.held. Case c and contention hold the internal queue so staging stays in flight. Refs R0Y00#1914 Refs R0Y00#874 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@R0Y00, your same-buffer cross-queue case is fixed, and the branch is rebased onto The stale read (
Rebase onto main's changes:
Results:
AI-assisted. |
|
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 AI-assisted. |
|
Title pair rerun on
AI-assisted. |
9b8c36f to
07455f0
Compare
Review of R0Y00#2218: - before_submit snapshots the copied buffers' work under mutex_, then takes, creates or waits for staging (a full pool waits up to 5 s for the oldest fence), fills it, resets and records a refresh list and runs ExecuteCommandLists without the lock, and publishes the result under it again. A release(), the fixture exports or another queue's submission no longer wait behind a fence wait or ExecuteCommandLists. Staging is still reused only after its fence, the refresh still runs at submit, and a buffer whose staging fails is still marked stale. - In render mode the refresh runs before queue_execute takes draw_lock and allocator_lock, so a staging wait does not stall list recording. - x2w_d3d12_linear_buffer_info returns false for a wrapper without a desktop object. The fixture adds a contention path (X2W_TEST_LINEAR_STAGING_LIMIT=1): while a refresh waits for the only staging buffer behind a gate, the info export, release() and a second queue's submission must finish, and a hold-lock mutant that keeps the lock across the wait must fail. The copy path also refreshes on COMPUTE and COPY queues, read by a dispatch and by CopyBufferRegion. Refs R0Y00#1914 Refs R0Y00#874 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two submissions that snapshot the same copied 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, never one that misses a change. Comment only (tedin7's review nit on R0Y00#2218). Refs R0Y00#1914 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of R0Y00#2218 (R0Y00): one copied buffer, one CPU write, then a list on queue 1 behind an unsignalled gate and a list on queue 2. Queue 2 read the old bytes: queue 1's refresh was enqueued behind its gate but recorded as uploaded, so queue 2 skipped its own. - Every refresh now runs on one internal COPY queue per device, which never waits on a title fence, and signals an internal fence value. Each copied buffer remembers the value of its last refresh. - Every submission through a queue wrapper first makes its queue wait for the highest such value among the live copied buffers that has not completed. A consumer on any queue runs after every refresh enqueued before it, and no title queue waits on another, so title-owned cross-queue fences cannot form a cycle with a refresh. - Staging is reused once its copy's internal fence value completes. The per-title-queue fences, after_submit and linear_submitted go. - If the internal queue or fence cannot be created, copied placements keep the default backing with that HRESULT recorded. - x2w_d3d12_linear_buffer_internal_queue lets fixtures hold refreshes. The fixture adds gate2q (both reads see the CPU write), gate2q.held (the second queue waits for a held refresh), xq (queue 1 waits on a fence queue 2 signals: no deadlock, both read the write) and a skip-consumer-wait mutant that must fail gate2q.held. Case c and contention hold the internal queue so staging stays in flight. Refs R0Y00#1914 Refs R0Y00#874 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Rebased onto How the conflicts were resolved
Re-verified at
Review and merge. Under the updated merge scope, our own PR goes to another maintainer.
AI-assisted; commands listed were executed locally. |
…pt-in) X2W_D3D12_LINEAR_BUFFERS=1 (or =copy) gives device slot 133 buffers in COMMON state (row-major or unknown layout) a backing that keeps the title's bytes visible to the GPU. Unset, slot 133 is unchanged. - Share only after D3D12_FEATURE_EXISTING_HEAPS reports support (queried once, before any open), for a buffer inside one committed private allocation at a 64 KiB-aligned offset. The heap is cached by base, which the open heap keeps from being released. - An XMem view is not shared: a heap opened from a view makes XMem's unmap of those pages fail with error 87 (measured), and desktop resources live for the process. Sharing reports 0x80070032 and the buffer is copied. - Copy into a committed default buffer at each submission through the queue wrapper, before the title's lists run, never at bind or record. Only changed bytes are copied, through staging buffers that are reused only after their submission's queue fence completes. - Refuse with a defined HRESULT where the copy cannot keep the guarantees: a GPU-written use returns the sharing HRESULT (or DXGI_ERROR_UNSUPPORTED when sharing was not attempted), no submit fence returns E_NOT_VALID_STATE, and a submission whose refresh cannot be staged is not executed. tests/linear_buffer_backing_check.cpp drives slot 133, wrapper lists and the queue wrapper in d3d12_xs.dll over XMem pages and a private range with the R0Y00#1942 cases and sentinels: default (old behaviour asserted), share, copy, host sharing refusal (EXISTING_HEAPS forced to 0) and a copy without a submit fence, plus four mutants that each remove one guarantee inside the DLL and must fail their case. Refs R0Y00#1914 Refs R0Y00#874 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A title run with X2W_D3D12_LINEAR_BUFFERS=1 faulted at 1.76 s: the first eligible placement, a GPU-written buffer across XMem views, was refused with 0x80070057, and the title, for which CreatePlacedResourceX never fails on the console, used the null object. - Where neither sharing nor the copy keeps its guarantees (a GPU-written use that is not shared, no submit fence, no copy buffer), slot 133 now keeps the default backing and returns what it returns with the switch off. The refusal HRESULT is appended to the slot 133 log line, kept in x2w_d3d12_linear_buffer_info (path 3, refusal_hr) and counted in the totals (kept_default, last_refusal_hr). - A submission whose refresh cannot be staged now runs. The buffer keeps its last upload and is reported stale (info: stale, refresh_failures, last_refresh_hr; totals: refresh_failures, last_refresh_hr) until a later refresh succeeds; the first failures are logged. The fixture asserts the old behaviour and the reported refusal for every kept default (the log line read back through X2W_TRAP_LOG), adds a stale path (X2W_TEST_LINEAR_REFRESH_FAIL) and a refusal-silent mutant that drops the report and must fail. Refs R0Y00#1914 Refs R0Y00#874 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of R0Y00#2218: - before_submit snapshots the copied buffers' work under mutex_, then takes, creates or waits for staging (a full pool waits up to 5 s for the oldest fence), fills it, resets and records a refresh list and runs ExecuteCommandLists without the lock, and publishes the result under it again. A release(), the fixture exports or another queue's submission no longer wait behind a fence wait or ExecuteCommandLists. Staging is still reused only after its fence, the refresh still runs at submit, and a buffer whose staging fails is still marked stale. - In render mode the refresh runs before queue_execute takes draw_lock and allocator_lock, so a staging wait does not stall list recording. - x2w_d3d12_linear_buffer_info returns false for a wrapper without a desktop object. The fixture adds a contention path (X2W_TEST_LINEAR_STAGING_LIMIT=1): while a refresh waits for the only staging buffer behind a gate, the info export, release() and a second queue's submission must finish, and a hold-lock mutant that keeps the lock across the wait must fail. The copy path also refreshes on COMPUTE and COPY queues, read by a dispatch and by CopyBufferRegion. Refs R0Y00#1914 Refs R0Y00#874 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two submissions that snapshot the same copied 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, never one that misses a change. Comment only (tedin7's review nit on R0Y00#2218). Refs R0Y00#1914 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review of R0Y00#2218 (R0Y00): one copied buffer, one CPU write, then a list on queue 1 behind an unsignalled gate and a list on queue 2. Queue 2 read the old bytes: queue 1's refresh was enqueued behind its gate but recorded as uploaded, so queue 2 skipped its own. - Every refresh now runs on one internal COPY queue per device, which never waits on a title fence, and signals an internal fence value. Each copied buffer remembers the value of its last refresh. - Every submission through a queue wrapper first makes its queue wait for the highest such value among the live copied buffers that has not completed. A consumer on any queue runs after every refresh enqueued before it, and no title queue waits on another, so title-owned cross-queue fences cannot form a cycle with a refresh. - Staging is reused once its copy's internal fence value completes. The per-title-queue fences, after_submit and linear_submitted go. - If the internal queue or fence cannot be created, copied placements keep the default backing with that HRESULT recorded. - x2w_d3d12_linear_buffer_internal_queue lets fixtures hold refreshes. The fixture adds gate2q (both reads see the CPU write), gate2q.held (the second queue waits for a held refresh), xq (queue 1 waits on a fence queue 2 signals: no deadlock, both read the write) and a skip-consumer-wait mutant that must fail gate2q.held. Case c and contention hold the internal queue so staging stays in flight. Refs R0Y00#1914 Refs R0Y00#874 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With X2W_D3D12_BUDGET=1, slot 133's linear buffers are counted as the default backing counts its own: a shared buffer as a placed resource whose heap (opened once per private range) has a backing-heap ticket in use while a buffer on it is held, a copied buffer as a committed default buffer. The pool's staging buffers are counted as upload memory when they are created; they live for the process. The fixture enables the budget and checks, on the share and copy paths, that one placement goes live in its category, the heap is live for a shared one, and the title's release moves it to retained, with nothing unmeasured. Refs R0Y00#1914 Refs R0Y00#874 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The mesh XMem lease path (R0Y00#2280; X2W_MESH86_XMEM_SRV or X2W_MESH_INDIRECT_XMEM) takes the default copied placements of XMem pages whose console flags are 0: it mirrors their GPU writes into a leased view of the section and publishes that to mesh readers. Those are exactly the GPU-read XMem buffers the linear copy path would back. While the lease path is on, slot 133 now keeps the default backing for such a placement and records the deferral as a refusal, HRESULT_FROM_WIN32(ERROR_BUSY), in the log line, the info and the totals, so one placement never has two owners. Other placements are unaffected, and nothing changes while the lease path is off. The fixture adds a lease path (=copy with X2W_MESH86_XMEM_SRV=1): an XMem buffer keeps the default backing with the deferral reported, and a private one is still copied. Refs R0Y00#1914 Refs R0Y00#874 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Main now forwards CopyBufferRegion and CopyResource into slot 133 placed buffers (list_copy.inl), so a copied linear buffer can be written by the GPU. Those bytes never reach the title memory, and a later refresh whose changed span covers them copied the title's older bytes over them. A copied buffer that a recorded copy writes now keeps the GPU's bytes from that recording on and is no longer refreshed, as the default backing behaves for it. The info (gpu_written) and the totals report it, and the first few are logged. The fixture adds gpuw on the copy path: a list CopyBufferRegion (list slot 15) writes G into the buffer, the title changes the words on both sides, and the next read must still see G. The refresh-gpu-written mutant keeps refreshing and must fail it. Refs R0Y00#1914 Refs R0Y00#874 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…erral Describe, for slot 133's opt-in linear buffers on current main: the refresh and consumer Wait ahead of red_producers and split mesh submissions, the D3D12 budget categories, a copied buffer that a list copy wrote, and the deferral to the mesh XMem lease path. Record the budget, gpuw and lease cases, the refresh-gpu-written control and the results at ff06794 on WARP and an RX 9070 XT (driver 32.0.32029.2010), and note sharing XMem views through the section lease (R0Y00#2280) as a follow-up. Refs R0Y00#1914 Refs R0Y00#874 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
07455f0 to
bfdd583
Compare
|
Rebased again after today's merges, including #2468 (slice 2) and #2504. The head is now Conflicts, both in
Re-verified at
@tedin7, @R0Y00: the review and merge request from my earlier comment still stands. R0Y00's change request from AI-assisted; commands executed locally. |
|
@R0Y00, a point-by-point answer to your change request from
Full run at 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. |
R0Y00
left a comment
There was a problem hiding this comment.
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_' -VWindows 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.
| 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); |
There was a problem hiding this comment.
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 Win2025 run for head Verified on Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP) at commit
AI-assisted; commands listed were executed locally. |
|
Thanks, @R0Y00 and @tedin7 for the Win2025 run. Both points are understood and I'm working on them:
I'll post the new head with the results. AI-assisted. |
legacy-code-archaeologist
left a comment
There was a problem hiding this comment.
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:
- Thread A copies the title bytes X into staging.
- The CPU writes Y.
- Thread B copies Y into staging.
- B takes
internal_mutex_first and gets value 1. A follows with value 2, so the backing ends up holding X. - A publishes
uploaded = X, then B publishesuploaded = Y. - 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
uploadedfor a buffer only from a refresh whose fence value is higher than the last one published for it.
2. Title memory is read after the lock is dropped, so a concurrent release can fault in the DLL (before_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
liveand readability right before the memcpy, withretire()and the memcpy under the same lock. - Or guard the copy with SEH and mark that buffer stale.
AI-assisted (Claude Code).
|
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:
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. |
A list copy into a copied linear buffer changed the backing when the copy was recorded. A recording that was closed and then reset without being submitted therefore stopped the buffer's refreshes for good: the next read saw the old upload instead of the CPU's later bytes, on XMem and private memory alike (review repro on WARP and an RTX 4060). The write is now pending on the recording, next to the texture writes that list_copy.inl already tracks: commit_list_gpu_writes marks the buffer GPU-written after the recording's ExecuteCommandLists, and a Reset or a failed Close (discard_list_gpu_writes) drops it. The recording's own submission still refreshes the buffer first, and its queue waits for that refresh before the copy runs. The gpuw-at-record mutant restores the recording-time mark. Refs R0Y00#1914 Refs R0Y00#874 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A refresh's copy into a copied linear buffer was ordered only before later consumers (their queues Wait for the internal fence). An earlier submission that still reads or writes the backing, on any queue, could run at the same time as the internal COPY queue overwrote it. Simultaneous access allows concurrent operations on one buffer only on disjoint ranges. Each queue wrapper now signals a user fence of its own after the title's lists (render and plain submissions). Before a refresh's copy executes, the internal queue Waits for every queue's latest user fence value that has not completed (totals: producer_waits). The wrappers cannot tell which buffers a submission reads, since titles bind them by GPU virtual address, so every earlier submission counts as a user of every copied backing. A queue whose latest submission sits behind a title Wait (queue slot 17) on a fence that has not been reached is not waited for (totals: producer_wait_skips, logged): a later submission that waits for this refresh may be the one that signals that fence, and waiting would deadlock both queues. That submission has not started and reads the CPU's newer bytes once it runs. A fence reached while the copy still executes can still overlap the read; the header says so. A submission now also waits for the refresh it enqueued itself, even if the title released the buffer meanwhile; before, such a refresh was left out of the consumer Wait. The contention case asserts the new order: S1, gated, reads B because C's copy waits for it; S2 reads C. The gate opens before the internal queue is drained. The skip-producer-wait mutant removes the wait. Refs R0Y00#1914 Refs R0Y00#874 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two submissions on different threads could snapshot one copied buffer against the same upload record, stage the title's bytes at different times, execute their copies in one order and publish the upload record in the other. With X staged first, the CPU then writing Y and Y staged second, Y's copy could take the lower internal fence value and X's the higher, so the backing held X while the record said Y. No later submission refreshed the buffer until the title changed those bytes again. The comment that called this a redundant copy at worst was wrong. A copied buffer now remembers the internal fence value of its newest applied publish. A newer refresh applies its span; an older one that arrives after it drops the record (totals: reordered_publishes), and the next submission copies the whole buffer. An unknown record is set again only by a copy of the whole buffer. The publish-out-of-order mutant applies every publish in lock order, as before. Refs R0Y00#1914 Refs R0Y00#874 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
before_submit snapshots every live copied buffer, not only those the submitted lists read, and probes its title memory under the lock. refresh() then copied that memory into staging without the lock. If the title released one of those buffers on another thread and freed or unmapped its pages in between, the copy faulted inside d3d12_xs.dll. The title memory is now probed again right before it is staged, and the copy runs under a fault guard (access violation or in-page error). A buffer whose memory is gone is skipped and counted (unreadable), as the snapshot already does; a read that faults anyway is counted (copy_faults) and fails that buffer's refresh. A buffer released after the snapshot whose pages are still mapped is staged for that submission, which may read it (the contention case does). The wrappers cannot tell which buffers a submission's lists read, so the snapshot still covers every live copied buffer. The copy-after-retire mutant skips the second probe; the guard then catches the faulting read. Refs R0Y00#1914 Refs R0Y00#874 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ear_buffer_backing New cases on the copy path, on XMem and private memory: - gpuw.discard (the review repro): a list copy into a copied buffer is recorded, closed and reset without a submission; after the CPU writes B the next read must see B, with gpu_written 0. - war: a read of A on queue 1 behind a title gate; the CPU writes B and queue 2 submits a read. Queue 2 must not complete while the gate is closed, queue 1 must read A, queue 2 B, and producer_waits must grow. - xq.write: queue 1 waits through its wrapper (slot 17) on a title fence and submits a read; after the CPU writes B, queue 2's read must complete while queue 1 still waits (no deadlock), both read B, and the skip is counted. - order: two threads refresh one buffer, parked through a new fixture hook (x2w_d3d12_linear_buffer_test_pause) so that the older copy publishes last; the next submission must refresh and read D. - retire: a submission parks after its snapshot while the title releases X and frees its pages; X must be skipped as unreadable, with no copy fault and no failed refresh, and Y must read C. Four controls run on WARP with WILL_FAIL, each failing its own case: gpuw-at-record, skip-producer-wait, publish-out-of-order and copy-after-retire. The totals line prints the new counters. Refs R0Y00#1914 Refs R0Y00#874 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nd refresh races Describe the review fixes for slot 133's copied linear buffers. A list copy marks a buffer GPU-written only when its recording is submitted. A refresh's copy waits for every queue's earlier submission, except one that sits behind an unreached title Wait, which is skipped so that title fences cannot close a cycle. Uploads are published in the order their copies execute. Title memory is probed again and read under a fault guard right before it is staged. Add the gpuw.discard, war, xq.write, order and retire cases, the changed contention expectation (S1 reads B), the four new controls, and the results at 981b519 on WARP and an RX 9070 XT (driver 32.0.32029.2010) in the dev and release presets. Note the remaining overlap window and the cost of treating every submission as a user of every backing. Refs R0Y00#1914 Refs R0Y00#874 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@R0Y00, @legacy-code-archaeologist: all four points are addressed at
Decision needed: one exception to "wait on all prior users" (fix 2).
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:
Runs (Windows 11 build 26300; WARP 10.0.26100.9818; AMD Radeon RX 9070 XT, driver 32.0.32029.2010):
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. |
|
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. |
|
@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 AI-assisted. |
|
For the 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. |
|
@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. |
|
Thanks, @R0Y00: understood, and thanks @tedin7, no harm done. For
New head and results to follow. AI-assisted. |
What and why
This is the first production slice of the #1914 decision, as R0Y00 asked after #1942 merged. It wires #1942's comparison to one ordinary linear buffer that the CPU writes and the GPU reads, and it keeps the current backing as the default.
The buffer kind is device slot 133 (
CreatePlacedResourceX) with a buffer description, row-major or unknown layout, and initial stateCOMMON. This is the narrowest production kind that is linear, CPU-written and GPU-read:S_OKwith a zero-filled buffer that does not alias the title memory.Buffers in
UNORDERED_ACCESSor acceleration-structure state, textures and command-list slot 148 keep their current paths.X2W_D3D12_LINEAR_BUFFERS=1(or=copy) opts in. Unset or0, none of the new code runs.Rebase onto main (
ff06794b) and follow-upsThe branch is rebased onto
ff06794bas a series. Main had changed slot 133,release()andqueue_executesubstantially.Integration with main:
release(): main's budgetend_usecalls,drop_mesh_lease_ownerand the list-kinddiscard_mesh_lease_recordingare kept. The linearretireruns afterretire_placement, under the opt-in.queue_execute: main'ssubmitlambda (red_producers().execute,retire_address_uploads,retire_draw_sampler_heaps,note_submits,commit_list_gpu_writes) and the mesh XMem split path are unchanged. The internal-queue refresh and the consumerWaitrun once per guest call before the wrapper's locks, so they precede every list of the submission in both the render and non-render paths. That covers the producer fencesred_producersadds and each split mesh submission, and leavesred_producerssemantics as they are.publish_placed_buffercarries main's tail: theindex_resourcecallback inpublish_placement,x2w_budget::resource(..., placed)plus the heap'sbacking_budgetwithbegin_usewhen aliased, andx2w_budget::committed(..., DEFAULT)otherwise. Main's default path uses it unchanged.docs/experiments.md: main's "A lease for committed XMem section pages" and "GPU queue handoff to an XMem-backed root SRV" sections come first, then this one.New commits on top:
gpu: count linear-buffer backings in the D3D12 budget).budget(share, copy): one placement goes live in its category (placed with its heap live, or buffer), and the title's release moves it to retained, with nothing unmeasured.gpu: defer slot 133 linear buffers to the XMem lease path).X2W_MESH86_XMEM_SRVorX2W_MESH_INDIRECT_XMEM) takes the default copied placements of XMem pages whose console flags are 0.note_mesh_xmem_writerequiresPlacement::copied_bufferandconsole.Flags == NONE, then mirrors GPU writes into a leased view and publishes it to mesh readers.HRESULT_FROM_WIN32(ERROR_BUSY)(0x800700aa, "deferred to the lease path") in the log line, the info and the totals. Other placements, and everything while the lease path is off, are unchanged.lease: the XMem buffer keeps the default backing (reads zero, as before) with the deferral reported, and a private one is still copied.gpu: stop refreshing a copied linear buffer that a list copy writes).CopyBufferRegionandCopyResourceinto slot 133 placed buffers (list_copy.inl), so a copied linear buffer can be GPU-written. Those bytes never reach title memory, and a refresh whose changed span covered them would have copied older title bytes over them.gpu_writtenin the info and totals.gpuw(copy path): a listCopyBufferRegionwrites G, the title changes the words on both sides, and the read still sees G.refresh-gpu-writtenkeeps refreshing; it reads A instead, and fails 2 of 2.Follow-up, not in this PR: with #2280's section lease (pinned slots mapped as one view, opened as a D3D12 heap and released after GPU completion), XMem views could be shared through a lease instead of copied. This PR keeps copying them; view sharing stays refused (
0x80070032) because an open heap pins the title's own view.Review changes (R0Y00)
The repro. One copied buffer held A, and its first read was complete. Two read-only direct lists were recorded for it, and the CPU wrote B once before submitting either. List 1 went to queue 1 behind an unsignalled gate. List 2 went to queue 2, completed before the gate opened, and read A in 1,024 of 1,024 words; list 1 later read B. No refresh failure was reported.
The cause. Queue 1's submission enqueued the refresh on queue 1 behind the gate, but
uploadedwas updated at enqueue. Queue 2's diff therefore saw no change and skipped its refresh.Fix (
src/startup_stubs/linear_buffer_backing.h):ExecuteCommandListsandSignalon that queue are serialized by a small mutex of their own, so values stay in order. The backing's main lock is still never held across a wait orExecuteCommandLists.Wait(internal_fence, V). V is the highest value among the live copied buffers that has not completed; buffers the title released are not waited for. Recordinguploadedat enqueue is now correct, because every later consumer waits for the copy to land.after_submit, the per-title-queue fences andlinear_submittedare gone.docs/startup-runtime.md.X2W_TEST_SUBMIT_FENCE_FAIL=1still givesE_NOT_VALID_STATE. Nothing returns stale data silently.x2w_d3d12_linear_buffer_internal_queuereturns the internal queue, so a fixture can hold refreshes in flight behind a fence of its own. Cases c, contention andgate2q.helduse it. Without it, staging is free almost at once, and the in-flight cases would test nothing.Tests.
gate2q(R0Y00's case; copy path, private and XMem): queue 2 completes while queue 1's gate is still closed and reads B; queue 1 then reads B.gate2q.held: the internal queue is also held. Queue 2 must not complete in 200 ms before the refresh lands, then reads B. Queue 1 reads B.xq: queue 1 waits on a title fence that queue 2 signals after its list. Both complete, with no deadlock, and both read B.skip-consumer-wait: submissions no longer wait.gate2q.heldthen has queue 2 read A before the held refresh lands (2 of 2), and case c reads zeros.contentionnow holds the internal queue rather than a title fence. The probes still take 0 ms while the refresh waits about 310 ms. S1 and S2, both behind the title gate, now both read C, the CPU's last write before they ran. Under the old per-queue design S1 read B.reuse-earlystill fails it.q.compandq.copystill pass: the consumers on COMPUTE and COPY queues wait for the internal fence.Review changes (tedin7)
b0669e06. Inqueue_execute, runtime: allocate command-list upload memory on the recording allocator #2216'sretire_address_uploads(queue, ready)andlinear_submitted(queue, linear)are both kept, in that order. Main's "Command-list upload allocation (slot 148)" section precedes this one indocs/startup-runtime.md.before_submitno longer holdsmutex_across a fence wait orExecuteCommandLists.acquire_staging), creates staging (create_staging), waits up to 5 s for the oldest staging fence when the pool is full, copies into staging, takes and resets a refresh list (acquire_list), records it and runsExecuteCommandLists.shared_ptr, so a snapshot outlives a concurrentdiscard.after_submitstill signals the queue fence under the lock. That keeps fence values monotonic across threads;Signaldoes not wait.queue_executenow refreshes before it takesdraw_lockandallocator_lock, so a staging wait no longer stalls list recording either.linear_submittedruns after the ready check, so an executed refresh always gets its fence value.contentionpath (X2W_TEST_LINEAR_STAGING_LIMIT=1): S1 holds the only staging buffer behind a gate, and S2's refresh waits for it on another thread. While S2 waits, three probes must finish: the info export,release()of the buffer, and a submission on a second direct queue. Each took 0 ms, and S2 was still waiting after all three. After the gate opens, S2 takes the same staging buffer (none created) and reads its own bytes.hold-lockkeeps the lock across the wait, as before. The info probe then blocks for 4.7 s until the wait times out, S2 goes stale and reads the old bytes, and the case fails 2 of 2.q.compandq.copyon the copy path. The buffer is read by a dispatch on a COMPUTE queue and byCopyBufferRegionon a COPY queue, each through its queue wrapper. The refresh runs on that queue: the buffer is promoted fromCOMMONtoCOPY_DESTthere and decays after. The first submission reads B with 131,072 bytes copied, and a 16-word change then copies 64 bytes. This holds on both adapters with the debug layer on and off, with no debug-layer errors. Both queue types are supported, so neither is refused.x2w_d3d12_linear_buffer_inforeturns false for a wrapper whoseown().realis null. The totals export takes no wrapper.after_submit,linear_submittedand per-queue refresh lists are gone. The snapshot, unlocked work and publish structure is unchanged.Design (
src/startup_stubs/linear_buffer_backing.h)XMem keeps the title memory (identity, mapping, offsets, lifetime). The new file owns the desktop backing and the fences that say when the GPU is done with it.
Share only after
D3D12_FEATURE_EXISTING_HEAPSreports support. The query runs once per device, before any open. The buffer must lie inside one committed private allocation at a 64 KiB-aligned offset, and the heap must cover it. The heap is cached by allocation base: while it is open, the range cannot be released or decommitted (error 87, gpu: compare one linear buffer through sharing, copying and refused sharing #1942), so no other allocation can appear at that base. Each opened heap gets a generation.No sharing of XMem views. This was measured here: a heap opened from an XMem view makes XMem's unmap of those pages fail with error 87, and it succeeds after release. Desktop resources live for the process, so sharing a view would keep the title from ever unmapping or freeing its pages. Sharing reports
HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED)(0x80070032) and the buffer is copied. A buffer across several allocations, or at an unaligned offset, reportsE_INVALIDARG. Both are decided before any D3D12 call.Copy into a committed default buffer, refreshed from title memory at each submission through a queue wrapper's
ExecuteCommandLists(render and non-render paths), just before the title's lists run, never at bind or record.Keep the default backing and record the refusal where neither path keeps its guarantees. Slot 133 then returns what it returns with the switch off; the console never fails
CreatePlacedResourceX(see Title run). The refusals:ALLOW_UNORDERED_ACCESS) that cannot be shared has no copy-back point: the sharing HRESULT, orDXGI_ERROR_UNSUPPORTEDwhen sharing was not attempted;E_NOT_VALID_STATEunderX2W_TEST_SUBMIT_FENCE_FAIL=1, else the creation HRESULT;Each refusal is recorded three ways:
(kept default backing: linear refusal 0x..., use=... type=... existing-heaps=... share=...)appended;x2w_d3d12_linear_buffer_info, as path 3 withrefusal_hr;kept_defaultandlast_refusal_hr.Never hold a submission back, and never hold the lock across a wait. Work is snapshotted under the backing's lock, staged, recorded and executed without it, and published under it again (see Review changes). Consumers on direct, compute and copy queues all wait for the internal fence.
Refresh failures. If a copied buffer's refresh cannot be staged, the submission still runs. This happens when staging or a refresh list cannot be created, or when the pool stays full of buffers in flight past a 5 s wait (
DXGI_ERROR_WAS_STILL_DRAWING). The buffer keeps its last upload and is marked stale until a later refresh succeeds. The first failures are logged with their HRESULT, and every one is counted:stale,refresh_failuresandlast_refresh_hrin the info, andrefresh_failuresandlast_refresh_hrin the totals.d3d12_xs_device.cppchanges in four places:publish_placed_buffer. With the switch off, the default log line gets an empty suffix.releaseretires a copied buffer.queue_executerefreshes and inserts the consumer wait before the title's lists. In render mode this happens before the wrapper's locks.x2w_d3d12_linear_buffer_info,x2w_d3d12_linear_buffer_totals(layouts inlinear_buffer_report.h) andx2w_d3d12_linear_buffer_internal_queue.Fixture-only switches:
X2W_TEST_EXISTING_HEAPS_UNSUPPORTED=1X2W_TEST_LINEAR_REFRESH_FAIL=<n>(staging requests 2, 2 + n, ... fail withE_OUTOFMEMORY)X2W_TEST_LINEAR_STAGING_LIMIT=<n>(staging pool of n buffers instead of 256)X2W_TEST_LINEAR_BUFFER_MUTANT=<name>Title run
Measured on an RX 9070 XT (driver 32.0.31044.16, Windows 11 build 26300, Release) with a warm shader cache,
-Render -Translate -FakeUser -GpuMirror -StartupBelow40 -MemoryGiB 32and the same post-confirmation input in every run. Counts only; no title is named here.Earlier revision (
32ddb0bc), which returned the refusal from slot 133:X2W_D3D12_LINEAR_BUFFERS=1: the title faulted at 1.76 s, reading address0x18. Its first eligible slot 133 placement waswidth=0xae00000 flags=0x20004 type=0x40000 (MEM_MAPPED) use=gpu-written share=0x80070057, and slot 133 returned0x80070057. On the consoleCreatePlacedResourceXdoes not fail, so the title used the null object.That is why every refusal now keeps the default backing and is only recorded.
This revision (
14769462), matched pair on one build:X2W_D3D12_LINEAR_BUFFERS=10x80070057split or unaligned GPU-written, 440x80070032XMem view)The opt-in no longer changes how far the run gets, and the frame rate stays within 1% of the switch-off arm. The peak-commit difference is not attributed: a switch-off cold-cache run on the same input earlier today peaked at 16,289 MiB, so peak commit varies with how much a run loads. The opt-in arm had 2 missing pipelines and 3 undrawn draws where the switch-off arm had none; I have not investigated that difference.
Title run on this head (
9b8c36fe, rebased ontoff06794b)Correction: in this pair, neither arm got past the legal and acceptance page. Both ended at 420 s on that page with its boxes unticked. The scripted presses (the last at about 272 s) ran identically in both arms but no longer reach confirmation on current
main; the page most likely appears later than before. So this pair covers the startup phase up to that page, not the post-confirmation load. A rerun with input that reaches confirmation will follow.This is a matched pair on one build with the same input: RX 9070 XT (driver 32.0.32029.2010), Windows 11 build 26300, warm cache,
-Render -Translate -FakeUser -GpuMirror -StartupBelow40 -MemoryGiB 32, and a 420 s limit. The opt-in arm ran first. System shared commit was read withNtQuerySystemInformationbefore each arm and 10 s after it exited.X2W_D3D12_LINEAR_BUFFERS=10x80070057, 440x80070032)Test
tests/linear_buffer_backing_check.cppdrives the production entry points, not a model:ExecuteCommandLists(queue slot 10) on the queue wrapper, in render mode.It reuses #1942's sentinels and cases. The GPU reads through a root SRV and writes through a root UAV. Title memory is either
xmem.dllphysical pages (X2W_XMEM_SHARED_VIEWS=1, five pages per view, buffer at+0x30000, first buffer on freed slots that must read zero) or one committed private range.A kept default must meet three conditions:
S_OKwith an object;X2W_TRAP_LOG, written next to the executable aslinear_buffer_backing_<path>_<adapter>.log.The cases:
Waiton a gate.release()and another queue's submission finish while a refresh waits for the only staging buffer, whose copy is held on the internal queue.Results
Environment:
ff06794b(head9b8c36fe), Windows 11 build 26300.9974.1414:008c, driver 10.0.26100.9818) and AMD Radeon RX 9070 XT (1002:7550, driver 32.0.32029.2010; the driver changed since the earlier runs). Both reportD3D12_FEATURE_EXISTING_HEAPS.X2W_TEST_DEBUG_LAYER=1). No errors were stored.The results were identical in all four configurations, including every totals line. All eight paths pass, with no skips.
Bytes are those copied from title memory into the backing. HRESULTs are the slot 133 result, then the sharing result and the recorded refusal.
S_OK/ not attempted / noneS_OK/ not attempted / noneS_OK/S_OK/ noneS_OK/0x80070032, split0x80070057/ b, d20x80070032S_OK/ not attempted / b, d20x887A0004S_OK/0x887A0004from the feature gate / b, d20x887A0004S_OK/ not attempted / a0x8007139F(E_NOT_VALID_STATE), b and d20x887A0004S_OK/ not attempted / noneS_OK/ not attempted / none.held: queue 2 waits for the held refresh; xq: both complete and read BS_OK/ not attempted / noneS_OK/ not attempted / nonegpu_written1S_OK/S_OK/ noneS_OK/ not attempted /0x800700AAS_OK/ not attempted / noneS_OK/ not attempted / none0x8007000Ein info and log; next submission reads B, stale cleared; 2 refresh failures in totalsTotals per run:
Measured, not asserted (share path, XMem): on both adapters
OpenExistingHeapFromAddresson the five-page view and a placed buffer at+0x30000returnS_OK. While they live, XMem's unmap fails with error 87. After their release it succeeds and the pages are freed. This is why views are copied.Negative controls
Each control sets
X2W_TEST_LINEAR_BUFFER_MUTANT, which removes one guarantee insided3d12_xs.dll. Each must fail its case in both pools, and in all four configurations each does:skip-refresh(copy)reuse-early(copy)copy-gpu-writes(copy)ignore-feature(refusal)EXISTING_HEAPS = 0; gate 1 of 1 failedrefusal-silent(copy)hold-lock(contention)skip-consumer-wait(copy)gate2q.held: queue 2 completes before the held refresh lands and reads A; 2 of 2 failed (case c also reads zeros)refresh-gpu-written(copy)gpuw: the refresh of the title's two changed words spans the written region and copies A over G; 2 of 2 failedInside the run there are also these oracle controls:
Commands
ff06794b):ctest --preset release --no-tests=error -R '^(linear_buffer_backing|startup_upload_arena|startup_upload_lifetime|startup_list_resubmit|startup_address_console_|xmem_section_lease_|unified_buffer_paths_)' -j 4passed 53/53, covering WARP and hardware. That is 24linear_buffer_backing(8 paths on 2 adapters, plus 8 controls), 5unified_buffer_paths, 6xmem_section_lease, 8startup_list_resubmit, 6startup_address_console, 2startup_upload_arenaand 2startup_upload_lifetime.X2W_TEST_DEBUG_LAYER=1,-R '^linear_buffer_backing'passed 24/24.linear_buffer_backing_checkwas also run directly: all 8 paths and all 8 mutants, on both adapters, debug layer off and on. Every path passes, every mutant fails all its targeted rows, and the path totals are identical across the four configurations.out/diag/perfinfo.py), before the release build and after all of these runs:SharedCommittedPages: 926,231 → 922,226 pages, −4,005 pages (about −15.6 MiB). No shared-commit growth.CommittedPages: +79,010 pages (about 309 MiB) over the same window, which includes the release build and other activity on the machine.52d779d9), environmental failure: one earlier debug-layerctestattempt failedunified_buffer_paths_{warp,hardware}with setup errors. The cause was the system commit limit, with 51 MB free of 184 GB while a title run was active. The section pool's 256 MiB pagefile section could not be created, andgititself failed with0xC000012D. The same binaries then failed identically without the debug layer. Once commit was free again, the same command passed 25/25.14769462); not rerun for this one:ctest --preset dev --no-tests=error -R '^(vm_|era_|xmem|unified_buffer_paths|startup_|linear_buffer_backing)' -j 6selected 513 tests:linear_buffer_backing_*and 5unified_buffer_paths_*tests.startup_view_heap_{warp,hardware}andstartup_logical_view_{warp,hardware}.startup_run_ps1. It compares the translator's--watchpath against the 8.3 short form of%TEMP%and gets the long form, because the profile path on this host contains a space. It also fails on unmodified main on this host, so it is pre-existing.startup_gamesave_*C3066 build failure seen on an earlier base is fixed on main by tests: call the saved QueryApiImpl through load_real_query() #2204. It no longer occurs here.Skips
None on WARP or the RX 9070 XT.
linear_buffer_backing_share_hardwarereturns 77 on an adapter without existing-heap support, andrefusalcovers that case there. On a Gen9 adapter thesharerun would skip while the other paths run. That has not been measured here.Not covered
frame_copyat record, and graphics root SRVs still takeupload_from_titleat bind. Neither reads the slot 133 backing; moving them to the submit copy point is a separate change.OpenExistingHeapFromFileMapping) with section and offset from XMem.X2W_TEST_EXISTING_HEAPS_UNSUPPORTED=1.Refs #1914
Refs #874
🤖 Generated with Claude Code