Skip to content

startup-runtime: guest-released committed textures are never freed, so local video memory exceeds the DXGI budget until the device is removed #2379

Backlog

Description

@JB2WIN

Commit or build

Upstream main at 09551998, Release build.

Summary

With X2W_D3D12_BUDGET=1, a start-up run shows guest-released committed textures accumulating in the retained column until DXGI local usage is more than twice the local budget. Shortly after, the device is removed. release() in src/startup_stubs/d3d12_xs_device.cpp keeps every wrapper and its desktop object for the life of the process ("The wrappers and their desktop objects stay alive for the process (experiment scope)."), so the local allocation of a released texture is never returned.

Environment

Windows 11 Pro 26200, i5-13600K, NVIDIA GeForce RTX 3080 10 GB (driver 32.0.16.2124), 32 GB RAM plus a 32 GB page file. Debug layer off.

Command

$env:X2W_D3D12_BUDGET = "1"
.\tools\startup\run.ps1 -Exe <dir>\<title>.exe -DataDir <package root> -LogDir out\startup\run15 -Seconds 600 -MemoryGiB 40 -Render -Translate -FakeUser -GpuMirror -HostCpu -StartupBelow40 -ContinueAsserts 1000 -InputScript "<menu script>" -StoragePath <dir>

Observed

x2w-budget lines from one run (71 heartbeats):

Heartbeat local usage / budget texture live (bytes/objects) texture retained (bytes/objects)
1 0.56 GB / 9.73 GB 0.30 GB / 32 0 / 0
25 (first over budget) 8.6 GB / 8.1 GB
71 (last) 21.5 GB / 9.1 GB 7.0 GB / 2,283 13.4 GB / 6,226

Buffers retained at the last heartbeat: 0.60 GB / 8,420 objects.

At 372 s: x2w-d3d12 DEVICE REMOVED, reason 0x887a0007, first noticed after Device view 18. Two earlier runs with the same -MemoryGiB 40 reported DEVICE REMOVED, reason 0x887a0005, first noticed after CommandQueue execute 35 at 419 s and 348 s, followed by Present failed 0x887a0005 and every thread waiting until the timeout. Runs with -MemoryGiB 28 stopped earlier on E_OUTOFMEMORY from CreatePlacedResource and never reported a device removal.

Expected

A resource whose last guest reference is released has its desktop allocation freed once the GPU work that can still reference it has completed, so local usage stays near the live column.

Not established

That the overcommit causes the device removal: this is a correlation from the budget heartbeat, not a traced cause. The live column alone (7.0 GB of textures) would fit the budget.

I am prototyping a deferred release (after the queues pass a fence recorded at the final guest release) locally and will report measurements here before opening a PR.

AI-assisted (Claude Code).

