Repository navigation
startup: track UAV/RTV/DSV descriptor slots in the retire class (slice 3a) - #2719
Conversation
…3a, Refs R0Y00#2379) view_slot<19>, <20> and <21> took their resource out of the retire class unconditionally (slot 19 twice, for its resource and its counter), so a class texture named by a UAV/RTV/DSV descriptor could never be freed. - d3d12_capture.inl: view_refs_add/release/leave_class handle slots 18-21 as one reference per tracked descriptor slot (slot 19: one for the resource and one for the counter). note_view adds a materialized view's refs when the destination slot is tracked, releases the previous record's refs on overwrite, and keeps the retire_leave_class fallback for a descriptor no shadow slot tracks. note_copy moves refs with the copied views, releases the overwritten destination's refs, and leaves the class only when the copy goes into an untracked heap. - d3d12_xs_device.cpp: view_slot<19..21> looks the destination up with shadow_slot() under note_lock (note_view's existing lock): a tracked slot lets note_view own the accounting and keeps the resource in the class; an untracked slot or a destination with no desktop handle keeps retire_leave_class. A destroyed descriptor heap drops the refs of every tracked slot. - x2w_d3d12_retire_probe: reports retire_view_refs as view_refs (fixture-only). - startup_resource_retire_title: case 8 drives RTV/DSV/UAV references through create, the same view again, overwrite, descriptor copy and heap destruction (plus a slot-19 counter); case 9 covers the tracked and untracked fallback of a refused view on a class texture in both switch modes. No freeing rule change: the drain still frees only at retire_view_refs == 0.
…, Refs R0Y00#2379) - startup-runtime.md#d3d12-resource-budget: the tracked descriptor slots now cover 18-21, one reference per materialized view (slot 19 also for its counter resource), released by overwrite, descriptor copy and heap destruction; the untracked-heap retire_leave_class fallback stays. Notes that the class still excludes RT/DS/UAV textures, so a class texture's 19-21 view is the refused console-only case today, and that RELEASE_RETIRED_VIEWS keeps rewriting only slot 18 SRVs. - experiments.md: new Slice 3a section with the WARP/GTX 1660 SUPER fixture results and the four failing mutants; closes the code fence the Slice 2 section left open.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour 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. |
tedin7
left a comment
There was a problem hiding this comment.
Review of 14d1c53 (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.- The PR states that a class texture's 19-21 view is always the refused path (so this is a regression guard, not a memory fix), and the docs say the same. Good.
- Fixtures: cases 8 and 9 assert the ref counts via the probe and the retained budget. The mutation table in the PR body covers add, release-on-overwrite, release-on-heap-destroy and the old unconditional leave-class.
- No other open or merged PR covers this slice. No game or startup claim.
Nit (not blocking): git diff --check reports a blank line at EOF in tests/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.
|
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. |
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.