Skip to content

vulkan, wsi/win32: Cache and re-use surface objects

Jesse Natalie requested to merge jenatali/mesa:wsi-win32-surface-caching into main

A surface object represents the persistent state for a window that is supposed to be uncoupled from a swapchain. When we're using DXGI swapchains with DComp surfaces, that's where the DComp side of things lives. However, a Win32 HWND can only have one DComp surface bound to it at a time. Some apps leak these surface objects, or at least attempt to overlap their lifetimes, which is problematic for this type of usage. Specifically, DOOM Eternal creates a new surface every time you alt+tab, but then attempting to create a new DComp target for that new surface fails, leading to a swapchain creation failure.

A simple solution is to add an instance-level cache of surfaces, so each native HWND only gets one refcounted WSI surface at a time.

Split out from !22225 (merged) to review/land separately.

/cc @gfxstrand

Edited by Jesse Natalie

Merge request reports

Loading