Activity

  1. R0Y00 commented on Nov 25, 2026

    @R0Y00
    Owner

    Please continue the prototype here. For the first source-built slice, choose one committed texture class whose uses can be accounted for. Record its use before the guest drops its last reference, then submit while the queue is held at a fence. A second recording should also be able to hold the same object. The fixture should prove that both recordings still see the expected pixels, that release happens only after the last relevant fence, and that discarded recordings drop their references without inventing a submission. An early-release mutant should fail. Keep the existing descriptor and address-lookup lifetime for paths without this proof.

    Please keep local-budget and process-commit samples separate. Compare at the same load progress and record the first device failure and debug-layer status when available. The budget report gives a retention signal; the removal cause is still open.

  2. JB2WIN commented on Nov 25, 2026

    @JB2WIN
    ContributorAuthor

    Local prototype result (branch not pushed yet). Same host and command as above, build f555b535 plus the prototype, X2W_D3D12_BUDGET=1.

    The prototype, behind an opt-in X2W_D3D12_RELEASE_RETIRED=1, releases a resource's desktop object after its final guest release, once every shim-created queue has passed a fence signalled at that release. It covers committed resources from slots 27 and 127, and slot 133 textures and non-aliased buffers. Aliased placements, heaps and tiled address SRVs stay retained. The wrapper storage is kept. The resource is removed from the address index and the per-pointer caches before the desktop release.

    Run max local / budget texture retained at the end device removed
    without the switch 21.5 GB / 9.1 GB 13.4 GB / 6,226 yes, 372 s
    first version (no title_memory resources) 21.6 GB / 8.7 GB 14.8 GB / 6,721 yes
    with slot 133 included 10.3 GB / 8.7 GB 0 / 0 no, 600 s time limit reached

    In the last run, 43,000 resources were freed (35.7 GB in total over the run), the process commit peak dropped from about 32 GB to 22.8 GB, and 15,500 frames were presented.

    Source-built check (startup_resource_retire_{warp,hardware}, plus _off_ variants without the switch) on WARP and the RTX 3080: a release while the queue is held by an unsignalled fence wait is not freed until the gate is signalled, retained returns to the baseline afterwards, and a new slot 133 texture at the same title address finds only the new wrapper. Two mutations fail it: freeing without the fence condition, and skipping the address index removal. ctest --preset release --no-tests=error -R 'd3d12|budget|startup_draw|offscreen|startup_stubs|startup_resource_retire|capture|memory_srv|placed': 84 passed, 0 failed, 1 skipped (d3d12_xs_shim_heap_indexing, 77, also skipped without the change).

    Not established: multi-queue and multi-thread release races beyond the fixture, and a title that uses a resource after its final release (Map, GetDesc and GetGPUVirtualAddress would then dereference a null desktop object).

    AI-assisted (Claude Code).

  3. R0Y00 commented on Nov 25, 2026

    @R0Y00
    Owner

    The matched opt-in run and same-address reuse check are useful. Please publish the source-built fixture and the narrowest texture slice when ready. A fence signalled at final guest Release covers work already queued on that queue. A command list may already reference the texture while still waiting to be submitted. The next discriminator is to record two lists, release the last guest reference while both are closed but unsubmitted, let the Release-time fences complete, and then submit the lists separately. Both must read back correctly. Hold the second submission at its own fence and verify retirement waits for it. Add Reset or destruction of an unsubmitted list as the discard case. This would pin the recording and submission lifetime before expanding to more resource classes. The run is useful progress evidence on this host. The precise device-removal cause remains open.

  4. MasterDomino commented on Nov 25, 2026

    @MasterDomino
    Collaborator

    An AMD data point that matches this, and how it ends when the job commit cap is reached first.

    Setup:

    • main at 7092683a, Release, X2W_D3D12_BUDGET=1.
    • AMD Radeon RX 9070 XT, 16 GB, driver 32.0.32029.2010.
    • Windows 11 build 26300, 64 GB RAM.
    • -Render -Translate -FakeUser -GpuMirror -StartupBelow40 -MemoryGiB 32, warm cache, fresh storage.
    • Input that clears first-run setup and the acceptance page.
    x2w-budget heartbeat local usage / budget texture live (GiB/objects) texture retained buffer retained
    1 0.5 / 16.2 GB 0.25 / 32 0 / 0 0 / 0
    47 (before confirmation) 5.3 / 16.2 GB 4.17 / 1,238 0.08 / 13 0.00 / 2
    71 (post-confirmation load) 12.7 / 16.2 GB 6.51 / 2,596 4.62 / 2,324 0.22 / 3,421
    95 (last) 18.9 / 16.2 GB 6.70 / 2,427 10.32 / 5,115 0.71 / 11,190

    Placed, upload, readback and heap stay flat, and unmeasured is 0.

    • Commit grows with the retained columns. The process commit from the storage heartbeat is about 11.6 GB until confirmation, then 18.7, 24.3 and 29.7 GB at 320, 380 and 440 s, until the 32 GiB job cap.
    • The run ends at the cap, not in a device removal.
      • The stand-in logs an XMemMapPhysicalPagesScatter map-view failure with error 1455.
      • Queue slot 31's pool request fails with 0x800705af.
      • The title then takes a second-chance null-object read in the main executable at about 495 s.
      • In three runs on this build and on a branch based on it, the stop came at 492–507 s, after the opening credits had rendered.
    • Raising the cap only moves the end. With -MemoryGiB 48 the same input reaches the 600 s limit, and commit is still rising: 25.7 GB at 410 s, 32.0 at 470 s and 38.1 at 560 s.
    • An earlier build peaked much lower. At c374c7bf this morning, the same post-confirmation phase peaked at 20 GB by 560 s and was levelling off. I haven't bisected which change since then increased the texture churn.

    When the X2W_D3D12_RELEASE_RETIRED fixture and slice are published, I can rerun this matched input on the RX 9070 XT with the opt-in on and off, and report the budget columns and the end point.

    AI-assisted.

  5. JB2WIN commented on Nov 25, 2026

    @JB2WIN
    ContributorAuthor

    Status, for anyone picking this up:

    • Slice 1 is startup: opt-in release of retired committed 2D textures after list and fence lifetimes (slice 1) #2443 (opt-in X2W_D3D12_RELEASE_RETIRED=1). It covers committed 2D textures from slot 27/127 without title memory, with list holds, submission fences and release-time fences, as requested above. The fixture covers the two-list, held-second-submission and discard cases, and 11 local mutants fail it. Please leave review comments on that PR. I keep pushing to its branch myself.
    • Open: slice 2. The class has to be extended to slot 133 textures with title memory: these are the ones that grow in local start-up runs (in my 600 s run, texture retained reached 7.6 GB and slice 1 released 0). This needs the proof that is still missing for the title-address index (resource_address_index / existing_memory_texture), texture_uploads, written_textures and descriptor or view reuse, before anything there is freed.
    • If you start on slice 2, please say so here first, so that we do not build the same thing twice. Base it on startup: opt-in release of retired committed 2D textures after list and fence lifetimes (slice 1) #2443 or wait until it is merged.

    AI-assisted (Claude Code)

  6. triggered02 commented on Nov 25, 2026

    @triggered02
    Contributor

    Claiming Slice 2 (based on #2443 at 1ecd4cfc), extending X2W_D3D12_RELEASE_RETIRED=1 to slot 133 (device_place_resource_x) committed 2D textures with title_memory (keeping non-RT/DS/UAV, 1-sample, DEFAULT heap, and keeping slot 127 __XMemAllocationHooks__ resources excluded).

    Plan for the four Slice 2 requirements listed above:

    1. resource_address_index / existing_memory_texture: Erase (title_memory, wrapper) from resource_address_index() under note_lock when drain_retired_resources() claims the retired wrapper (refs CAS 0 -> retired_refs), keeping resource_infos() intact. Verify same-address slot 133 + slot 70 existing_memory_texture() reuse and X2W_RESOURCE_INDEX_CHECK=1.
    2. texture_uploads / pending_gpu_writes / list_copy_texture: Fix list_copy_texture.inl to check title_memory (rather than !retire_when_idle) so retiring slot 133 textures still upload on CopyTextureRegion; synchronize texture_uploads() in list_copy.inl / list_copy_texture.inl under draw_lock; erase real from texture_uploads() under draw_lock in drain_retired_resources() before real->Release().
    3. written_textures: Snapshot written_textures()[addr].generation at final guest Release() and clear stale entries on retirement only when the generation is unchanged and no tiled_address_srv exists at addr (preserving any newer XG / slot-70 write at the same address while preventing stale bc7_width / desktop_rows from skipping a later texture's upload).
    4. Descriptor & view reuse (view_slot<18> SRVs + draw_translated): Track shadow_slot descriptor references in note_view / note_copy / descriptor-heap release() (falling back to retire_leave_class if a view targets an untracked slot or slots 19/20/21), and hold bound SRV textures in draw_translated via retire_hold(list, resource). Existing #2443 controls (including a resource whose SRV remains live in a descriptor heap) stay retained; once overwritten/freed and all lists/fences complete, the slot 133 texture retires.

    Will build and verify on WARP and physical hardware (GTX 1660 SUPER) with source-built fixtures + fail-first mutations, and open a PR stacked on #2443.

    AI-assisted (Gemini).

  7. triggered02 commented on Nov 25, 2026

    @triggered02
    Contributor

    Slice 2 draft PR (stacked on #2443 at 1ecd4cfc) is up: #2468. Verified on WARP and GTX 1660 SUPER (startup_resource_*, startup_list_copy*, startup_address_srv_*: 29 passed, 8 debug1 skipped, 0 failed) plus 4 fail-first mutations covering slot-133 upload/copy holds, resource_address_index/slot-70 same-address reuse (X2W_RESOURCE_INDEX_CHECK=1), written_textures stale bc7_width cleanup, and tracked slot-18 SRV descriptor reuse.

  8. JB2WIN commented on Nov 25, 2026

    @JB2WIN
    ContributorAuthor

    @triggered02 thanks for taking slice 2. For comparison, here is a local start-up data point on the same host (RTX 3080 10 GB, 32 GB RAM plus 32 GB page file, 40 GiB job cap, X2W_D3D12_BUDGET=1). It uses the unreviewed v2 prototype, which also frees slot 133 committed stand-ins with title memory after the release-time fences (it does NOT have the list-hold proof from #2443):

    run build end freed local / budget at the end texture retained OOM / device removed
    A #2443 (slice 1) access violation at 435 s after 8× E_OUTOFMEMORY in slot 133 placement 0 22.4 / 9.4 GB 13.7 GB 8 / 0
    B v2 prototype process exited normally at 753 s 21000 resources, 16.3 GB 8.7 / 9.5 GB 0 0 / 0

    So slot 133 title-memory textures are the class that matters in that workload. The v2 branch is JB2WIN:experimental/release-retired-v2 for testers only. It is not proposed for merge.

    AI-assisted (Claude Code)

  9. MasterDomino commented on Nov 25, 2026

    @MasterDomino
    Collaborator

    AMD data point for @JB2WIN's experimental/release-retired-v2 (bf937be2, one commit on main 673d8e4a). I used one release build for both arms, with only X2W_D3D12_RELEASE_RETIRED differing.

    Host:

    • GPU and OS: AMD Radeon RX 9070 XT (16 GB, driver 32.0.32029.2010), Windows 11 build 26300, 64 GB RAM.
    • Run settings: a 32 GiB job cap, X2W_D3D12_BUDGET=1 and X2W_D3D12_RENDER=1 (run.ps1 -Render), 600 s.
    • Input: the same scripted input in both arms; the passes repeat every 35 s from 190 s to 400 s to clear the agreement page.
    • Shader cache: a warm local cache, the same one for both arms.
    arm end freed peak local / budget texture retained, peak 0x8007000e / device removed
    off (= main 673d8e4a) access violation in the title at 493.9 s 0 21.0 / 16.2 GB 11.40 GB / 5171 14 / 0
    on still running at the 600 s timeout 23000 resources, 18.8 GB 10.3 / 16.2 GB 0.01 GB / 8 0 / 0

    System commit was 25.5 GiB before the runs and 24.4 GiB 10 s after each exit. Neither arm left a commit increase behind.

    This matches the RTX 3080 table above: on AMD too, slot 133 committed stand-ins with title memory are the class that grows, and freeing them after the release-time fences keeps the run inside the budget. The off arm also reproduces the ~495 s crash at this cap that I reported earlier on 7092683a.

    Limits:

    I'll run the same input on #2468 once its next head (the S3 fix) is up.

    AI-assisted; runs executed locally, aggregates only.

  10. R0Y00 commented on Nov 25, 2026

    @R0Y00
    Owner

    Slice 2 is on main in #2468 (6b9fb9d9). The final Release candidate passed all 12 focused WARP and RTX 4060 Laptop retirement tests. The same-address control fails if the older descriptor's view reference is ignored. @MasterDomino, your offered matched run is now unblocked. Keep the executable, saved profile, cache, job cap and observation interval identical, flip only X2W_D3D12_RELEASE_RETIRED, and report retained bytes/count, DXGI budget/peak, first failure or timeout, and the last visible stage. The earlier prototype run remains separate evidence.

  11. MasterDomino commented on Nov 25, 2026

    @MasterDomino
    Collaborator

    @R0Y00, here is the matched run you asked for, on main 6b9fb9d9 (#2468 merged).

    Setup:

    • Build: one release build for both arms; only X2W_D3D12_RELEASE_RETIRED differs.
    • Run settings: the same executable, saved profile and warm shader cache, a 32 GiB job cap, X2W_D3D12_BUDGET=1, run.ps1 -Render, and a 600 s observation window.
    • Input: the same scripted input, which clears the legal and acceptance page.
    • Host: AMD Radeon RX 9070 XT (16 GB, driver 32.0.32029.2010), Windows 11 build 26300.
    switch off switch on
    first failure or timeout access violation in the title at 490.7 s, after 8× 0x8007000e none; still running at the 600 s timeout
    0x8007000e / device removed 8 / 0 0 / 0
    desktop references dropped by the retire drain 0 53,000
    texture retained, peak 10.67 GB / 4,874 (at the failure) 9.41 GB / 4,364
    texture retained, end 10.67 GB / 4,874 9.10 GB / 4,267
    DXGI local usage / budget, peak 20.32 / 14.51 GB 19.91 / 14.46 GB
    DXGI non-local usage, peak 6.01 GB 6.43 GB
    system commit 10 s after exit 24.9 GiB 25.0 GiB (no growth left behind)
    last visible stage a rendered in-title scene, the same scene the earlier runs reached the final capture at 600 s is one uniform constant color; frame and draw counters were still advancing (see below)

    Retention over time (budget heartbeats about 5 s apart, retained bytes / count):

    arm ~290 s ~375 s ~460 s ~520 s
    off 0.08 GB / 13 6.00 GB / 2,817 (~370 s) 7.83 GB / 3,792 (~430 s) failed at 490.7 s
    on 0.08 GB / 8 3.80 GB / 1,810 6.28 GB / 2,903 9.39 GB / 4,360

    Plainly: in this pair slice 2 removed the out-of-memory failure within the 600 s window, but it does not remove the blocker.

    • Retention: still climbs in steps to about 9.4 GB and doesn't come back down.
    • Budget: local usage stays about 5.4 GB over the DXGI budget.
    • Margin: an earlier run of the same runtime code at d03296d3 failed at 573.8 s under the same cap, so surviving to 600 s is marginal, not a fix.
    • Consistency: a second switch-on run at e29b1a7b, which has the same slice 2 code, also reached the timeout, with 9.14 GB retained.
    • Compared with v2: the unreviewed v2 prototype kept retention at 0.01 GB, so most of the remainder is releasable in principle.

    About the uniform-color frame: both earlier switch-on runs ended at 600 s on the same rendered sequence as the off arm, so this capture differs. Translation activity was comparable: 763,721 translated draws and 72 translated programs on this arm, against 781,344 and 71 at e29b1a7b. I can't attribute the uniform-color frame from one capture and am only recording it.

    What's left, which as far as I can see no issue or PR covers yet (a "slice 3"):

    1. Descriptor-held textures: slot 133 textures that stay counted through descriptor slots that are never overwritten (the S7 hypothesis on startup: release retired slot-133 title-memory textures and track slot-18 SRV reuse (slice 2) #2468), which is most of the ~9 GB above.
    2. UAV/RTV/DSV views: the slots 19–21 branch that @ChazY11 found no fixture drives on startup: release retired slot-133 title-memory textures and track slot-18 SRV reuse (slice 2) #2468.

    Does anyone (@JB2WIN, @triggered02) already plan this? If not, I can open an issue for it.

    Limits: one run per arm, and these are local executable runs, not source-built fixtures. I checked aggregate counters only; I didn't verify per resource. No addresses, paths or captures are posted.

    AI-assisted; runs executed locally.

  12. 7 remaining items

  13. SimSalabimse commented on Nov 25, 2026

    @SimSalabimse
    Contributor

    Follow-up measurement (tip fb2f86ac, after account picker)

    Environment: Windows 11 10.0.26200, RTX 4070 Ti driver 32.0.16.2135, FakeUser offline, xgameruntime.dll present under System32. Account picker advances (QueryApiImpl / providers proxied).

    subst G: "<package root>"
    .\tools\startup\run.ps1 `
      -Exe "<title>.exe" -DataDir "G:\" -BuildDir out\build\dev `
      -LogDir out\startup\av-tip-retest `
      -Seconds 600 -ContinueAsserts 1000 -Render -Translate -FakeUser -GpuMirror `
      -TraceApi -InputScript "20@90,4@120,4@180"

    Without retire switches (build=fb2f86ac): earlier null AV in d3d12_xs on 381abc31 is gone. Stop is a title soft-assert (0x80000003) at ~255 s with rax/rcx=0x8007000e. Immediately before that: several CreatePlacedResourceX texture creates return 0x8007000e, plus multiple DirectStorage out of memory lines.

    With #2579 opt-ins:

    $env:X2W_D3D12_BUDGET='1'
    $env:X2W_D3D12_RELEASE_RETIRED='1'
    $env:X2W_D3D12_RELEASE_RETIRED_VIEWS='1'
    $env:X2W_D3D12_RETIRE_REASONS='1'
    # same run.ps1 … -LogDir out\startup\av-tip-retire

    Budget/retire heartbeats appear (x2w-budget / x2w-retire held: never-class:…). Failure mode changes: second-chance C++ exception (0xe06d7363) ~254 s with stack dominated by xmem.dll (not the title int3). CreatePlaced E_OUTOFMEMORY counts were not clearly eliminated.

    Not claiming this proves the device-removal path in the OP; it is the same chapter (post-picker resource pressure / retained desktop objects) measured on another host after FakeUser sign-in works.

    Refs #2379. Part of #870 only as startup-runtime measurement.

    AI-assisted.

  14. SimSalabimse commented on Nov 25, 2026

    @SimSalabimse
    Contributor

    Tip measurement (build=fb2f86ac) — retire A/B after account picker

    Same host past the account picker (-FakeUser, System32 xgameruntime.dll present). Title-neutral; no game files.

    Environment: Windows 11 Pro 10.0.26200.8655 · NVIDIA GeForce RTX 4070 Ti · driver 32.0.16.2135 · tip stand-ins stamped D3D12XboxCreateDevice … build=fb2f86ac.

    Without retire / budget switches

    .\tools\startup\run.ps1 `
      -Exe <run-dir>\<title>.exe `
      -DataDir <package-root> `
      -BuildDir out\build\dev `
      -LogDir out\startup\tip-oom-assert `
      -Seconds 400 `
      -ContinueAsserts 1000 `
      -Render -Translate -FakeUser -GpuMirror `
      -InputScript "4@70"
    • Eight Device::slot133(CreatePlacedResourceX?) … -> 0x8007000e not aliased
    • Twelve DirectStorage out of memory
    • No x2w-budget / x2w-retire lines
    • Stop: first-chance 0x80000003 at game_scarlett_master.exe+0x193e00f after 254.62 s with rax/rcx/rsi = 0x8007000e (title soft-assert on OOM)
    • Prior d3d12_xs.dll+0x1635a70 AV (build=381abc31) is gone on tip

    With BUDGET + RELEASE_RETIRED + RELEASE_RETIRED_VIEWS + RETIRE_REASONS

    $env:X2W_D3D12_BUDGET = "1"
    $env:X2W_D3D12_RELEASE_RETIRED = "1"
    $env:X2W_D3D12_RELEASE_RETIRED_VIEWS = "1"
    $env:X2W_D3D12_RETIRE_REASONS = "1"
    .\tools\startup\run.ps1 `
      -Exe <run-dir>\<title>.exe `
      -DataDir <package-root> `
      -BuildDir out\build\dev `
      -LogDir out\startup\tip-retire-oom `
      -Seconds 400 `
      -ContinueAsserts 1000 `
      -Render -Translate -FakeUser -GpuMirror `
      -InputScript "4@70"
    • CreatePlacedResourceX 0x8007000e: still 8 (not reduced)
    • DirectStorage out of memory: still 12 (not reduced)
    • x2w-budget / x2w-retire: 35 heartbeats each (switches live); late x2w-retire held: still shows never-class held resources (~100–137 MiB)
    • Stop: second-chance C++ exception 0xe06d7363 at KernelBase.dll after ~253.66 s, return-address stack dominated by xmem.dll (not the title int3 OOM soft-assert)

    Takeaway

    Opt-in retire (#2579 path) is active here but does not clear the CreatePlaced / DStorage OOM prelude on this tip host run; it does change the debugger stop to an xmem-dominated C++ exception. Filing as a comment on this issue rather than a duplicate tracker.

    AI-assisted analysis of uploaded stderr/finished logs.

  15. R0Y00 commented on Nov 25, 2026

    @R0Y00
    Owner

    Thanks for the paired comparison. On the reported build, both runs still recorded eight placed-resource allocation failures and twelve DirectStorage OOMs. The retirement switches changed the later debugger stop, while those earlier counts stayed the same. For the next bounded replay, please record process commit and local video-memory budget/usage immediately before the first failure in each run, plus the first failing subsystem and result code. The four-switch comparison can establish whether the failure moves; a single-switch comparison can then identify which setting matters. Keep addresses, raw logs and private input local. The live-slot rebind guarantee and the #2468 check still apply.

  16. Not-Saii commented on Nov 26, 2026

    @Not-Saii
    Contributor

    A matched startup pair on main at f4c6998a (RTX 4090, driver 32.0.16.1088, 20 GiB job cap, same profile, cache and scripted input in both arms) with and without X2W_D3D12_RELEASE_RETIRED=1 plus X2W_D3D12_RELEASE_RETIRED_VIEWS=1:

    Release off Release on
    Retained committed textures, last sample 3,563 MiB 143 MiB
    DXGI local usage / budget, last sample 11,577 / 23,370 MiB 8,662 / 23,370 MiB
    Stop (process seconds) 69.7 s 155.2 s
    First failure slot 133 texture placement E_OUTOFMEMORY same
    Device removed no no

    On this 24 GB card local usage stayed under budget in both arms, so neither run reproduced the device removal reported here. The release kept retained textures flat, and the run lasted about 85 s longer before process commit reached the 20 GiB job cap. At the stop, X2W_D3D12_RETIRE_REASONS=1 still listed 484 MiB held, almost all outside the release class: 5,163 buffers (339 MiB) and 11 render-target, depth or UAV resources (144 MiB). The commit timeline and the untracked part are in #1199.

    AI-assisted (Claude Code).

  17. R0Y00 commented on Nov 26, 2026

    @R0Y00
    Owner

    We’re keeping the same-slot rebind guarantee from #2468. A live slot-18 descriptor or its copy holds the resource until the slot is explicitly overwritten or the heap is destroyed. A recorded or submitted use also keeps the resource alive until that use retires. The #2579 opt-in currently clears slots when those slots are the remaining owners. We’ll remove that rewrite in a separate correction and keep the base retirement path. The old switch can report the retained views without changing any descriptor.

    The 20 GiB A/B above is still useful memory-pressure evidence. The correction will verify a nonzero readback from the original slot and its copy after the last guest Release, including a held recording, and verify actual retirement after overwrite. We’ll run those checks both with and without the old switch.

  18. R0Y00 commented on Nov 26, 2026

    @R0Y00
    Owner

    The correction is open in #2679 at d1d92612. The Windows Release suite passed 26/26 on WARP and RTX 4060 Laptop, with the legacy switch both on and off. The same new fixture against the prior shim failed because the resource retired before its slot was overwritten. The measured slot and recording lifetimes are in the PR. This remains separate from the process-commit growth in #1199.

  19. triggered02 commented on Nov 26, 2026

    @triggered02
    Contributor

    Slice 3b needs a maintainer decision, because the design I proposed is the one #2679 already rejected � and I could not find a safe variant of it.

    What I verified

    1. The rule d3d12: keep live SRVs intact during resource retirement #2679 enforces (git show 293e77f, plus ests/startup_resource_retire_views.cpp): a materialized view in a tracked descriptor slot is an owning reference until the slot is explicitly overwritten, copied over, or the heap wrapper is released. The drain may only free when
      etire_view_refs == 0 and must never rewrite a live descriptor. X2W_D3D12_RELEASE_RETIRED_VIEWS is now a legacy diagnostic that logs clearing is disabled (d3d12_xs_device.cpp:829-837).
    2. The bounded condition I proposed is empty. "Null only when no live guest wrapper, no hold, no flight, and no recorded view whose heap is still live" while
      etire_view_refs > 0 cannot hold: every one of those refs exists because a materialized record sits in a live shadow cell, and cells are cleared only by overwrite, CopyDescriptors*, or the heap wrapper's final Release. So the condition collapses to �iew_refs == 0, which the drain already frees � my step would be dead code; the only remaining "win" state is observably identical to d3d12: keep live SRVs intact during resource retirement #2679's keep case.
    3. Empirical check. I temporarily re-applied only the source half of the d3d12: opt-in release of retired textures held only by never-overwritten descriptor slots #2579 revert and ran the merged d3d12: keep live SRVs intact during resource retirement #2679 fixture: it fails immediately at
      ests/startup_resource_retire_views.cpp:423 � FAIL: T1 retired before its slot was overwritten (the first drain after the guest Release). Worktree restored, branch clean, nothing shipped.

    The three designs

    A. #2579 (reverted) B. #2679 (current) C. policy-gated eviction
    Descriptor is disposable an owner until overwritten an owner, evictable under an explicit opt-in
    Nulls a live slot yes, after release fences never yes, only when a documented policy says so
    Memory descriptor-only textures freed the ~9 GB stays retained (intended) some memory back, bounded and lossy
    Cost later bind of that slot reads zeros; contradicts #2679 cases 1-4 unbounded retention reverses #2679 for the opt-in path; the keep fixture cannot pass as written; needs a documented "released resource may read null" contract

    What I am asking

    3b is not code that can be merged as-is; it is a semantics decision about who owns a released-but-still-named texture. If you want the ~9 GB back, design C is the only honest route and it needs (a) your explicit approval to reverse #2679 for an opt-in path, (b) a switch documented as lossy ("a descriptor naming a released resource may read null after retirement"), (c) a fixture that forks the keep cases instead of contradicting them. If you prefer B, then slice 3a is the end of this series and #2379 should record the retention as intended behavior with the numbers.

    Either answer is fine � I am not shipping the reverted behavior without it. 3a is in review as #2719.

  20. R0Y00 commented on Nov 26, 2026

    @R0Y00
    Owner

    Keep design B. A materialized descriptor and its copies own the resource until the slot is overwritten or the heap is destroyed. Last guest Release and completed fences can retire prior references and submissions, while the live slot must still support rebinding. Your #2679 mutation confirms the observable failure, so end this slice with #2719 and keep the old switch diagnostic-only. Please record the approximately 9 GB result as pressure measured in that run, alongside the bytes still owned by live slots, recording holds and in-flight work where the counters distinguish them.

  21. triggered02 commented on Nov 26, 2026

    @triggered02
    Contributor

    Understood — keeping design B (#2679 compatibility: materialized descriptors and their copies own the resource until overwritten, copied over, or heap destruction). We will end slice 3 with #2719 (19–21 slot tracking + retire_leave_class only on untracked destinations) and keep X2W_D3D12_RELEASE_RETIRED_VIEWS diagnostic-only.

    I will record the ~9 GB retained pressure from the diagnostic run alongside the live-slot, recording-hold, and in-flight breakdown counters in docs/experiments.md (either on #2719 if helpful or in a clean docs follow-up after #2719 lands).

  22. tedin7 commented on Nov 26, 2026

    @tedin7
    Collaborator

    @triggered02 a question before we start anything in your area.

    When local video memory is exhausted, the slot 133 CreateCommittedResource for a placed texture returns E_OUTOFMEMORY, the guest gets a failed creation, and a title can go on to use a resource that does not exist. #2773 should push that point much further out, and #2379 design B covers the release side. Neither makes the creation itself survive a full card.

    We would like to take a small, separate fallback on top of #2773: when the default-heap creation fails with E_OUTOFMEMORY, retry once in a custom heap in system memory (D3D12_HEAP_TYPE_CUSTOM, D3D12_MEMORY_POOL_L0), count it in x2w_budget as nonlocal, and log one line per fallback. It would be slower to sample but would not fail. It would be opt-in first, with a WARP + hardware readback test that forces the first creation to fail and checks the fallback texture samples the same texels.

    It touches the same creation path as #2773, so we would wait for #2773 to land and build on it, or fit in however you prefer. Is that fine with you, or is it already on your list?

  23. added
    priority: P0
    on Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: P0

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions