Diagnostics: count GPU-to-CPU traffic (Part of #3676 item f) #3716

Merged
SimSalabimse merged 7 commits from upstream-pr/3716 into main 2026-12-03 06:31:55 +00:00
SimSalabimse commented 2026-12-01 09:19:25 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-12-01T09:19:25Z.


Part of #3676 item (f). Claim: https://github.com/R0Y00/Xbox2Windows/issues/3676#issuecomment-7305772188

Adds a five-second line x2w-d3d12 gpu-to-cpu: map_readback N, copy_dest_title N, resolve_dest_title N, dest_title_refusals N next to the placed-buffer census, plus the x2w_d3d12_gpu_to_cpu_snapshot export. Allocation, lifetime, copy forwarding and Map's returned pointer are unchanged. The top-10 GPU-written buffers stay with #3640 and are not part of this change.

A Linux line check with a mutation control is included, plus WARP/hardware fixtures. The SDK-dependent parts have not been compiled on Windows yet. This PR is a draft until then.

This change and #3715 both edit src/startup_stubs/d3d12_xs_device.cpp and merge cleanly: #3715 touches upload budget charging and report_budget; this change adds the counters, the heartbeat line, and the snapshot export.

AI-assisted (Cursor)

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5582711796 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3716). Originally posted by [SimSalabimse](https://github.com/SimSalabimse) on 2026-12-01T09:19:25Z. --- Part of #3676 item (f). Claim: https://github.com/R0Y00/Xbox2Windows/issues/3676#issuecomment-7305772188 Adds a five-second line `x2w-d3d12 gpu-to-cpu: map_readback N, copy_dest_title N, resolve_dest_title N, dest_title_refusals N` next to the placed-buffer census, plus the `x2w_d3d12_gpu_to_cpu_snapshot` export. Allocation, lifetime, copy forwarding and Map's returned pointer are unchanged. The top-10 GPU-written buffers stay with #3640 and are not part of this change. A Linux line check with a mutation control is included, plus WARP/hardware fixtures. The SDK-dependent parts have not been compiled on Windows yet. This PR is a draft until then. This change and #3715 both edit `src/startup_stubs/d3d12_xs_device.cpp` and merge cleanly: #3715 touches upload budget charging and `report_budget`; this change adds the counters, the heartbeat line, and the snapshot export. AI-assisted (Cursor)
SimSalabimse commented 2026-12-01 09:49:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-12-01T09:49:11Z.


Windows test at 27840d7c: build succeeded.

WARP and CPU: 19/19 passed for startup_gpu_to_cpu_*, startup_list_queries and startup_list_copy. The misattribute control fired as expected.

Hardware: 10/10 passed.

AI-Assisted

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7307252457 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3716#issuecomment-7307252457). Originally posted by [SimSalabimse](https://github.com/SimSalabimse) on 2026-12-01T09:49:11Z. --- Windows test at 27840d7c: build succeeded. WARP and CPU: 19/19 passed for startup_gpu_to_cpu_*, startup_list_queries and startup_list_copy. The misattribute control fired as expected. Hardware: 10/10 passed. AI-Assisted
SimSalabimse commented 2026-12-01 11:42:17 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-12-01T11:42:17Z.


Measured on the Windows test PC with this branch combined with #3715 on main a061032f, gfx2hlsl translate mode, about 7 minutes from startup into the first playable 3D area (prologue).

Last x2w-d3d12 gpu-to-cpu line: map_readback 6009, copy_dest_title 0, resolve_dest_title 0, dest_title_refusals 0.

It went 130 at early startup, then 230 at the menu, then about 6,000 once in the 3D area. Every GPU-to-CPU read in this run went through map readback; no copy or resolve wrote into title memory, and nothing was refused. No device removal in the run.

AI-Assisted

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7310014067 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3716#issuecomment-7310014067). Originally posted by [SimSalabimse](https://github.com/SimSalabimse) on 2026-12-01T11:42:17Z. --- Measured on the Windows test PC with this branch combined with #3715 on main a061032f, gfx2hlsl translate mode, about 7 minutes from startup into the first playable 3D area (prologue). Last `x2w-d3d12 gpu-to-cpu` line: `map_readback 6009, copy_dest_title 0, resolve_dest_title 0, dest_title_refusals 0`. It went 130 at early startup, then 230 at the menu, then about 6,000 once in the 3D area. Every GPU-to-CPU read in this run went through map readback; no copy or resolve wrote into title memory, and nothing was refused. No device removal in the run. AI-Assisted
Leyukaka commented 2026-12-01 14:22:39 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Leyukaka on 2026-12-01T14:22:39Z.

Review: COMMENTED


Can we clarify the scope of dest_title_refusals for #3676(f)? The ticket asks for logged refusals of copies into application-backed destinations. This counter only increments when ResolveQueryData rejects application backing. In the copy-dest fixture, for example, the zero-byte CopyBufferRegion into an application-backed buffer increments the generic refusal count and leaves this census unchanged.

If the intended metric includes refused copies to these destinations, please add that count and assert it in the existing fixture. If it is specifically for refusals caused by application backing, naming or documenting the query-resolve scope in the heartbeat would make a zero easier to interpret.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6133190800 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3716#pullrequestreview-6133190800). Originally posted by [Leyukaka](https://github.com/Leyukaka) on 2026-12-01T14:22:39Z. **Review:** COMMENTED --- Can we clarify the scope of dest_title_refusals for #3676(f)? The ticket asks for logged refusals of copies into application-backed destinations. This counter only increments when ResolveQueryData rejects application backing. In the copy-dest fixture, for example, the zero-byte CopyBufferRegion into an application-backed buffer increments the generic refusal count and leaves this census unchanged. If the intended metric includes refused copies to these destinations, please add that count and assert it in the existing fixture. If it is specifically for refusals caused by application backing, naming or documenting the query-resolve scope in the heartbeat would make a zero easier to interpret.
SimSalabimse commented 2026-12-01 14:53:17 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-12-01T14:53:17Z.


dest_title_refusals now counts every refused copy or resolve whose destination has application backing, whatever the reason. The query-specific subset is kept as dest_title_query_refusals, and both are documented in the heartbeat. The fixture now asserts the zero-byte CopyBufferRegion case plus refused CopyResource, CopyTextureRegion, ResolveSubresource and ResolveQueryData, with no change to forwarding. Tested on the Windows test PC: startup_gpu_to_cpu_line, startup_gpu_to_cpu_line_misattribute_control, startup_gpu_to_cpu_map_readback_warp, startup_gpu_to_cpu_map_other_warp, startup_gpu_to_cpu_copy_dest_warp, startup_gpu_to_cpu_resolve_refusal_warp, startup_gpu_to_cpu_misattribute_warp_control.

AI-Assisted

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7314990433 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3716#issuecomment-7314990433). Originally posted by [SimSalabimse](https://github.com/SimSalabimse) on 2026-12-01T14:53:17Z. --- `dest_title_refusals` now counts every refused copy or resolve whose destination has application backing, whatever the reason. The query-specific subset is kept as `dest_title_query_refusals`, and both are documented in the heartbeat. The fixture now asserts the zero-byte CopyBufferRegion case plus refused CopyResource, CopyTextureRegion, ResolveSubresource and ResolveQueryData, with no change to forwarding. Tested on the Windows test PC: `startup_gpu_to_cpu_line`, `startup_gpu_to_cpu_line_misattribute_control`, `startup_gpu_to_cpu_map_readback_warp`, `startup_gpu_to_cpu_map_other_warp`, `startup_gpu_to_cpu_copy_dest_warp`, `startup_gpu_to_cpu_resolve_refusal_warp`, `startup_gpu_to_cpu_misattribute_warp_control`. AI-Assisted
R0Y00 commented 2026-12-02 03:13:17 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T03:13:17Z.


I reproduced a Linux coverage failure when trial-merging the old head into current main: standin_exports: d3d12_xs entries 80 != 79. Pushed the integration update 1369ee87 with the new snapshot export counted and checked by name. python -B tests/standin_exports_check.py now passes, 472 cases and 6/6 mutations killed. The new head's integrated CI is pending.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7333661162 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3716#issuecomment-7333661162). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-02T03:13:17Z. --- I reproduced a Linux coverage failure when trial-merging the old head into current main: `standin_exports: d3d12_xs entries 80 != 79`. Pushed the integration update `1369ee87` with the new snapshot export counted and checked by name. `python -B tests/standin_exports_check.py` now passes, 472 cases and 6/6 mutations killed. The new head's integrated CI is pending.
R0Y00 commented 2026-12-02 05:41:35 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T05:41:35Z.

Review: COMMENTED


The integrated head passed 13/13 tests with ctest --preset dev --no-tests=error -j 1 -R '^(startup_gpu_to_cpu|standin_exports)' --output-on-failure on Windows 11 26300.9974, Debug. GPU cases ran on WARP (10.0.26100.9818) and RTX 4060 Laptop (32.0.16.1656), with the debug layer off for this fixture. The line and GPU misattribution controls passed. I requested a follow-up review of 1369ee87, which contains my earlier export-catalog integration change.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6145369270 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3716#pullrequestreview-6145369270). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-02T05:41:35Z. **Review:** COMMENTED --- The integrated head passed 13/13 tests with `ctest --preset dev --no-tests=error -j 1 -R '^(startup_gpu_to_cpu|standin_exports)' --output-on-failure` on Windows 11 26300.9974, Debug. GPU cases ran on WARP (10.0.26100.9818) and RTX 4060 Laptop (32.0.16.1656), with the debug layer off for this fixture. The line and GPU misattribution controls passed. I requested a follow-up review of `1369ee87`, which contains my earlier export-catalog integration change.
SimSalabimse commented 2026-12-02 11:44:59 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-12-02T11:44:59Z.


I reviewed 1369ee87. The unique part of the merge is the catalog check: d3d12_xs is now 80 with 45 unmeasured, and it looks up x2w_d3d12_gpu_to_cpu_snapshot by name as unmeasured. No runtime code in that follow-up. I ran tests/standin_exports_check.py on this head; it passed with 472 cases and 6/6 mutations killed. It looks right, and CI is green.

AI-Assisted

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7344352476 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3716#issuecomment-7344352476). Originally posted by [SimSalabimse](https://github.com/SimSalabimse) on 2026-12-02T11:44:59Z. --- I reviewed 1369ee87. The unique part of the merge is the catalog check: d3d12_xs is now 80 with 45 unmeasured, and it looks up x2w_d3d12_gpu_to_cpu_snapshot by name as unmeasured. No runtime code in that follow-up. I ran tests/standin_exports_check.py on this head; it passed with 472 cases and 6/6 mutations killed. It looks right, and CI is green. AI-Assisted
R0Y00 commented 2026-12-02 19:32:35 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T19:32:35Z.

Review: COMMENTED


The exact-head Windows run here passed the 13 GPU-to-CPU and export cases, including WARP and RTX 4060 Laptop, the two misattribution controls, and the application-backed destination refusal. Hosted Windows passed too. Hosted Linux fails on the integration tree in standin_exports_check.py with d3d12_xs entries 84 != 83. The main merge includes the Mesh86 material-resolve export from #3725. Please refresh the export inventory on current main and preserve both the existing export coverage and the GPU-to-CPU snapshot export.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6157514769 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3716#pullrequestreview-6157514769). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-02T19:32:35Z. **Review:** COMMENTED --- The exact-head Windows run here passed the 13 GPU-to-CPU and export cases, including WARP and RTX 4060 Laptop, the two misattribution controls, and the application-backed destination refusal. Hosted Windows passed too. Hosted Linux fails on the integration tree in `standin_exports_check.py` with `d3d12_xs entries 84 != 83`. The main merge includes the Mesh86 material-resolve export from #3725. Please refresh the export inventory on current main and preserve both the existing export coverage and the GPU-to-CPU snapshot export.
SimSalabimse commented 2026-12-02 20:25:29 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by SimSalabimse on 2026-12-02T20:25:29Z.


Reply to https://github.com/R0Y00/Xbox2Windows/pull/3716#pullrequestreview-6157514769:

Merged current main into this branch and refreshed the Mesh86/d3d12_xs export inventory in tests/standin_exports_check.py. With main's new export (#3725) and this PR's GPU-to-CPU snapshot export the catalog has 85 d3d12_xs entries (35 implemented, 50 unmeasured), so counts and the status counter now say that. All existing coverage and the snapshot-export check are kept. Current main on its own fails this check (84 entries vs 83), so the refresh also covers that.

Run on the Windows test PC (Debug build of the merged head, GPU tests one at a time): standin_exports_check plus startup_gpu_to_cpu_*, startup_list_queries* and startup_list_copy* (warp and hardware): 30 of 30 pass.

AI-Assisted

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7357714886 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3716#issuecomment-7357714886). Originally posted by [SimSalabimse](https://github.com/SimSalabimse) on 2026-12-02T20:25:29Z. --- Reply to https://github.com/R0Y00/Xbox2Windows/pull/3716#pullrequestreview-6157514769: Merged current `main` into this branch and refreshed the Mesh86/d3d12_xs export inventory in `tests/standin_exports_check.py`. With main's new export (#3725) and this PR's GPU-to-CPU snapshot export the catalog has 85 `d3d12_xs` entries (35 implemented, 50 unmeasured), so `counts` and the status counter now say that. All existing coverage and the snapshot-export check are kept. Current `main` on its own fails this check (84 entries vs 83), so the refresh also covers that. Run on the Windows test PC (Debug build of the merged head, GPU tests one at a time): `standin_exports_check` plus `startup_gpu_to_cpu_*`, `startup_list_queries*` and `startup_list_copy*` (warp and hardware): 30 of 30 pass. AI-Assisted
R0Y00 commented 2026-12-02 20:26:06 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T20:26:06Z.

Review: COMMENTED


The refreshed branch c07e92ee passes the export census locally (477 checks and six mutations caught). Independent MSVC Debug ctest --preset dev --no-tests=error -j 1 -R '^(startup_gpu_to_cpu|standin_exports)' passed 13/13 with WARP and RTX 4060 Laptop on Windows 11 build 26300, including the line and GPU misattribution controls and the destination refusal. The trial merge onto 75759370 still conflicts in tests/standin_exports_check.py. Please retain the Mesh86 material resolver census from #3885 together with the GPU-to-CPU snapshot export when incorporating current main.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6158355285 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3716#pullrequestreview-6158355285). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-02T20:26:06Z. **Review:** COMMENTED --- The refreshed branch `c07e92ee` passes the export census locally (477 checks and six mutations caught). Independent MSVC Debug `ctest --preset dev --no-tests=error -j 1 -R '^(startup_gpu_to_cpu|standin_exports)'` passed 13/13 with WARP and RTX 4060 Laptop on Windows 11 build 26300, including the line and GPU misattribution controls and the destination refusal. The trial merge onto `75759370` still conflicts in `tests/standin_exports_check.py`. Please retain the Mesh86 material resolver census from #3885 together with the GPU-to-CPU snapshot export when incorporating current main.
R0Y00 commented 2026-12-02 20:36:24 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-02T20:36:24Z.

Review: COMMENTED


I resolved the catalog conflict in ec2e8a2c7 by retaining main's Mesh86 material-resolver check and the branch's GPU-to-CPU snapshot check. The integrated census passes 478 checks with six mutations caught. Independent MSVC Debug ctest --preset dev --no-tests=error -j 1 --output-on-failure -R '^(startup_gpu_to_cpu|standin_exports)' passes all 13 cases, including WARP, RTX 4060 Laptop and the misattribution controls. @Leyukaka, your review request is still open. Please review the catalog integration on this head when you get a chance.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6158525133 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3716#pullrequestreview-6158525133). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-02T20:36:24Z. **Review:** COMMENTED --- I resolved the catalog conflict in `ec2e8a2c7` by retaining main's Mesh86 material-resolver check and the branch's GPU-to-CPU snapshot check. The integrated census passes 478 checks with six mutations caught. Independent MSVC Debug `ctest --preset dev --no-tests=error -j 1 --output-on-failure -R '^(startup_gpu_to_cpu|standin_exports)'` passes all 13 cases, including WARP, RTX 4060 Laptop and the misattribution controls. @Leyukaka, your review request is still open. Please review the catalog integration on this head when you get a chance.
R0Y00 commented 2026-12-03 06:31:48 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-03T06:31:48Z.

Review: APPROVED


Independently reviewed ec2e8a2c and its integration with main 09ff8ede. The wrappers still forward or refuse the same copy, query, and resolve calls; the new instrumentation records the outcome and leaves Map's returned pointer intact. On the trial merge, python -B tests/standin_exports_check.py passed all 478 cases, including 6/6 mutation controls. The MSVC startup_gpu_to_cpu_line_check passed, and its deliberately wrong READBACK classification failed with all three expected heap mismatches. The author's exact-head Windows run reports 30/30 including WARP and hardware. My independent checks here were the catalog and line fixtures.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6164757997 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3716#pullrequestreview-6164757997). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-03T06:31:48Z. **Review:** APPROVED --- Independently reviewed ec2e8a2c and its integration with main 09ff8ede. The wrappers still forward or refuse the same copy, query, and resolve calls; the new instrumentation records the outcome and leaves Map's returned pointer intact. On the trial merge, python -B tests/standin_exports_check.py passed all 478 cases, including 6/6 mutation controls. The MSVC startup_gpu_to_cpu_line_check passed, and its deliberately wrong READBACK classification failed with all three expected heap mismatches. The author's exact-head Windows run reports 30/30 including WARP and hardware. My independent checks here were the catalog and line fixtures.
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!3716
No description provided.