startup: implement ResolveSubresource command-list slot (Part of #870) #2042

Closed
tedin7 wants to merge 1 commit from upstream-pr/2049 into main
tedin7 commented 2026-11-24 23:38:02 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T23:38:02Z.


Part of #870

What this unblocks: MSAA render targets can be resolved into a single-sample texture, so a title's resolve step no longer falls to the no-op stub.

Forwards command list slot 19 (ResolveSubresource, desktop order) to the desktop list. Both textures must use COMMON state tracking. The list moves them to RESOLVE_DEST / RESOLVE_SOURCE for the call. Calls that do not fit (buffer, multisampled destination, single-sample source, size mismatch, subresource out of range, unknown format) are refused and logged instead of reaching the driver. The rules live in src/startup_stubs/resolve_subresource.h (no Windows types) with a unit test.

Verification:

  • g++ -std=c++17 -Wall -o /tmp/rs_test tests/startup_resolve_subresource.cpp && /tmp/rs_test (Linux host) -> startup_resolve_subresource: ok
  • git diff --check -> clean
  • Win2025: NOT run. The d3d12_xs_device.cpp change is not compiled yet, and slot 19 has no call-site confirmation (it is the desktop slot, bracketed by confirmed slots 13 and 20). Needs a Win2025 build and ctest -R startup_resolve_subresource before merge.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6593644031 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2049). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T23:38:02Z. --- Part of #870 What this unblocks: MSAA render targets can be resolved into a single-sample texture, so a title's resolve step no longer falls to the no-op stub. Forwards command list slot 19 (`ResolveSubresource`, desktop order) to the desktop list. Both textures must use COMMON state tracking. The list moves them to RESOLVE_DEST / RESOLVE_SOURCE for the call. Calls that do not fit (buffer, multisampled destination, single-sample source, size mismatch, subresource out of range, unknown format) are refused and logged instead of reaching the driver. The rules live in `src/startup_stubs/resolve_subresource.h` (no Windows types) with a unit test. Verification: - `g++ -std=c++17 -Wall -o /tmp/rs_test tests/startup_resolve_subresource.cpp && /tmp/rs_test` (Linux host) -> `startup_resolve_subresource: ok` - `git diff --check` -> clean - Win2025: NOT run. The `d3d12_xs_device.cpp` change is not compiled yet, and slot 19 has no call-site confirmation (it is the desktop slot, bracketed by confirmed slots 13 and 20). Needs a Win2025 build and `ctest -R startup_resolve_subresource` before merge.
