Repository navigation
feat(win32): add opt-in drag-only synchronized resize path (RUNE_RESIZE_SYNC=1) - #2133
Merged
Merged
Conversation
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.
Refs #2113
Adds an opt-in (
RUNE_RESIZE_SYNC=1, off by default), drag-only synchronized resize path on Windows using public Microsoft-documented APIs only. No new public Rust API is added, and whenRUNE_RESIZE_SYNCis unset or0, Windows presentation,Slotpacing,WM_NCCALCSIZE, andWM_ERASEBKGNDremain unchanged with zero D3D11 devices, shared textures, or second swap chains created.State machine & data flow
stateDiagram-v2 [*] --> Idle Idle --> Entering: WM_ENTERSIZEMOVE (eligible) Entering --> Idle: WM_EXITSIZEMOVE (pure move) / Handover / Hide / Destroy / DeviceLost Entering --> Dragging: first Resize -> BeginDrag ok Entering --> Idle: DragFailed Dragging --> Dragging: Resize / Redraw -> RenderDragFrame Dragging --> Leaving: WM_EXITSIZEMOVE -> RequestExitFrame + WakeAt(500ms) Dragging --> Idle: Handover / Hide / Destroy / DeviceLost / zero size Leaving --> Idle: ExitFrameCompleted / TimerDue / Handover / Hide / Destroy / DeviceLost Leaving --> Entering: WM_ENTERSIZEMOVE (re-entry)flowchart LR RT[Rune Runtime + Renderer] --> D12[D3D12 Shared Texture<br/>D3D12_HEAP_FLAG_SHARED] D12 -->|Queue::Signal ready| F[Shared Fence<br/>ID3D12Fence <-> ID3D11Fence] F -->|Context::Wait ready| D11[D3D11 CopyResource] D11 -->|BeginPaint / Present 0 / EndPaint| SC[D3D11 DXGI_SWAP_EFFECT_DISCARD<br/>HWND Swap Chain] D11 -->|Context::Signal release| FChanges
crates/rune-gpu/src/d3d11_interop.rs): Lazy System32-onlyD3D11CreateDeviceon the active D3D12 adapter LUID,ID3D12Fence<->ID3D11Fenceshared fences, andID3D12Resource<->ID3D11Texture2Dshared render targets; shared withcrates/rune-media/src/video/windows/gpu.rs.WVR_VALIDRECTS(crates/rune/src/window/win32/resize_sync/machine.rs): Explicitrune::machinestate machine (Idle,Entering,Dragging,Leaving) withAttempt-fenced exit timer, strictly gated toWM_ENTERSIZEMOVE..WM_EXITSIZEMOVEon opaque app windows with a settled Rune-ownedHandover(SurfaceMode::Handed). Excludes transparent windows (WS_EX_NOREDIRECTIONBITMAP), overlays,DxgiFromHwnd, andSurfaceMode::Cpu/HandingOver/Rebinding.crates/rune/src/window/win32/resize_sync/{gpu,present}.rs,resize_sync.rs): Renders drag frames into a D3D12 shared texture (TextureUses::PRESENT/COMMONhandoff), signals shared fences, and presents via a D3D11DXGI_SWAP_EFFECT_DISCARDHWND swap chain insideWM_PAINT(BeginPaint/EndPaint) behindDragSeam, with zero presents to the hidden D3D12 composition swap chain during drag.crates/rune/src/platform/win32/{dcomp_handover,dpi_drag,frame}.rs):Handover::detach_root/attach_root(IDCompositionTarget::SetRoot),WVR_VALIDRECTSfor both custom-frame and standard-frame windows,WM_ERASEBKGNDsuppression, and scopedWM_PAINTtrampoline — all inactive unlessRUNE_RESIZE_SYNC=1and inDragging.Slotduring resize (crates/rune/src/window/host/draw.rs) is untouched; noSetOffsetX/SetOffsetYor undocumented APIs are used.RUNE_RESIZE_SYNC=1incrates/rune/README.mdand addedchangelog/unreleased/2026-11-25-windows-drag-resize-sync.md.Scope & live-window status
WVR_VALIDRECTSrect math, opt-in-off zero-allocation guarantee (test-gpu-counters), and real-adapter D3D12-to-D3D11 shared-texture/fence creation, cleanup, and bit-exact pixel parity (Bgra8UnormandBgra8UnormSrgbacross resize).Win32DragSeam(CreateSwapChainForHwnd(DISCARD),BeginPaint/EndPaint,SetRoot(None)/SetRoot(root)during a liveWM_ENTERSIZEMOVE..WM_EXITSIZEMOVEdrag) has not been observed on a live Windows 11 display yet; the path stays off by default until live verification.