Repository navigation
fix(win32): release ResizeSync D3D11 DragDevice after drag finishes - #2817
Merged
Merged
Conversation
With ResizeSync::On, DragResizeSync::release_drag_resources freed the copy-model HWND swap chain and shared render-target ring on drag exit but kept the lazily created D3D11 DragDevice cached until device loss or window destruction, retaining ~12 MiB of idle memory after a single resize drag. - Group transient drag GPU resources (DxgiDragSwapChain, DragTargetRing, and DragDevice) into ActiveDragGpu with strict drop order (swap chain -> ring -> DragDevice) and unify Effect::DropD3d11Device into Effect::ReleaseDragResources so State::Idle and State::Entering retain zero drag GPU objects. - Keep ActiveDragGpu alive through State::Leaving until steady-state DirectComposition re-attaches (Effect::AttachDcomp) before releasing it, preventing any exit flash. - Flush deferred D3D11 destructions (ClearState + Flush) and call IDXGIDevice3::Trim in DragDevice::drop, drop shared fences before the D3D11 device (and D3d11Device context before device/factory), and poll wgpu after Effect::ReleaseDragResources so dropped shared D3D12 textures reclaim immediately while idle. - Add off-screen GPU and state-machine regression coverage proving lazy DragDevice acquisition, idle release after drag exit, and clean lazy recreation on a second drag. Addresses #2113
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DragDevice(~12 MiB) once aResizeSync::Ondrag finishes and steady-state DirectComposition presentation has resumed, eliminating post-drag idle memory retention reported in Windows: steady live resize by syncing each drag frame with the window's size step #2113.Design
ActiveDragGpu): GroupsDxgiDragSwapChain,DragTargetRing, andDragDevicein strict drop order (swap_chain->ring->device) and unifiesEffect::DropD3d11DeviceintoEffect::ReleaseDragResources.State::IdleandState::Enteringalways hold zero drag GPU objects.ActiveDragGpualive acrossState::Leavinguntil the post-drag D3D12 flip-model frame finishes andEffect::AttachDcomp(SetRoot+Commit+WaitForCommitCompletion) restores steady-state DirectComposition, then runsEffect::ReleaseDragResources.DragDevicefields so shared fences drop befored3d11(andD3d11Devicecontext drops before device/factory), runsID3D11DeviceContext::ClearState()+Flush()+IDXGIDevice3::Trim()inDragDevice::drop, and calls non-blockingrune_gpu::health::pollafterEffect::ReleaseDragResourcesso wgpu reclaims dropped shared D3D12 textures immediately while idle.ensure_gpu_targetdrops that device.Verification
cargo check -p rune --libcargo check -p rune --lib --target wasm32-unknown-unknownandcargo check -p rune-gpu --lib --target wasm32-unknown-unknowncargo test -p rune --lib --features rune/test-gpu-counters,rune-gpu/test-gpu-counters resize_sync(29 passed, including newdrag_device_is_acquired_lazily_dropped_on_idle_and_recreated_on_second_dragproving lazy acquisition, idle drop with zero leaked wgpu textures, and clean recreation on a second drag)cargo test -p rune-gpu --lib d3d11_interop(2 passed)scripts/file-size.sh(0 errors)Addresses #2113