startup: opt-in release of retired committed 2D textures after list and fence lifetimes (slice 1) #2435
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2443"
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 JB2WIN on 2026-11-25T16:57:16Z.
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
Imported from R0Y00/Xbox2Windows. Originally posted by triggered02 on 2026-11-25T17:18:04Z.
Review: COMMENTED
Independent Windows verification and audit of
1ecd4cfc(no P1/P2 bugs found).Verified locally on Windows (
F:\x2w-wt-2443)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
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().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.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).
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T17:31:51Z.
Review: COMMENTED
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):Result: 14/14 passed, with no skips.
retire_*_debug0:debug_layer=off mode=on;retire_*_debug1:debug_layer=enabled mode=on,debug_errors_or_warnings=0;retire_off_*:mode=off.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.
Imported from R0Y00/Xbox2Windows. Originally posted by MasterDomino on 2026-11-25T18:26:16Z.
Review: APPROVED
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:retire_*_debug1with the D3D12 debug layer enabled (debug_errors_or_warnings=0) andretire_off_*(switch off, behaviour unchanged).startup_resource_budget_*cases pass unchanged.main.Negative control
I applied each mutant to
drain_retired_resources()insrc/startup_stubs/d3d12_xs_device.cpp, rebuilt, ran it, then reverted:retire_{warp,hardware}_debug0reached = true)FAIL: early release (release-time fence)if (false))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
/O2and coverage skips come from explicit workflow conditions.@triggered02's P3 notes stay open as follow-ups: the
dropped.insertgrowth underretire_lockin abad_alloccase, and the fixture hygiene items.AI-assisted; commands listed were executed locally.