startup: implement next copy command-list slot in d3d12_xs_device (Part of #870) #2070
No reviewers
Labels
No labels
accessibility
awaiting author
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
priority: P0
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/R0Y00--Xbox2Windows!2070
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2070/head"
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?
@tedin7 on GitHub · 2026-11-24 23:58 UTC · original
tedin7:x2w-870-copy-slot→main· +738 −1 · 7 files · 7 commits · merged 2026-11-25 14:51 UTCPart of #870
What this unblocks: command-list slot 16
CopyTextureRegion(texture to texture, texture to buffer, buffer to texture) is no longer dropped in render mode, so title copies reach the desktop list.What changes
COPY_SOURCE/COPY_DESTfor the call (Close returns them toCOMMON), and forwards the call.unknown_resource,buffer_to_buffer,bad_box,source_overflow,dest_overflow,bad_pitch,bad_offset,footprint_overflow,sample_mismatch,bad_alignment.src/startup_stubs/list_copy_texture.h; the handler is inlist_copy_texture.inl(one include and one install line ind3d12_xs_device.cpp).x2w_d3d12_list_copy_texture_statsexports the counters.CopyTiles(18) is left out on purpose. Slots 15, 17, 19 are in #1944.The slot placement follows the unshifted order of slots 12 to 25 and has not been seen in a title log yet.
Verification: (Win2025:
x2w_pipe.py win2025 2070at head 91c13296, debug and release /O2, release ctest 23/23 passed incl.startup_list_copy_textureandstartup_list_copy_texture_overflow_control; Linux checks below)@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 00:07 UTC · original · edited 2026-11-25 00:13 UTC
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
91c1329ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 00:13 UTC · original
For footprint buffers on UPLOAD or READBACK heaps, these calls emit invalid barriers.
device_create_committed_x()creates those resources in GENERIC_READ and COPY_DEST respectively, butrequire_state()assumes an unseen resource starts in COMMON, transitions it to the requested state, and returns it to COMMON at Close. Upload/readback resources must remain in their fixed heap states, so ordinary buffer-to-texture uploads and texture-to-buffer readbacks can invalidate the whole command list. Detect these heap types and exclude them from the COMMON-based transition tracking.Useful? React with 👍 / 👎.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 00:13 UTC · original
When a source texture has been filled through its guest backing but has never been sampled, unwrapping
own().realdoes not provide its current contents. Placed textures use non-aliased desktop stand-ins, andd3d12_draw.inl::upload_texture()normally populates them lazily during a draw; this handler never invokes that synchronization. Likewise, slot 133 can return non-aliasedPlacement::copied_buffersources. Copies from these backings therefore read stale or zero desktop data instead of the supplied source bytes. Materialize the relevant source data before forwarding, or explicitly refuse unsupported backings.Useful? React with 👍 / 👎.
@ -0,0 +155,4 @@to.pResource = real_dst;from.pResource = real_src;static_cast<ID3D12GraphicsCommandList*>(self->own().real)->CopyTextureRegion(&to, x, y, z, &from, box ? box : nullptr);InterlockedIncrement(&list_copy_texture_forwarded);@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 00:13 UTC · original
For a destination texture with
title_memory, no render-target/depth/UAV flags, and no previous sampler bind, this copy updates only the desktop resource and leaves itsTextureUploadcache untouched. On the first subsequent sample,draw_translated()callsupload_texture(), whose initialdone == falseschedules an upload from the stale guest backing over the copied pixels. Thus a valid copy from a rendered texture into a shader-only texture is lost before it is sampled. Publish the GPU write to the texture-coherence tracking so the first-bind uploader preserves copied contents.Useful? React with 👍 / 👎.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 00:13 UTC · original
When the locations name different subresources of the same texture, such as two array slices, both checks pass but
real_src == real_dst.require_state()tracks states per resource, andtransition()always uses ALL_SUBRESOURCES, so the second call moves the source subresource back out of COPY_SOURCE and into COPY_DEST immediately before the copy. This turns a legal intra-resource copy into an invalid D3D12 command. Track and transition the selected subresources independently, or refuse this case until that is supported.Useful? React with 👍 / 👎.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 00:13 UTC · original
For partial footprint copies, the byte-end calculation uses only the copied extent and ignores both the destination origin and the source box origin. The portable checker returns
okfor a 1x1 RGBA8 copy into a 64x64 footprint with row pitch 256, buffer size 256, and destination Y=63, although the write ends at byte 16132. Source boxes with nonzero top/front have the same problem, and 3D slice strides must use the footprint height rather than the copied height. Include those offsets and strides, or conservatively validate the complete footprint, before forwarding an out-of-buffer copy.Useful? React with 👍 / 👎.
@ -4786,6 +4787,7 @@ void build_tables()list_typed[139] = reinterpret_cast<ListTyped>(&list_reset);list_typed[148] = reinterpret_cast<ListTyped>(&list_allocate_upload);list_typed[12] = reinterpret_cast<ListTyped>(&list_draw);list_typed[16] = reinterpret_cast<ListTyped>(&list_copy_texture);@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 00:13 UTC · original
Installing slot 16 changes the public startup-runtime capability and adds a new reproducible fixture, but neither
README.mdnordocs/experiments.mdis updated; repository-wide searches find the new fixture only in source, tests, and CMake. The rootAGENTS.mdexplicitly requires updating one of those documents when a public capability or reproduction command changes. Add the fixture command, its measured portable-check scope, and the unverified Windows-forwarding status rather than leaving that information only in the commit message.AGENTS.md reference: AGENTS.md:L211-L212
Useful? React with 👍 / 👎.
@tedin7 on GitHub · 2026-11-25 01:13 UTC · original
All 6 review threads fixed and pushed in 394dbe3a (rebased on origin/main).
@tedin7 on GitHub · 2026-11-25 01:33 UTC · original
Fixed in 394dbe3a:
fixed_heap_state()detects UPLOAD/READBACK buffers and skipsrequire_state()for them; an upload destination or readback source is refused (bad_heap). Win2025x2w_pipe.py win2025 2070: dev and release 23/23 ctest passed, incl. startup_list_copy_texture and its overflow control.AI-assisted; commands listed were executed locally.
@tedin7 on GitHub · 2026-11-25 01:33 UTC · original
Fixed in 394dbe3a: texture sides call
upload_texture()before the copy; a non-aliased copied-buffer source is refused (stale_source). Win2025x2w_pipe.py win2025 2070: dev and release 23/23 ctest passed, incl. startup_list_copy_texture and its overflow control.AI-assisted; commands listed were executed locally.
@ -0,0 +155,4 @@to.pResource = real_dst;from.pResource = real_src;static_cast<ID3D12GraphicsCommandList*>(self->own().real)->CopyTextureRegion(&to, x, y, z, &from, box ? box : nullptr);InterlockedIncrement(&list_copy_texture_forwarded);@tedin7 on GitHub · 2026-11-25 01:33 UTC · original
Fixed in 394dbe3a: the destination texture is uploaded via
upload_texture()before the copy, so the first sample no longer schedules an upload over the copied texels. Win2025x2w_pipe.py win2025 2070: dev and release 23/23 ctest passed, incl. startup_list_copy_texture and its overflow control.AI-assisted; commands listed were executed locally.
@tedin7 on GitHub · 2026-11-25 01:33 UTC · original
Fixed in 394dbe3a: a copy whose two sides are the same resource is refused (
same_resource) since states are tracked per resource. Win2025x2w_pipe.py win2025 2070: dev and release 23/23 ctest passed, incl. startup_list_copy_texture and its overflow control.AI-assisted; commands listed were executed locally.
@tedin7 on GitHub · 2026-11-25 01:33 UTC · original
Fixed in 394dbe3a:
footprint_end()includes the destination/source-box origin and the footprint-height slice stride; tests added (dest origin Y=63 -> footprint_overflow, box origin, 3D slice stride). Win2025x2w_pipe.py win2025 2070: dev and release 23/23 ctest passed, incl. startup_list_copy_texture and its overflow control.AI-assisted; commands listed were executed locally.
@ -4786,6 +4787,7 @@ void build_tables()list_typed[139] = reinterpret_cast<ListTyped>(&list_reset);list_typed[148] = reinterpret_cast<ListTyped>(&list_allocate_upload);list_typed[12] = reinterpret_cast<ListTyped>(&list_draw);list_typed[16] = reinterpret_cast<ListTyped>(&list_copy_texture);@tedin7 on GitHub · 2026-11-25 01:33 UTC · original
Fixed in a2702c0d: new section 'Command list CopyTextureRegion (list slot 16)' in docs/startup-runtime.md with capability, scope, unverified Windows forwarding, and the command
ctest --preset dev --no-tests=error -R '^startup_list_copy_texture' -V. Win2025x2w_pipe.py win2025 2070: dev and release 23/23 ctest passed, incl. startup_list_copy_texture and its overflow control.AI-assisted; commands listed were executed locally.
@tedin7 on GitHub · 2026-11-25 03:03 UTC · original
Addressed in d7610f5b (code in 2927598b).
Fix:
mip + slice * mips + plane * mips * array_sizeand must lie insidemips * array_size * planes. A mip-only modulo no longer reads an out-of-range slice as mip 0 (bad_subresource). Planar formats are refused (planar_unsupported).format_mismatch) and the same sample count (sample_mismatch). A multisampled copy must be whole subresource to whole subresource at origin 0 (partial_multisample).Regression tests:
startup_list_copy_texture(Linux and Windows): index decode, last valid index, one past the last slice,0xffffffff, sample counts, formats, checked arithmetic. Negative controls:startup_list_copy_texture_overflow_control,startup_list_copy_texture_slice_control.startup_list_copy_texture_warp(new): through the wrapped list, two images round-trip through array slices 1 and 2 and read back byte for byte. A list with subresource 6,0xffffffffand a format mismatch is refused before any desktop copy, and a sentinel-filled readback buffer stays unchanged.Verification:
g++ -std=c++17 -Wall -Wextra -Isrc tests/startup_list_copy_texture_check.cppand run: ok. Both--mutate overflowand--mutate slicefail as expected.python3 -B tests/docs_links_check.pyandtests/bidi_controls_check.py: pass.python3 /root/.local/state/xbox2windows/pipeline/x2w_pipe.py win2025 2070at d7610f5b: dev 25/25 and release 25/25 pass (100%), includingstartup_list_copy_texture_warp.AI-assisted; commands listed were executed locally.
@chatgpt-codex-connector[bot] on GitHub · 2026-11-25 00:13 UTC · original · reviewed
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit:
91c1329631ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
@R0Y00 on GitHub · 2026-11-25 02:00 UTC · original · requested changes
The validation currently derives
mipusing modulo without checking the full subresource index (including array slice and plane), and computesformat_src/format_dstwithout checking compatibility. An invalid subresource can reach the desktop call. A multisample mismatch also needs exact sample-count validation and whole-subresource restrictions. Please begin with a documented slice whose subresource range, formats and sample count are all known, and refuse the others before upload or barriers. Make the footprint extent arithmetic checked at each multiply/add before submitting. Add a source-built wrapped-list readback, with a bad index and incompatible format rejected before any desktop copy; arithmetic-only tests can continue to cover the size checks. Desktop CopyTextureRegion contract@R0Y00 on GitHub · 2026-11-25 14:45 UTC · original · approved these changes
The array-slice, format and footprint changes address the original review. During recheck I found that a multisampled copy could still forward a non-null source box covering the full resource. The desktop API requires a null box for those copies and for depth-stencil copies. I added exact controls for both and kept the existing reasons for other refusals. Windows Release passed all five selected checks. The wrapped-list copies round-tripped both slices and kept the refused index/format cases off the desktop path on WARP and RTX 4060 Laptop.
Reference: https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12graphicscommandlist-copytextureregion