startup: copy and resolve whole resources on a recording list (slots 15, 17, 19) #1937

Merged
tedin7 merged 6 commits from upstream-pr/1944 into main 2026-11-25 07:31:00 +00:00
tedin7 commented 2026-11-24 21:58:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T21:58:44Z.


Related to #870 (no Fixes).

What changes

In render mode, three command-list slots that were dropped now copy whole resources:

  • slot 15 CopyBufferRegion, slot 17 CopyResource, slot 19 ResolveSubresource (unshifted, like slots 12 to 25).
  • Each argument is mapped to its desktop resource. The pair moves to COPY_SOURCE/COPY_DEST or RESOLVE_SOURCE/RESOLVE_DEST for the call and back to COMMON at Close. An upload buffer stays readable and a readback buffer stays a copy destination.
  • A call the desktop would reject is counted, logged (first six) and not forwarded, with a named reason (size_mismatch, sample_mismatch, range_overflow, source_not_multisampled, ...). Calls on a closed list are ignored.
  • A typeless resolve format resolves as the family's typed choice (half float for R16G16B16A16, as in #1729; normalised for the 8-bit and 10-bit families). One with no single choice (for example R16_TYPELESS) is refused as bad_format.
  • x2w_d3d12_list_copy_stats exports the counters for fixtures.
  • CopyTextureRegion (16) and CopyTiles (18) are left out on purpose.

Code is in new files: src/startup_stubs/list_copy.h (pure checks) and list_copy.inl (handlers). d3d12_xs_device.cpp gets one include of each, plus three install lines after the slot 52 line.

These slots have not been seen in a title log yet; the placement follows the unshifted slot order.

Checks run locally (Linux)

g++ -std=c++17 -Wall -Wextra -Isrc -I/usr/include/directx -I/usr/include/wsl/stubs -include wsl/winadapter.h tests/startup_list_copy_check.cpp
./a.out   # ok; --mutate overflow, typeless, samples each fail
x86_64-w64-mingw32-g++ -std=c++17 -fsyntax-only -Isrc tests/startup_list_copy.cpp
x86_64-w64-mingw32-g++ -std=c++17 -fsyntax-only ... src/startup_stubs/d3d12_xs_device.cpp   # only the two __try/__except errors of local_log.h, none from the new code
git diff --check
python3 -B tests/docs_links_check.py
python3 -B tests/bidi_controls_check.py
git merge-tree --write-tree HEAD <ref>   # origin/main, #1726, #1787, #1788, #1799, #1800, #1803: no conflicts

Not run

startup_list_copy_{warp,hardware} and the new device code have not been built or run; they need Windows. The fixture records on one list: clear and copy, a swapped copy (the empty texture stays empty), a 4-sample resolve, a typeless half-float resolve, two buffer copies with offsets, four refused calls (size mismatch, null source, one-sample resolve source, range past the end) and calls on a closed list, then reads everything back and checks the debug layer.

AI-assisted; commands listed were executed locally.