upstream-sync closed this pull request 2026-11-25 01:01:19 +00:00
chatgpt-codex-connector[bot commented 2026-11-25 01:01:19 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T23:47:53Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b3ac4aec3a

ℹ️ 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:6049284747 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2049#pullrequestreview-6049284747). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T23:47:53Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `b3ac4aec3a` <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>
chatgpt-codex-connector[bot commented 2026-11-25 01:01:58 +00:00 (Migrated from github.com)

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


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-24T23:47:56.814324Z b3ac4ae 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:7147677842 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2049#issuecomment-7147677842). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T23:41:00Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"b3ac4aec3a69e14473701ee51fa117e6b7d59325","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-24T23:47:56.814324Z">2026-11-24T23:47:56.814324Z</relative-time> | `b3ac4ae` | 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>
ChazY11 commented 2026-11-25 01:02:00 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T23:55:02Z.


Ran your host test under MSVC, broke the rules seven ways: six caught, and the seventh is a real gap

Your command works on Windows too, with cl instead of g++:

cl /nologo /std:c++17 /EHsc tests/startup_resolve_subresource.cpp /I src/startup_stubs
startup_resolve_subresource: ok      exit 0
mutation in resolve_subresource.h result
destination.sample_count != 1 removed caught
source.sample_count <= 1 → < 1 caught
the is_texture2d requirement removed caught
if (!format) removed caught
destination_subresource >= subresource_count → > caught
mip_extent floor 1 → 0 caught
the height comparison replaced with false not caught

The height check is unpinned, and it is the one that matters most

Only the width is compared by the fixture. A probe that varies only the height proves it both ways:

// 256x128 destination, 256x256 source: equal width and mip, different height
const Verdict v = check(dst, 0, src, 0, 28);
unmutated header:      height-only mismatch -> size_mismatch     exit 0
height check removed:  height-only mismatch -> NOT rejected      exit 1   <- the probe notices
your fixture:          exit 0                                    <- it does not

So today the header is correct and the height clause is untested. That is the clause whose failure mode the file's own comment describes: the call reaches
the driver and the desktop runtime treats it as a device-removing error. A one-line case closes it:

const Side dst_h = side(256, 128, 1, 1, 1, true);
const Side src_h = side(256, 256, 1, 1, 4, true);
expect(check(dst_h, 0, src_h, 0, 28) == Verdict::size_mismatch, "height mismatch is refused");

Two things the fixture does well

  • mip_extent's floor at 1 is caught: without it, a mip chain that shifts a small base to zero would compare 0 != 1 for identical textures and refuse
    valid resolves. That is a real one and it is pinned.
  • The subresource bounds are pinned in the strict direction (>=, not >), which is the boundary that off-by-one always lands on.

What I did not check

d3d12_xs_device.cpp's use of these verdicts — the state transitions to RESOLVE_DEST/RESOLVE_SOURCE and the logging path are Windows-only and I have no
device here. The header is genuinely "no Windows types" as claimed, which is what made this review possible without a build tree.

Notes

  • AI-assisted review.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7147935936 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2049#issuecomment-7147935936). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T23:55:02Z. --- ## Ran your host test under MSVC, broke the rules seven ways: six caught, and the seventh is a real gap Your command works on Windows too, with `cl` instead of `g++`: ```powershell cl /nologo /std:c++17 /EHsc tests/startup_resolve_subresource.cpp /I src/startup_stubs startup_resolve_subresource: ok exit 0 ``` | mutation in `resolve_subresource.h` | result | |---|---| | `destination.sample_count != 1` removed | **caught** | | `source.sample_count <= 1` → `< 1` | **caught** | | the `is_texture2d` requirement removed | **caught** | | `if (!format)` removed | **caught** | | `destination_subresource >= subresource_count` → `>` | **caught** | | `mip_extent` floor `1` → `0` | **caught** | | **the height comparison replaced with `false`** | **not caught** | ## The height check is unpinned, and it is the one that matters most Only the width is compared by the fixture. A probe that varies **only the height** proves it both ways: ```cpp // 256x128 destination, 256x256 source: equal width and mip, different height const Verdict v = check(dst, 0, src, 0, 28); ``` ```text unmutated header: height-only mismatch -> size_mismatch exit 0 height check removed: height-only mismatch -> NOT rejected exit 1 <- the probe notices your fixture: exit 0 <- it does not ``` So today the header is correct and the height clause is untested. That is the clause whose failure mode the file's own comment describes: the call reaches the driver and the desktop runtime treats it as a **device-removing** error. A one-line case closes it: ```cpp const Side dst_h = side(256, 128, 1, 1, 1, true); const Side src_h = side(256, 256, 1, 1, 4, true); expect(check(dst_h, 0, src_h, 0, 28) == Verdict::size_mismatch, "height mismatch is refused"); ``` ## Two things the fixture does well - `mip_extent`'s floor at 1 is caught: without it, a mip chain that shifts a small base to zero would compare `0 != 1` for identical textures and refuse valid resolves. That is a real one and it is pinned. - The subresource bounds are pinned in the strict direction (`>=`, not `>`), which is the boundary that off-by-one always lands on. ## What I did not check `d3d12_xs_device.cpp`'s use of these verdicts — the state transitions to `RESOLVE_DEST`/`RESOLVE_SOURCE` and the logging path are Windows-only and I have no device here. The header is genuinely "no Windows types" as claimed, which is what made this review possible without a build tree. ## Notes - AI-assisted review.
tedin7 commented 2026-11-25 01:02:06 +00:00 (Migrated from github.com)

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


Closing as duplicate of our broader open PR #1944 (which already covers slot 19 alongside slots 15/17 and hardware tests).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7148588327 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2049#issuecomment-7148588327). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T00:30:59Z. --- Closing as duplicate of our broader open PR #1944 (which already covers slot 19 alongside slots 15/17 and hardware tests).
chatgpt-codex-connector[bot commented 2026-11-25 01:02:13 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T23:47:53Z.

Code review location: src/startup_stubs/d3d12_xs_device.cpp; line 2333

@@ -2297,6 +2298,40 @@ void __stdcall list_stencil_ref(Wrapper* self, UINT reference)
 {
     if (auto* list = recording(self)) list->OMSetStencilRef(reference);
 }
+// List slot 19, ResolveSubresource(dest, dest subresource, source, source subresource, format). Both
+// textures use COMMON state tracking; the list moves them to RESOLVE_DEST / RESOLVE_SOURCE for the call.
+void __stdcall list_resolve_subresource(Wrapper* self, void* destination, UINT destination_subresource, void* source,
+                                        UINT source_subresource, UINT format)
+{
+    const auto refuse = [](const char* reason) {
+        static LONG refusals;
+        if (first_calls(refusals, 16)) log("x2w-render ResolveSubresource refused: %s", reason);
+    };
+    auto* list = recording(self);
+    if (!list) return refuse("list is closed");
+    Wrapper* to = as_wrapper(destination);
+    Wrapper* from = as_wrapper(source);
+    if (!to || !from || to->own().kind != resource_kind || from->own().kind != resource_kind || !to->own().real ||
+        !from->own().real || to == from)
+        return refuse("missing desktop resource");
+    const auto* to_info = resource_info(to);
+    const auto* from_info = resource_info(from);
+    if (!to_info || !from_info || to_info->initial_state != D3D12_RESOURCE_STATE_COMMON ||
+        from_info->initial_state != D3D12_RESOURCE_STATE_COMMON)
+        return refuse("resource does not use COMMON state tracking");
+    auto* target = static_cast<ID3D12Resource*>(to->own().real);
+    auto* origin = static_cast<ID3D12Resource*>(from->own().real);
+    const auto side = [](ID3D12Resource* resource) {
+        const D3D12_RESOURCE_DESC desc = resource->GetDesc();
+        return x2w_resolve::Side{desc.Width, desc.Height, desc.MipLevels, desc.DepthOrArraySize, desc.SampleDesc.Count,
+                                 desc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE2D};
+    };
+    const auto verdict = x2w_resolve::check(side(target), destination_subresource, side(origin), source_subresource, format);
+    if (verdict != x2w_resolve::Verdict::ok) return refuse("arguments do not describe a valid resolve");
+    require_state(self, target, D3D12_RESOURCE_STATE_RESOLVE_DEST);
+    require_state(self, origin, D3D12_RESOURCE_STATE_RESOLVE_SOURCE);
+    list->ResolveSubresource(target, destination_subresource, origin, source_subresource, static_cast<DXGI_FORMAT>(format));

P1 Badge Preserve resolved data when uploading sampled textures

For a resolve destination with Flags == D3D12_RESOURCE_FLAG_NONE and readable title-memory backing, such as a texture created through slot 133, this updates only the desktop texture. The next translated SRV bind unconditionally calls upload_texture (src/startup_stubs/d3d12_draw.inl:999), which excludes only render-target, depth-stencil and UAV resources. On its first bind, it therefore uploads the untouched CPU backing over the resolved pixels. A valid resolve-then-sample sequence reads stale CPU data instead of the resolve result. Record the destination's GPU-written contents and make the upload path preserve them.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688168425 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2049#discussion_r4688168425). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T23:47:53Z. **Code review location:** `src/startup_stubs/d3d12_xs_device.cpp`; line 2333 ~~~~diff @@ -2297,6 +2298,40 @@ void __stdcall list_stencil_ref(Wrapper* self, UINT reference) { if (auto* list = recording(self)) list->OMSetStencilRef(reference); } +// List slot 19, ResolveSubresource(dest, dest subresource, source, source subresource, format). Both +// textures use COMMON state tracking; the list moves them to RESOLVE_DEST / RESOLVE_SOURCE for the call. +void __stdcall list_resolve_subresource(Wrapper* self, void* destination, UINT destination_subresource, void* source, + UINT source_subresource, UINT format) +{ + const auto refuse = [](const char* reason) { + static LONG refusals; + if (first_calls(refusals, 16)) log("x2w-render ResolveSubresource refused: %s", reason); + }; + auto* list = recording(self); + if (!list) return refuse("list is closed"); + Wrapper* to = as_wrapper(destination); + Wrapper* from = as_wrapper(source); + if (!to || !from || to->own().kind != resource_kind || from->own().kind != resource_kind || !to->own().real || + !from->own().real || to == from) + return refuse("missing desktop resource"); + const auto* to_info = resource_info(to); + const auto* from_info = resource_info(from); + if (!to_info || !from_info || to_info->initial_state != D3D12_RESOURCE_STATE_COMMON || + from_info->initial_state != D3D12_RESOURCE_STATE_COMMON) + return refuse("resource does not use COMMON state tracking"); + auto* target = static_cast<ID3D12Resource*>(to->own().real); + auto* origin = static_cast<ID3D12Resource*>(from->own().real); + const auto side = [](ID3D12Resource* resource) { + const D3D12_RESOURCE_DESC desc = resource->GetDesc(); + return x2w_resolve::Side{desc.Width, desc.Height, desc.MipLevels, desc.DepthOrArraySize, desc.SampleDesc.Count, + desc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE2D}; + }; + const auto verdict = x2w_resolve::check(side(target), destination_subresource, side(origin), source_subresource, format); + if (verdict != x2w_resolve::Verdict::ok) return refuse("arguments do not describe a valid resolve"); + require_state(self, target, D3D12_RESOURCE_STATE_RESOLVE_DEST); + require_state(self, origin, D3D12_RESOURCE_STATE_RESOLVE_SOURCE); + list->ResolveSubresource(target, destination_subresource, origin, source_subresource, static_cast<DXGI_FORMAT>(format)); ~~~~ --- **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Preserve resolved data when uploading sampled textures** For a resolve destination with `Flags == D3D12_RESOURCE_FLAG_NONE` and readable title-memory backing, such as a texture created through slot 133, this updates only the desktop texture. The next translated SRV bind unconditionally calls `upload_texture` (`src/startup_stubs/d3d12_draw.inl:999`), which excludes only render-target, depth-stencil and UAV resources. On its first bind, it therefore uploads the untouched CPU backing over the resolved pixels. A valid resolve-then-sample sequence reads stale CPU data instead of the resolve result. Record the destination's GPU-written contents and make the upload path preserve them. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot commented 2026-11-25 01:02:13 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T23:47:53Z.

Code review location: src/startup_stubs/d3d12_xs_device.cpp; line 2333

@@ -2297,6 +2298,40 @@ void __stdcall list_stencil_ref(Wrapper* self, UINT reference)
 {
     if (auto* list = recording(self)) list->OMSetStencilRef(reference);
 }
+// List slot 19, ResolveSubresource(dest, dest subresource, source, source subresource, format). Both
+// textures use COMMON state tracking; the list moves them to RESOLVE_DEST / RESOLVE_SOURCE for the call.
+void __stdcall list_resolve_subresource(Wrapper* self, void* destination, UINT destination_subresource, void* source,
+                                        UINT source_subresource, UINT format)
+{
+    const auto refuse = [](const char* reason) {
+        static LONG refusals;
+        if (first_calls(refusals, 16)) log("x2w-render ResolveSubresource refused: %s", reason);
+    };
+    auto* list = recording(self);
+    if (!list) return refuse("list is closed");
+    Wrapper* to = as_wrapper(destination);
+    Wrapper* from = as_wrapper(source);
+    if (!to || !from || to->own().kind != resource_kind || from->own().kind != resource_kind || !to->own().real ||
+        !from->own().real || to == from)
+        return refuse("missing desktop resource");
+    const auto* to_info = resource_info(to);
+    const auto* from_info = resource_info(from);
+    if (!to_info || !from_info || to_info->initial_state != D3D12_RESOURCE_STATE_COMMON ||
+        from_info->initial_state != D3D12_RESOURCE_STATE_COMMON)
+        return refuse("resource does not use COMMON state tracking");
+    auto* target = static_cast<ID3D12Resource*>(to->own().real);
+    auto* origin = static_cast<ID3D12Resource*>(from->own().real);
+    const auto side = [](ID3D12Resource* resource) {
+        const D3D12_RESOURCE_DESC desc = resource->GetDesc();
+        return x2w_resolve::Side{desc.Width, desc.Height, desc.MipLevels, desc.DepthOrArraySize, desc.SampleDesc.Count,
+                                 desc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE2D};
+    };
+    const auto verdict = x2w_resolve::check(side(target), destination_subresource, side(origin), source_subresource, format);
+    if (verdict != x2w_resolve::Verdict::ok) return refuse("arguments do not describe a valid resolve");
+    require_state(self, target, D3D12_RESOURCE_STATE_RESOLVE_DEST);
+    require_state(self, origin, D3D12_RESOURCE_STATE_RESOLVE_SOURCE);
+    list->ResolveSubresource(target, destination_subresource, origin, source_subresource, static_cast<DXGI_FORMAT>(format));

P1 Badge Normalize console formats before submitting the resolve

When the caller supplies console colour format 116 or 117, sanitized() creates both desktop resources as DXGI_FORMAT_R10G10B10A2_UNORM through desktop_format(), but this call forwards the original console value. Both values pass x2w_resolve::check because its format check rejects only zero. Consequently, successfully created stand-ins receive a resolve with an unsupported desktop format that also differs from their actual format, potentially invalidating the command list or removing the device. Apply the existing desktop-format conversion before validating and forwarding the call.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688168435 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2049#discussion_r4688168435). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T23:47:53Z. **Code review location:** `src/startup_stubs/d3d12_xs_device.cpp`; line 2333 ~~~~diff @@ -2297,6 +2298,40 @@ void __stdcall list_stencil_ref(Wrapper* self, UINT reference) { if (auto* list = recording(self)) list->OMSetStencilRef(reference); } +// List slot 19, ResolveSubresource(dest, dest subresource, source, source subresource, format). Both +// textures use COMMON state tracking; the list moves them to RESOLVE_DEST / RESOLVE_SOURCE for the call. +void __stdcall list_resolve_subresource(Wrapper* self, void* destination, UINT destination_subresource, void* source, + UINT source_subresource, UINT format) +{ + const auto refuse = [](const char* reason) { + static LONG refusals; + if (first_calls(refusals, 16)) log("x2w-render ResolveSubresource refused: %s", reason); + }; + auto* list = recording(self); + if (!list) return refuse("list is closed"); + Wrapper* to = as_wrapper(destination); + Wrapper* from = as_wrapper(source); + if (!to || !from || to->own().kind != resource_kind || from->own().kind != resource_kind || !to->own().real || + !from->own().real || to == from) + return refuse("missing desktop resource"); + const auto* to_info = resource_info(to); + const auto* from_info = resource_info(from); + if (!to_info || !from_info || to_info->initial_state != D3D12_RESOURCE_STATE_COMMON || + from_info->initial_state != D3D12_RESOURCE_STATE_COMMON) + return refuse("resource does not use COMMON state tracking"); + auto* target = static_cast<ID3D12Resource*>(to->own().real); + auto* origin = static_cast<ID3D12Resource*>(from->own().real); + const auto side = [](ID3D12Resource* resource) { + const D3D12_RESOURCE_DESC desc = resource->GetDesc(); + return x2w_resolve::Side{desc.Width, desc.Height, desc.MipLevels, desc.DepthOrArraySize, desc.SampleDesc.Count, + desc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE2D}; + }; + const auto verdict = x2w_resolve::check(side(target), destination_subresource, side(origin), source_subresource, format); + if (verdict != x2w_resolve::Verdict::ok) return refuse("arguments do not describe a valid resolve"); + require_state(self, target, D3D12_RESOURCE_STATE_RESOLVE_DEST); + require_state(self, origin, D3D12_RESOURCE_STATE_RESOLVE_SOURCE); + list->ResolveSubresource(target, destination_subresource, origin, source_subresource, static_cast<DXGI_FORMAT>(format)); ~~~~ --- **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Normalize console formats before submitting the resolve** When the caller supplies console colour format 116 or 117, `sanitized()` creates both desktop resources as `DXGI_FORMAT_R10G10B10A2_UNORM` through `desktop_format()`, but this call forwards the original console value. Both values pass `x2w_resolve::check` because its format check rejects only zero. Consequently, successfully created stand-ins receive a resolve with an unsupported desktop format that also differs from their actual format, potentially invalidating the command list or removing the device. Apply the existing desktop-format conversion before validating and forwarding the call. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot commented 2026-11-25 01:02:13 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T23:47:53Z.

Code review location: src/startup_stubs/d3d12_xs_device.cpp; line 2333

@@ -2297,6 +2298,40 @@ void __stdcall list_stencil_ref(Wrapper* self, UINT reference)
 {
     if (auto* list = recording(self)) list->OMSetStencilRef(reference);
 }
+// List slot 19, ResolveSubresource(dest, dest subresource, source, source subresource, format). Both
+// textures use COMMON state tracking; the list moves them to RESOLVE_DEST / RESOLVE_SOURCE for the call.
+void __stdcall list_resolve_subresource(Wrapper* self, void* destination, UINT destination_subresource, void* source,
+                                        UINT source_subresource, UINT format)
+{
+    const auto refuse = [](const char* reason) {
+        static LONG refusals;
+        if (first_calls(refusals, 16)) log("x2w-render ResolveSubresource refused: %s", reason);
+    };
+    auto* list = recording(self);
+    if (!list) return refuse("list is closed");
+    Wrapper* to = as_wrapper(destination);
+    Wrapper* from = as_wrapper(source);
+    if (!to || !from || to->own().kind != resource_kind || from->own().kind != resource_kind || !to->own().real ||
+        !from->own().real || to == from)
+        return refuse("missing desktop resource");
+    const auto* to_info = resource_info(to);
+    const auto* from_info = resource_info(from);
+    if (!to_info || !from_info || to_info->initial_state != D3D12_RESOURCE_STATE_COMMON ||
+        from_info->initial_state != D3D12_RESOURCE_STATE_COMMON)
+        return refuse("resource does not use COMMON state tracking");
+    auto* target = static_cast<ID3D12Resource*>(to->own().real);
+    auto* origin = static_cast<ID3D12Resource*>(from->own().real);
+    const auto side = [](ID3D12Resource* resource) {
+        const D3D12_RESOURCE_DESC desc = resource->GetDesc();
+        return x2w_resolve::Side{desc.Width, desc.Height, desc.MipLevels, desc.DepthOrArraySize, desc.SampleDesc.Count,
+                                 desc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE2D};
+    };
+    const auto verdict = x2w_resolve::check(side(target), destination_subresource, side(origin), source_subresource, format);
+    if (verdict != x2w_resolve::Verdict::ok) return refuse("arguments do not describe a valid resolve");
+    require_state(self, target, D3D12_RESOURCE_STATE_RESOLVE_DEST);
+    require_state(self, origin, D3D12_RESOURCE_STATE_RESOLVE_SOURCE);
+    list->ResolveSubresource(target, destination_subresource, origin, source_subresource, static_cast<DXGI_FORMAT>(format));

P1 Badge Restore attachment states before subsequent draws

If the single-sample destination is already bound as a render target, resolving into it and then drawing again without rebinding leaves it in RESOLVE_DEST. list_targets() establishes render-target state only at bind time, while list_draw() and draw_translated() do not re-establish it; the title's barrier calls are still no-ops. Since targets_bound remains true, the next draw is recorded against an attachment in the wrong state, producing validation errors and possible device removal. Restore the previous tracked states after resolving, or ensure subsequent draws transition their bound attachments back to the required states.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688168445 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2049#discussion_r4688168445). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T23:47:53Z. **Code review location:** `src/startup_stubs/d3d12_xs_device.cpp`; line 2333 ~~~~diff @@ -2297,6 +2298,40 @@ void __stdcall list_stencil_ref(Wrapper* self, UINT reference) { if (auto* list = recording(self)) list->OMSetStencilRef(reference); } +// List slot 19, ResolveSubresource(dest, dest subresource, source, source subresource, format). Both +// textures use COMMON state tracking; the list moves them to RESOLVE_DEST / RESOLVE_SOURCE for the call. +void __stdcall list_resolve_subresource(Wrapper* self, void* destination, UINT destination_subresource, void* source, + UINT source_subresource, UINT format) +{ + const auto refuse = [](const char* reason) { + static LONG refusals; + if (first_calls(refusals, 16)) log("x2w-render ResolveSubresource refused: %s", reason); + }; + auto* list = recording(self); + if (!list) return refuse("list is closed"); + Wrapper* to = as_wrapper(destination); + Wrapper* from = as_wrapper(source); + if (!to || !from || to->own().kind != resource_kind || from->own().kind != resource_kind || !to->own().real || + !from->own().real || to == from) + return refuse("missing desktop resource"); + const auto* to_info = resource_info(to); + const auto* from_info = resource_info(from); + if (!to_info || !from_info || to_info->initial_state != D3D12_RESOURCE_STATE_COMMON || + from_info->initial_state != D3D12_RESOURCE_STATE_COMMON) + return refuse("resource does not use COMMON state tracking"); + auto* target = static_cast<ID3D12Resource*>(to->own().real); + auto* origin = static_cast<ID3D12Resource*>(from->own().real); + const auto side = [](ID3D12Resource* resource) { + const D3D12_RESOURCE_DESC desc = resource->GetDesc(); + return x2w_resolve::Side{desc.Width, desc.Height, desc.MipLevels, desc.DepthOrArraySize, desc.SampleDesc.Count, + desc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE2D}; + }; + const auto verdict = x2w_resolve::check(side(target), destination_subresource, side(origin), source_subresource, format); + if (verdict != x2w_resolve::Verdict::ok) return refuse("arguments do not describe a valid resolve"); + require_state(self, target, D3D12_RESOURCE_STATE_RESOLVE_DEST); + require_state(self, origin, D3D12_RESOURCE_STATE_RESOLVE_SOURCE); + list->ResolveSubresource(target, destination_subresource, origin, source_subresource, static_cast<DXGI_FORMAT>(format)); ~~~~ --- **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Restore attachment states before subsequent draws** If the single-sample destination is already bound as a render target, resolving into it and then drawing again without rebinding leaves it in `RESOLVE_DEST`. `list_targets()` establishes render-target state only at bind time, while `list_draw()` and `draw_translated()` do not re-establish it; the title's barrier calls are still no-ops. Since `targets_bound` remains true, the next draw is recorded against an attachment in the wrong state, producing validation errors and possible device removal. Restore the previous tracked states after resolving, or ensure subsequent draws transition their bound attachments back to the required states. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot commented 2026-11-25 01:02:13 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T23:47:53Z.

Code review location: CMakeLists.txt; line 666

@@ -659,6 +659,11 @@ endforeach()
 add_executable(startup_command_list_slot_names tests/startup_command_list_slot_names.cpp)
 target_compile_features(startup_command_list_slot_names PRIVATE cxx_std_17)
 add_test(NAME startup_command_list_slot_names COMMAND startup_command_list_slot_names)
+
+# Rules that gate a title's ResolveSubresource (src/startup_stubs/resolve_subresource.h, #870).
+add_executable(startup_resolve_subresource tests/startup_resolve_subresource.cpp)
+target_compile_features(startup_resolve_subresource PRIVATE cxx_std_17)
+add_test(NAME startup_resolve_subresource COMMAND startup_resolve_subresource)

P1 Badge Document the new resolve capability and reproduction command

This adds an externally usable startup operation and a new CTest command, but a repository-wide search for ResolveSubresource and resolve_subresource finds no corresponding README or experiment-documentation entry. AGENTS.md requires updating the relevant README row or docs/experiments.md when a public capability or reproduction command changes. Add the supported resource constraints, the fixture's reproduction command and result, and the distinction between the tested argument predicates and the still-unverified Windows forwarding path.

AGENTS.md reference: AGENTS.md:L211-L212

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4688168451 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2049#discussion_r4688168451). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T23:47:53Z. **Code review location:** `CMakeLists.txt`; line 666 ~~~~diff @@ -659,6 +659,11 @@ endforeach() add_executable(startup_command_list_slot_names tests/startup_command_list_slot_names.cpp) target_compile_features(startup_command_list_slot_names PRIVATE cxx_std_17) add_test(NAME startup_command_list_slot_names COMMAND startup_command_list_slot_names) + +# Rules that gate a title's ResolveSubresource (src/startup_stubs/resolve_subresource.h, #870). +add_executable(startup_resolve_subresource tests/startup_resolve_subresource.cpp) +target_compile_features(startup_resolve_subresource PRIVATE cxx_std_17) +add_test(NAME startup_resolve_subresource COMMAND startup_resolve_subresource) ~~~~ --- **<sub><sub>![P1 Badge](https://img.shields.io/badge/P1-orange?style=flat)</sub></sub> Document the new resolve capability and reproduction command** This adds an externally usable startup operation and a new CTest command, but a repository-wide search for `ResolveSubresource` and `resolve_subresource` finds no corresponding README or experiment-documentation entry. `AGENTS.md` requires updating the relevant README row or `docs/experiments.md` when a public capability or reproduction command changes. Add the supported resource constraints, the fixture's reproduction command and result, and the distinction between the tested argument predicates and the still-unverified Windows forwarding path. AGENTS.md reference: [AGENTS.md:L211-L212](https://github.com/R0Y00/Xbox2Windows/blob/b3ac4aec3a69e14473701ee51fa117e6b7d59325/AGENTS.md#L211-L212) Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->

Pull request closed

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!2042
No description provided.