Repository navigation
fix(win32): wait for first drag Present before detaching DComp and clamp split pass scissor - #2646
Merged
Merged
Conversation
…amp split pass scissor Addresses #2113.\n\nOn BeginDrag, run_drag_frame previously detached DirectComposition\n(SetRoot(None) + Commit + WaitForCommitCompletion) immediately after the\nasynchronous D3D11 DXGI_SWAP_EFFECT_DISCARD Present(0, 0) returned to the\nCPU, without waiting for the GPU to finish rendering, copying, and\nblitting the first drag frame into the HWND redirection surface. When\nnormal frames between drags had changed the window (for example opening or\nclosing a dialog or combobox), detaching DirectComposition early briefly\nrevealed the stale redirection surface from the previous drag or startup,\ncausing a single whole-window flicker on the first drag while subsequent\ndrags were smooth.\n\nChanges:\n- Add a reusable auto-reset Win32 event on DragDevice with\n signal_post_present() + wait_for_release(), invoked once on BeginDrag\n (never on steady-state drag steps) right after EndPaint and strictly\n before detach_dcomp(), making drag entry symmetric with drag exit.\n- Enable WVR_VALIDRECTS / WM_ERASEBKGND suppression before the first\n BeginPaint on BeginDrag (rolled back on DragFailed).\n- Disarm any stray retained partial damage before encoding a drag frame so\n draw_ui always renders whole into the capacited shared target.\n- Clamp both viewport and default scissor to the active sub-rect in\n ActivePass::split when re-opening a root pass on an oversized target.
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.
Addresses #2113.
Root cause
During Windows synchronized drag resize (
ResizeSync::On/RUNE_RESIZE_SYNC=1), the post-drag exit path (Leaving -> Idle) waits for the GPU to finish presenting the normal D3D12 flip-model frame before re-attaching DirectComposition (attach_root). The drag-entry path (BeginDrag) did not have the symmetric wait:DxgiDragSwapChain::copy_and_presentqueued D3D11Wait(ready)->CopySubresourceRegion->Present(0, 0)(asynchronous GPU blt into the HWND's DWM redirection surface) and returned immediately.run_drag_frameimmediately calleddetach_dcomp()(SetRoot(None)+Commit+WaitForCommitCompletion) before the GPU finished rendering, copying, and blitting the first drag frame into the redirection surface.Additionally,
run_drag_frameenabledWM_ERASEBKGNDsuppression only after the firstBeginPaint, disarmed retained damage only afterdraw_ui, andActivePass::splitleft the default scissor unclamped when re-opening a root pass on an oversized capacited target texture.Changes
BeginDragonly (crates/rune/src/window/win32/resize_sync/{gpu,present,frame}.rs): add a reusable Win32 event handle onDragDevice, signalrelease+Flushstrictly afterPresent(0, 0)whenwait_for_presentis true (BeginDragonly; zero overhead on steady-state drag steps), and wait on the fence right afterEndPaintbefore callingdetach_dcomp().crates/rune/src/window/win32/resize_sync/frame.rs): enableset_valid_rects_active(true)before the firstBeginPaint(rolled back viaEvent::DragFailed->ReleaseDragResourceson failure) and callrenderer.damage_drawn()beforedraw_uiso drag frames never enterdraw_armedagainst a capacited target.crates/rune/src/render/pass.rs): clamp both viewport and default scissor to(size[0].min(src_tex.width()), size[1].min(src_tex.height()))whenActivePass::splitre-opens a render pass withscissor: None.crates/rune/src/window/win32/resize_sync/entry_tests.rs): verifyBeginDragordering (set_valid_rects_active(true)->present_shared(wait_for_present=true)+ live D3D11 fence wait ->detach_dcomp), steady-state non-blocking steps, failure rollback, and bit-exact capacited-target pixel parity across stray armed damage (matching capacity dimensions), isolated dialog layers,El::cache, andEl::backdrop_blurpass splits on bothBgra8UnormandBgra8UnormSrgb.Verification
cargo test -p rune --lib resize_sync(20 passed),cargo test -p rune --lib render::backdrop(6 passed),cargo test -p rune --lib render::damaged(4 passed), andcargo check -p rune --lib --tests.