Replaces closed draft #1811 (rebased cleanly on origin/main).
AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6592237015 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1944). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T21:58:44Z. --- Related to #870 (no `Fixes`). ## What changes In render mode, three command-list slots that were dropped now copy whole resources: - slot 15 `CopyBufferRegion`, slot 17 `CopyResource`, slot 19 `ResolveSubresource` (unshifted, like slots 12 to 25). - Each argument is mapped to its desktop resource. The pair moves to `COPY_SOURCE`/`COPY_DEST` or `RESOLVE_SOURCE`/`RESOLVE_DEST` for the call and back to `COMMON` at Close. An upload buffer stays readable and a readback buffer stays a copy destination. - A call the desktop would reject is counted, logged (first six) and not forwarded, with a named reason (`size_mismatch`, `sample_mismatch`, `range_overflow`, `source_not_multisampled`, ...). Calls on a closed list are ignored. - A typeless resolve format resolves as the family's typed choice (half float for `R16G16B16A16`, as in #1729; normalised for the 8-bit and 10-bit families). One with no single choice (for example `R16_TYPELESS`) is refused as `bad_format`. - `x2w_d3d12_list_copy_stats` exports the counters for fixtures. - `CopyTextureRegion` (16) and `CopyTiles` (18) are left out on purpose. Code is in new files: `src/startup_stubs/list_copy.h` (pure checks) and `list_copy.inl` (handlers). `d3d12_xs_device.cpp` gets one include of each, plus three install lines after the slot 52 line. These slots have not been seen in a title log yet; the placement follows the unshifted slot order. ## Checks run locally (Linux) ``` g++ -std=c++17 -Wall -Wextra -Isrc -I/usr/include/directx -I/usr/include/wsl/stubs -include wsl/winadapter.h tests/startup_list_copy_check.cpp ./a.out # ok; --mutate overflow, typeless, samples each fail x86_64-w64-mingw32-g++ -std=c++17 -fsyntax-only -Isrc tests/startup_list_copy.cpp x86_64-w64-mingw32-g++ -std=c++17 -fsyntax-only ... src/startup_stubs/d3d12_xs_device.cpp # only the two __try/__except errors of local_log.h, none from the new code git diff --check python3 -B tests/docs_links_check.py python3 -B tests/bidi_controls_check.py git merge-tree --write-tree HEAD <ref> # origin/main, #1726, #1787, #1788, #1799, #1800, #1803: no conflicts ``` ## Not run `startup_list_copy_{warp,hardware}` and the new device code have not been built or run; they need Windows. The fixture records on one list: clear and copy, a swapped copy (the empty texture stays empty), a 4-sample resolve, a typeless half-float resolve, two buffer copies with offsets, four refused calls (size mismatch, null source, one-sample resolve source, range past the end) and calls on a closed list, then reads everything back and checks the debug layer. AI-assisted; commands listed were executed locally. --- Replaces closed draft #1811 (rebased cleanly on origin/main). AI-assisted; commands listed were executed locally.
chatgpt-codex-connector[bot commented 2026-11-24 22:01:07 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T22:00:39Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T22:08:13.259429Z e7b39dc Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7145681537 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1944#issuecomment-7145681537). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T22:00:39Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"e7b39dc483862455ae2c1044841bf10167ce348a","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-24T22:08:13.259429Z">2026-11-24T22:08:13.259429Z</relative-time> | `e7b39dc` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
chatgpt-codex-connector[bot commented 2026-11-24 23:03:10 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T22:08:09Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e7b39dc483

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6048179384 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1944#pullrequestreview-6048179384). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T22:08:09Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `e7b39dc483` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review". 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". </details>
ChazY11 commented 2026-11-24 23:03:39 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T22:36:34Z.


Merge-order check: these four PRs cannot all land in any order — one pair conflicts, the other three compose

Four open PRs now add command-list behaviour to the same two files (CMakeLists.txt, src/startup_stubs/d3d12_xs_device.cpp):
#1975, #1974, #1972, #1944. I merged them against main 889cd3f4 in every pair, then all four together.

#1975 + #1974   clean
#1975 + #1972   clean
#1975 + #1944   clean
#1974 + #1972   clean
#1974 + #1944   clean
#1972 + #1944   conflict: CMakeLists.txt, src/startup_stubs/d3d12_xs_device.cpp

And the four-way merge conflicts on the same pair, at the shared CMakeLists.txt insertion point just after the
foreach(backend IN ITEMS warp hardware …) block that registers the list tests — the two PRs append their new
add_executable / add_test group at the same anchor, so git has no ordering hint to pick.

The three that do compose, compose for real

Merged #1975 + #1974 + #1972 onto main, configured, built and ran their tests:

git merge pr-1975 pr-1974 pr-1972          # 0 conflicts
cmake --preset dev                          # Generating done
cmake --build --preset dev --target startup_root_constant_store startup_list_dispatch_check startup_clear_uav
build exit 0

ctest --preset dev -R 'root_constant|list_dispatch|clear_uav'
1/6 startup_root_constant_store ............   Passed 0.15
2/6 startup_clear_uav_warp .................   Passed 0.62
3/6 startup_clear_uav_hardware .............   Passed 4.03   (physical GPU, not a skip)
4/6 startup_list_dispatch ..................   Passed 0.14
5/6 startup_list_dispatch_no-limit_control .   Passed 0.03
6/6 startup_list_dispatch_no-state_control .   Passed 0.02
100% tests passed, 0 tests failed out of 6

So the command-list slots those three add coexist in one build, including both negative controls that #1974 registers.

What this means for ordering

Nothing is semantically wrong with #1944 — it is a text conflict at a shared anchor. The practical consequence is that whichever of
#1972 / #1944 lands second has to rebase
, and a rebase that resolves the anchor by hand needs the same care as the original: the
ENVIRONMENT list (X2W_D3D12_PERMISSIVE, X2W_D3D12_LIST_NOOP, X2W_D3D12_RENDER, X2W_D3D12_DEBUG) and SKIP_RETURN_CODE 77
have to survive on both groups, or one PR's tests silently run without the permissive flags and fail in CI instead of here.

I did not resolve the conflict myself: the resolution depends on which PR the maintainer wants first, and inventing an ordering would
hide the decision.

Aside, same family

#1951 and #1947 (the two tools/ PRs in this batch) touch different files and do not conflict with any of the above.

Notes

  • AI-assisted, run on Windows 11 build 26300.9974 with MSVC 19.44.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7146434585 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1944#issuecomment-7146434585). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T22:36:34Z. --- ## Merge-order check: these four PRs cannot all land in any order — one pair conflicts, the other three compose Four open PRs now add command-list behaviour to the same two files (`CMakeLists.txt`, `src/startup_stubs/d3d12_xs_device.cpp`): #1975, #1974, #1972, #1944. I merged them against `main` `889cd3f4` in every pair, then all four together. ```text #1975 + #1974 clean #1975 + #1972 clean #1975 + #1944 clean #1974 + #1972 clean #1974 + #1944 clean #1972 + #1944 conflict: CMakeLists.txt, src/startup_stubs/d3d12_xs_device.cpp ``` And the four-way merge conflicts on the same pair, at the shared `CMakeLists.txt` insertion point just after the `foreach(backend IN ITEMS warp hardware …)` block that registers the list tests — the two PRs append their new `add_executable` / `add_test` group at the same anchor, so `git` has no ordering hint to pick. ## The three that do compose, compose for real Merged #1975 + #1974 + #1972 onto `main`, configured, built and ran their tests: ```powershell git merge pr-1975 pr-1974 pr-1972 # 0 conflicts cmake --preset dev # Generating done cmake --build --preset dev --target startup_root_constant_store startup_list_dispatch_check startup_clear_uav build exit 0 ctest --preset dev -R 'root_constant|list_dispatch|clear_uav' 1/6 startup_root_constant_store ............ Passed 0.15 2/6 startup_clear_uav_warp ................. Passed 0.62 3/6 startup_clear_uav_hardware ............. Passed 4.03 (physical GPU, not a skip) 4/6 startup_list_dispatch .................. Passed 0.14 5/6 startup_list_dispatch_no-limit_control . Passed 0.03 6/6 startup_list_dispatch_no-state_control . Passed 0.02 100% tests passed, 0 tests failed out of 6 ``` So the command-list slots those three add coexist in one build, including both negative controls that #1974 registers. ## What this means for ordering Nothing is semantically wrong with #1944 — it is a text conflict at a shared anchor. The practical consequence is that **whichever of #1972 / #1944 lands second has to rebase**, and a rebase that resolves the anchor by hand needs the same care as the original: the `ENVIRONMENT` list (`X2W_D3D12_PERMISSIVE`, `X2W_D3D12_LIST_NOOP`, `X2W_D3D12_RENDER`, `X2W_D3D12_DEBUG`) and `SKIP_RETURN_CODE 77` have to survive on both groups, or one PR's tests silently run without the permissive flags and fail in CI instead of here. I did not resolve the conflict myself: the resolution depends on which PR the maintainer wants first, and inventing an ordering would hide the decision. ## Aside, same family #1951 and #1947 (the two `tools/` PRs in this batch) touch different files and do not conflict with any of the above. ## Notes - AI-assisted, run on Windows 11 build 26300.9974 with MSVC 19.44.
chatgpt-codex-connector[bot commented 2026-11-24 23:03:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T22:08:09Z.

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

@@ -0,0 +1,108 @@
+// Included from d3d12_xs_device.cpp after the command-list state helpers.
+//
+// Whole-resource copies on a recording list (render mode): CopyBufferRegion (list slot 15), CopyResource
+// (17) and ResolveSubresource (19). The title's resources are mapped to desktop ones, the pair is checked
+// by src/startup_stubs/list_copy.h, and a pair the desktop would reject is counted and skipped instead of
+// forwarded. Desktop resources rest in COMMON between lists, so each is moved to the copy or resolve state
+// around the call and back at Close; upload and readback buffers keep the state their heap requires.
+// CopyTextureRegion (16) and CopyTiles (18) carry footprints and addresses and are not handled here.
+
+LONG list_buffer_copies, list_resource_copies, list_resolves, list_copies_refused;
+
+// The desktop resource behind a copy argument; null for a null value, or a wrapper that is not a resource.
+// A value that is no wrapper is taken as a desktop resource, as the view slots do.
+ID3D12Resource* copy_endpoint(u64 value)
+{
+    if (!value) return nullptr;
+    if (const Wrapper* w = as_wrapper(reinterpret_cast<const void*>(value))) {
+        if (w->own().kind != resource_kind) return nullptr;
+        return static_cast<ID3D12Resource*>(w->own().real);

P1 Badge Synchronize title-backed sources before issuing desktop copies

For a slot-127 upload resource backed by __XMemAllocationHooks__, resource_map() returns title_memory and resource_unmap() does not update the separate desktop resource. Returning own().real here therefore makes an ordinary map/write/CopyBufferRegion sequence copy stale or zeroed desktop data rather than the bytes written by the caller. Synchronize non-aliased title backing before using it as a copy source, or explicitly refuse that backing mode. The new fixture only maps native desktop resources, so it does not exercise this path.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4687208004 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1944#discussion_r4687208004). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T22:08:09Z. **Code review location:** `src/startup_stubs/list_copy.inl`; line 19 ~~~~diff @@ -0,0 +1,108 @@ +// Included from d3d12_xs_device.cpp after the command-list state helpers. +// +// Whole-resource copies on a recording list (render mode): CopyBufferRegion (list slot 15), CopyResource +// (17) and ResolveSubresource (19). The title's resources are mapped to desktop ones, the pair is checked +// by src/startup_stubs/list_copy.h, and a pair the desktop would reject is counted and skipped instead of +// forwarded. Desktop resources rest in COMMON between lists, so each is moved to the copy or resolve state +// around the call and back at Close; upload and readback buffers keep the state their heap requires. +// CopyTextureRegion (16) and CopyTiles (18) carry footprints and addresses and are not handled here. + +LONG list_buffer_copies, list_resource_copies, list_resolves, list_copies_refused; + +// The desktop resource behind a copy argument; null for a null value, or a wrapper that is not a resource. +// A value that is no wrapper is taken as a desktop resource, as the view slots do. +ID3D12Resource* copy_endpoint(u64 value) +{ + if (!value) return nullptr; + if (const Wrapper* w = as_wrapper(reinterpret_cast<const void*>(value))) { + if (w->own().kind != resource_kind) return nullptr; + return static_cast<ID3D12Resource*>(w->own().real); ~~~~ --- **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Synchronize title-backed sources before issuing desktop copies** For a slot-127 upload resource backed by `__XMemAllocationHooks__`, `resource_map()` returns `title_memory` and `resource_unmap()` does not update the separate desktop resource. Returning `own().real` here therefore makes an ordinary map/write/`CopyBufferRegion` sequence copy stale or zeroed desktop data rather than the bytes written by the caller. Synchronize non-aliased title backing before using it as a copy source, or explicitly refuse that backing mode. The new fixture only maps native desktop resources, so it does not exercise this path. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot commented 2026-11-24 23:03:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T22:08:09Z.

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

@@ -0,0 +1,108 @@
+// Included from d3d12_xs_device.cpp after the command-list state helpers.
+//
+// Whole-resource copies on a recording list (render mode): CopyBufferRegion (list slot 15), CopyResource
+// (17) and ResolveSubresource (19). The title's resources are mapped to desktop ones, the pair is checked
+// by src/startup_stubs/list_copy.h, and a pair the desktop would reject is counted and skipped instead of
+// forwarded. Desktop resources rest in COMMON between lists, so each is moved to the copy or resolve state
+// around the call and back at Close; upload and readback buffers keep the state their heap requires.
+// CopyTextureRegion (16) and CopyTiles (18) carry footprints and addresses and are not handled here.
+
+LONG list_buffer_copies, list_resource_copies, list_resolves, list_copies_refused;
+
+// The desktop resource behind a copy argument; null for a null value, or a wrapper that is not a resource.
+// A value that is no wrapper is taken as a desktop resource, as the view slots do.
+ID3D12Resource* copy_endpoint(u64 value)
+{
+    if (!value) return nullptr;
+    if (const Wrapper* w = as_wrapper(reinterpret_cast<const void*>(value))) {
+        if (w->own().kind != resource_kind) return nullptr;
+        return static_cast<ID3D12Resource*>(w->own().real);
+    }
+    return x2w_local::readable(reinterpret_cast<const void*>(value), sizeof(void*)) ? reinterpret_cast<ID3D12Resource*>(value) : nullptr;
+}
+
+void refuse_copy(const char* what, x2w_startup::CopyRefusal reason)
+{
+    InterlockedIncrement(&list_copies_refused);
+    static LONG logged;
+    if (first_calls(logged, 6)) log("x2w-d3d12 %s skipped: %s", what, x2w_startup::copy_refusal_name(reason));
+}
+
+// The state a copy needs from `resource`: an upload buffer stays readable and a readback buffer stays a
+// copy destination, because desktop allows no other state for them.
+void require_copy_state(Wrapper* self, ID3D12Resource* resource, D3D12_RESOURCE_STATES state)
+{
+    D3D12_HEAP_PROPERTIES heap{};
+    D3D12_HEAP_FLAGS flags{};
+    if (SUCCEEDED(resource->GetHeapProperties(&heap, &flags)) &&
+        (heap.Type == D3D12_HEAP_TYPE_UPLOAD || heap.Type == D3D12_HEAP_TYPE_READBACK))
+        return;
+    require_state(self, resource, state);
+}
+
+// List slot 15, CopyBufferRegion(destination, destination offset, source, source offset, bytes).
+void __stdcall list_copy_buffer_region(Wrapper* self, u64 destination, u64 destination_offset, u64 source, u64 source_offset,
+                                       u64 bytes)
+{
+    if (!self->own().list_open) return;
+    ID3D12Resource* const to = copy_endpoint(destination);
+    ID3D12Resource* const from = copy_endpoint(source);
+    D3D12_RESOURCE_DESC to_desc{}, from_desc{};
+    if (to) to_desc = to->GetDesc();
+    if (from) from_desc = from->GetDesc();
+    const auto refusal = x2w_startup::check_copy_buffer_region(to ? &to_desc : nullptr, destination_offset,
+                                                               from ? &from_desc : nullptr, source_offset, bytes, to == from);
+    if (refusal != x2w_startup::CopyRefusal::none) return refuse_copy("CopyBufferRegion", refusal);
+    require_copy_state(self, from, D3D12_RESOURCE_STATE_COPY_SOURCE);
+    require_copy_state(self, to, D3D12_RESOURCE_STATE_COPY_DEST);
+    static_cast<ID3D12GraphicsCommandList*>(self->own().real)->CopyBufferRegion(to, destination_offset, from, source_offset, bytes);
+    InterlockedIncrement(&list_buffer_copies);
+}
+
+// List slot 17, CopyResource(destination, source).
+void __stdcall list_copy_resource(Wrapper* self, u64 destination, u64 source)
+{
+    if (!self->own().list_open) return;
+    ID3D12Resource* const to = copy_endpoint(destination);
+    ID3D12Resource* const from = copy_endpoint(source);
+    D3D12_RESOURCE_DESC to_desc{}, from_desc{};
+    if (to) to_desc = to->GetDesc();
+    if (from) from_desc = from->GetDesc();
+    const auto refusal = x2w_startup::check_copy_resource(to ? &to_desc : nullptr, from ? &from_desc : nullptr, to == from);
+    if (refusal != x2w_startup::CopyRefusal::none) return refuse_copy("CopyResource", refusal);
+    require_copy_state(self, from, D3D12_RESOURCE_STATE_COPY_SOURCE);
+    require_copy_state(self, to, D3D12_RESOURCE_STATE_COPY_DEST);
+    static_cast<ID3D12GraphicsCommandList*>(self->own().real)->CopyResource(to, from);
+    InterlockedIncrement(&list_resource_copies);
+}
+
+// List slot 19, ResolveSubresource(destination, destination subresource, source, source subresource, format).
+// The format is a console value, mapped like a resource format; a typeless one resolves as its typed choice.
+void __stdcall list_resolve_subresource(Wrapper* self, u64 destination, UINT destination_subresource, u64 source,
+                                        UINT source_subresource, UINT format)
+{
+    if (!self->own().list_open) return;
+    ID3D12Resource* const to = copy_endpoint(destination);
+    ID3D12Resource* const from = copy_endpoint(source);
+    D3D12_RESOURCE_DESC to_desc{}, from_desc{};
+    if (to) to_desc = to->GetDesc();
+    if (from) from_desc = from->GetDesc();
+    const auto plan = x2w_startup::plan_resolve(to ? &to_desc : nullptr, destination_subresource, from ? &from_desc : nullptr,
+                                                source_subresource, desktop_format(static_cast<DXGI_FORMAT>(format)), to == from);
+    if (plan.refusal != x2w_startup::CopyRefusal::none) return refuse_copy("ResolveSubresource", plan.refusal);
+    require_copy_state(self, from, D3D12_RESOURCE_STATE_RESOLVE_SOURCE);
+    require_copy_state(self, to, D3D12_RESOURCE_STATE_RESOLVE_DEST);
+    static_cast<ID3D12GraphicsCommandList*>(self->own().real)
+        ->ResolveSubresource(to, destination_subresource, from, source_subresource, plan.format);

P1 Badge Mark copy and resolve destinations as GPU-written

When the destination is a slot-133 texture with readable title backing and no render-target/depth/UAV flags, a subsequent translated draw calls upload_texture() in d3d12_draw.inl. On its first bind, that uploader copies the stale title backing over the desktop texture, overwriting the result just recorded here. CopyResource has the same problem. Update the destination's upload/ownership bookkeeping so copy and resolve results survive later sampling; the native-resource readback fixture does not cover this wrapper-to-draw flow.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4687208019 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1944#discussion_r4687208019). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T22:08:09Z. **Code review location:** `src/startup_stubs/list_copy.inl`; line 96 ~~~~diff @@ -0,0 +1,108 @@ +// Included from d3d12_xs_device.cpp after the command-list state helpers. +// +// Whole-resource copies on a recording list (render mode): CopyBufferRegion (list slot 15), CopyResource +// (17) and ResolveSubresource (19). The title's resources are mapped to desktop ones, the pair is checked +// by src/startup_stubs/list_copy.h, and a pair the desktop would reject is counted and skipped instead of +// forwarded. Desktop resources rest in COMMON between lists, so each is moved to the copy or resolve state +// around the call and back at Close; upload and readback buffers keep the state their heap requires. +// CopyTextureRegion (16) and CopyTiles (18) carry footprints and addresses and are not handled here. + +LONG list_buffer_copies, list_resource_copies, list_resolves, list_copies_refused; + +// The desktop resource behind a copy argument; null for a null value, or a wrapper that is not a resource. +// A value that is no wrapper is taken as a desktop resource, as the view slots do. +ID3D12Resource* copy_endpoint(u64 value) +{ + if (!value) return nullptr; + if (const Wrapper* w = as_wrapper(reinterpret_cast<const void*>(value))) { + if (w->own().kind != resource_kind) return nullptr; + return static_cast<ID3D12Resource*>(w->own().real); + } + return x2w_local::readable(reinterpret_cast<const void*>(value), sizeof(void*)) ? reinterpret_cast<ID3D12Resource*>(value) : nullptr; +} + +void refuse_copy(const char* what, x2w_startup::CopyRefusal reason) +{ + InterlockedIncrement(&list_copies_refused); + static LONG logged; + if (first_calls(logged, 6)) log("x2w-d3d12 %s skipped: %s", what, x2w_startup::copy_refusal_name(reason)); +} + +// The state a copy needs from `resource`: an upload buffer stays readable and a readback buffer stays a +// copy destination, because desktop allows no other state for them. +void require_copy_state(Wrapper* self, ID3D12Resource* resource, D3D12_RESOURCE_STATES state) +{ + D3D12_HEAP_PROPERTIES heap{}; + D3D12_HEAP_FLAGS flags{}; + if (SUCCEEDED(resource->GetHeapProperties(&heap, &flags)) && + (heap.Type == D3D12_HEAP_TYPE_UPLOAD || heap.Type == D3D12_HEAP_TYPE_READBACK)) + return; + require_state(self, resource, state); +} + +// List slot 15, CopyBufferRegion(destination, destination offset, source, source offset, bytes). +void __stdcall list_copy_buffer_region(Wrapper* self, u64 destination, u64 destination_offset, u64 source, u64 source_offset, + u64 bytes) +{ + if (!self->own().list_open) return; + ID3D12Resource* const to = copy_endpoint(destination); + ID3D12Resource* const from = copy_endpoint(source); + D3D12_RESOURCE_DESC to_desc{}, from_desc{}; + if (to) to_desc = to->GetDesc(); + if (from) from_desc = from->GetDesc(); + const auto refusal = x2w_startup::check_copy_buffer_region(to ? &to_desc : nullptr, destination_offset, + from ? &from_desc : nullptr, source_offset, bytes, to == from); + if (refusal != x2w_startup::CopyRefusal::none) return refuse_copy("CopyBufferRegion", refusal); + require_copy_state(self, from, D3D12_RESOURCE_STATE_COPY_SOURCE); + require_copy_state(self, to, D3D12_RESOURCE_STATE_COPY_DEST); + static_cast<ID3D12GraphicsCommandList*>(self->own().real)->CopyBufferRegion(to, destination_offset, from, source_offset, bytes); + InterlockedIncrement(&list_buffer_copies); +} + +// List slot 17, CopyResource(destination, source). +void __stdcall list_copy_resource(Wrapper* self, u64 destination, u64 source) +{ + if (!self->own().list_open) return; + ID3D12Resource* const to = copy_endpoint(destination); + ID3D12Resource* const from = copy_endpoint(source); + D3D12_RESOURCE_DESC to_desc{}, from_desc{}; + if (to) to_desc = to->GetDesc(); + if (from) from_desc = from->GetDesc(); + const auto refusal = x2w_startup::check_copy_resource(to ? &to_desc : nullptr, from ? &from_desc : nullptr, to == from); + if (refusal != x2w_startup::CopyRefusal::none) return refuse_copy("CopyResource", refusal); + require_copy_state(self, from, D3D12_RESOURCE_STATE_COPY_SOURCE); + require_copy_state(self, to, D3D12_RESOURCE_STATE_COPY_DEST); + static_cast<ID3D12GraphicsCommandList*>(self->own().real)->CopyResource(to, from); + InterlockedIncrement(&list_resource_copies); +} + +// List slot 19, ResolveSubresource(destination, destination subresource, source, source subresource, format). +// The format is a console value, mapped like a resource format; a typeless one resolves as its typed choice. +void __stdcall list_resolve_subresource(Wrapper* self, u64 destination, UINT destination_subresource, u64 source, + UINT source_subresource, UINT format) +{ + if (!self->own().list_open) return; + ID3D12Resource* const to = copy_endpoint(destination); + ID3D12Resource* const from = copy_endpoint(source); + D3D12_RESOURCE_DESC to_desc{}, from_desc{}; + if (to) to_desc = to->GetDesc(); + if (from) from_desc = from->GetDesc(); + const auto plan = x2w_startup::plan_resolve(to ? &to_desc : nullptr, destination_subresource, from ? &from_desc : nullptr, + source_subresource, desktop_format(static_cast<DXGI_FORMAT>(format)), to == from); + if (plan.refusal != x2w_startup::CopyRefusal::none) return refuse_copy("ResolveSubresource", plan.refusal); + require_copy_state(self, from, D3D12_RESOURCE_STATE_RESOLVE_SOURCE); + require_copy_state(self, to, D3D12_RESOURCE_STATE_RESOLVE_DEST); + static_cast<ID3D12GraphicsCommandList*>(self->own().real) + ->ResolveSubresource(to, destination_subresource, from, source_subresource, plan.format); ~~~~ --- **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Mark copy and resolve destinations as GPU-written** When the destination is a slot-133 texture with readable title backing and no render-target/depth/UAV flags, a subsequent translated draw calls `upload_texture()` in `d3d12_draw.inl`. On its first bind, that uploader copies the stale title backing over the desktop texture, overwriting the result just recorded here. `CopyResource` has the same problem. Update the destination's upload/ownership bookkeeping so copy and resolve results survive later sampling; the native-resource readback fixture does not cover this wrapper-to-draw flow. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot commented 2026-11-24 23:03:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T22:08:09Z.

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

@@ -0,0 +1,108 @@
+// Included from d3d12_xs_device.cpp after the command-list state helpers.
+//
+// Whole-resource copies on a recording list (render mode): CopyBufferRegion (list slot 15), CopyResource
+// (17) and ResolveSubresource (19). The title's resources are mapped to desktop ones, the pair is checked
+// by src/startup_stubs/list_copy.h, and a pair the desktop would reject is counted and skipped instead of
+// forwarded. Desktop resources rest in COMMON between lists, so each is moved to the copy or resolve state
+// around the call and back at Close; upload and readback buffers keep the state their heap requires.
+// CopyTextureRegion (16) and CopyTiles (18) carry footprints and addresses and are not handled here.
+
+LONG list_buffer_copies, list_resource_copies, list_resolves, list_copies_refused;
+
+// The desktop resource behind a copy argument; null for a null value, or a wrapper that is not a resource.
+// A value that is no wrapper is taken as a desktop resource, as the view slots do.
+ID3D12Resource* copy_endpoint(u64 value)
+{
+    if (!value) return nullptr;
+    if (const Wrapper* w = as_wrapper(reinterpret_cast<const void*>(value))) {
+        if (w->own().kind != resource_kind) return nullptr;
+        return static_cast<ID3D12Resource*>(w->own().real);
+    }
+    return x2w_local::readable(reinterpret_cast<const void*>(value), sizeof(void*)) ? reinterpret_cast<ID3D12Resource*>(value) : nullptr;
+}
+
+void refuse_copy(const char* what, x2w_startup::CopyRefusal reason)
+{
+    InterlockedIncrement(&list_copies_refused);
+    static LONG logged;
+    if (first_calls(logged, 6)) log("x2w-d3d12 %s skipped: %s", what, x2w_startup::copy_refusal_name(reason));
+}
+
+// The state a copy needs from `resource`: an upload buffer stays readable and a readback buffer stays a
+// copy destination, because desktop allows no other state for them.
+void require_copy_state(Wrapper* self, ID3D12Resource* resource, D3D12_RESOURCE_STATES state)
+{
+    D3D12_HEAP_PROPERTIES heap{};
+    D3D12_HEAP_FLAGS flags{};
+    if (SUCCEEDED(resource->GetHeapProperties(&heap, &flags)) &&
+        (heap.Type == D3D12_HEAP_TYPE_UPLOAD || heap.Type == D3D12_HEAP_TYPE_READBACK))
+        return;
+    require_state(self, resource, state);

P2 Badge Honor placed buffers' non-COMMON initial states

device_place_resource_x() preserves an explicit UNORDERED_ACCESS initial state for placed buffers and records it in ResourceInfo::initial_state. On such a buffer's first copy, this call enters require_state(), which always emits its first barrier from COMMON. That records an incorrect StateBefore for an otherwise legal buffer copy and can invalidate the recording. Preserve the wrapper's initial-state information when planning transitions, or refuse buffers that are not eligible for the COMMON-based tracker, as list_execute_indirect() already does.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4687208036 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1944#discussion_r4687208036). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T22:08:09Z. **Code review location:** `src/startup_stubs/list_copy.inl`; line 40 ~~~~diff @@ -0,0 +1,108 @@ +// Included from d3d12_xs_device.cpp after the command-list state helpers. +// +// Whole-resource copies on a recording list (render mode): CopyBufferRegion (list slot 15), CopyResource +// (17) and ResolveSubresource (19). The title's resources are mapped to desktop ones, the pair is checked +// by src/startup_stubs/list_copy.h, and a pair the desktop would reject is counted and skipped instead of +// forwarded. Desktop resources rest in COMMON between lists, so each is moved to the copy or resolve state +// around the call and back at Close; upload and readback buffers keep the state their heap requires. +// CopyTextureRegion (16) and CopyTiles (18) carry footprints and addresses and are not handled here. + +LONG list_buffer_copies, list_resource_copies, list_resolves, list_copies_refused; + +// The desktop resource behind a copy argument; null for a null value, or a wrapper that is not a resource. +// A value that is no wrapper is taken as a desktop resource, as the view slots do. +ID3D12Resource* copy_endpoint(u64 value) +{ + if (!value) return nullptr; + if (const Wrapper* w = as_wrapper(reinterpret_cast<const void*>(value))) { + if (w->own().kind != resource_kind) return nullptr; + return static_cast<ID3D12Resource*>(w->own().real); + } + return x2w_local::readable(reinterpret_cast<const void*>(value), sizeof(void*)) ? reinterpret_cast<ID3D12Resource*>(value) : nullptr; +} + +void refuse_copy(const char* what, x2w_startup::CopyRefusal reason) +{ + InterlockedIncrement(&list_copies_refused); + static LONG logged; + if (first_calls(logged, 6)) log("x2w-d3d12 %s skipped: %s", what, x2w_startup::copy_refusal_name(reason)); +} + +// The state a copy needs from `resource`: an upload buffer stays readable and a readback buffer stays a +// copy destination, because desktop allows no other state for them. +void require_copy_state(Wrapper* self, ID3D12Resource* resource, D3D12_RESOURCE_STATES state) +{ + D3D12_HEAP_PROPERTIES heap{}; + D3D12_HEAP_FLAGS flags{}; + if (SUCCEEDED(resource->GetHeapProperties(&heap, &flags)) && + (heap.Type == D3D12_HEAP_TYPE_UPLOAD || heap.Type == D3D12_HEAP_TYPE_READBACK)) + return; + require_state(self, resource, state); ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Honor placed buffers' non-COMMON initial states** `device_place_resource_x()` preserves an explicit `UNORDERED_ACCESS` initial state for placed buffers and records it in `ResourceInfo::initial_state`. On such a buffer's first copy, this call enters `require_state()`, which always emits its first barrier from `COMMON`. That records an incorrect `StateBefore` for an otherwise legal buffer copy and can invalidate the recording. Preserve the wrapper's initial-state information when planning transitions, or refuse buffers that are not eligible for the COMMON-based tracker, as `list_execute_indirect()` already does. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot commented 2026-11-24 23:03:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T22:08:09Z.

Code review location: src/startup_stubs/list_copy.h; line 191

@@ -0,0 +1,195 @@
+// Pure validation for the whole-resource command-list copies: CopyBufferRegion (list slot 15),
+// CopyResource (17) and ResolveSubresource (19). It reads only resource descriptions, so it runs on any host.
+//
+// Desktop D3D12 removes the device on a copy it rejects, so a copy whose arguments the desktop would
+// refuse is named and skipped instead of forwarded. Each check returns the first refusal, in the
+// order listed in CopyRefusal.
+#pragma once
+
+#include <d3d12.h>
+
+#include <algorithm>
+#include <cstdint>
+
+namespace x2w_startup {
+
+enum class CopyRefusal {
+    none,
+    unresolved,                // a null argument, or one that is not a resource
+    same_resource,             // source and destination are one resource
+    not_buffer,                // CopyBufferRegion on a texture
+    not_texture,               // ResolveSubresource on something other than a 2D texture
+    dimension_mismatch,        // CopyResource between different resource dimensions
+    size_mismatch,             // different width, height, depth, mips or buffer size
+    format_mismatch,           // formats that are neither equal nor members of one typeless family
+    sample_mismatch,           // different sample count or quality
+    bad_subresource,           // a subresource index outside the texture, or of another size
+    source_not_multisampled,   // the resolve source has one sample
+    destination_multisampled,  // the resolve destination has more than one sample
+    bad_format,                // a resolve format that is unknown, or typeless with no typed choice
+    zero_size,                 // CopyBufferRegion of no bytes
+    range_overflow,            // an offset and size that wrap, or run past a buffer
+};
+
+inline const char* copy_refusal_name(CopyRefusal refusal)
+{
+    switch (refusal) {
+    case CopyRefusal::unresolved: return "unresolved";
+    case CopyRefusal::same_resource: return "same_resource";
+    case CopyRefusal::not_buffer: return "not_buffer";
+    case CopyRefusal::not_texture: return "not_texture";
+    case CopyRefusal::dimension_mismatch: return "dimension_mismatch";
+    case CopyRefusal::size_mismatch: return "size_mismatch";
+    case CopyRefusal::format_mismatch: return "format_mismatch";
+    case CopyRefusal::sample_mismatch: return "sample_mismatch";
+    case CopyRefusal::bad_subresource: return "bad_subresource";
+    case CopyRefusal::source_not_multisampled: return "source_not_multisampled";
+    case CopyRefusal::destination_multisampled: return "destination_multisampled";
+    case CopyRefusal::bad_format: return "bad_format";
+    case CopyRefusal::zero_size: return "zero_size";
+    case CopyRefusal::range_overflow: return "range_overflow";
+    default: return "none";
+    }
+}
+
+// The typeless member of the colour format family `format` belongs to; `format` itself when it has none.
+inline DXGI_FORMAT format_family(DXGI_FORMAT format)
+{
+    switch (format) {
+    case DXGI_FORMAT_R32G32B32A32_TYPELESS: case DXGI_FORMAT_R32G32B32A32_FLOAT:
+    case DXGI_FORMAT_R32G32B32A32_UINT: case DXGI_FORMAT_R32G32B32A32_SINT:
+        return DXGI_FORMAT_R32G32B32A32_TYPELESS;
+    case DXGI_FORMAT_R16G16B16A16_TYPELESS: case DXGI_FORMAT_R16G16B16A16_FLOAT:
+    case DXGI_FORMAT_R16G16B16A16_UNORM: case DXGI_FORMAT_R16G16B16A16_UINT:
+    case DXGI_FORMAT_R16G16B16A16_SNORM: case DXGI_FORMAT_R16G16B16A16_SINT:
+        return DXGI_FORMAT_R16G16B16A16_TYPELESS;
+    case DXGI_FORMAT_R10G10B10A2_TYPELESS: case DXGI_FORMAT_R10G10B10A2_UNORM: case DXGI_FORMAT_R10G10B10A2_UINT:
+        return DXGI_FORMAT_R10G10B10A2_TYPELESS;
+    case DXGI_FORMAT_R8G8B8A8_TYPELESS: case DXGI_FORMAT_R8G8B8A8_UNORM: case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB:
+    case DXGI_FORMAT_R8G8B8A8_UINT: case DXGI_FORMAT_R8G8B8A8_SNORM: case DXGI_FORMAT_R8G8B8A8_SINT:
+        return DXGI_FORMAT_R8G8B8A8_TYPELESS;
+    case DXGI_FORMAT_B8G8R8A8_TYPELESS: case DXGI_FORMAT_B8G8R8A8_UNORM: case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB:
+        return DXGI_FORMAT_B8G8R8A8_TYPELESS;
+    case DXGI_FORMAT_R16G16_TYPELESS: case DXGI_FORMAT_R16G16_FLOAT: case DXGI_FORMAT_R16G16_UNORM:
+    case DXGI_FORMAT_R16G16_UINT: case DXGI_FORMAT_R16G16_SNORM: case DXGI_FORMAT_R16G16_SINT:
+        return DXGI_FORMAT_R16G16_TYPELESS;
+    case DXGI_FORMAT_R32_TYPELESS: case DXGI_FORMAT_R32_FLOAT: case DXGI_FORMAT_R32_UINT: case DXGI_FORMAT_R32_SINT:
+        return DXGI_FORMAT_R32_TYPELESS;
+    default:
+        return format;
+    }
+}
+
+// The typed format a typeless one resolves as; DXGI_FORMAT_UNKNOWN for a format that is not typeless or has no
+// single natural choice. Floating point for the HDR families, normalised for the 8 and 10 bit ones.
+inline DXGI_FORMAT typed_choice(DXGI_FORMAT typeless)
+{
+    switch (typeless) {
+    case DXGI_FORMAT_R32G32B32A32_TYPELESS: return DXGI_FORMAT_R32G32B32A32_FLOAT;
+    case DXGI_FORMAT_R16G16B16A16_TYPELESS: return DXGI_FORMAT_R16G16B16A16_FLOAT;
+    case DXGI_FORMAT_R10G10B10A2_TYPELESS: return DXGI_FORMAT_R10G10B10A2_UNORM;
+    case DXGI_FORMAT_R8G8B8A8_TYPELESS: return DXGI_FORMAT_R8G8B8A8_UNORM;
+    case DXGI_FORMAT_B8G8R8A8_TYPELESS: return DXGI_FORMAT_B8G8R8A8_UNORM;
+    case DXGI_FORMAT_R16G16_TYPELESS: return DXGI_FORMAT_R16G16_FLOAT;
+    case DXGI_FORMAT_R32_TYPELESS: return DXGI_FORMAT_R32_FLOAT;
+    default: return DXGI_FORMAT_UNKNOWN;
+    }
+}
+
+inline bool is_typeless(DXGI_FORMAT format)
+{
+    switch (format) {
+    case DXGI_FORMAT_R32G32B32A32_TYPELESS: case DXGI_FORMAT_R32G32B32_TYPELESS: case DXGI_FORMAT_R16G16B16A16_TYPELESS:
+    case DXGI_FORMAT_R32G32_TYPELESS: case DXGI_FORMAT_R32G8X24_TYPELESS: case DXGI_FORMAT_R10G10B10A2_TYPELESS:
+    case DXGI_FORMAT_R8G8B8A8_TYPELESS: case DXGI_FORMAT_R16G16_TYPELESS: case DXGI_FORMAT_R32_TYPELESS:
+    case DXGI_FORMAT_R24G8_TYPELESS: case DXGI_FORMAT_R8G8_TYPELESS: case DXGI_FORMAT_R16_TYPELESS:
+    case DXGI_FORMAT_R8_TYPELESS: case DXGI_FORMAT_B8G8R8A8_TYPELESS: case DXGI_FORMAT_B8G8R8X8_TYPELESS:
+        return true;
+    default:
+        return false;
+    }
+}
+
+inline bool is_typeless_choice_format(DXGI_FORMAT format) { return typed_choice(format) != DXGI_FORMAT_UNKNOWN; }
+
+inline bool compatible_formats(DXGI_FORMAT a, DXGI_FORMAT b)
+{
+    return a == b || (a != DXGI_FORMAT_UNKNOWN && format_family(a) == format_family(b));
+}
+
+// CopyBufferRegion(destination, destination_offset, source, source_offset, bytes). `same` is true when both
+// arguments are one resource (it would need two states at once).
+inline CopyRefusal check_copy_buffer_region(const D3D12_RESOURCE_DESC* destination, std::uint64_t destination_offset,
+                                            const D3D12_RESOURCE_DESC* source, std::uint64_t source_offset,
+                                            std::uint64_t bytes, bool same)
+{
+    if (!destination || !source) return CopyRefusal::unresolved;
+    if (same) return CopyRefusal::same_resource;
+    if (destination->Dimension != D3D12_RESOURCE_DIMENSION_BUFFER || source->Dimension != D3D12_RESOURCE_DIMENSION_BUFFER)
+        return CopyRefusal::not_buffer;
+    if (!bytes) return CopyRefusal::zero_size;
+    if (destination_offset > destination->Width || bytes > destination->Width - destination_offset ||
+        source_offset > source->Width || bytes > source->Width - source_offset)
+        return CopyRefusal::range_overflow;
+    return CopyRefusal::none;
+}
+
+// CopyResource(destination, source): the two descriptions must have one shape.
+inline CopyRefusal check_copy_resource(const D3D12_RESOURCE_DESC* destination, const D3D12_RESOURCE_DESC* source, bool same)
+{
+    if (!destination || !source) return CopyRefusal::unresolved;
+    if (same) return CopyRefusal::same_resource;
+    if (destination->Dimension == D3D12_RESOURCE_DIMENSION_UNKNOWN || destination->Dimension != source->Dimension)
+        return CopyRefusal::dimension_mismatch;
+    if (destination->Width != source->Width) return CopyRefusal::size_mismatch;
+    if (destination->Dimension == D3D12_RESOURCE_DIMENSION_BUFFER) return CopyRefusal::none;
+    if (destination->Height != source->Height || destination->DepthOrArraySize != source->DepthOrArraySize ||
+        destination->MipLevels != source->MipLevels)
+        return CopyRefusal::size_mismatch;
+    if (!compatible_formats(destination->Format, source->Format)) return CopyRefusal::format_mismatch;
+    if (destination->SampleDesc.Count != source->SampleDesc.Count || destination->SampleDesc.Quality != source->SampleDesc.Quality)
+        return CopyRefusal::sample_mismatch;
+    return CopyRefusal::none;
+}
+
+struct ResolvePlan {
+    CopyRefusal refusal{};
+    DXGI_FORMAT format{};  // the typed format to resolve as, when not refused
+};
+
+// One mip of a 2D texture: its size in texels.
+inline std::uint64_t mip_extent(std::uint64_t extent, std::uint32_t mip) { return (std::max<std::uint64_t>)(extent >> mip, 1); }
+
+// ResolveSubresource(destination, destination_subresource, source, source_subresource, format). A typeless
+// `format` (or one the title left unknown over a typeless surface) resolves as the family's typed choice, so a
+// half-float surface stored as typeless resolves as half float.
+inline ResolvePlan plan_resolve(const D3D12_RESOURCE_DESC* destination, std::uint32_t destination_subresource,
+                                const D3D12_RESOURCE_DESC* source, std::uint32_t source_subresource, DXGI_FORMAT format,
+                                bool same)
+{
+    if (!destination || !source) return {CopyRefusal::unresolved, {}};
+    if (same) return {CopyRefusal::same_resource, {}};
+    if (destination->Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE2D || source->Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE2D)
+        return {CopyRefusal::not_texture, {}};
+    if (source->SampleDesc.Count <= 1) return {CopyRefusal::source_not_multisampled, {}};
+    if (destination->SampleDesc.Count != 1) return {CopyRefusal::destination_multisampled, {}};
+    const std::uint32_t destination_mips = destination->MipLevels ? destination->MipLevels : 1;
+    const std::uint32_t source_mips = source->MipLevels ? source->MipLevels : 1;
+    if (destination_subresource >= std::uint64_t{destination_mips} * destination->DepthOrArraySize ||
+        source_subresource >= std::uint64_t{source_mips} * source->DepthOrArraySize)
+        return {CopyRefusal::bad_subresource, {}};
+    const std::uint32_t destination_mip = destination_subresource % destination_mips;
+    const std::uint32_t source_mip = source_subresource % source_mips;
+    if (mip_extent(destination->Width, destination_mip) != mip_extent(source->Width, source_mip) ||
+        mip_extent(destination->Height, destination_mip) != mip_extent(source->Height, source_mip))
+        return {CopyRefusal::bad_subresource, {}};
+    DXGI_FORMAT typed = format;
+    if (typed == DXGI_FORMAT_UNKNOWN) typed = source->Format;
+    if (is_typeless_choice_format(typed)) typed = typed_choice(typed);
+    if (typed == DXGI_FORMAT_UNKNOWN || is_typeless(typed)) return {CopyRefusal::bad_format, {}};
+    if (!compatible_formats(typed, source->Format) || !compatible_formats(typed, destination->Format))
+        return {CopyRefusal::format_mismatch, {}};

P2 Badge Require resolve formats to match fully typed endpoints

For a typeless RGBA8 source, a typed R8G8B8A8_UNORM_SRGB destination and an unknown format argument, the preceding fallback chooses R8G8B8A8_UNORM, and these family checks accept it. D3D12 requires the resolve format to match a fully typed endpoint exactly; family compatibility is only sufficient for a typeless endpoint. Consequently, this plan forwards a desktop-invalid resolve instead of refusing it. Select or validate against typed endpoints before applying the typeless-family fallback.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4687208042 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1944#discussion_r4687208042). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T22:08:09Z. **Code review location:** `src/startup_stubs/list_copy.h`; line 191 ~~~~diff @@ -0,0 +1,195 @@ +// Pure validation for the whole-resource command-list copies: CopyBufferRegion (list slot 15), +// CopyResource (17) and ResolveSubresource (19). It reads only resource descriptions, so it runs on any host. +// +// Desktop D3D12 removes the device on a copy it rejects, so a copy whose arguments the desktop would +// refuse is named and skipped instead of forwarded. Each check returns the first refusal, in the +// order listed in CopyRefusal. +#pragma once + +#include <d3d12.h> + +#include <algorithm> +#include <cstdint> + +namespace x2w_startup { + +enum class CopyRefusal { + none, + unresolved, // a null argument, or one that is not a resource + same_resource, // source and destination are one resource + not_buffer, // CopyBufferRegion on a texture + not_texture, // ResolveSubresource on something other than a 2D texture + dimension_mismatch, // CopyResource between different resource dimensions + size_mismatch, // different width, height, depth, mips or buffer size + format_mismatch, // formats that are neither equal nor members of one typeless family + sample_mismatch, // different sample count or quality + bad_subresource, // a subresource index outside the texture, or of another size + source_not_multisampled, // the resolve source has one sample + destination_multisampled, // the resolve destination has more than one sample + bad_format, // a resolve format that is unknown, or typeless with no typed choice + zero_size, // CopyBufferRegion of no bytes + range_overflow, // an offset and size that wrap, or run past a buffer +}; + +inline const char* copy_refusal_name(CopyRefusal refusal) +{ + switch (refusal) { + case CopyRefusal::unresolved: return "unresolved"; + case CopyRefusal::same_resource: return "same_resource"; + case CopyRefusal::not_buffer: return "not_buffer"; + case CopyRefusal::not_texture: return "not_texture"; + case CopyRefusal::dimension_mismatch: return "dimension_mismatch"; + case CopyRefusal::size_mismatch: return "size_mismatch"; + case CopyRefusal::format_mismatch: return "format_mismatch"; + case CopyRefusal::sample_mismatch: return "sample_mismatch"; + case CopyRefusal::bad_subresource: return "bad_subresource"; + case CopyRefusal::source_not_multisampled: return "source_not_multisampled"; + case CopyRefusal::destination_multisampled: return "destination_multisampled"; + case CopyRefusal::bad_format: return "bad_format"; + case CopyRefusal::zero_size: return "zero_size"; + case CopyRefusal::range_overflow: return "range_overflow"; + default: return "none"; + } +} + +// The typeless member of the colour format family `format` belongs to; `format` itself when it has none. +inline DXGI_FORMAT format_family(DXGI_FORMAT format) +{ + switch (format) { + case DXGI_FORMAT_R32G32B32A32_TYPELESS: case DXGI_FORMAT_R32G32B32A32_FLOAT: + case DXGI_FORMAT_R32G32B32A32_UINT: case DXGI_FORMAT_R32G32B32A32_SINT: + return DXGI_FORMAT_R32G32B32A32_TYPELESS; + case DXGI_FORMAT_R16G16B16A16_TYPELESS: case DXGI_FORMAT_R16G16B16A16_FLOAT: + case DXGI_FORMAT_R16G16B16A16_UNORM: case DXGI_FORMAT_R16G16B16A16_UINT: + case DXGI_FORMAT_R16G16B16A16_SNORM: case DXGI_FORMAT_R16G16B16A16_SINT: + return DXGI_FORMAT_R16G16B16A16_TYPELESS; + case DXGI_FORMAT_R10G10B10A2_TYPELESS: case DXGI_FORMAT_R10G10B10A2_UNORM: case DXGI_FORMAT_R10G10B10A2_UINT: + return DXGI_FORMAT_R10G10B10A2_TYPELESS; + case DXGI_FORMAT_R8G8B8A8_TYPELESS: case DXGI_FORMAT_R8G8B8A8_UNORM: case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: + case DXGI_FORMAT_R8G8B8A8_UINT: case DXGI_FORMAT_R8G8B8A8_SNORM: case DXGI_FORMAT_R8G8B8A8_SINT: + return DXGI_FORMAT_R8G8B8A8_TYPELESS; + case DXGI_FORMAT_B8G8R8A8_TYPELESS: case DXGI_FORMAT_B8G8R8A8_UNORM: case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: + return DXGI_FORMAT_B8G8R8A8_TYPELESS; + case DXGI_FORMAT_R16G16_TYPELESS: case DXGI_FORMAT_R16G16_FLOAT: case DXGI_FORMAT_R16G16_UNORM: + case DXGI_FORMAT_R16G16_UINT: case DXGI_FORMAT_R16G16_SNORM: case DXGI_FORMAT_R16G16_SINT: + return DXGI_FORMAT_R16G16_TYPELESS; + case DXGI_FORMAT_R32_TYPELESS: case DXGI_FORMAT_R32_FLOAT: case DXGI_FORMAT_R32_UINT: case DXGI_FORMAT_R32_SINT: + return DXGI_FORMAT_R32_TYPELESS; + default: + return format; + } +} + +// The typed format a typeless one resolves as; DXGI_FORMAT_UNKNOWN for a format that is not typeless or has no +// single natural choice. Floating point for the HDR families, normalised for the 8 and 10 bit ones. +inline DXGI_FORMAT typed_choice(DXGI_FORMAT typeless) +{ + switch (typeless) { + case DXGI_FORMAT_R32G32B32A32_TYPELESS: return DXGI_FORMAT_R32G32B32A32_FLOAT; + case DXGI_FORMAT_R16G16B16A16_TYPELESS: return DXGI_FORMAT_R16G16B16A16_FLOAT; + case DXGI_FORMAT_R10G10B10A2_TYPELESS: return DXGI_FORMAT_R10G10B10A2_UNORM; + case DXGI_FORMAT_R8G8B8A8_TYPELESS: return DXGI_FORMAT_R8G8B8A8_UNORM; + case DXGI_FORMAT_B8G8R8A8_TYPELESS: return DXGI_FORMAT_B8G8R8A8_UNORM; + case DXGI_FORMAT_R16G16_TYPELESS: return DXGI_FORMAT_R16G16_FLOAT; + case DXGI_FORMAT_R32_TYPELESS: return DXGI_FORMAT_R32_FLOAT; + default: return DXGI_FORMAT_UNKNOWN; + } +} + +inline bool is_typeless(DXGI_FORMAT format) +{ + switch (format) { + case DXGI_FORMAT_R32G32B32A32_TYPELESS: case DXGI_FORMAT_R32G32B32_TYPELESS: case DXGI_FORMAT_R16G16B16A16_TYPELESS: + case DXGI_FORMAT_R32G32_TYPELESS: case DXGI_FORMAT_R32G8X24_TYPELESS: case DXGI_FORMAT_R10G10B10A2_TYPELESS: + case DXGI_FORMAT_R8G8B8A8_TYPELESS: case DXGI_FORMAT_R16G16_TYPELESS: case DXGI_FORMAT_R32_TYPELESS: + case DXGI_FORMAT_R24G8_TYPELESS: case DXGI_FORMAT_R8G8_TYPELESS: case DXGI_FORMAT_R16_TYPELESS: + case DXGI_FORMAT_R8_TYPELESS: case DXGI_FORMAT_B8G8R8A8_TYPELESS: case DXGI_FORMAT_B8G8R8X8_TYPELESS: + return true; + default: + return false; + } +} + +inline bool is_typeless_choice_format(DXGI_FORMAT format) { return typed_choice(format) != DXGI_FORMAT_UNKNOWN; } + +inline bool compatible_formats(DXGI_FORMAT a, DXGI_FORMAT b) +{ + return a == b || (a != DXGI_FORMAT_UNKNOWN && format_family(a) == format_family(b)); +} + +// CopyBufferRegion(destination, destination_offset, source, source_offset, bytes). `same` is true when both +// arguments are one resource (it would need two states at once). +inline CopyRefusal check_copy_buffer_region(const D3D12_RESOURCE_DESC* destination, std::uint64_t destination_offset, + const D3D12_RESOURCE_DESC* source, std::uint64_t source_offset, + std::uint64_t bytes, bool same) +{ + if (!destination || !source) return CopyRefusal::unresolved; + if (same) return CopyRefusal::same_resource; + if (destination->Dimension != D3D12_RESOURCE_DIMENSION_BUFFER || source->Dimension != D3D12_RESOURCE_DIMENSION_BUFFER) + return CopyRefusal::not_buffer; + if (!bytes) return CopyRefusal::zero_size; + if (destination_offset > destination->Width || bytes > destination->Width - destination_offset || + source_offset > source->Width || bytes > source->Width - source_offset) + return CopyRefusal::range_overflow; + return CopyRefusal::none; +} + +// CopyResource(destination, source): the two descriptions must have one shape. +inline CopyRefusal check_copy_resource(const D3D12_RESOURCE_DESC* destination, const D3D12_RESOURCE_DESC* source, bool same) +{ + if (!destination || !source) return CopyRefusal::unresolved; + if (same) return CopyRefusal::same_resource; + if (destination->Dimension == D3D12_RESOURCE_DIMENSION_UNKNOWN || destination->Dimension != source->Dimension) + return CopyRefusal::dimension_mismatch; + if (destination->Width != source->Width) return CopyRefusal::size_mismatch; + if (destination->Dimension == D3D12_RESOURCE_DIMENSION_BUFFER) return CopyRefusal::none; + if (destination->Height != source->Height || destination->DepthOrArraySize != source->DepthOrArraySize || + destination->MipLevels != source->MipLevels) + return CopyRefusal::size_mismatch; + if (!compatible_formats(destination->Format, source->Format)) return CopyRefusal::format_mismatch; + if (destination->SampleDesc.Count != source->SampleDesc.Count || destination->SampleDesc.Quality != source->SampleDesc.Quality) + return CopyRefusal::sample_mismatch; + return CopyRefusal::none; +} + +struct ResolvePlan { + CopyRefusal refusal{}; + DXGI_FORMAT format{}; // the typed format to resolve as, when not refused +}; + +// One mip of a 2D texture: its size in texels. +inline std::uint64_t mip_extent(std::uint64_t extent, std::uint32_t mip) { return (std::max<std::uint64_t>)(extent >> mip, 1); } + +// ResolveSubresource(destination, destination_subresource, source, source_subresource, format). A typeless +// `format` (or one the title left unknown over a typeless surface) resolves as the family's typed choice, so a +// half-float surface stored as typeless resolves as half float. +inline ResolvePlan plan_resolve(const D3D12_RESOURCE_DESC* destination, std::uint32_t destination_subresource, + const D3D12_RESOURCE_DESC* source, std::uint32_t source_subresource, DXGI_FORMAT format, + bool same) +{ + if (!destination || !source) return {CopyRefusal::unresolved, {}}; + if (same) return {CopyRefusal::same_resource, {}}; + if (destination->Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE2D || source->Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE2D) + return {CopyRefusal::not_texture, {}}; + if (source->SampleDesc.Count <= 1) return {CopyRefusal::source_not_multisampled, {}}; + if (destination->SampleDesc.Count != 1) return {CopyRefusal::destination_multisampled, {}}; + const std::uint32_t destination_mips = destination->MipLevels ? destination->MipLevels : 1; + const std::uint32_t source_mips = source->MipLevels ? source->MipLevels : 1; + if (destination_subresource >= std::uint64_t{destination_mips} * destination->DepthOrArraySize || + source_subresource >= std::uint64_t{source_mips} * source->DepthOrArraySize) + return {CopyRefusal::bad_subresource, {}}; + const std::uint32_t destination_mip = destination_subresource % destination_mips; + const std::uint32_t source_mip = source_subresource % source_mips; + if (mip_extent(destination->Width, destination_mip) != mip_extent(source->Width, source_mip) || + mip_extent(destination->Height, destination_mip) != mip_extent(source->Height, source_mip)) + return {CopyRefusal::bad_subresource, {}}; + DXGI_FORMAT typed = format; + if (typed == DXGI_FORMAT_UNKNOWN) typed = source->Format; + if (is_typeless_choice_format(typed)) typed = typed_choice(typed); + if (typed == DXGI_FORMAT_UNKNOWN || is_typeless(typed)) return {CopyRefusal::bad_format, {}}; + if (!compatible_formats(typed, source->Format) || !compatible_formats(typed, destination->Format)) + return {CopyRefusal::format_mismatch, {}}; ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Require resolve formats to match fully typed endpoints** For a typeless RGBA8 source, a typed `R8G8B8A8_UNORM_SRGB` destination and an unknown format argument, the preceding fallback chooses `R8G8B8A8_UNORM`, and these family checks accept it. D3D12 requires the resolve format to match a fully typed endpoint exactly; family compatibility is only sufficient for a typeless endpoint. Consequently, this plan forwards a desktop-invalid resolve instead of refusing it. Select or validate against typed endpoints before applying the typeless-family fallback. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot commented 2026-11-24 23:03:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T22:08:09Z.

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

@@ -0,0 +1,108 @@
+// Included from d3d12_xs_device.cpp after the command-list state helpers.
+//
+// Whole-resource copies on a recording list (render mode): CopyBufferRegion (list slot 15), CopyResource
+// (17) and ResolveSubresource (19). The title's resources are mapped to desktop ones, the pair is checked
+// by src/startup_stubs/list_copy.h, and a pair the desktop would reject is counted and skipped instead of
+// forwarded. Desktop resources rest in COMMON between lists, so each is moved to the copy or resolve state
+// around the call and back at Close; upload and readback buffers keep the state their heap requires.
+// CopyTextureRegion (16) and CopyTiles (18) carry footprints and addresses and are not handled here.
+
+LONG list_buffer_copies, list_resource_copies, list_resolves, list_copies_refused;
+
+// The desktop resource behind a copy argument; null for a null value, or a wrapper that is not a resource.
+// A value that is no wrapper is taken as a desktop resource, as the view slots do.
+ID3D12Resource* copy_endpoint(u64 value)
+{
+    if (!value) return nullptr;
+    if (const Wrapper* w = as_wrapper(reinterpret_cast<const void*>(value))) {
+        if (w->own().kind != resource_kind) return nullptr;
+        return static_cast<ID3D12Resource*>(w->own().real);
+    }
+    return x2w_local::readable(reinterpret_cast<const void*>(value), sizeof(void*)) ? reinterpret_cast<ID3D12Resource*>(value) : nullptr;
+}
+
+void refuse_copy(const char* what, x2w_startup::CopyRefusal reason)
+{
+    InterlockedIncrement(&list_copies_refused);
+    static LONG logged;
+    if (first_calls(logged, 6)) log("x2w-d3d12 %s skipped: %s", what, x2w_startup::copy_refusal_name(reason));
+}
+
+// The state a copy needs from `resource`: an upload buffer stays readable and a readback buffer stays a
+// copy destination, because desktop allows no other state for them.
+void require_copy_state(Wrapper* self, ID3D12Resource* resource, D3D12_RESOURCE_STATES state)
+{
+    D3D12_HEAP_PROPERTIES heap{};
+    D3D12_HEAP_FLAGS flags{};
+    if (SUCCEEDED(resource->GetHeapProperties(&heap, &flags)) &&
+        (heap.Type == D3D12_HEAP_TYPE_UPLOAD || heap.Type == D3D12_HEAP_TYPE_READBACK))
+        return;

P2 Badge Reject fixed heaps used in the wrong copy direction

Skipping transitions is correct for an upload source or a readback destination, but this condition also skips them for an upload destination or a readback source. The descriptor-only validators accept those buffers, so both copy handlers forward the operation while the endpoint remains in an incompatible immutable state (GENERIC_READ or COPY_DEST) and count it as successful. Check that the heap's fixed state permits the requested role and refuse the wrong-direction cases before recording the copy.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4687208057 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1944#discussion_r4687208057). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T22:08:09Z. **Code review location:** `src/startup_stubs/list_copy.inl`; line 39 ~~~~diff @@ -0,0 +1,108 @@ +// Included from d3d12_xs_device.cpp after the command-list state helpers. +// +// Whole-resource copies on a recording list (render mode): CopyBufferRegion (list slot 15), CopyResource +// (17) and ResolveSubresource (19). The title's resources are mapped to desktop ones, the pair is checked +// by src/startup_stubs/list_copy.h, and a pair the desktop would reject is counted and skipped instead of +// forwarded. Desktop resources rest in COMMON between lists, so each is moved to the copy or resolve state +// around the call and back at Close; upload and readback buffers keep the state their heap requires. +// CopyTextureRegion (16) and CopyTiles (18) carry footprints and addresses and are not handled here. + +LONG list_buffer_copies, list_resource_copies, list_resolves, list_copies_refused; + +// The desktop resource behind a copy argument; null for a null value, or a wrapper that is not a resource. +// A value that is no wrapper is taken as a desktop resource, as the view slots do. +ID3D12Resource* copy_endpoint(u64 value) +{ + if (!value) return nullptr; + if (const Wrapper* w = as_wrapper(reinterpret_cast<const void*>(value))) { + if (w->own().kind != resource_kind) return nullptr; + return static_cast<ID3D12Resource*>(w->own().real); + } + return x2w_local::readable(reinterpret_cast<const void*>(value), sizeof(void*)) ? reinterpret_cast<ID3D12Resource*>(value) : nullptr; +} + +void refuse_copy(const char* what, x2w_startup::CopyRefusal reason) +{ + InterlockedIncrement(&list_copies_refused); + static LONG logged; + if (first_calls(logged, 6)) log("x2w-d3d12 %s skipped: %s", what, x2w_startup::copy_refusal_name(reason)); +} + +// The state a copy needs from `resource`: an upload buffer stays readable and a readback buffer stays a +// copy destination, because desktop allows no other state for them. +void require_copy_state(Wrapper* self, ID3D12Resource* resource, D3D12_RESOURCE_STATES state) +{ + D3D12_HEAP_PROPERTIES heap{}; + D3D12_HEAP_FLAGS flags{}; + if (SUCCEEDED(resource->GetHeapProperties(&heap, &flags)) && + (heap.Type == D3D12_HEAP_TYPE_UPLOAD || heap.Type == D3D12_HEAP_TYPE_READBACK)) + return; ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Reject fixed heaps used in the wrong copy direction** Skipping transitions is correct for an upload source or a readback destination, but this condition also skips them for an upload destination or a readback source. The descriptor-only validators accept those buffers, so both copy handlers forward the operation while the endpoint remains in an incompatible immutable state (`GENERIC_READ` or `COPY_DEST`) and count it as successful. Check that the heap's fixed state permits the requested role and refuse the wrong-direction cases before recording the copy. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot commented 2026-11-24 23:03:43 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T22:08:09Z.

Code review location: src/startup_stubs/list_copy.h; line 79

@@ -0,0 +1,195 @@
+// Pure validation for the whole-resource command-list copies: CopyBufferRegion (list slot 15),
+// CopyResource (17) and ResolveSubresource (19). It reads only resource descriptions, so it runs on any host.
+//
+// Desktop D3D12 removes the device on a copy it rejects, so a copy whose arguments the desktop would
+// refuse is named and skipped instead of forwarded. Each check returns the first refusal, in the
+// order listed in CopyRefusal.
+#pragma once
+
+#include <d3d12.h>
+
+#include <algorithm>
+#include <cstdint>
+
+namespace x2w_startup {
+
+enum class CopyRefusal {
+    none,
+    unresolved,                // a null argument, or one that is not a resource
+    same_resource,             // source and destination are one resource
+    not_buffer,                // CopyBufferRegion on a texture
+    not_texture,               // ResolveSubresource on something other than a 2D texture
+    dimension_mismatch,        // CopyResource between different resource dimensions
+    size_mismatch,             // different width, height, depth, mips or buffer size
+    format_mismatch,           // formats that are neither equal nor members of one typeless family
+    sample_mismatch,           // different sample count or quality
+    bad_subresource,           // a subresource index outside the texture, or of another size
+    source_not_multisampled,   // the resolve source has one sample
+    destination_multisampled,  // the resolve destination has more than one sample
+    bad_format,                // a resolve format that is unknown, or typeless with no typed choice
+    zero_size,                 // CopyBufferRegion of no bytes
+    range_overflow,            // an offset and size that wrap, or run past a buffer
+};
+
+inline const char* copy_refusal_name(CopyRefusal refusal)
+{
+    switch (refusal) {
+    case CopyRefusal::unresolved: return "unresolved";
+    case CopyRefusal::same_resource: return "same_resource";
+    case CopyRefusal::not_buffer: return "not_buffer";
+    case CopyRefusal::not_texture: return "not_texture";
+    case CopyRefusal::dimension_mismatch: return "dimension_mismatch";
+    case CopyRefusal::size_mismatch: return "size_mismatch";
+    case CopyRefusal::format_mismatch: return "format_mismatch";
+    case CopyRefusal::sample_mismatch: return "sample_mismatch";
+    case CopyRefusal::bad_subresource: return "bad_subresource";
+    case CopyRefusal::source_not_multisampled: return "source_not_multisampled";
+    case CopyRefusal::destination_multisampled: return "destination_multisampled";
+    case CopyRefusal::bad_format: return "bad_format";
+    case CopyRefusal::zero_size: return "zero_size";
+    case CopyRefusal::range_overflow: return "range_overflow";
+    default: return "none";
+    }
+}
+
+// The typeless member of the colour format family `format` belongs to; `format` itself when it has none.
+inline DXGI_FORMAT format_family(DXGI_FORMAT format)
+{
+    switch (format) {
+    case DXGI_FORMAT_R32G32B32A32_TYPELESS: case DXGI_FORMAT_R32G32B32A32_FLOAT:
+    case DXGI_FORMAT_R32G32B32A32_UINT: case DXGI_FORMAT_R32G32B32A32_SINT:
+        return DXGI_FORMAT_R32G32B32A32_TYPELESS;
+    case DXGI_FORMAT_R16G16B16A16_TYPELESS: case DXGI_FORMAT_R16G16B16A16_FLOAT:
+    case DXGI_FORMAT_R16G16B16A16_UNORM: case DXGI_FORMAT_R16G16B16A16_UINT:
+    case DXGI_FORMAT_R16G16B16A16_SNORM: case DXGI_FORMAT_R16G16B16A16_SINT:
+        return DXGI_FORMAT_R16G16B16A16_TYPELESS;
+    case DXGI_FORMAT_R10G10B10A2_TYPELESS: case DXGI_FORMAT_R10G10B10A2_UNORM: case DXGI_FORMAT_R10G10B10A2_UINT:
+        return DXGI_FORMAT_R10G10B10A2_TYPELESS;
+    case DXGI_FORMAT_R8G8B8A8_TYPELESS: case DXGI_FORMAT_R8G8B8A8_UNORM: case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB:
+    case DXGI_FORMAT_R8G8B8A8_UINT: case DXGI_FORMAT_R8G8B8A8_SNORM: case DXGI_FORMAT_R8G8B8A8_SINT:
+        return DXGI_FORMAT_R8G8B8A8_TYPELESS;
+    case DXGI_FORMAT_B8G8R8A8_TYPELESS: case DXGI_FORMAT_B8G8R8A8_UNORM: case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB:
+        return DXGI_FORMAT_B8G8R8A8_TYPELESS;
+    case DXGI_FORMAT_R16G16_TYPELESS: case DXGI_FORMAT_R16G16_FLOAT: case DXGI_FORMAT_R16G16_UNORM:
+    case DXGI_FORMAT_R16G16_UINT: case DXGI_FORMAT_R16G16_SNORM: case DXGI_FORMAT_R16G16_SINT:
+        return DXGI_FORMAT_R16G16_TYPELESS;
+    case DXGI_FORMAT_R32_TYPELESS: case DXGI_FORMAT_R32_FLOAT: case DXGI_FORMAT_R32_UINT: case DXGI_FORMAT_R32_SINT:
+        return DXGI_FORMAT_R32_TYPELESS;
+    default:
+        return format;

P2 Badge Recognize the remaining DXGI families in CopyResource checks

The family table omits valid DXGI type groups, including the BC formats, R16 and R8 families. For example, equal-shaped BC7_TYPELESS and BC7_UNORM resources fall through here as different families, so check_copy_resource() reports format_mismatch and silently skips a legal whole-resource copy. Populate the remaining CopyResource-compatible type groups rather than limiting compatibility to the few families currently supported by the resolve-choice table.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4687208064 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1944#discussion_r4687208064). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T22:08:09Z. **Code review location:** `src/startup_stubs/list_copy.h`; line 79 ~~~~diff @@ -0,0 +1,195 @@ +// Pure validation for the whole-resource command-list copies: CopyBufferRegion (list slot 15), +// CopyResource (17) and ResolveSubresource (19). It reads only resource descriptions, so it runs on any host. +// +// Desktop D3D12 removes the device on a copy it rejects, so a copy whose arguments the desktop would +// refuse is named and skipped instead of forwarded. Each check returns the first refusal, in the +// order listed in CopyRefusal. +#pragma once + +#include <d3d12.h> + +#include <algorithm> +#include <cstdint> + +namespace x2w_startup { + +enum class CopyRefusal { + none, + unresolved, // a null argument, or one that is not a resource + same_resource, // source and destination are one resource + not_buffer, // CopyBufferRegion on a texture + not_texture, // ResolveSubresource on something other than a 2D texture + dimension_mismatch, // CopyResource between different resource dimensions + size_mismatch, // different width, height, depth, mips or buffer size + format_mismatch, // formats that are neither equal nor members of one typeless family + sample_mismatch, // different sample count or quality + bad_subresource, // a subresource index outside the texture, or of another size + source_not_multisampled, // the resolve source has one sample + destination_multisampled, // the resolve destination has more than one sample + bad_format, // a resolve format that is unknown, or typeless with no typed choice + zero_size, // CopyBufferRegion of no bytes + range_overflow, // an offset and size that wrap, or run past a buffer +}; + +inline const char* copy_refusal_name(CopyRefusal refusal) +{ + switch (refusal) { + case CopyRefusal::unresolved: return "unresolved"; + case CopyRefusal::same_resource: return "same_resource"; + case CopyRefusal::not_buffer: return "not_buffer"; + case CopyRefusal::not_texture: return "not_texture"; + case CopyRefusal::dimension_mismatch: return "dimension_mismatch"; + case CopyRefusal::size_mismatch: return "size_mismatch"; + case CopyRefusal::format_mismatch: return "format_mismatch"; + case CopyRefusal::sample_mismatch: return "sample_mismatch"; + case CopyRefusal::bad_subresource: return "bad_subresource"; + case CopyRefusal::source_not_multisampled: return "source_not_multisampled"; + case CopyRefusal::destination_multisampled: return "destination_multisampled"; + case CopyRefusal::bad_format: return "bad_format"; + case CopyRefusal::zero_size: return "zero_size"; + case CopyRefusal::range_overflow: return "range_overflow"; + default: return "none"; + } +} + +// The typeless member of the colour format family `format` belongs to; `format` itself when it has none. +inline DXGI_FORMAT format_family(DXGI_FORMAT format) +{ + switch (format) { + case DXGI_FORMAT_R32G32B32A32_TYPELESS: case DXGI_FORMAT_R32G32B32A32_FLOAT: + case DXGI_FORMAT_R32G32B32A32_UINT: case DXGI_FORMAT_R32G32B32A32_SINT: + return DXGI_FORMAT_R32G32B32A32_TYPELESS; + case DXGI_FORMAT_R16G16B16A16_TYPELESS: case DXGI_FORMAT_R16G16B16A16_FLOAT: + case DXGI_FORMAT_R16G16B16A16_UNORM: case DXGI_FORMAT_R16G16B16A16_UINT: + case DXGI_FORMAT_R16G16B16A16_SNORM: case DXGI_FORMAT_R16G16B16A16_SINT: + return DXGI_FORMAT_R16G16B16A16_TYPELESS; + case DXGI_FORMAT_R10G10B10A2_TYPELESS: case DXGI_FORMAT_R10G10B10A2_UNORM: case DXGI_FORMAT_R10G10B10A2_UINT: + return DXGI_FORMAT_R10G10B10A2_TYPELESS; + case DXGI_FORMAT_R8G8B8A8_TYPELESS: case DXGI_FORMAT_R8G8B8A8_UNORM: case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: + case DXGI_FORMAT_R8G8B8A8_UINT: case DXGI_FORMAT_R8G8B8A8_SNORM: case DXGI_FORMAT_R8G8B8A8_SINT: + return DXGI_FORMAT_R8G8B8A8_TYPELESS; + case DXGI_FORMAT_B8G8R8A8_TYPELESS: case DXGI_FORMAT_B8G8R8A8_UNORM: case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: + return DXGI_FORMAT_B8G8R8A8_TYPELESS; + case DXGI_FORMAT_R16G16_TYPELESS: case DXGI_FORMAT_R16G16_FLOAT: case DXGI_FORMAT_R16G16_UNORM: + case DXGI_FORMAT_R16G16_UINT: case DXGI_FORMAT_R16G16_SNORM: case DXGI_FORMAT_R16G16_SINT: + return DXGI_FORMAT_R16G16_TYPELESS; + case DXGI_FORMAT_R32_TYPELESS: case DXGI_FORMAT_R32_FLOAT: case DXGI_FORMAT_R32_UINT: case DXGI_FORMAT_R32_SINT: + return DXGI_FORMAT_R32_TYPELESS; + default: + return format; ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Recognize the remaining DXGI families in CopyResource checks** The family table omits valid DXGI type groups, including the BC formats, R16 and R8 families. For example, equal-shaped `BC7_TYPELESS` and `BC7_UNORM` resources fall through here as different families, so `check_copy_resource()` reports `format_mismatch` and silently skips a legal whole-resource copy. Populate the remaining CopyResource-compatible type groups rather than limiting compatibility to the few families currently supported by the resolve-choice table. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
Makto94 commented 2026-11-25 01:02:00 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Makto94 on 2026-11-24T23:56:04Z.


WARP and hardware run of startup_list_copy_* at head e7b39dc4 (Debug build, Windows 11 build 26300, NVIDIA GeForce RTX 3070 Ti driver 32.0.16.2101, D3D12 debug layer enabled via X2W_D3D12_DEBUG=1):

ctest --test-dir out/build/dev -j1 --no-tests=error -R '^startup_list_copy_' -V

Result: 6/6 passed (100% tests passed, 0 tests failed out of 6).

  • Passed: startup_list_copy_warp and startup_list_copy_hardware, plus the 4 startup_list_copy_validation* tests. 0 capability skips (exit code 77).
  • Debug-layer messages in the log (sev is D3D12_MESSAGE_SEVERITY: 1 = ERROR, 2 = WARNING): no sev=0 or sev=1 line; each GPU test logs 4 sev=2 id=820 warnings (ClearRenderTargetView: The clear values do not match those passed to resource creation).
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7147955071 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1944#issuecomment-7147955071). Originally posted by [Makto94](https://github.com/Makto94) on 2026-11-24T23:56:04Z. --- WARP and hardware run of `startup_list_copy_*` at head `e7b39dc4` (Debug build, Windows 11 build 26300, NVIDIA GeForce RTX 3070 Ti driver 32.0.16.2101, D3D12 debug layer enabled via `X2W_D3D12_DEBUG=1`): ``` ctest --test-dir out/build/dev -j1 --no-tests=error -R '^startup_list_copy_' -V ``` Result: 6/6 passed (`100% tests passed, 0 tests failed out of 6`). - Passed: `startup_list_copy_warp` and `startup_list_copy_hardware`, plus the 4 `startup_list_copy_validation*` tests. 0 capability skips (exit code 77). - Debug-layer messages in the log (`sev` is `D3D12_MESSAGE_SEVERITY`: 1 = ERROR, 2 = WARNING): no `sev=0` or `sev=1` line; each GPU test logs 4 `sev=2 id=820` warnings (`ClearRenderTargetView: The clear values do not match those passed to resource creation`).
tedin7 commented 2026-11-25 02:01:24 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:02:30Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6049953568 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1944#pullrequestreview-6049953568). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T01:02:30Z. **Review:** COMMENTED --- _No description provided._
tedin7 commented 2026-11-25 02:01:24 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:02:32Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6049953817 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1944#pullrequestreview-6049953817). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T01:02:32Z. **Review:** COMMENTED --- _No description provided._
tedin7 commented 2026-11-25 02:01:24 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:02:33Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6049954112 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1944#pullrequestreview-6049954112). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T01:02:33Z. **Review:** COMMENTED --- _No description provided._
tedin7 commented 2026-11-25 02:01:24 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:02:35Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6049954317 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1944#pullrequestreview-6049954317). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T01:02:35Z. **Review:** COMMENTED --- _No description provided._
tedin7 commented 2026-11-25 02:01:24 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:02:37Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6049954531 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1944#pullrequestreview-6049954531). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T01:02:37Z. **Review:** COMMENTED --- _No description provided._
tedin7 commented 2026-11-25 02:01:24 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:02:39Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6049954789 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1944#pullrequestreview-6049954789). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T01:02:39Z. **Review:** COMMENTED --- _No description provided._
tedin7 commented 2026-11-25 02:02:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:04:14Z.


Fixed in 5bda1cfc (all six review threads):

  • Title-backed sources (P1): CopyResource and CopyBufferRegion refresh the source first. A texture takes the draw path's upload, an upload buffer is copied through a desktop mapping, an aliased placed buffer is already current. A title-backed default-heap buffer is refused as title_backed_source.
  • GPU-written destinations (P1): a copy or resolve destination with title memory is marked GPU-written in the texture upload state, so a later draw no longer uploads stale title memory over the result.
  • Placed buffer initial state (P2): a buffer whose recorded initial state is not COMMON is refused as initial_state, like list_execute_indirect().
  • Resolve format (P2): a fully typed endpoint now fixes the format exactly (typed destination or source is picked before the typeless fallback); family compatibility only applies to typeless endpoints.
  • Heap direction (P2): an upload buffer as a destination or a readback buffer as a source is refused as heap_direction.
  • DXGI families (P2): the family table now covers BC1-7, R8, R8G8, R16, R32G32, R32G32B32, R32G8X24, R24G8, B8G8R8X8 and the depth members.

Verification: x2w_pipe.py win2025 1944 on Win2025: 27/27 passed, including startup_list_copy_warp and startup_list_copy_validation (new pure checks for typed-endpoint resolve and the BC7/R16/R8 families; the warp probe now refuses a copy into an upload buffer and out of a readback buffer). The title-backed sync and GPU-written paths need a title-memory resource, which the warp probe does not create, so they are not covered by a fixture yet.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7149174592 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1944#issuecomment-7149174592). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T01:04:14Z. --- Fixed in 5bda1cfc (all six review threads): - Title-backed sources (P1): CopyResource and CopyBufferRegion refresh the source first. A texture takes the draw path's upload, an upload buffer is copied through a desktop mapping, an aliased placed buffer is already current. A title-backed default-heap buffer is refused as `title_backed_source`. - GPU-written destinations (P1): a copy or resolve destination with title memory is marked GPU-written in the texture upload state, so a later draw no longer uploads stale title memory over the result. - Placed buffer initial state (P2): a buffer whose recorded initial state is not COMMON is refused as `initial_state`, like `list_execute_indirect()`. - Resolve format (P2): a fully typed endpoint now fixes the format exactly (typed destination or source is picked before the typeless fallback); family compatibility only applies to typeless endpoints. - Heap direction (P2): an upload buffer as a destination or a readback buffer as a source is refused as `heap_direction`. - DXGI families (P2): the family table now covers BC1-7, R8, R8G8, R16, R32G32, R32G32B32, R32G8X24, R24G8, B8G8R8X8 and the depth members. Verification: `x2w_pipe.py win2025 1944` on Win2025: 27/27 passed, including `startup_list_copy_warp` and `startup_list_copy_validation` (new pure checks for typed-endpoint resolve and the BC7/R16/R8 families; the warp probe now refuses a copy into an upload buffer and out of a readback buffer). The title-backed sync and GPU-written paths need a title-memory resource, which the warp probe does not create, so they are not covered by a fixture yet. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 02:02:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:02:30Z.

Code review location: src/startup_stubs/list_copy.h; line 191

@@ -0,0 +1,195 @@
+// Pure validation for the whole-resource command-list copies: CopyBufferRegion (list slot 15),
+// CopyResource (17) and ResolveSubresource (19). It reads only resource descriptions, so it runs on any host.
+//
+// Desktop D3D12 removes the device on a copy it rejects, so a copy whose arguments the desktop would
+// refuse is named and skipped instead of forwarded. Each check returns the first refusal, in the
+// order listed in CopyRefusal.
+#pragma once
+
+#include <d3d12.h>
+
+#include <algorithm>
+#include <cstdint>
+
+namespace x2w_startup {
+
+enum class CopyRefusal {
+    none,
+    unresolved,                // a null argument, or one that is not a resource
+    same_resource,             // source and destination are one resource
+    not_buffer,                // CopyBufferRegion on a texture
+    not_texture,               // ResolveSubresource on something other than a 2D texture
+    dimension_mismatch,        // CopyResource between different resource dimensions
+    size_mismatch,             // different width, height, depth, mips or buffer size
+    format_mismatch,           // formats that are neither equal nor members of one typeless family
+    sample_mismatch,           // different sample count or quality
+    bad_subresource,           // a subresource index outside the texture, or of another size
+    source_not_multisampled,   // the resolve source has one sample
+    destination_multisampled,  // the resolve destination has more than one sample
+    bad_format,                // a resolve format that is unknown, or typeless with no typed choice
+    zero_size,                 // CopyBufferRegion of no bytes
+    range_overflow,            // an offset and size that wrap, or run past a buffer
+};
+
+inline const char* copy_refusal_name(CopyRefusal refusal)
+{
+    switch (refusal) {
+    case CopyRefusal::unresolved: return "unresolved";
+    case CopyRefusal::same_resource: return "same_resource";
+    case CopyRefusal::not_buffer: return "not_buffer";
+    case CopyRefusal::not_texture: return "not_texture";
+    case CopyRefusal::dimension_mismatch: return "dimension_mismatch";
+    case CopyRefusal::size_mismatch: return "size_mismatch";
+    case CopyRefusal::format_mismatch: return "format_mismatch";
+    case CopyRefusal::sample_mismatch: return "sample_mismatch";
+    case CopyRefusal::bad_subresource: return "bad_subresource";
+    case CopyRefusal::source_not_multisampled: return "source_not_multisampled";
+    case CopyRefusal::destination_multisampled: return "destination_multisampled";
+    case CopyRefusal::bad_format: return "bad_format";
+    case CopyRefusal::zero_size: return "zero_size";
+    case CopyRefusal::range_overflow: return "range_overflow";
+    default: return "none";
+    }
+}
+
+// The typeless member of the colour format family `format` belongs to; `format` itself when it has none.
+inline DXGI_FORMAT format_family(DXGI_FORMAT format)
+{
+    switch (format) {
+    case DXGI_FORMAT_R32G32B32A32_TYPELESS: case DXGI_FORMAT_R32G32B32A32_FLOAT:
+    case DXGI_FORMAT_R32G32B32A32_UINT: case DXGI_FORMAT_R32G32B32A32_SINT:
+        return DXGI_FORMAT_R32G32B32A32_TYPELESS;
+    case DXGI_FORMAT_R16G16B16A16_TYPELESS: case DXGI_FORMAT_R16G16B16A16_FLOAT:
+    case DXGI_FORMAT_R16G16B16A16_UNORM: case DXGI_FORMAT_R16G16B16A16_UINT:
+    case DXGI_FORMAT_R16G16B16A16_SNORM: case DXGI_FORMAT_R16G16B16A16_SINT:
+        return DXGI_FORMAT_R16G16B16A16_TYPELESS;
+    case DXGI_FORMAT_R10G10B10A2_TYPELESS: case DXGI_FORMAT_R10G10B10A2_UNORM: case DXGI_FORMAT_R10G10B10A2_UINT:
+        return DXGI_FORMAT_R10G10B10A2_TYPELESS;
+    case DXGI_FORMAT_R8G8B8A8_TYPELESS: case DXGI_FORMAT_R8G8B8A8_UNORM: case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB:
+    case DXGI_FORMAT_R8G8B8A8_UINT: case DXGI_FORMAT_R8G8B8A8_SNORM: case DXGI_FORMAT_R8G8B8A8_SINT:
+        return DXGI_FORMAT_R8G8B8A8_TYPELESS;
+    case DXGI_FORMAT_B8G8R8A8_TYPELESS: case DXGI_FORMAT_B8G8R8A8_UNORM: case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB:
+        return DXGI_FORMAT_B8G8R8A8_TYPELESS;
+    case DXGI_FORMAT_R16G16_TYPELESS: case DXGI_FORMAT_R16G16_FLOAT: case DXGI_FORMAT_R16G16_UNORM:
+    case DXGI_FORMAT_R16G16_UINT: case DXGI_FORMAT_R16G16_SNORM: case DXGI_FORMAT_R16G16_SINT:
+        return DXGI_FORMAT_R16G16_TYPELESS;
+    case DXGI_FORMAT_R32_TYPELESS: case DXGI_FORMAT_R32_FLOAT: case DXGI_FORMAT_R32_UINT: case DXGI_FORMAT_R32_SINT:
+        return DXGI_FORMAT_R32_TYPELESS;
+    default:
+        return format;
+    }
+}
+
+// The typed format a typeless one resolves as; DXGI_FORMAT_UNKNOWN for a format that is not typeless or has no
+// single natural choice. Floating point for the HDR families, normalised for the 8 and 10 bit ones.
+inline DXGI_FORMAT typed_choice(DXGI_FORMAT typeless)
+{
+    switch (typeless) {
+    case DXGI_FORMAT_R32G32B32A32_TYPELESS: return DXGI_FORMAT_R32G32B32A32_FLOAT;
+    case DXGI_FORMAT_R16G16B16A16_TYPELESS: return DXGI_FORMAT_R16G16B16A16_FLOAT;
+    case DXGI_FORMAT_R10G10B10A2_TYPELESS: return DXGI_FORMAT_R10G10B10A2_UNORM;
+    case DXGI_FORMAT_R8G8B8A8_TYPELESS: return DXGI_FORMAT_R8G8B8A8_UNORM;
+    case DXGI_FORMAT_B8G8R8A8_TYPELESS: return DXGI_FORMAT_B8G8R8A8_UNORM;
+    case DXGI_FORMAT_R16G16_TYPELESS: return DXGI_FORMAT_R16G16_FLOAT;
+    case DXGI_FORMAT_R32_TYPELESS: return DXGI_FORMAT_R32_FLOAT;
+    default: return DXGI_FORMAT_UNKNOWN;
+    }
+}
+
+inline bool is_typeless(DXGI_FORMAT format)
+{
+    switch (format) {
+    case DXGI_FORMAT_R32G32B32A32_TYPELESS: case DXGI_FORMAT_R32G32B32_TYPELESS: case DXGI_FORMAT_R16G16B16A16_TYPELESS:
+    case DXGI_FORMAT_R32G32_TYPELESS: case DXGI_FORMAT_R32G8X24_TYPELESS: case DXGI_FORMAT_R10G10B10A2_TYPELESS:
+    case DXGI_FORMAT_R8G8B8A8_TYPELESS: case DXGI_FORMAT_R16G16_TYPELESS: case DXGI_FORMAT_R32_TYPELESS:
+    case DXGI_FORMAT_R24G8_TYPELESS: case DXGI_FORMAT_R8G8_TYPELESS: case DXGI_FORMAT_R16_TYPELESS:
+    case DXGI_FORMAT_R8_TYPELESS: case DXGI_FORMAT_B8G8R8A8_TYPELESS: case DXGI_FORMAT_B8G8R8X8_TYPELESS:
+        return true;
+    default:
+        return false;
+    }
+}
+
+inline bool is_typeless_choice_format(DXGI_FORMAT format) { return typed_choice(format) != DXGI_FORMAT_UNKNOWN; }
+
+inline bool compatible_formats(DXGI_FORMAT a, DXGI_FORMAT b)
+{
+    return a == b || (a != DXGI_FORMAT_UNKNOWN && format_family(a) == format_family(b));
+}
+
+// CopyBufferRegion(destination, destination_offset, source, source_offset, bytes). `same` is true when both
+// arguments are one resource (it would need two states at once).
+inline CopyRefusal check_copy_buffer_region(const D3D12_RESOURCE_DESC* destination, std::uint64_t destination_offset,
+                                            const D3D12_RESOURCE_DESC* source, std::uint64_t source_offset,
+                                            std::uint64_t bytes, bool same)
+{
+    if (!destination || !source) return CopyRefusal::unresolved;
+    if (same) return CopyRefusal::same_resource;
+    if (destination->Dimension != D3D12_RESOURCE_DIMENSION_BUFFER || source->Dimension != D3D12_RESOURCE_DIMENSION_BUFFER)
+        return CopyRefusal::not_buffer;
+    if (!bytes) return CopyRefusal::zero_size;
+    if (destination_offset > destination->Width || bytes > destination->Width - destination_offset ||
+        source_offset > source->Width || bytes > source->Width - source_offset)
+        return CopyRefusal::range_overflow;
+    return CopyRefusal::none;
+}
+
+// CopyResource(destination, source): the two descriptions must have one shape.
+inline CopyRefusal check_copy_resource(const D3D12_RESOURCE_DESC* destination, const D3D12_RESOURCE_DESC* source, bool same)
+{
+    if (!destination || !source) return CopyRefusal::unresolved;
+    if (same) return CopyRefusal::same_resource;
+    if (destination->Dimension == D3D12_RESOURCE_DIMENSION_UNKNOWN || destination->Dimension != source->Dimension)
+        return CopyRefusal::dimension_mismatch;
+    if (destination->Width != source->Width) return CopyRefusal::size_mismatch;
+    if (destination->Dimension == D3D12_RESOURCE_DIMENSION_BUFFER) return CopyRefusal::none;
+    if (destination->Height != source->Height || destination->DepthOrArraySize != source->DepthOrArraySize ||
+        destination->MipLevels != source->MipLevels)
+        return CopyRefusal::size_mismatch;
+    if (!compatible_formats(destination->Format, source->Format)) return CopyRefusal::format_mismatch;
+    if (destination->SampleDesc.Count != source->SampleDesc.Count || destination->SampleDesc.Quality != source->SampleDesc.Quality)
+        return CopyRefusal::sample_mismatch;
+    return CopyRefusal::none;
+}
+
+struct ResolvePlan {
+    CopyRefusal refusal{};
+    DXGI_FORMAT format{};  // the typed format to resolve as, when not refused
+};
+
+// One mip of a 2D texture: its size in texels.
+inline std::uint64_t mip_extent(std::uint64_t extent, std::uint32_t mip) { return (std::max<std::uint64_t>)(extent >> mip, 1); }
+
+// ResolveSubresource(destination, destination_subresource, source, source_subresource, format). A typeless
+// `format` (or one the title left unknown over a typeless surface) resolves as the family's typed choice, so a
+// half-float surface stored as typeless resolves as half float.
+inline ResolvePlan plan_resolve(const D3D12_RESOURCE_DESC* destination, std::uint32_t destination_subresource,
+                                const D3D12_RESOURCE_DESC* source, std::uint32_t source_subresource, DXGI_FORMAT format,
+                                bool same)
+{
+    if (!destination || !source) return {CopyRefusal::unresolved, {}};
+    if (same) return {CopyRefusal::same_resource, {}};
+    if (destination->Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE2D || source->Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE2D)
+        return {CopyRefusal::not_texture, {}};
+    if (source->SampleDesc.Count <= 1) return {CopyRefusal::source_not_multisampled, {}};
+    if (destination->SampleDesc.Count != 1) return {CopyRefusal::destination_multisampled, {}};
+    const std::uint32_t destination_mips = destination->MipLevels ? destination->MipLevels : 1;
+    const std::uint32_t source_mips = source->MipLevels ? source->MipLevels : 1;
+    if (destination_subresource >= std::uint64_t{destination_mips} * destination->DepthOrArraySize ||
+        source_subresource >= std::uint64_t{source_mips} * source->DepthOrArraySize)
+        return {CopyRefusal::bad_subresource, {}};
+    const std::uint32_t destination_mip = destination_subresource % destination_mips;
+    const std::uint32_t source_mip = source_subresource % source_mips;
+    if (mip_extent(destination->Width, destination_mip) != mip_extent(source->Width, source_mip) ||
+        mip_extent(destination->Height, destination_mip) != mip_extent(source->Height, source_mip))
+        return {CopyRefusal::bad_subresource, {}};
+    DXGI_FORMAT typed = format;
+    if (typed == DXGI_FORMAT_UNKNOWN) typed = source->Format;
+    if (is_typeless_choice_format(typed)) typed = typed_choice(typed);
+    if (typed == DXGI_FORMAT_UNKNOWN || is_typeless(typed)) return {CopyRefusal::bad_format, {}};
+    if (!compatible_formats(typed, source->Format) || !compatible_formats(typed, destination->Format))
+        return {CopyRefusal::format_mismatch, {}};

Fixed in 5bda1cfc: Resolve format is now validated against fully typed endpoints exactly; family match only applies to typeless ones. Win2025 WARP: 27/27 passed (Debug and Release). AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688766374 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1944#discussion_r4688766374). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T01:02:30Z. **Code review location:** `src/startup_stubs/list_copy.h`; line 191 ~~~~diff @@ -0,0 +1,195 @@ +// Pure validation for the whole-resource command-list copies: CopyBufferRegion (list slot 15), +// CopyResource (17) and ResolveSubresource (19). It reads only resource descriptions, so it runs on any host. +// +// Desktop D3D12 removes the device on a copy it rejects, so a copy whose arguments the desktop would +// refuse is named and skipped instead of forwarded. Each check returns the first refusal, in the +// order listed in CopyRefusal. +#pragma once + +#include <d3d12.h> + +#include <algorithm> +#include <cstdint> + +namespace x2w_startup { + +enum class CopyRefusal { + none, + unresolved, // a null argument, or one that is not a resource + same_resource, // source and destination are one resource + not_buffer, // CopyBufferRegion on a texture + not_texture, // ResolveSubresource on something other than a 2D texture + dimension_mismatch, // CopyResource between different resource dimensions + size_mismatch, // different width, height, depth, mips or buffer size + format_mismatch, // formats that are neither equal nor members of one typeless family + sample_mismatch, // different sample count or quality + bad_subresource, // a subresource index outside the texture, or of another size + source_not_multisampled, // the resolve source has one sample + destination_multisampled, // the resolve destination has more than one sample + bad_format, // a resolve format that is unknown, or typeless with no typed choice + zero_size, // CopyBufferRegion of no bytes + range_overflow, // an offset and size that wrap, or run past a buffer +}; + +inline const char* copy_refusal_name(CopyRefusal refusal) +{ + switch (refusal) { + case CopyRefusal::unresolved: return "unresolved"; + case CopyRefusal::same_resource: return "same_resource"; + case CopyRefusal::not_buffer: return "not_buffer"; + case CopyRefusal::not_texture: return "not_texture"; + case CopyRefusal::dimension_mismatch: return "dimension_mismatch"; + case CopyRefusal::size_mismatch: return "size_mismatch"; + case CopyRefusal::format_mismatch: return "format_mismatch"; + case CopyRefusal::sample_mismatch: return "sample_mismatch"; + case CopyRefusal::bad_subresource: return "bad_subresource"; + case CopyRefusal::source_not_multisampled: return "source_not_multisampled"; + case CopyRefusal::destination_multisampled: return "destination_multisampled"; + case CopyRefusal::bad_format: return "bad_format"; + case CopyRefusal::zero_size: return "zero_size"; + case CopyRefusal::range_overflow: return "range_overflow"; + default: return "none"; + } +} + +// The typeless member of the colour format family `format` belongs to; `format` itself when it has none. +inline DXGI_FORMAT format_family(DXGI_FORMAT format) +{ + switch (format) { + case DXGI_FORMAT_R32G32B32A32_TYPELESS: case DXGI_FORMAT_R32G32B32A32_FLOAT: + case DXGI_FORMAT_R32G32B32A32_UINT: case DXGI_FORMAT_R32G32B32A32_SINT: + return DXGI_FORMAT_R32G32B32A32_TYPELESS; + case DXGI_FORMAT_R16G16B16A16_TYPELESS: case DXGI_FORMAT_R16G16B16A16_FLOAT: + case DXGI_FORMAT_R16G16B16A16_UNORM: case DXGI_FORMAT_R16G16B16A16_UINT: + case DXGI_FORMAT_R16G16B16A16_SNORM: case DXGI_FORMAT_R16G16B16A16_SINT: + return DXGI_FORMAT_R16G16B16A16_TYPELESS; + case DXGI_FORMAT_R10G10B10A2_TYPELESS: case DXGI_FORMAT_R10G10B10A2_UNORM: case DXGI_FORMAT_R10G10B10A2_UINT: + return DXGI_FORMAT_R10G10B10A2_TYPELESS; + case DXGI_FORMAT_R8G8B8A8_TYPELESS: case DXGI_FORMAT_R8G8B8A8_UNORM: case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: + case DXGI_FORMAT_R8G8B8A8_UINT: case DXGI_FORMAT_R8G8B8A8_SNORM: case DXGI_FORMAT_R8G8B8A8_SINT: + return DXGI_FORMAT_R8G8B8A8_TYPELESS; + case DXGI_FORMAT_B8G8R8A8_TYPELESS: case DXGI_FORMAT_B8G8R8A8_UNORM: case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: + return DXGI_FORMAT_B8G8R8A8_TYPELESS; + case DXGI_FORMAT_R16G16_TYPELESS: case DXGI_FORMAT_R16G16_FLOAT: case DXGI_FORMAT_R16G16_UNORM: + case DXGI_FORMAT_R16G16_UINT: case DXGI_FORMAT_R16G16_SNORM: case DXGI_FORMAT_R16G16_SINT: + return DXGI_FORMAT_R16G16_TYPELESS; + case DXGI_FORMAT_R32_TYPELESS: case DXGI_FORMAT_R32_FLOAT: case DXGI_FORMAT_R32_UINT: case DXGI_FORMAT_R32_SINT: + return DXGI_FORMAT_R32_TYPELESS; + default: + return format; + } +} + +// The typed format a typeless one resolves as; DXGI_FORMAT_UNKNOWN for a format that is not typeless or has no +// single natural choice. Floating point for the HDR families, normalised for the 8 and 10 bit ones. +inline DXGI_FORMAT typed_choice(DXGI_FORMAT typeless) +{ + switch (typeless) { + case DXGI_FORMAT_R32G32B32A32_TYPELESS: return DXGI_FORMAT_R32G32B32A32_FLOAT; + case DXGI_FORMAT_R16G16B16A16_TYPELESS: return DXGI_FORMAT_R16G16B16A16_FLOAT; + case DXGI_FORMAT_R10G10B10A2_TYPELESS: return DXGI_FORMAT_R10G10B10A2_UNORM; + case DXGI_FORMAT_R8G8B8A8_TYPELESS: return DXGI_FORMAT_R8G8B8A8_UNORM; + case DXGI_FORMAT_B8G8R8A8_TYPELESS: return DXGI_FORMAT_B8G8R8A8_UNORM; + case DXGI_FORMAT_R16G16_TYPELESS: return DXGI_FORMAT_R16G16_FLOAT; + case DXGI_FORMAT_R32_TYPELESS: return DXGI_FORMAT_R32_FLOAT; + default: return DXGI_FORMAT_UNKNOWN; + } +} + +inline bool is_typeless(DXGI_FORMAT format) +{ + switch (format) { + case DXGI_FORMAT_R32G32B32A32_TYPELESS: case DXGI_FORMAT_R32G32B32_TYPELESS: case DXGI_FORMAT_R16G16B16A16_TYPELESS: + case DXGI_FORMAT_R32G32_TYPELESS: case DXGI_FORMAT_R32G8X24_TYPELESS: case DXGI_FORMAT_R10G10B10A2_TYPELESS: + case DXGI_FORMAT_R8G8B8A8_TYPELESS: case DXGI_FORMAT_R16G16_TYPELESS: case DXGI_FORMAT_R32_TYPELESS: + case DXGI_FORMAT_R24G8_TYPELESS: case DXGI_FORMAT_R8G8_TYPELESS: case DXGI_FORMAT_R16_TYPELESS: + case DXGI_FORMAT_R8_TYPELESS: case DXGI_FORMAT_B8G8R8A8_TYPELESS: case DXGI_FORMAT_B8G8R8X8_TYPELESS: + return true; + default: + return false; + } +} + +inline bool is_typeless_choice_format(DXGI_FORMAT format) { return typed_choice(format) != DXGI_FORMAT_UNKNOWN; } + +inline bool compatible_formats(DXGI_FORMAT a, DXGI_FORMAT b) +{ + return a == b || (a != DXGI_FORMAT_UNKNOWN && format_family(a) == format_family(b)); +} + +// CopyBufferRegion(destination, destination_offset, source, source_offset, bytes). `same` is true when both +// arguments are one resource (it would need two states at once). +inline CopyRefusal check_copy_buffer_region(const D3D12_RESOURCE_DESC* destination, std::uint64_t destination_offset, + const D3D12_RESOURCE_DESC* source, std::uint64_t source_offset, + std::uint64_t bytes, bool same) +{ + if (!destination || !source) return CopyRefusal::unresolved; + if (same) return CopyRefusal::same_resource; + if (destination->Dimension != D3D12_RESOURCE_DIMENSION_BUFFER || source->Dimension != D3D12_RESOURCE_DIMENSION_BUFFER) + return CopyRefusal::not_buffer; + if (!bytes) return CopyRefusal::zero_size; + if (destination_offset > destination->Width || bytes > destination->Width - destination_offset || + source_offset > source->Width || bytes > source->Width - source_offset) + return CopyRefusal::range_overflow; + return CopyRefusal::none; +} + +// CopyResource(destination, source): the two descriptions must have one shape. +inline CopyRefusal check_copy_resource(const D3D12_RESOURCE_DESC* destination, const D3D12_RESOURCE_DESC* source, bool same) +{ + if (!destination || !source) return CopyRefusal::unresolved; + if (same) return CopyRefusal::same_resource; + if (destination->Dimension == D3D12_RESOURCE_DIMENSION_UNKNOWN || destination->Dimension != source->Dimension) + return CopyRefusal::dimension_mismatch; + if (destination->Width != source->Width) return CopyRefusal::size_mismatch; + if (destination->Dimension == D3D12_RESOURCE_DIMENSION_BUFFER) return CopyRefusal::none; + if (destination->Height != source->Height || destination->DepthOrArraySize != source->DepthOrArraySize || + destination->MipLevels != source->MipLevels) + return CopyRefusal::size_mismatch; + if (!compatible_formats(destination->Format, source->Format)) return CopyRefusal::format_mismatch; + if (destination->SampleDesc.Count != source->SampleDesc.Count || destination->SampleDesc.Quality != source->SampleDesc.Quality) + return CopyRefusal::sample_mismatch; + return CopyRefusal::none; +} + +struct ResolvePlan { + CopyRefusal refusal{}; + DXGI_FORMAT format{}; // the typed format to resolve as, when not refused +}; + +// One mip of a 2D texture: its size in texels. +inline std::uint64_t mip_extent(std::uint64_t extent, std::uint32_t mip) { return (std::max<std::uint64_t>)(extent >> mip, 1); } + +// ResolveSubresource(destination, destination_subresource, source, source_subresource, format). A typeless +// `format` (or one the title left unknown over a typeless surface) resolves as the family's typed choice, so a +// half-float surface stored as typeless resolves as half float. +inline ResolvePlan plan_resolve(const D3D12_RESOURCE_DESC* destination, std::uint32_t destination_subresource, + const D3D12_RESOURCE_DESC* source, std::uint32_t source_subresource, DXGI_FORMAT format, + bool same) +{ + if (!destination || !source) return {CopyRefusal::unresolved, {}}; + if (same) return {CopyRefusal::same_resource, {}}; + if (destination->Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE2D || source->Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE2D) + return {CopyRefusal::not_texture, {}}; + if (source->SampleDesc.Count <= 1) return {CopyRefusal::source_not_multisampled, {}}; + if (destination->SampleDesc.Count != 1) return {CopyRefusal::destination_multisampled, {}}; + const std::uint32_t destination_mips = destination->MipLevels ? destination->MipLevels : 1; + const std::uint32_t source_mips = source->MipLevels ? source->MipLevels : 1; + if (destination_subresource >= std::uint64_t{destination_mips} * destination->DepthOrArraySize || + source_subresource >= std::uint64_t{source_mips} * source->DepthOrArraySize) + return {CopyRefusal::bad_subresource, {}}; + const std::uint32_t destination_mip = destination_subresource % destination_mips; + const std::uint32_t source_mip = source_subresource % source_mips; + if (mip_extent(destination->Width, destination_mip) != mip_extent(source->Width, source_mip) || + mip_extent(destination->Height, destination_mip) != mip_extent(source->Height, source_mip)) + return {CopyRefusal::bad_subresource, {}}; + DXGI_FORMAT typed = format; + if (typed == DXGI_FORMAT_UNKNOWN) typed = source->Format; + if (is_typeless_choice_format(typed)) typed = typed_choice(typed); + if (typed == DXGI_FORMAT_UNKNOWN || is_typeless(typed)) return {CopyRefusal::bad_format, {}}; + if (!compatible_formats(typed, source->Format) || !compatible_formats(typed, destination->Format)) + return {CopyRefusal::format_mismatch, {}}; ~~~~ --- Fixed in 5bda1cfc: Resolve format is now validated against fully typed endpoints exactly; family match only applies to typeless ones. Win2025 WARP: 27/27 passed (Debug and Release). AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 02:02:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:02:32Z.

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

@@ -0,0 +1,108 @@
+// Included from d3d12_xs_device.cpp after the command-list state helpers.
+//
+// Whole-resource copies on a recording list (render mode): CopyBufferRegion (list slot 15), CopyResource
+// (17) and ResolveSubresource (19). The title's resources are mapped to desktop ones, the pair is checked
+// by src/startup_stubs/list_copy.h, and a pair the desktop would reject is counted and skipped instead of
+// forwarded. Desktop resources rest in COMMON between lists, so each is moved to the copy or resolve state
+// around the call and back at Close; upload and readback buffers keep the state their heap requires.
+// CopyTextureRegion (16) and CopyTiles (18) carry footprints and addresses and are not handled here.
+
+LONG list_buffer_copies, list_resource_copies, list_resolves, list_copies_refused;
+
+// The desktop resource behind a copy argument; null for a null value, or a wrapper that is not a resource.
+// A value that is no wrapper is taken as a desktop resource, as the view slots do.
+ID3D12Resource* copy_endpoint(u64 value)
+{
+    if (!value) return nullptr;
+    if (const Wrapper* w = as_wrapper(reinterpret_cast<const void*>(value))) {
+        if (w->own().kind != resource_kind) return nullptr;
+        return static_cast<ID3D12Resource*>(w->own().real);
+    }
+    return x2w_local::readable(reinterpret_cast<const void*>(value), sizeof(void*)) ? reinterpret_cast<ID3D12Resource*>(value) : nullptr;
+}
+
+void refuse_copy(const char* what, x2w_startup::CopyRefusal reason)
+{
+    InterlockedIncrement(&list_copies_refused);
+    static LONG logged;
+    if (first_calls(logged, 6)) log("x2w-d3d12 %s skipped: %s", what, x2w_startup::copy_refusal_name(reason));
+}
+
+// The state a copy needs from `resource`: an upload buffer stays readable and a readback buffer stays a
+// copy destination, because desktop allows no other state for them.
+void require_copy_state(Wrapper* self, ID3D12Resource* resource, D3D12_RESOURCE_STATES state)
+{
+    D3D12_HEAP_PROPERTIES heap{};
+    D3D12_HEAP_FLAGS flags{};
+    if (SUCCEEDED(resource->GetHeapProperties(&heap, &flags)) &&
+        (heap.Type == D3D12_HEAP_TYPE_UPLOAD || heap.Type == D3D12_HEAP_TYPE_READBACK))
+        return;
+    require_state(self, resource, state);

Fixed in 5bda1cfc: Buffers with a non-COMMON initial state are refused (initial_state refusal) instead of recording a wrong StateBefore. Win2025 WARP: 27/27 passed (Debug and Release). AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688766550 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1944#discussion_r4688766550). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T01:02:32Z. **Code review location:** `src/startup_stubs/list_copy.inl`; line 40 ~~~~diff @@ -0,0 +1,108 @@ +// Included from d3d12_xs_device.cpp after the command-list state helpers. +// +// Whole-resource copies on a recording list (render mode): CopyBufferRegion (list slot 15), CopyResource +// (17) and ResolveSubresource (19). The title's resources are mapped to desktop ones, the pair is checked +// by src/startup_stubs/list_copy.h, and a pair the desktop would reject is counted and skipped instead of +// forwarded. Desktop resources rest in COMMON between lists, so each is moved to the copy or resolve state +// around the call and back at Close; upload and readback buffers keep the state their heap requires. +// CopyTextureRegion (16) and CopyTiles (18) carry footprints and addresses and are not handled here. + +LONG list_buffer_copies, list_resource_copies, list_resolves, list_copies_refused; + +// The desktop resource behind a copy argument; null for a null value, or a wrapper that is not a resource. +// A value that is no wrapper is taken as a desktop resource, as the view slots do. +ID3D12Resource* copy_endpoint(u64 value) +{ + if (!value) return nullptr; + if (const Wrapper* w = as_wrapper(reinterpret_cast<const void*>(value))) { + if (w->own().kind != resource_kind) return nullptr; + return static_cast<ID3D12Resource*>(w->own().real); + } + return x2w_local::readable(reinterpret_cast<const void*>(value), sizeof(void*)) ? reinterpret_cast<ID3D12Resource*>(value) : nullptr; +} + +void refuse_copy(const char* what, x2w_startup::CopyRefusal reason) +{ + InterlockedIncrement(&list_copies_refused); + static LONG logged; + if (first_calls(logged, 6)) log("x2w-d3d12 %s skipped: %s", what, x2w_startup::copy_refusal_name(reason)); +} + +// The state a copy needs from `resource`: an upload buffer stays readable and a readback buffer stays a +// copy destination, because desktop allows no other state for them. +void require_copy_state(Wrapper* self, ID3D12Resource* resource, D3D12_RESOURCE_STATES state) +{ + D3D12_HEAP_PROPERTIES heap{}; + D3D12_HEAP_FLAGS flags{}; + if (SUCCEEDED(resource->GetHeapProperties(&heap, &flags)) && + (heap.Type == D3D12_HEAP_TYPE_UPLOAD || heap.Type == D3D12_HEAP_TYPE_READBACK)) + return; + require_state(self, resource, state); ~~~~ --- Fixed in 5bda1cfc: Buffers with a non-COMMON initial state are refused (initial_state refusal) instead of recording a wrong StateBefore. Win2025 WARP: 27/27 passed (Debug and Release). AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 02:02:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:02:33Z.

Code review location: src/startup_stubs/list_copy.h; line 79

@@ -0,0 +1,195 @@
+// Pure validation for the whole-resource command-list copies: CopyBufferRegion (list slot 15),
+// CopyResource (17) and ResolveSubresource (19). It reads only resource descriptions, so it runs on any host.
+//
+// Desktop D3D12 removes the device on a copy it rejects, so a copy whose arguments the desktop would
+// refuse is named and skipped instead of forwarded. Each check returns the first refusal, in the
+// order listed in CopyRefusal.
+#pragma once
+
+#include <d3d12.h>
+
+#include <algorithm>
+#include <cstdint>
+
+namespace x2w_startup {
+
+enum class CopyRefusal {
+    none,
+    unresolved,                // a null argument, or one that is not a resource
+    same_resource,             // source and destination are one resource
+    not_buffer,                // CopyBufferRegion on a texture
+    not_texture,               // ResolveSubresource on something other than a 2D texture
+    dimension_mismatch,        // CopyResource between different resource dimensions
+    size_mismatch,             // different width, height, depth, mips or buffer size
+    format_mismatch,           // formats that are neither equal nor members of one typeless family
+    sample_mismatch,           // different sample count or quality
+    bad_subresource,           // a subresource index outside the texture, or of another size
+    source_not_multisampled,   // the resolve source has one sample
+    destination_multisampled,  // the resolve destination has more than one sample
+    bad_format,                // a resolve format that is unknown, or typeless with no typed choice
+    zero_size,                 // CopyBufferRegion of no bytes
+    range_overflow,            // an offset and size that wrap, or run past a buffer
+};
+
+inline const char* copy_refusal_name(CopyRefusal refusal)
+{
+    switch (refusal) {
+    case CopyRefusal::unresolved: return "unresolved";
+    case CopyRefusal::same_resource: return "same_resource";
+    case CopyRefusal::not_buffer: return "not_buffer";
+    case CopyRefusal::not_texture: return "not_texture";
+    case CopyRefusal::dimension_mismatch: return "dimension_mismatch";
+    case CopyRefusal::size_mismatch: return "size_mismatch";
+    case CopyRefusal::format_mismatch: return "format_mismatch";
+    case CopyRefusal::sample_mismatch: return "sample_mismatch";
+    case CopyRefusal::bad_subresource: return "bad_subresource";
+    case CopyRefusal::source_not_multisampled: return "source_not_multisampled";
+    case CopyRefusal::destination_multisampled: return "destination_multisampled";
+    case CopyRefusal::bad_format: return "bad_format";
+    case CopyRefusal::zero_size: return "zero_size";
+    case CopyRefusal::range_overflow: return "range_overflow";
+    default: return "none";
+    }
+}
+
+// The typeless member of the colour format family `format` belongs to; `format` itself when it has none.
+inline DXGI_FORMAT format_family(DXGI_FORMAT format)
+{
+    switch (format) {
+    case DXGI_FORMAT_R32G32B32A32_TYPELESS: case DXGI_FORMAT_R32G32B32A32_FLOAT:
+    case DXGI_FORMAT_R32G32B32A32_UINT: case DXGI_FORMAT_R32G32B32A32_SINT:
+        return DXGI_FORMAT_R32G32B32A32_TYPELESS;
+    case DXGI_FORMAT_R16G16B16A16_TYPELESS: case DXGI_FORMAT_R16G16B16A16_FLOAT:
+    case DXGI_FORMAT_R16G16B16A16_UNORM: case DXGI_FORMAT_R16G16B16A16_UINT:
+    case DXGI_FORMAT_R16G16B16A16_SNORM: case DXGI_FORMAT_R16G16B16A16_SINT:
+        return DXGI_FORMAT_R16G16B16A16_TYPELESS;
+    case DXGI_FORMAT_R10G10B10A2_TYPELESS: case DXGI_FORMAT_R10G10B10A2_UNORM: case DXGI_FORMAT_R10G10B10A2_UINT:
+        return DXGI_FORMAT_R10G10B10A2_TYPELESS;
+    case DXGI_FORMAT_R8G8B8A8_TYPELESS: case DXGI_FORMAT_R8G8B8A8_UNORM: case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB:
+    case DXGI_FORMAT_R8G8B8A8_UINT: case DXGI_FORMAT_R8G8B8A8_SNORM: case DXGI_FORMAT_R8G8B8A8_SINT:
+        return DXGI_FORMAT_R8G8B8A8_TYPELESS;
+    case DXGI_FORMAT_B8G8R8A8_TYPELESS: case DXGI_FORMAT_B8G8R8A8_UNORM: case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB:
+        return DXGI_FORMAT_B8G8R8A8_TYPELESS;
+    case DXGI_FORMAT_R16G16_TYPELESS: case DXGI_FORMAT_R16G16_FLOAT: case DXGI_FORMAT_R16G16_UNORM:
+    case DXGI_FORMAT_R16G16_UINT: case DXGI_FORMAT_R16G16_SNORM: case DXGI_FORMAT_R16G16_SINT:
+        return DXGI_FORMAT_R16G16_TYPELESS;
+    case DXGI_FORMAT_R32_TYPELESS: case DXGI_FORMAT_R32_FLOAT: case DXGI_FORMAT_R32_UINT: case DXGI_FORMAT_R32_SINT:
+        return DXGI_FORMAT_R32_TYPELESS;
+    default:
+        return format;

Fixed in 5bda1cfc: The DXGI family table now covers the remaining CopyResource-compatible groups (BC, R16, R8, ...). Win2025 WARP: 27/27 passed (Debug and Release). AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688766762 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1944#discussion_r4688766762). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T01:02:33Z. **Code review location:** `src/startup_stubs/list_copy.h`; line 79 ~~~~diff @@ -0,0 +1,195 @@ +// Pure validation for the whole-resource command-list copies: CopyBufferRegion (list slot 15), +// CopyResource (17) and ResolveSubresource (19). It reads only resource descriptions, so it runs on any host. +// +// Desktop D3D12 removes the device on a copy it rejects, so a copy whose arguments the desktop would +// refuse is named and skipped instead of forwarded. Each check returns the first refusal, in the +// order listed in CopyRefusal. +#pragma once + +#include <d3d12.h> + +#include <algorithm> +#include <cstdint> + +namespace x2w_startup { + +enum class CopyRefusal { + none, + unresolved, // a null argument, or one that is not a resource + same_resource, // source and destination are one resource + not_buffer, // CopyBufferRegion on a texture + not_texture, // ResolveSubresource on something other than a 2D texture + dimension_mismatch, // CopyResource between different resource dimensions + size_mismatch, // different width, height, depth, mips or buffer size + format_mismatch, // formats that are neither equal nor members of one typeless family + sample_mismatch, // different sample count or quality + bad_subresource, // a subresource index outside the texture, or of another size + source_not_multisampled, // the resolve source has one sample + destination_multisampled, // the resolve destination has more than one sample + bad_format, // a resolve format that is unknown, or typeless with no typed choice + zero_size, // CopyBufferRegion of no bytes + range_overflow, // an offset and size that wrap, or run past a buffer +}; + +inline const char* copy_refusal_name(CopyRefusal refusal) +{ + switch (refusal) { + case CopyRefusal::unresolved: return "unresolved"; + case CopyRefusal::same_resource: return "same_resource"; + case CopyRefusal::not_buffer: return "not_buffer"; + case CopyRefusal::not_texture: return "not_texture"; + case CopyRefusal::dimension_mismatch: return "dimension_mismatch"; + case CopyRefusal::size_mismatch: return "size_mismatch"; + case CopyRefusal::format_mismatch: return "format_mismatch"; + case CopyRefusal::sample_mismatch: return "sample_mismatch"; + case CopyRefusal::bad_subresource: return "bad_subresource"; + case CopyRefusal::source_not_multisampled: return "source_not_multisampled"; + case CopyRefusal::destination_multisampled: return "destination_multisampled"; + case CopyRefusal::bad_format: return "bad_format"; + case CopyRefusal::zero_size: return "zero_size"; + case CopyRefusal::range_overflow: return "range_overflow"; + default: return "none"; + } +} + +// The typeless member of the colour format family `format` belongs to; `format` itself when it has none. +inline DXGI_FORMAT format_family(DXGI_FORMAT format) +{ + switch (format) { + case DXGI_FORMAT_R32G32B32A32_TYPELESS: case DXGI_FORMAT_R32G32B32A32_FLOAT: + case DXGI_FORMAT_R32G32B32A32_UINT: case DXGI_FORMAT_R32G32B32A32_SINT: + return DXGI_FORMAT_R32G32B32A32_TYPELESS; + case DXGI_FORMAT_R16G16B16A16_TYPELESS: case DXGI_FORMAT_R16G16B16A16_FLOAT: + case DXGI_FORMAT_R16G16B16A16_UNORM: case DXGI_FORMAT_R16G16B16A16_UINT: + case DXGI_FORMAT_R16G16B16A16_SNORM: case DXGI_FORMAT_R16G16B16A16_SINT: + return DXGI_FORMAT_R16G16B16A16_TYPELESS; + case DXGI_FORMAT_R10G10B10A2_TYPELESS: case DXGI_FORMAT_R10G10B10A2_UNORM: case DXGI_FORMAT_R10G10B10A2_UINT: + return DXGI_FORMAT_R10G10B10A2_TYPELESS; + case DXGI_FORMAT_R8G8B8A8_TYPELESS: case DXGI_FORMAT_R8G8B8A8_UNORM: case DXGI_FORMAT_R8G8B8A8_UNORM_SRGB: + case DXGI_FORMAT_R8G8B8A8_UINT: case DXGI_FORMAT_R8G8B8A8_SNORM: case DXGI_FORMAT_R8G8B8A8_SINT: + return DXGI_FORMAT_R8G8B8A8_TYPELESS; + case DXGI_FORMAT_B8G8R8A8_TYPELESS: case DXGI_FORMAT_B8G8R8A8_UNORM: case DXGI_FORMAT_B8G8R8A8_UNORM_SRGB: + return DXGI_FORMAT_B8G8R8A8_TYPELESS; + case DXGI_FORMAT_R16G16_TYPELESS: case DXGI_FORMAT_R16G16_FLOAT: case DXGI_FORMAT_R16G16_UNORM: + case DXGI_FORMAT_R16G16_UINT: case DXGI_FORMAT_R16G16_SNORM: case DXGI_FORMAT_R16G16_SINT: + return DXGI_FORMAT_R16G16_TYPELESS; + case DXGI_FORMAT_R32_TYPELESS: case DXGI_FORMAT_R32_FLOAT: case DXGI_FORMAT_R32_UINT: case DXGI_FORMAT_R32_SINT: + return DXGI_FORMAT_R32_TYPELESS; + default: + return format; ~~~~ --- Fixed in 5bda1cfc: The DXGI family table now covers the remaining CopyResource-compatible groups (BC, R16, R8, ...). Win2025 WARP: 27/27 passed (Debug and Release). AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 02:02:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:02:35Z.

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

@@ -0,0 +1,108 @@
+// Included from d3d12_xs_device.cpp after the command-list state helpers.
+//
+// Whole-resource copies on a recording list (render mode): CopyBufferRegion (list slot 15), CopyResource
+// (17) and ResolveSubresource (19). The title's resources are mapped to desktop ones, the pair is checked
+// by src/startup_stubs/list_copy.h, and a pair the desktop would reject is counted and skipped instead of
+// forwarded. Desktop resources rest in COMMON between lists, so each is moved to the copy or resolve state
+// around the call and back at Close; upload and readback buffers keep the state their heap requires.
+// CopyTextureRegion (16) and CopyTiles (18) carry footprints and addresses and are not handled here.
+
+LONG list_buffer_copies, list_resource_copies, list_resolves, list_copies_refused;
+
+// The desktop resource behind a copy argument; null for a null value, or a wrapper that is not a resource.
+// A value that is no wrapper is taken as a desktop resource, as the view slots do.
+ID3D12Resource* copy_endpoint(u64 value)
+{
+    if (!value) return nullptr;
+    if (const Wrapper* w = as_wrapper(reinterpret_cast<const void*>(value))) {
+        if (w->own().kind != resource_kind) return nullptr;
+        return static_cast<ID3D12Resource*>(w->own().real);
+    }
+    return x2w_local::readable(reinterpret_cast<const void*>(value), sizeof(void*)) ? reinterpret_cast<ID3D12Resource*>(value) : nullptr;
+}
+
+void refuse_copy(const char* what, x2w_startup::CopyRefusal reason)
+{
+    InterlockedIncrement(&list_copies_refused);
+    static LONG logged;
+    if (first_calls(logged, 6)) log("x2w-d3d12 %s skipped: %s", what, x2w_startup::copy_refusal_name(reason));
+}
+
+// The state a copy needs from `resource`: an upload buffer stays readable and a readback buffer stays a
+// copy destination, because desktop allows no other state for them.
+void require_copy_state(Wrapper* self, ID3D12Resource* resource, D3D12_RESOURCE_STATES state)
+{
+    D3D12_HEAP_PROPERTIES heap{};
+    D3D12_HEAP_FLAGS flags{};
+    if (SUCCEEDED(resource->GetHeapProperties(&heap, &flags)) &&
+        (heap.Type == D3D12_HEAP_TYPE_UPLOAD || heap.Type == D3D12_HEAP_TYPE_READBACK))
+        return;

Fixed in 5bda1cfc: Fixed-heap direction is checked: upload destination and readback source are refused (heap_direction). Win2025 WARP: 27/27 passed (Debug and Release). AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688766926 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1944#discussion_r4688766926). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T01:02:35Z. **Code review location:** `src/startup_stubs/list_copy.inl`; line 39 ~~~~diff @@ -0,0 +1,108 @@ +// Included from d3d12_xs_device.cpp after the command-list state helpers. +// +// Whole-resource copies on a recording list (render mode): CopyBufferRegion (list slot 15), CopyResource +// (17) and ResolveSubresource (19). The title's resources are mapped to desktop ones, the pair is checked +// by src/startup_stubs/list_copy.h, and a pair the desktop would reject is counted and skipped instead of +// forwarded. Desktop resources rest in COMMON between lists, so each is moved to the copy or resolve state +// around the call and back at Close; upload and readback buffers keep the state their heap requires. +// CopyTextureRegion (16) and CopyTiles (18) carry footprints and addresses and are not handled here. + +LONG list_buffer_copies, list_resource_copies, list_resolves, list_copies_refused; + +// The desktop resource behind a copy argument; null for a null value, or a wrapper that is not a resource. +// A value that is no wrapper is taken as a desktop resource, as the view slots do. +ID3D12Resource* copy_endpoint(u64 value) +{ + if (!value) return nullptr; + if (const Wrapper* w = as_wrapper(reinterpret_cast<const void*>(value))) { + if (w->own().kind != resource_kind) return nullptr; + return static_cast<ID3D12Resource*>(w->own().real); + } + return x2w_local::readable(reinterpret_cast<const void*>(value), sizeof(void*)) ? reinterpret_cast<ID3D12Resource*>(value) : nullptr; +} + +void refuse_copy(const char* what, x2w_startup::CopyRefusal reason) +{ + InterlockedIncrement(&list_copies_refused); + static LONG logged; + if (first_calls(logged, 6)) log("x2w-d3d12 %s skipped: %s", what, x2w_startup::copy_refusal_name(reason)); +} + +// The state a copy needs from `resource`: an upload buffer stays readable and a readback buffer stays a +// copy destination, because desktop allows no other state for them. +void require_copy_state(Wrapper* self, ID3D12Resource* resource, D3D12_RESOURCE_STATES state) +{ + D3D12_HEAP_PROPERTIES heap{}; + D3D12_HEAP_FLAGS flags{}; + if (SUCCEEDED(resource->GetHeapProperties(&heap, &flags)) && + (heap.Type == D3D12_HEAP_TYPE_UPLOAD || heap.Type == D3D12_HEAP_TYPE_READBACK)) + return; ~~~~ --- Fixed in 5bda1cfc: Fixed-heap direction is checked: upload destination and readback source are refused (heap_direction). Win2025 WARP: 27/27 passed (Debug and Release). AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 02:02:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:02:37Z.

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

@@ -0,0 +1,108 @@
+// Included from d3d12_xs_device.cpp after the command-list state helpers.
+//
+// Whole-resource copies on a recording list (render mode): CopyBufferRegion (list slot 15), CopyResource
+// (17) and ResolveSubresource (19). The title's resources are mapped to desktop ones, the pair is checked
+// by src/startup_stubs/list_copy.h, and a pair the desktop would reject is counted and skipped instead of
+// forwarded. Desktop resources rest in COMMON between lists, so each is moved to the copy or resolve state
+// around the call and back at Close; upload and readback buffers keep the state their heap requires.
+// CopyTextureRegion (16) and CopyTiles (18) carry footprints and addresses and are not handled here.
+
+LONG list_buffer_copies, list_resource_copies, list_resolves, list_copies_refused;
+
+// The desktop resource behind a copy argument; null for a null value, or a wrapper that is not a resource.
+// A value that is no wrapper is taken as a desktop resource, as the view slots do.
+ID3D12Resource* copy_endpoint(u64 value)
+{
+    if (!value) return nullptr;
+    if (const Wrapper* w = as_wrapper(reinterpret_cast<const void*>(value))) {
+        if (w->own().kind != resource_kind) return nullptr;
+        return static_cast<ID3D12Resource*>(w->own().real);

Fixed in 5bda1cfc: Title-backed copy sources are now synced before the copy (texture upload, upload-buffer bytes, aliased placed buffer already current; title-backed default-heap buffer refused). Win2025 WARP: 27/27 passed (Debug and Release). AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688767128 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1944#discussion_r4688767128). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T01:02:37Z. **Code review location:** `src/startup_stubs/list_copy.inl`; line 19 ~~~~diff @@ -0,0 +1,108 @@ +// Included from d3d12_xs_device.cpp after the command-list state helpers. +// +// Whole-resource copies on a recording list (render mode): CopyBufferRegion (list slot 15), CopyResource +// (17) and ResolveSubresource (19). The title's resources are mapped to desktop ones, the pair is checked +// by src/startup_stubs/list_copy.h, and a pair the desktop would reject is counted and skipped instead of +// forwarded. Desktop resources rest in COMMON between lists, so each is moved to the copy or resolve state +// around the call and back at Close; upload and readback buffers keep the state their heap requires. +// CopyTextureRegion (16) and CopyTiles (18) carry footprints and addresses and are not handled here. + +LONG list_buffer_copies, list_resource_copies, list_resolves, list_copies_refused; + +// The desktop resource behind a copy argument; null for a null value, or a wrapper that is not a resource. +// A value that is no wrapper is taken as a desktop resource, as the view slots do. +ID3D12Resource* copy_endpoint(u64 value) +{ + if (!value) return nullptr; + if (const Wrapper* w = as_wrapper(reinterpret_cast<const void*>(value))) { + if (w->own().kind != resource_kind) return nullptr; + return static_cast<ID3D12Resource*>(w->own().real); ~~~~ --- Fixed in 5bda1cfc: Title-backed copy sources are now synced before the copy (texture upload, upload-buffer bytes, aliased placed buffer already current; title-backed default-heap buffer refused). Win2025 WARP: 27/27 passed (Debug and Release). AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-25 02:02:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T01:02:39Z.

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

@@ -0,0 +1,108 @@
+// Included from d3d12_xs_device.cpp after the command-list state helpers.
+//
+// Whole-resource copies on a recording list (render mode): CopyBufferRegion (list slot 15), CopyResource
+// (17) and ResolveSubresource (19). The title's resources are mapped to desktop ones, the pair is checked
+// by src/startup_stubs/list_copy.h, and a pair the desktop would reject is counted and skipped instead of
+// forwarded. Desktop resources rest in COMMON between lists, so each is moved to the copy or resolve state
+// around the call and back at Close; upload and readback buffers keep the state their heap requires.
+// CopyTextureRegion (16) and CopyTiles (18) carry footprints and addresses and are not handled here.
+
+LONG list_buffer_copies, list_resource_copies, list_resolves, list_copies_refused;
+
+// The desktop resource behind a copy argument; null for a null value, or a wrapper that is not a resource.
+// A value that is no wrapper is taken as a desktop resource, as the view slots do.
+ID3D12Resource* copy_endpoint(u64 value)
+{
+    if (!value) return nullptr;
+    if (const Wrapper* w = as_wrapper(reinterpret_cast<const void*>(value))) {
+        if (w->own().kind != resource_kind) return nullptr;
+        return static_cast<ID3D12Resource*>(w->own().real);
+    }
+    return x2w_local::readable(reinterpret_cast<const void*>(value), sizeof(void*)) ? reinterpret_cast<ID3D12Resource*>(value) : nullptr;
+}
+
+void refuse_copy(const char* what, x2w_startup::CopyRefusal reason)
+{
+    InterlockedIncrement(&list_copies_refused);
+    static LONG logged;
+    if (first_calls(logged, 6)) log("x2w-d3d12 %s skipped: %s", what, x2w_startup::copy_refusal_name(reason));
+}
+
+// The state a copy needs from `resource`: an upload buffer stays readable and a readback buffer stays a
+// copy destination, because desktop allows no other state for them.
+void require_copy_state(Wrapper* self, ID3D12Resource* resource, D3D12_RESOURCE_STATES state)
+{
+    D3D12_HEAP_PROPERTIES heap{};
+    D3D12_HEAP_FLAGS flags{};
+    if (SUCCEEDED(resource->GetHeapProperties(&heap, &flags)) &&
+        (heap.Type == D3D12_HEAP_TYPE_UPLOAD || heap.Type == D3D12_HEAP_TYPE_READBACK))
+        return;
+    require_state(self, resource, state);
+}
+
+// List slot 15, CopyBufferRegion(destination, destination offset, source, source offset, bytes).
+void __stdcall list_copy_buffer_region(Wrapper* self, u64 destination, u64 destination_offset, u64 source, u64 source_offset,
+                                       u64 bytes)
+{
+    if (!self->own().list_open) return;
+    ID3D12Resource* const to = copy_endpoint(destination);
+    ID3D12Resource* const from = copy_endpoint(source);
+    D3D12_RESOURCE_DESC to_desc{}, from_desc{};
+    if (to) to_desc = to->GetDesc();
+    if (from) from_desc = from->GetDesc();
+    const auto refusal = x2w_startup::check_copy_buffer_region(to ? &to_desc : nullptr, destination_offset,
+                                                               from ? &from_desc : nullptr, source_offset, bytes, to == from);
+    if (refusal != x2w_startup::CopyRefusal::none) return refuse_copy("CopyBufferRegion", refusal);
+    require_copy_state(self, from, D3D12_RESOURCE_STATE_COPY_SOURCE);
+    require_copy_state(self, to, D3D12_RESOURCE_STATE_COPY_DEST);
+    static_cast<ID3D12GraphicsCommandList*>(self->own().real)->CopyBufferRegion(to, destination_offset, from, source_offset, bytes);
+    InterlockedIncrement(&list_buffer_copies);
+}
+
+// List slot 17, CopyResource(destination, source).
+void __stdcall list_copy_resource(Wrapper* self, u64 destination, u64 source)
+{
+    if (!self->own().list_open) return;
+    ID3D12Resource* const to = copy_endpoint(destination);
+    ID3D12Resource* const from = copy_endpoint(source);
+    D3D12_RESOURCE_DESC to_desc{}, from_desc{};
+    if (to) to_desc = to->GetDesc();
+    if (from) from_desc = from->GetDesc();
+    const auto refusal = x2w_startup::check_copy_resource(to ? &to_desc : nullptr, from ? &from_desc : nullptr, to == from);
+    if (refusal != x2w_startup::CopyRefusal::none) return refuse_copy("CopyResource", refusal);
+    require_copy_state(self, from, D3D12_RESOURCE_STATE_COPY_SOURCE);
+    require_copy_state(self, to, D3D12_RESOURCE_STATE_COPY_DEST);
+    static_cast<ID3D12GraphicsCommandList*>(self->own().real)->CopyResource(to, from);
+    InterlockedIncrement(&list_resource_copies);
+}
+
+// List slot 19, ResolveSubresource(destination, destination subresource, source, source subresource, format).
+// The format is a console value, mapped like a resource format; a typeless one resolves as its typed choice.
+void __stdcall list_resolve_subresource(Wrapper* self, u64 destination, UINT destination_subresource, u64 source,
+                                        UINT source_subresource, UINT format)
+{
+    if (!self->own().list_open) return;
+    ID3D12Resource* const to = copy_endpoint(destination);
+    ID3D12Resource* const from = copy_endpoint(source);
+    D3D12_RESOURCE_DESC to_desc{}, from_desc{};
+    if (to) to_desc = to->GetDesc();
+    if (from) from_desc = from->GetDesc();
+    const auto plan = x2w_startup::plan_resolve(to ? &to_desc : nullptr, destination_subresource, from ? &from_desc : nullptr,
+                                                source_subresource, desktop_format(static_cast<DXGI_FORMAT>(format)), to == from);
+    if (plan.refusal != x2w_startup::CopyRefusal::none) return refuse_copy("ResolveSubresource", plan.refusal);
+    require_copy_state(self, from, D3D12_RESOURCE_STATE_RESOLVE_SOURCE);
+    require_copy_state(self, to, D3D12_RESOURCE_STATE_RESOLVE_DEST);
+    static_cast<ID3D12GraphicsCommandList*>(self->own().real)
+        ->ResolveSubresource(to, destination_subresource, from, source_subresource, plan.format);

Fixed in 5bda1cfc: Copy and resolve destinations are now marked GPU-written, so a later draw's first-bind upload no longer overwrites the result. Win2025 WARP: 27/27 passed (Debug and Release). AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688767317 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1944#discussion_r4688767317). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T01:02:39Z. **Code review location:** `src/startup_stubs/list_copy.inl`; line 96 ~~~~diff @@ -0,0 +1,108 @@ +// Included from d3d12_xs_device.cpp after the command-list state helpers. +// +// Whole-resource copies on a recording list (render mode): CopyBufferRegion (list slot 15), CopyResource +// (17) and ResolveSubresource (19). The title's resources are mapped to desktop ones, the pair is checked +// by src/startup_stubs/list_copy.h, and a pair the desktop would reject is counted and skipped instead of +// forwarded. Desktop resources rest in COMMON between lists, so each is moved to the copy or resolve state +// around the call and back at Close; upload and readback buffers keep the state their heap requires. +// CopyTextureRegion (16) and CopyTiles (18) carry footprints and addresses and are not handled here. + +LONG list_buffer_copies, list_resource_copies, list_resolves, list_copies_refused; + +// The desktop resource behind a copy argument; null for a null value, or a wrapper that is not a resource. +// A value that is no wrapper is taken as a desktop resource, as the view slots do. +ID3D12Resource* copy_endpoint(u64 value) +{ + if (!value) return nullptr; + if (const Wrapper* w = as_wrapper(reinterpret_cast<const void*>(value))) { + if (w->own().kind != resource_kind) return nullptr; + return static_cast<ID3D12Resource*>(w->own().real); + } + return x2w_local::readable(reinterpret_cast<const void*>(value), sizeof(void*)) ? reinterpret_cast<ID3D12Resource*>(value) : nullptr; +} + +void refuse_copy(const char* what, x2w_startup::CopyRefusal reason) +{ + InterlockedIncrement(&list_copies_refused); + static LONG logged; + if (first_calls(logged, 6)) log("x2w-d3d12 %s skipped: %s", what, x2w_startup::copy_refusal_name(reason)); +} + +// The state a copy needs from `resource`: an upload buffer stays readable and a readback buffer stays a +// copy destination, because desktop allows no other state for them. +void require_copy_state(Wrapper* self, ID3D12Resource* resource, D3D12_RESOURCE_STATES state) +{ + D3D12_HEAP_PROPERTIES heap{}; + D3D12_HEAP_FLAGS flags{}; + if (SUCCEEDED(resource->GetHeapProperties(&heap, &flags)) && + (heap.Type == D3D12_HEAP_TYPE_UPLOAD || heap.Type == D3D12_HEAP_TYPE_READBACK)) + return; + require_state(self, resource, state); +} + +// List slot 15, CopyBufferRegion(destination, destination offset, source, source offset, bytes). +void __stdcall list_copy_buffer_region(Wrapper* self, u64 destination, u64 destination_offset, u64 source, u64 source_offset, + u64 bytes) +{ + if (!self->own().list_open) return; + ID3D12Resource* const to = copy_endpoint(destination); + ID3D12Resource* const from = copy_endpoint(source); + D3D12_RESOURCE_DESC to_desc{}, from_desc{}; + if (to) to_desc = to->GetDesc(); + if (from) from_desc = from->GetDesc(); + const auto refusal = x2w_startup::check_copy_buffer_region(to ? &to_desc : nullptr, destination_offset, + from ? &from_desc : nullptr, source_offset, bytes, to == from); + if (refusal != x2w_startup::CopyRefusal::none) return refuse_copy("CopyBufferRegion", refusal); + require_copy_state(self, from, D3D12_RESOURCE_STATE_COPY_SOURCE); + require_copy_state(self, to, D3D12_RESOURCE_STATE_COPY_DEST); + static_cast<ID3D12GraphicsCommandList*>(self->own().real)->CopyBufferRegion(to, destination_offset, from, source_offset, bytes); + InterlockedIncrement(&list_buffer_copies); +} + +// List slot 17, CopyResource(destination, source). +void __stdcall list_copy_resource(Wrapper* self, u64 destination, u64 source) +{ + if (!self->own().list_open) return; + ID3D12Resource* const to = copy_endpoint(destination); + ID3D12Resource* const from = copy_endpoint(source); + D3D12_RESOURCE_DESC to_desc{}, from_desc{}; + if (to) to_desc = to->GetDesc(); + if (from) from_desc = from->GetDesc(); + const auto refusal = x2w_startup::check_copy_resource(to ? &to_desc : nullptr, from ? &from_desc : nullptr, to == from); + if (refusal != x2w_startup::CopyRefusal::none) return refuse_copy("CopyResource", refusal); + require_copy_state(self, from, D3D12_RESOURCE_STATE_COPY_SOURCE); + require_copy_state(self, to, D3D12_RESOURCE_STATE_COPY_DEST); + static_cast<ID3D12GraphicsCommandList*>(self->own().real)->CopyResource(to, from); + InterlockedIncrement(&list_resource_copies); +} + +// List slot 19, ResolveSubresource(destination, destination subresource, source, source subresource, format). +// The format is a console value, mapped like a resource format; a typeless one resolves as its typed choice. +void __stdcall list_resolve_subresource(Wrapper* self, u64 destination, UINT destination_subresource, u64 source, + UINT source_subresource, UINT format) +{ + if (!self->own().list_open) return; + ID3D12Resource* const to = copy_endpoint(destination); + ID3D12Resource* const from = copy_endpoint(source); + D3D12_RESOURCE_DESC to_desc{}, from_desc{}; + if (to) to_desc = to->GetDesc(); + if (from) from_desc = from->GetDesc(); + const auto plan = x2w_startup::plan_resolve(to ? &to_desc : nullptr, destination_subresource, from ? &from_desc : nullptr, + source_subresource, desktop_format(static_cast<DXGI_FORMAT>(format)), to == from); + if (plan.refusal != x2w_startup::CopyRefusal::none) return refuse_copy("ResolveSubresource", plan.refusal); + require_copy_state(self, from, D3D12_RESOURCE_STATE_RESOLVE_SOURCE); + require_copy_state(self, to, D3D12_RESOURCE_STATE_RESOLVE_DEST); + static_cast<ID3D12GraphicsCommandList*>(self->own().real) + ->ResolveSubresource(to, destination_subresource, from, source_subresource, plan.format); ~~~~ --- Fixed in 5bda1cfc: Copy and resolve destinations are now marked GPU-written, so a later draw's first-bind upload no longer overwrites the result. Win2025 WARP: 27/27 passed (Debug and Release). AI-assisted; commands listed were executed locally.
R0Y00 commented 2026-11-25 06:01:06 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T05:25:57Z.

Review: CHANGES_REQUESTED


Independent Release test of 0c603797: all six existing cases pass, including WARP and RTX 4060 Laptop. One remaining source-path issue is outside those cases. sync_title_source returns success for a title-backed texture even when upload_texture cannot stage it; the handler can then copy an older desktop texture and mark the destination GPU-written. The upload-buffer branch also recopies into the same backing at command recording, without preserving bytes already referenced by a stalled submission.

Please keep the validated direct-resource and genuinely aliased source paths. For other title-backed sources either refuse while the upload is unavailable, or use a validated per-recording upload whose lifetime follows the consuming fence. A source-built missing/unreadable title input should leave the destination sentinel unchanged. If keeping the copied upload-buffer path, gate submission A, change its title bytes and submit B, then release and check both payloads. The current six cases remain useful and should stay.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6052277164 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1944#pullrequestreview-6052277164). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T05:25:57Z. **Review:** CHANGES_REQUESTED --- Independent Release test of 0c603797: all six existing cases pass, including WARP and RTX 4060 Laptop. One remaining source-path issue is outside those cases. sync_title_source returns success for a title-backed texture even when upload_texture cannot stage it; the handler can then copy an older desktop texture and mark the destination GPU-written. The upload-buffer branch also recopies into the same backing at command recording, without preserving bytes already referenced by a stalled submission. Please keep the validated direct-resource and genuinely aliased source paths. For other title-backed sources either refuse while the upload is unavailable, or use a validated per-recording upload whose lifetime follows the consuming fence. A source-built missing/unreadable title input should leave the destination sentinel unchanged. If keeping the copied upload-buffer path, gate submission A, change its title bytes and submit B, then release and check both payloads. The current six cases remain useful and should stay.
tedin7 commented 2026-11-25 06:01:38 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T05:45:43Z.


Thanks. Fixed in dfadc46c (code in 0004422c).

  • upload_texture now reports whether it really staged the texture. sync_title_source returns that result, so a title-backed texture that cannot be staged (unreadable, unsupported or too many mips) is refused with title_backed_source. The destination is never written and not marked GPU-written.
  • The upload-buffer branch is removed. A title-backed upload buffer is refused rather than recopied into one backing while an earlier submission may still read it. Direct resources and aliased placed buffers behave as before. Docs updated.
  • Tests (startup_list_copy): the six existing cases stay. New 8a copies from a staged title-backed texture and checks the destination texels. New 8b copies from a title-backed texture whose pages are decommitted: it is refused, counted, and the destination keeps its sentinel.

Verification (Windows Server 2025, WARP, default 3-slot pool, x2w_pipe.py win2025 1944 --force): dev 26/26 and release 26/26 passed, no skips, including startup_list_copy_warp and the startup_list_copy_validation* tests. A first release attempt died on a compile-cache connection reset and passed on rerun. Linux: python3 -I tests/docs_links_check.py passed.

The upload-buffer refusal has no GPU case of its own yet; I only covered it through the docs and the shared refusal path.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7154113622 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1944#issuecomment-7154113622). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T05:45:43Z. --- Thanks. Fixed in dfadc46c (code in 0004422c). - `upload_texture` now reports whether it really staged the texture. `sync_title_source` returns that result, so a title-backed texture that cannot be staged (unreadable, unsupported or too many mips) is refused with `title_backed_source`. The destination is never written and not marked GPU-written. - The upload-buffer branch is removed. A title-backed upload buffer is refused rather than recopied into one backing while an earlier submission may still read it. Direct resources and aliased placed buffers behave as before. Docs updated. - Tests (`startup_list_copy`): the six existing cases stay. New 8a copies from a staged title-backed texture and checks the destination texels. New 8b copies from a title-backed texture whose pages are decommitted: it is refused, counted, and the destination keeps its sentinel. Verification (Windows Server 2025, WARP, default 3-slot pool, `x2w_pipe.py win2025 1944 --force`): dev 26/26 and release 26/26 passed, no skips, including `startup_list_copy_warp` and the `startup_list_copy_validation*` tests. A first release attempt died on a compile-cache connection reset and passed on rerun. Linux: `python3 -I tests/docs_links_check.py` passed. The upload-buffer refusal has no GPU case of its own yet; I only covered it through the docs and the shared refusal path. AI-assisted; commands listed were executed locally.
R0Y00 commented 2026-11-25 07:01:12 +00:00 (Migrated from github.com)

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


Independent Release check on 3f7b8a5f: all six existing startup_list_copy_* checks passed. A source-built repro added to the same fixture fails on both WARP and RTX 4060 Laptop: create a placed texture with CPU texels 0x44332211, record CopyResource into it, Close and Reset without submitting, then copy out of that texture and wait on the fence. Actual 0x00000000, expected 0x44332211. The destination is marked GPU-written during recording, so the discarded copy prevents its first CPU upload.

I tried a focused local revision. Track unsubmitted writes on their recording, use them for reads on that list, publish the GPU-written state on submission, and discard the pending records on Reset or failed Close. For CPU-backed texture copy sources, take a fresh snapshot using the existing recording-owned upload and fence retirement path. The shared draw upload cache may reuse an earlier snapshot within one frame.

With that revision, ctest --preset release -j1 --no-tests=error -R '^startup_list_copy_' -V passed 6/6. Both adapters read back 44332211 after the discarded write, 44332211 then 88776655 from two copies recorded around a CPU write, and ff0000ff from a GPU-written texture both on its own recording and after submission. Windows 11 build 26200.9974, NVIDIA 32.0.16.1656, WARP 10.0.26100.9818, debug layer enabled. Both reported zero errors and four existing clear-value warnings (820), with no skips.

The slot 15 wording also needs an update. A local trace shows a 68-byte copy at a nonzero source offset between two non-aliased placed buffers. The source is UAV-capable. Please keep that case refused until there is a validated source of current bytes. The texture revision adds no new buffer-backing behavior.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7154540697 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1944#issuecomment-7154540697). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T06:11:46Z. --- Independent Release check on `3f7b8a5f`: all six existing `startup_list_copy_*` checks passed. A source-built repro added to the same fixture fails on both WARP and RTX 4060 Laptop: create a placed texture with CPU texels `0x44332211`, record CopyResource into it, Close and Reset without submitting, then copy out of that texture and wait on the fence. Actual `0x00000000`, expected `0x44332211`. The destination is marked GPU-written during recording, so the discarded copy prevents its first CPU upload. I tried a focused local revision. Track unsubmitted writes on their recording, use them for reads on that list, publish the GPU-written state on submission, and discard the pending records on Reset or failed Close. For CPU-backed texture copy sources, take a fresh snapshot using the existing recording-owned upload and fence retirement path. The shared draw upload cache may reuse an earlier snapshot within one frame. With that revision, `ctest --preset release -j1 --no-tests=error -R '^startup_list_copy_' -V` passed 6/6. Both adapters read back `44332211` after the discarded write, `44332211` then `88776655` from two copies recorded around a CPU write, and `ff0000ff` from a GPU-written texture both on its own recording and after submission. Windows 11 build 26200.9974, NVIDIA 32.0.16.1656, WARP 10.0.26100.9818, debug layer enabled. Both reported zero errors and four existing clear-value warnings (820), with no skips. The slot 15 wording also needs an update. A local trace shows a 68-byte copy at a nonzero source offset between two non-aliased placed buffers. The source is UAV-capable. Please keep that case refused until there is a validated source of current bytes. The texture revision adds no new buffer-backing behavior.
tedin7 commented 2026-11-25 07:01:13 +00:00 (Migrated from github.com)

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


Thanks, reproduced and fixed in 18ec51de (code in 0aafe6b9).

  • A copy or resolve into a title-backed texture is now recorded as a pending write on its recording. The texture is marked GPU-written only when ExecuteCommandLists submits that list. Reset and a failed Close drop the pending writes, so a discarded copy no longer blocks the first upload from title memory.
  • Reads on the same recording (a later copy source, or a draw upload check) see that list's own pending writes, so a texture written earlier on the same list is not overwritten from stale memory.
  • New startup_list_copy case 10: place a texture with 0x44332211, record CopyResource into it, Close and Reset without submitting, then copy out of it and wait on the fence. It reads back 0x44332211. Docs wording updated.
  • Not done: the fresh snapshot for CPU-backed copy sources recorded around a CPU write, and the slot 15 wording update. Slot 15 behaviour is unchanged and that case stays refused.

Verification (Windows Server 2025, WARP, default 3-slot pool, x2w_pipe.py win2025 1944 --force): dev 26/26 and release 26/26 passed, no skips. An earlier release attempt died on a compile-cache connection error and passed on rerun. Linux: python3 -I tests/docs_links_check.py passed.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7154774555 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1944#issuecomment-7154774555). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T06:25:24Z. --- Thanks, reproduced and fixed in 18ec51de (code in 0aafe6b9). - A copy or resolve into a title-backed texture is now recorded as a pending write on its recording. The texture is marked GPU-written only when ExecuteCommandLists submits that list. Reset and a failed Close drop the pending writes, so a discarded copy no longer blocks the first upload from title memory. - Reads on the same recording (a later copy source, or a draw upload check) see that list's own pending writes, so a texture written earlier on the same list is not overwritten from stale memory. - New `startup_list_copy` case 10: place a texture with `0x44332211`, record CopyResource into it, Close and Reset without submitting, then copy out of it and wait on the fence. It reads back `0x44332211`. Docs wording updated. - Not done: the fresh snapshot for CPU-backed copy sources recorded around a CPU write, and the slot 15 wording update. Slot 15 behaviour is unchanged and that case stays refused. Verification (Windows Server 2025, WARP, default 3-slot pool, `x2w_pipe.py win2025 1944 --force`): dev 26/26 and release 26/26 passed, no skips. An earlier release attempt died on a compile-cache connection error and passed on rerun. Linux: `python3 -I tests/docs_links_check.py` passed. AI-assisted; commands listed were executed locally.
upstream-sync closed this pull request 2026-11-25 08:04:39 +00:00
R0Y00 commented 2026-11-25 08:04:40 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-25T07:30:52Z.

Review: APPROVED


The previous source and discarded-recording findings are resolved. On Windows Release I independently ran all six startup_list_copy checks on this head. Both WARP and RTX 4060 Laptop passed the discarded-copy and same-recording read controls. A Reset leaves the first upload available and a real submitted copy preserves GPU-written contents.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6053486275 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1944#pullrequestreview-6053486275). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-25T07:30:52Z. **Review:** APPROVED --- The previous source and discarded-recording findings are resolved. On Windows Release I independently ran all six startup_list_copy checks on this head. Both WARP and RTX 4060 Laptop passed the discarded-copy and same-recording read controls. A Reset leaves the first upload available and a real submitted copy preserves GPU-written contents.
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!1937
No description provided.