startup: track UAV/RTV/DSV descriptor slots in the retire class (slice 3a) #2711
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2719"
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 triggered02 on 2026-11-26T03:28:15Z.
Slice 3a of #2379: UAV (slot 19), RTV (slot 20) and DSV (slot 21) descriptor slots now hold a retire reference exactly like slot-18 SRV slots, instead of taking the resource out of the retire class for good.
What changed
src/startup_stubs/d3d12_capture.inl:view_slot_names_resource()(slots 18-21; 17 CBV and 22 sampler name none) and three helpers —view_refs_add,view_refs_release,view_refs_leave_class. Slot 19 (UAV) counts both the view resource and its counter resource; 20/21 count the resource.note_viewadds on a materialized view in a trackedshadow_slot()and releases the previous record's refs when a different view takes the slot (the same view written again keeps its id and changes no count).note_copyadds a ref for every materialized copied-in record and releases the ones the destination slots named before, so a self-copy is idempotent.retire_drop_heap_viewsreleases the refs of every materialized record still in that heap's shadow entries.src/startup_stubs/d3d12_xs_device.cpp:view_slot<19..21>keeps the oldretire_leave_classonly when the destination descriptor slot is not tracked (or there is no desktop destination handle); when it is tracked,note_viewowns the reference and the resource stays in the class.retire_drop_heap_viewscovers 18-21. The fixture probex2w_d3d12_retire_probegainsview_refs(the resource'sretire_view_refs), read under the same switch.tests/startup_resource_retire_title.cpp;tests/startup_resource_retire.cppgets the matching probe field.docs/startup-runtime.md(budget section) and a newdocs/experiments.mdsection that also closes the code fence the Slice 2 record left open.Semantics
The ref is taken at view creation and dropped when the slot is overwritten, copied over, or its heap is destroyed — so a resource survives exactly as long as some tracked descriptor still names it, and the drain's existing
retire_view_refs == 0gate frees it afterwards. Untracked heaps keep the old conservativeretire_leave_classfallback; nothing is freed under a descriptor the shim cannot follow.One design fact worth stating up front
retire_classifyexcludes textures created withALLOW_RENDER_TARGET,ALLOW_DEPTH_STENCILorALLOW_UNORDERED_ACCESS, and desktop only materializes a UAV/RTV/DSV on a resource carrying the matching flag. So a class texture's 19-21 view call is always the console-only/refused path — it records nothing and adds no ref. This slice is therefore a correctness and regression guard (a refused 19-21 view must not permanently exclude a class texture), not the fix for the remaining retained memory; that is slice 3b (descriptor-held textures whose slots are never overwritten). The fixture proves the ref contract through the probe counter and through the tracked-vs-untracked branch with the real budget oracle, and the docs say so rather than claiming a budget drop this cannot produce.Verified (
14d1c534onorigin/maine46d336c)WARP (
Microsoft Basic Render Driver) andNVIDIA GeForce GTX 1660 SUPER.docs_links_check.py(526 links),bidi_controls_check.py(1971 files),git diff --check: pass. Adjacent^startup_(resource_budget|view_census)→ 14 selected, 10 passed, 4_debug1skipped, 0 failed.Fail-first mutants (temporary edits, reverted; each fails on WARP, (c) on hardware too):
FAIL: RTV created in a tracked slot: 0 tracked slot refs, expected 1FAIL: RTV overwrote the slot: previous resource: 1 tracked slot refs, expected 0retire_leave_classfor 19-21FAIL: a refused view in a tracked slot kept the texture out of the retire class(retained=65536/1 expected=0/0)FAIL: copy heap destroyed: 1 tracked slot refs, expected 0Running the new fixture against the pre-change sources fails as expected (
retained=65536/1 expected=0/0), so it is fail-first rather than a fixture written to the new behavior.Not established
CreateUnorderedAccessViewwith a counter on a texture removes the device), so the counter half is driven with a structured buffer UAV; the shim still records the invalid console-style call as unmaterialized.X2W_D3D12_RELEASE_RETIRED_VIEWS=1still rewrites slot 18 only, so a 19-21 ref is never nulled and such a resource is kept — unreachable for class textures today, documented in the docs.Refs #2379. CC @JB2WIN @MasterDomino for the slice-3 split discussed on the issue — this is part 1; the never-overwritten-descriptor half (3b) is next and is the one that changes the memory outcome.
AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T03:39:51Z.
Review: COMMENTED
Review of
14d1c534(code + fixture tests only; the update with main did not change this PR's own diff).Checked:
view_refs_add/view_refs_release/view_refs_leave_classkeep add and release symmetric for slots 18-21, with the slot-19 counter handled on both sides.note_view,note_copy(both the tracked and the untracked source branches) andretire_drop_heap_viewsall go through the same helpers, so a slot-18 record behaves as before.view_slot<19..21>only keeps the oldretire_leave_classwhen the destination is untracked, so nothing is freed under a descriptor the shim cannot follow.Nit (not blocking):
git diff --checkreports a blank line at EOF intests/startup_resource_retire_title.cpp:1294.Commands run (Linux):
git diff --check origin/main...HEAD,python3 tests/docs_links_check.py,python3 tests/bidi_controls_check.py. The fixtures need the Windows build, so they are covered by the Win2025 run that follows.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T03:55:18Z.
Review: COMMENTED
Review of head
0630b20d(comment only).What I read:
d3d12_capture.inl(view_slot_names_resource,view_refs_add/release/leave_class,note_view,note_copy),d3d12_xs_device.cpp(view_slot<19..21>,retire_drop_heap_views,x2w_d3d12_retire_probe), docs. The ref accounting reads consistent: one ref per tracked slot, slot 19 also counts the counter resource, same-view rewrite changes nothing, copy adds before it releases, untracked destinations fall back toretire_leave_class.Blocking: Windows Server 2025 WARP fails on this head. Debug and release build fine, but the retire suite (
--regex startup_resource_retire, 26 tests) has 4 failures, reproduced on a second run:startup_resource_retire_views_warp_debug0startup_resource_retire_views_keep_warpstartup_resource_retire_views_hardware_debug0startup_resource_retire_views_keep_hardware(not the PR's fault if it is only the missing adapter, but it fails with the same stage)First error line of the WARP run:
FAIL: T1 kept although only a descriptor names it/stage 'T1 freed with its descriptor never overwritten' live=0/0 expected=0/0 retained=65536/1 expected=0/0So a resource named only by a slot-18 SRV (created by a slot 18 view into a tracked heap, never overwritten) stays retained after the title frees it. The
views_noretireandtitle/reasonssuites pass. I did not check whether the same stage also fails on current main, so please confirm whether this comes from the newtrackedpre-check inview_slotor from the probe change (as_wrapper(...)->own().realis no longer required to reportview_refs).Linux checks:
tests/docs_links_check.pyok,tests/bidi_controls_check.pyok,git diff --check origin/main...HEADclean.Not merged: Win2025 does not pass, so this stays open. Startup-path claims are not verified on the title; that stays with the maintainers.
Commands run:
x2w_pipe.py win2025 2719 --wait 7200 --keep-release(build only, pass) and... --regex startup_resource_retire(4 failed of 26).AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T03:28:24Z.
Codex Review Summary: ✅ Completed
This comment shows the latest Codex review activity on this pull request.
14d1c53ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-26T03:45:24Z.
On a local integration of the 3a slice with main, the full resource-retirement group passed 26/26 on WARP and RTX, including the existing same-slot rebind and no-retire controls. When integrating the docs, please keep the main row that makes X2W_D3D12_RELEASE_RETIRED_VIEWS diagnostic-only. The 3a branch also adds an older duplicate option row and a paragraph that still describes automatically replacing slot-18 views with null. Both need to be removed so the accepted #2679 compatibility behavior stays clear.
Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-26T03:48:30Z.
Thanks for the review and for merging main in (
73ff7829) � I adopted your merge commit as-is.Nit fixed in �630b20d ( ests: drop the trailing blank line at end of the title retire fixture): the file now ends at the closing brace with a single line terminator, so git diff --check reports nothing (verified after the commit: git diff --check exit 0).
Re-ran the affected fixtures on that head rather than assuming a whitespace-only change is inert:
cmake --build --preset dev --target startup_resource_retire_title startup_resource_retire startup_resource_retire_views # exit 0 ctest --preset dev --no-tests=error -R '^startup_resource_retire(_title|_views)?_' ? 100% tests passed, 0 tests failed out of 26 (6 _debug1 skips, no debug layer on this host)Nothing else changed: no code, no fixture assertions, no docs. The slice split you noted (3a = regression guard, 3b = the never-overwritten descriptor lifetime that actually changes retained memory) is unchanged, and 3b is the next thing I will bring.
Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-26T04:08:55Z.
Thanks � this is exactly the report I wanted, and I can explain the four failures: the tree your Win2025 run exercised is older than #2679, not head �630b20d.
Evidence:
293e77f6, Keep live SRVs intact during resource retirement, merged 2026-11-26T03:21:47Z, co-authored by you). git log --all -S'T1 freed with its descriptor never overwritten' shows exactly three commits: c97ade7 (added),d1d92612,293e77f6(removed).263dd96dcd. So that stage string cannot be emitted by head �630b20d.Could you re-run x2w_pipe.py win2025 2719 --wait 7200 --keep-release with a clean build directory / fresh checkout at �630b20d and paste the checked-out base sha? If it still fails on that exact tree, the failing stage will be one that exists in blob
263dd96dand I will fix it � but with a stale pre-#2679 tree the four failures are expected and not caused by this PR.One design note for the record: #2719 does not reinstate descriptor clearing. It tracks 19-21 slots symmetric with 18 and is documented as a regression guard, not a memory fix. The reverted #2579 behavior is the subject of the next slice (#2379 3b), which has to solve the live-SRV safety that #2679 re-established, and I will not bring it without the iews_keep cases agreeing.
Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-26T04:16:22Z.
Doc correction pushed as 527cabe on this branch (no code, no fixture change).
While checking this against #2679 I found my slice-3a docs commit had kept a row and a paragraph from the withdrawn descriptor-clearing behavior: docs/startup-runtime.md listed X2W_D3D12_RELEASE_RETIRED_VIEWS twice � once correctly as a legacy diagnostic, once claiming a released class texture whose only references are never-overwritten slot-18 descriptors "is freed once those slots are replaced by null descriptors". That has not been true since #2679 (
293e77f6), which removed the clearing and stated the rule that now holds: a tracked descriptor reference is an owner until the slot is overwritten, copied over, or its heap is destroyed.527cabe deletes the duplicate row and rewrites the paragraph to the current rule, citing #2679. docs_links_check (527 links) and idi_controls_check pass; git diff --check clean. The 19-21 accounting itself is unchanged � that part was accurate.
Separately: I confirmed the four Win2025 iews_* failures come from a pre-#2679 tree (that stage string was removed by #2679 and ests/startup_resource_retire_views.cpp is byte-identical to main at this head), so nothing in the code halves of this PR is failing. Head is now 527cabe.
Imported from R0Y00/Xbox2Windows. Originally posted by RonLogic on 2026-11-26T04:17:46Z.
Independent Windows Release rerun from a clean checkout of
0630b20d609b6565a1a26c34922cc8e197055fcf: 26/26 passed, no skips, on in-box WARP 10.0.26100.10068 and RTX 4070 (32.0.16.2124), Windows 11 build 26300.10075. All six_debug1cases ran and passed. I verified that the tested commit contains293e77f6(#2679). The current heada527cabeadds a docs-only change relative to the tested commit.Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-26T04:57:24Z.
@R0Y00 @RonLogic Thank you both!
X2W_D3D12_RELEASE_RETIRED_VIEWSkept diagnostic-only; duplicate row and withdrawn slot-18 null-replacement paragraph removed) are in the current heada527cabe(docs: drop the withdrawn descriptor-clearing claim from the retire section), verified withdocs_links_check.py(527 links) andbidi_controls_check.py.0630b20d(26/26 passed, 0 skips on in-box WARP10.0.26100.10068and RTX 407032.0.16.2124, Windows 11 build 26300.10075, verifying #2679 is present).a527cabeadds only the docs fix above on top of0630b20d.Per @R0Y00's decision on #2379 to keep design B, this PR (#2719) concludes slice 3 with the 19-21 regression guard and #2679 compatibility preserved.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-26T06:49:37Z.
Review: APPROVED
Approving
a527cabe, checked merged with currentmain(e3cf6a91).Runs (WARP 10.0.26100.9818 and AMD Radeon RX 9070 XT, driver 32.0.32029.2010; Windows 11 build 26300):
ctest --preset dev --no-tests=error -j 4 -R '^startup_(resource_retire|resource_budget|view_census|compute_dispatch_texture|pixel_uav)': 44/44 passed, no skips, including the debug-layer variants.No path frees a resource that a live UAV, RTV or DSV slot still names:
view_slotrefuses a 19–21 view without the matching flag, so a class texture never has a materialized 19–21 view, and a UAV counter is always a buffer.own().realbeforeRelease.The
X2W_D3D12_RELEASE_RETIREDdefault stays off, and_VIEWSstays diagnostic-only. That meets @R0Y00's 3a criteria: slots 19–21 hold their resource until overwritten, copied over, or their heap is destroyed, and the #2468 same-slot rebind fixtures are unchanged and pass.Negative controls, with the shim rebuilt for each:
view_slot_names_resource: 4 of 26 fail, "DSV created in a tracked slot: 0 tracked slot refs, expected 1".retire_leave_class: 4 of 26 fail, "a refused view in a tracked slot kept the texture out of the retire class".Non-blocking follow-ups:
view_refs_leave_classfor a tracked view copied into an untracked heap (d3d12_capture.inl:462) still passes all 26, for slot 18 as well. A case for that copy would cover the one safety branch this PR rewrote.docs/startup-runtime.mdsays a refused class-texture 19–21 view "records no view", but since #2710 a refused UAV records an unmaterialized one.AI-assisted; commands listed were executed locally.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-26T07:41:50Z.
@tedin7 @R0Y00: the Release segfault in
startup_resource_retire_titlefrom #2768 is fixed in #2774.small_resulttook a live wrapper left in rdx as the hidden-pointer form and overwrote the descriptor heap's vtable. #2719's case 9 exposed it at/O2.AI-assisted; commands listed were executed locally.