runtime: report D3D12 resource budget and lifetimes #2248
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2256"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-25T08:16:52Z.
Refs #874. Budget telemetry request on #870
Change
Tests
The source-built fixture exercises committed resources, two explicit heaps with placed buffers and a texture, two slot 133 buffers sharing one mapped heap, slot 133 committed fallbacks, and two slot 148 requests sharing one upload page. It checks every category's byte and object delta, the shared heap after one child is released, page retirement after fence completion and allocator reuse, and exact restoration of the active baseline. It verifies retained backing separately.
The missing-release control leaves one 65,536-byte committed buffer active and fails with the expected diagnostic. The direct GTX 1060 run returned exit 6. A two-present smoke check on the GTX 1060 emitted one x2w-budget line with numeric values for both memory segments when enabled and only the regular heartbeat when unset.
Verification
Tested source matches
b5fd19f9a6, based one94e14ff. The build revision is e94e14ff-dirty because linked worktree metadata is read-only.Windows 10 build 19045.6456. Each row includes one baseline check and one expected-failure control. The debug-enabled tests reported zero D3D12 warnings or errors. Both adapters exercised the mapped-heap subcase. The neighbouring slot 148 and committed heap selection returned six passes and one failure. The no-debug WARP slot 148 test timed out waiting for its observer and returned exit 18 both on this patch and on a separate build of
e94e14ff.With a prepared requirements-dev.txt Python environment:
Limits
DXGI usage includes allocations outside the instrumented categories. The counters report allocation sizes and shim ownership, while DXGI reports the adapter's usage and budget. The change leaves resource ownership and retirement behavior as it was.
AI-assisted (Codex).
🤖 Generated with Claude Code
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T08:21:18Z.
Review: COMMENTED
Review of head
b5fd19f9a6dca2b2290180854157fce6368359e0.Result: no P1, no P2. Two nits.
Checked by reading the diff (11 files, +677/-10):
end_use(). Wrapper blocks are zero-initialised inwrap()(memset), so the newbudgetandbacking_budgetfields start null.begin_use()andend_use(), so the heap stays live while any child is alive.existing_heapskeeps the heap reference and the ticket together, so the raw pointer stays valid.SetPrivateDataInterfaceor an oversize allocation only bumpsunmeasured. The failed-Mapupload ring case ends up in retained, which matches the leaked desktop reference described in the comment.X2W_D3D12_BUDGET=1only. With it off,enabled()short-circuits every hook and the export returns FALSE.inline_controlmutation guard withPASS_REGULAR_EXPRESSION.Commands run locally on the worktree:
git diff --check origin/main...HEAD: cleanpython3 tests/docs_links_check.py: self-test passed, 18 Markdown files and 431 links OKpython3 tests/bidi_controls_check.py: self-test passed, 1537 files, no bidirectional controlsgh pr checks 2256: Linux Python checks, Windows build and test, and gfx1013 fixtures pass. The /O2 build is skipped.Not run: the new fixture is Windows-only C++, so I did not mutate or run it here. I did not queue the Windows VM. CI Windows is green on this head, and the fixture ships its own inline-control mutation test.
Nits (non-blocking):
src/startup_stubs/resource_budget.husesGetEnvironmentVariableA,SRWLOCKandInterlocked*with only<d3d12.h>included. It works through the transitivewindows.h, but an explicit#include <windows.h>would make the header self-contained.report_budget(d3d12_xs_device.cpp, near the new function beforequeue_present) creates a new DXGI factory at every heartbeat. This is fine while it is opt-in and the heartbeat is slow, but caching the adapter would avoid the churn.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-25T08:43:22Z.
Thanks for the review. Both nits make sense:
<windows.h>inresource_budget.h;report_budgetinstead of creating a factory every heartbeat.I'll fold them into the next change that touches this code, rather than open a PR for them alone.