startup: carry verified copy ranges into indirect draws #2232
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2240"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T07:05:38Z.
Depends on #1944 and #2236. Refs #870. The review base composes their tested heads
18ec51deand741e2ef7so this diff contains only the range handoff.With
X2W_TRANSLATED_INDIRECT_COPY_RANGES=1, the translated indirect Draw can bind a copied placed buffer when a verified slot 15 CopyBufferRegion on the same recording supplied the complete descriptor range. The source must be an authoritative desktop buffer, an exact alias, or a range already covered in that recording. An overlapping write without provenance drops the earlier proof. A new command-list recording must establish its own coverage. The draw reads the actual desktop destination at the recorded byte offset and leaves CPU backing alone.The source-built fixture recreates a 68-byte request at source offset
0xbfffa0. The compute writer fills the source, slot 15 copies it, and fenced colour readback gets eight red pixels while the title-memory sentinel stays green. The same DLL with the feature disabled leaves the target clear. Changing recordings, shortening the copy to 64 bytes, or overwriting part of it from an untracked endpoint also leaves the target clear. The observed request shape alone does not establish the provenance of a live non-aliased source.Local MSVC Release on Windows 11 build 26200.9974. WARP 10.0.26100.9818 and RTX 4060 Laptop 32.0.16.1656. The indirect draw fixtures enable the D3D12 debug layer.
12/12 passed, no skips. AI-assisted. Commands executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T07:10:28Z.
Review: COMMENTED
Review of head
13b21704066faf51a335d1a3068efb639e6eb898(range handoff on top of mergeb6755e9e).Verdict: no P1, no P2. Three nits. Linux-side review only; I did not build or run the MSVC/WARP fixtures (see "Not verified").
Commands executed locally (Linux):
gh pr checks 2240-> no CI checks reported on the branch.mergeable: MERGEABLE, title neutral.git diff --stat origin/main...HEAD-> 11 files, +1779/-21.git diff --stat b6755e9e HEAD-> 6 files; the handoff itself is small.python3 tests/docs_links_check.py-> "Checked 18 Markdown files and 412 links."python3 tests/bidi_controls_check.py-> "no bidirectional controls."git diff --check origin/main...HEAD-> exit 0.What I checked in the handoff diff:
d3d12_xs_device.cpp:2019-2040list_copied_gpu_range/note_copy_gpu_range: containment testoffset >= r.offset && bytes <= r.bytes && offset - r.offset <= r.bytes - bytescannot underflow or overflow. The overlap erase handles both orderings and is also run for non-authoritative writers, so an untracked overlapping copy drops the proof. Cap of 64 fails closed.Pass, whichrelease_targetsresets withpass = Pass{}at Close (:2071), matching the doc claim that another recording needs its own writer.list_copy.inl:158-174copy_source_authoritative: requires live wrapper,COMMONinitial state, same device, and for title-backed sources a unique placed owner that is either an alias or already covered. Reasonable and fail-closed.list_copy.inl:186-196: with the flag off,check_endpoint_roles+sync_title_sourceis equivalent to the oldcheck_roles_and_sync(..., true), so the old refusal behaviour is unchanged.d3d12_draw.inl:1446-1453: a non-alias placement now needslist_copied_gpu_rangefor the whole view; alias path unchanged.Findings:
list_copy.inl:196and:223-225:mark_gpu_writtenis no longer called for buffer destinations, for CopyBufferRegion and for CopyResource of buffers, and this also applies with the feature off. I found no consumer for buffers (gpu_writtenis read only for textures:d3d12_draw.inl:1034,list_copy.inl:87-88), so I think it is harmless, but please mention it in the PR body or keep the call to leave the flag-off path byte-identical.list_copy.inl:223: a whole-resourceCopyResourcebuffer-to-buffer from an authoritative source only erases ranges; it never records one. This is conservative (fails closed) but worth a one-line note indocs/experiments.mdso nobody expects it to qualify.d3d12_xs_device.cpp:2026:list_copied_gpu_rangereturns early on the env flag butnote_copy_gpu_rangeis also gated, so both are consistent; consider caching oneindirect_copy_ranges()result per call site to make that obvious. No functional issue.Not verified (honest limits):
startup_indirect_copy_provenance_{warp,hardware}and..._off_...rely on the author's reported local run. The PR is not Draft, and there are no CI checks, so a real Win2025 WARP dev+release pass is still needed before merge.offset - range.offset <= range.bytes - bytesbound; (2) skip the overlap erase innote_copy_gpu_range; (3) drop theplacement_devicecheck incopy_source_authoritative. The 64-byte-copy and untracked-overwrite cases in the fixture should kill (1) and (2); I could not tell from reading whether any case kills (3).AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T07:38:48Z.
Review: COMMENTED
Re-review of head
f81d3c8aada029fa30fbbbba136125facb66decd(previous review covered13b2170; this head merges main on top).Commands executed locally (worktree of the PR head):
git diff --stat origin/main...HEAD: 6 files, +173/-21 (CMakeLists, docs/experiments.md, d3d12_draw.inl, d3d12_xs_device.cpp, list_copy.inl, tests/startup_indirect_draw_indexed.cpp)python3 tests/docs_links_check.py: self-test passed, 18 Markdown files / 419 links OKpython3 tests/bidi_controls_check.py: 1527 files, no bidirectional controlsgit diff --check origin/main...HEAD: cleangh pr checks 2240: Linux Python checks, gfx1013 fixtures and Windows build/test pass; /O2 job skippedFindings
P2:
src/startup_stubs/list_copy.inl:~200(list_copy_buffer_region) and:~224(list_copy_resource, buffer branch). The unconditionalmark_gpu_written(self, to)is gone from both paths, and the new range bookkeeping returns early whenX2W_TRANSLATED_INDIRECT_COPY_RANGESis off. With the flag off (the default), a copy into a title-backed buffer no longer queues the destination inpending_gpu_writes.commit_list_gpu_writesthen never setsgpu_written/donefor it on submit. That is a behavior change on the default path for a PR that presents itself as opt-in. Suggested fix: keepmark_gpu_written(self, to)on the buffer paths regardless of the flag, and add the range note on top. Or, if the removal is intended because it never applied to buffers, say so in the commit message and cover it with a test. Today thecopy-provenance-offcase only checks that indirect draws are refused, so it would not notice this.P2 (test gap): the
-offcase does not pin that the pre-existing copy behavior is unchanged with the flag off. I'd add one assertion on the pending-write orgpu_writtenstate after a buffer copy with the flag off.Nit:
note_copy_gpu_rangesilently drops a range whenranges.size() >= 64and the 65th is authoritative. Overlapping ranges are erased first, so the stale entry is gone and the case fails closed. That is the right direction, but a one-line comment would make it deliberate.Nit:
note_copy_gpu_rangeswallowsstd::bad_allocwith a barereturn. That also fails closed (no range recorded), so it is fine. It just deserves a comment saying why.What looks right
offset - range.offset <= range.bytes - bytesis overflow-safe, andaddress + offsethas an explicit overflow guard.CopyResourceof a buffer records a non-authoritative range, which erases overlapping authoritative ranges. That correctly invalidates them.d3d12_draw.inlnow requireslist_copied_gpu_rangewhenever the placement has no alias. It stays fail-closed.AI-assisted; commands listed were executed locally.