Skip to content

Vulkan resolve, queues and swapchain growth; follow eye textures to a new device - #77

Open
feimos-dev wants to merge 4 commits into
mainfrom
compositor-resolve-devices
Open

feimos-dev wants to merge 4 commits into
mainfrom
compositor-resolve-devices

Conversation

@feimos-dev

@feimos-dev feimos-dev commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

Per-API compositor changes and following the game's device.

Vulkan compositor

  • Multisampled images through a blit. A multisampled image that needs a blit (flipped bounds, a format conversion, invertUsingShaders) is resolved into a single-sampled image of its own format first, and the blit reads that. Before, a multisampled image with flipped bounds was shown unflipped, and one that needed a conversion was refused. The resolve image is made at its first use. If it can't be made, the image is shown as before. A multisampled swapchain still takes a plain copy.
  • Other queues. A texture on another queue than the first texture's is used when that queue is of the same queue family. An empty submit on the texture's queue signals a semaphore (one per swapchain image) after the game's work there, and the copy runs on the session's queue, which the runtime syncs with, waiting for it. A queue of another family, or another device, is still refused (that eye is left out).
  • Growing swapchain. A texture that fits in the swapchain keeps it, and only its area is shown. A bigger one gets a swapchain that holds both sizes. Dynamic-resolution games no longer make a new swapchain at every size change. The stand-in runtime's gfx-vk-bounds expectations change to match: the image sizes change, the rects are the same.

Following a device change

When a D3D11 or D3D12 eye texture is on another device than the session's, the session is made again on the new device through the existing first-time path. The checks that can be made before the old session goes down come first; then, under the session lock, a temporary device is made to fall back on, both eyes' views are cleared (one already stored this frame names the old session's swapchain), and the session moves.

  • If the runtime refuses the new device, the game keeps running with its frames left out and isn't told to quit.
  • The session is made again at most three times a run, so eyes on two devices don't rebuild it every frame. Past that, or with no temporary device, the eye answers TextureIsOnWrongDevice.
  • Not followed: Vulkan (the old session's objects would be freed on a VkDevice the game may have destroyed already; the D3D ones are kept alive by their references), so a Vulkan texture of another device is refused as before; D3D10 (bridge device); OpenGL; frames copied through the D3D11 interop; overlay and skybox textures (they may be on a device of their own).
  • Devices are compared by interface pointer, so a layer that wraps the game's device in a proxy per texture would be taken for a device change.
  • An overlay texture on the old device isn't shown after a move until the game sets it again.

Checked on Linux

scripts/ci/build-linux.sh --tests x64, the stand-in runtime ctest, scripts/ci/conformance-linux.sh x64 and abort_sites.py --check all pass.

Checked on a GPU

On Windows with an NVIDIA GPU, against the stand-in runtime, with new conformance cases (in CI; the Vulkan ones skip there, as CI has no Vulkan driver). The Vulkan cases also ran with the Khronos validation layer on, which reported nothing.

  • Vulkan MSAA with flipped bounds (gfx-vk-odd, under scripts/gfx_vk_odd.json, whose runtime has single-sampled swapchains only): resolved, then shown upside down. 4x MSAA with full bounds is resolved as it is, and 4x MSAA BGRA8 is resolved and then converted into RGBA8 (gfx-vk-msaa-formats).
  • A second queue of the same family (gfx-vk-odd "other queue"): frames show.
  • Dynamic resolution (gfx-vk-dynamic-resolution, textures of 800, 640, 720 and 960 a side): the swapchain stays 800 x 800 for the first three and grows only for 960.
  • A game that makes its device again mid-run (gfx-d3d11-new-device): the session is made again on the new device, and its frames show. Vulkan (gfx-vk-new-device): the new device's frames are refused, as before.
  • The same where the runtime refuses the new device (scripts/gfx_new_device_refused.json): the frames are left out (InvalidTexture) and the game isn't told to quit. gfx-d3d12-new-device makes its second device on WARP, since D3D12 gives one device per adapter; the runtime refuses that adapter, and the game carries on the same way (TextureIsOnWrongDevice). With WARP the only adapter, as on CI, the D3D12 case is skipped.
  • Eyes on two D3D11 devices in one frame (gfx-d3d11-eyes-two-devices): the session follows three times, then the eye on the other device is left out; no frame names a swapchain of a session that's gone, and the game isn't told to quit.

The stand-in runtime's script takes max_swapchain_samples for these cases. A D3D12 move that the runtime accepts needs two adapters the runtime takes, which wasn't available.

Not in this change

  • MSAA depth resolve (D3D11, D3D12, Vulkan): it needs a shader pass or a depth-resolve render pass. Multisampled depth is still not sent.
  • Depth with flipped bounds.
  • Interop depth.
  • D3D9Ex shared-handle copy through D3D11.
  • D3D11/D3D12 colour MSAA with flipped bounds needs no change: it is already resolved before the shader pass.

@feimos-dev
feimos-dev force-pushed the compositor-resolve-devices branch from 6437005 to 09dcb52 Compare November 21, 2026 00:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants