Repository navigation
startup: opt-in release of retired committed 2D textures after list and fence lifetimes (slice 1) - #2443
Conversation
…ELEASE_RETIRED) With X2W_D3D12_RELEASE_RETIRED=1, a committed 2D texture of one narrow class (slot 27 or 127, one sample, no render-target/depth/UAV flag, default heap, no title memory) gives up its desktop object after its final guest Release, but only when the release-time fence of every queue has passed and no recorded list or submission still names it. Lists hold the resource across copy, texture copy and resolve until Reset or destruction (an unsubmitted list is discarded without any submission); each submission holds it until a fence signalled behind it passes. Views, MakeResident/Evict and Present take a resource out of the class. Unset, nothing changes. The fixture startup_resource_retire uses the budget retained column as oracle and reads results back through its own desktop queue. AI-assisted (Claude Code) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Refs R0Y00#2379
…follow-up) - Check the CopyResource destination hold by behaviour first: the fixture no longer asserts the hold count before the destination-released stage. - The retire probe export returns FALSE without the switch. - Document that the switch needs X2W_D3D12_RENDER=1, that a title exporting __XMemAllocationHooks__ leaves slot 127 outside the class, and the debug layer skip. Lists drop their holds on Reset, destruction or a Close that fails. - Take the submission reference only after its fence was signalled; shorten comments. AI-assisted (Claude Code) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Refs R0Y00#2379
triggered02
left a comment
There was a problem hiding this comment.
Independent Windows verification and audit of 1ecd4cfc (no P1/P2 bugs found).
Verified locally on Windows (F:\x2w-wt-2443)
- Built
d3d12_xs_shimandstartup_resource_retirewithcmake --preset dev(MSVC). ctest --preset dev --no-tests=error -R '^startup_resource_(retire|budget)' -V(focused retire targets built):startup_resource_retire_warp_debug0: PASS (Microsoft Basic Render Driver,debug_layer=off,mode=on,debug_errors_or_warnings=0)startup_resource_retire_off_warp: PASS (debug_layer=off,mode=off)startup_resource_retire_hardware_debug0: PASS (NVIDIA GeForce GTX 1660 SUPER,debug_layer=off,mode=on,debug_errors_or_warnings=0)startup_resource_retire_off_hardware: PASS (NVIDIA GeForce GTX 1660 SUPER,debug_layer=off,mode=off)*_debug1: skipped (77) — Graphics Tools debug layer is not installed on this host.
Audit notes
- Lock ordering & lifecycle:
retire_lockstays strictly a leaf lock (never acquired beforedraw_lock/allocator_lock/target_lock/pending_writes_lock);retire_note_submissionruns underdraw_lock+allocator_lockright afterExecuteCommandLists;drain_retired_resourcesusesTryAcquireSRWLockExclusiveand runs allID3D12Resource::Release()calls after releasingretire_lock;retire_queuesis append-only and queues never drop their desktop pointers inrelease(). - P3 — Unprotected
dropped.insertunderretire_lockindrain_retired_resources()(d3d12_xs_device.cpp):dropped.reserve(batch)is guarded before takingretire_lock, but theretire_flightsloop can exceedbatchand growdroppedviadropped.insert(...)while holdingretire_lockwithouttry/catchor an RAII lock guard (ifstd::bad_allococcurred there,retire_lockwould stay held and already-poppedretired_resourcesentries withreal = nullptrwould leak their desktop references). Stopping the flight loop before exceedingbatchwhen!dropped.empty()(or reserving insidetry/catchwith an RAII guard) would close that. - P3 — Minor fixture hygiene/coverage:
ComPtr<IUnknown> fence;inmake_queue(startup_resource_retire.cpp:252) is unused;title_memoryinclasses()leaks on the earlyreturn falsepath; and failedClose(), double-submitting one closed list,Evict(slot 35), and RTV/DSV/UAV exclusions (view_slot<19..21>) are verified by inspection rather than dedicated sub-cases.
AI-assisted (Gemini).
MasterDomino
left a comment
There was a problem hiding this comment.
AMD data for head 1ecd4cfc. This adds a hardware vendor to @triggered02's GTX 1660 SUPER run, plus the debug-layer variants that host had to skip.
Commands (Windows 11 build 26300, --preset dev):
cmake --build --preset dev --target d3d12_xs_shim startup_resource_retire startup_resource_budget
ctest --preset dev --no-tests=error -V -R '^startup_resource_(retire|budget)'Result: 14/14 passed, with no skips.
- Adapters: AMD Radeon RX 9070 XT (1002:7550, driver 32.0.32029.2010) and WARP 10.0.26100.9818.
- Retire fixtures, on both adapters:
retire_*_debug0:debug_layer=off mode=on;retire_*_debug1:debug_layer=enabled mode=on,debug_errors_or_warnings=0;retire_off_*:mode=off.
- Budget fixtures: all 8
startup_resource_budget_*cases, including the inline controls, pass unchanged with this branch.
The retire fixture's fences, list holds and release-time fence therefore behave the same on AMD as on NVIDIA and WARP, including under the debug layer.
Not covered here: I didn't rerun the 11 mutants or a title run. Per @JB2WIN's note in #2379, slice 1 doesn't reach the slot 133 title-memory textures that grow in local start-up runs, and that work continues in slice 2.
This is runtime code, so I'm leaving the verdict to the maintainer.
AI-assisted; commands listed were executed locally.
MasterDomino
left a comment
There was a problem hiding this comment.
Approved at head 1ecd4cfc. Slice 1 of #2379: an opt-in release of retired committed 2D textures (X2W_D3D12_RELEASE_RETIRED=1). This is the slice requested in #2379, and @triggered02's audit found no P1 or P2.
Fixture results (source-built)
Windows 11 build 26300, --preset dev:
cmake --build --preset dev --target d3d12_xs_shim startup_resource_retire startup_resource_budget
ctest --preset dev --no-tests=error -V -R '^startup_resource_(retire|budget)'- 14/14 pass on the AMD Radeon RX 9070 XT (1002:7550, driver 32.0.32029.2010) and WARP 10.0.26100.9818, with no skips. This includes
retire_*_debug1with the D3D12 debug layer enabled (debug_errors_or_warnings=0) andretire_off_*(switch off, behaviour unchanged). - The 8
startup_resource_budget_*cases pass unchanged. - The branch merges cleanly with current
main.
Negative control
I applied each mutant to drain_retired_resources() in src/startup_stubs/d3d12_xs_device.cpp, rebuilt, ran it, then reverted:
| Mutant | retire_{warp,hardware}_debug0 |
|---|---|
M1: release-time fence ignored (reached = true) |
fail, FAIL: early release (release-time fence) |
M2: submission fence ignored (flight check if (false)) |
fail on both adapters, FAIL: early release (submission fence) |
After reverting and rebuilding, all 14 pass again.
Executable results (separate from the fixtures; local title run, aggregates only)
This slice makes no start-up claim. @JB2WIN's measurement in #2379 shows it releases 0 resources in the title's start-up, where the growing class is slot 133 with title memory. That class is #2468's scope, stacked on this PR. My own executable pair in #2379 used the unreviewed v2 prototype, not this commit.
Merge checks
- Required CI passed at this head. The
/O2and coverage skips come from explicit workflow conditions. - There are no unresolved review threads.
- There are no dependencies.
@triggered02's P3 notes stay open as follow-ups: the dropped.insert growth under retire_lock in a bad_alloc case, and the fixture hygiene items.
AI-assisted; commands listed were executed locally.
Refs #2379. First source-built slice, as asked in the issue: one committed texture class whose uses are accounted for. Opt-in through
X2W_D3D12_RELEASE_RETIRED=1(needsX2W_D3D12_RENDER=1). When unset, nothing changes, and a fixture case checks that.What changes
Fixture
startup_resource_retire(WARP and hardware, plusoffand debug-layer variants)retainedcolumn until that fence is signalled.offcase runs without the switch and requires the previous behaviour.Mutants (local patches, each reverted after the run): 11 patches. Each makes the fixture fail with its own FAIL line:
Tests
Host: RTX 3080, driver 32.0.16.2124, Windows 11 26200, release build on top of
7092683a.Observation from a local start-up run (not a fixture, same host): 600 s with the switch,
X2W_D3D12_BUDGET=1and a 40 GiB job cap.texture retainedreached 7.6 GB, and local video memory was 17.1 GB against a 9.5 GB budget.Not tested:
__XMemAllocationHooks__(slot 127 then leaves the class, as documented);AI-assisted (Claude Code)
🤖 Generated with Claude Code