Skip to content

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

Open
SimSalabimse wants to merge 3 commits into
R0Y00:mainfrom
SimSalabimse:local/gpu-to-cpu-counters
Open

SimSalabimse wants to merge 3 commits into
R0Y00:mainfrom
SimSalabimse:local/gpu-to-cpu-counters

Conversation

@SimSalabimse

Copy link
Copy Markdown
Contributor

Part of #3676 item (f). Claim: #3676 (comment)

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)

Record Map calls on a READBACK heap, forwarded copies and resolves whose destination has title memory, and ResolveQueryData refusals of that destination. The five-second report prints the counts, and a snapshot lets a fixture read them. Allocation, copy forwarding and the pointer Map returns are unchanged.

AI-assisted (Cursor)

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
@SimSalabimse

Copy link
Copy Markdown
Contributor Author

Windows test at 27840d7: 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
SimSalabimse marked this pull request as ready for review December 1, 2026 09:49
@SimSalabimse

Copy link
Copy Markdown
Contributor Author

Measured on the Windows test PC with this branch combined with #3715 on main a061032, 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 Leyukaka left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Expand dest_title_refusals across the copy and resolve handlers while retaining a named query-specific subset. Exercise every covered refusal path in the existing fixture and clarify both heartbeat fields.

AI-assisted (Cursor)

Co-authored-by: SimSalabimse <SimSalabimse@users.noreply.github.com>
@SimSalabimse

Copy link
Copy Markdown
Contributor Author

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 Dec 2, 2026

Copy link
Copy Markdown
Owner

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
R0Y00 requested a review from Leyukaka December 2, 2026 05:40

@R0Y00 R0Y00 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants