Skip to content

Implement DXGI Swapchain on Vulkan - #8388

Open
cwfitzgerald wants to merge 6 commits into
gfx-rs:trunkfrom
cwfitzgerald:cw/dxgi-on-vulkan
Open

Implement DXGI Swapchain on Vulkan#8388
cwfitzgerald wants to merge 6 commits into
gfx-rs:trunkfrom
cwfitzgerald:cw/dxgi-on-vulkan

Conversation

@cwfitzgerald

@cwfitzgerald cwfitzgerald commented Oct 21, 2025

Copy link
Copy Markdown
Member

Connections

Part of #8354

Description

This implements the DXGI swapchain backend for vulkan. It does device interop with D3D12 and submits dummy command buffers before and after the relevant vulkan work to ensure proper synchronization with the swapchain. In my testing this works on all devices I've tested on, has negligible performance impact (something on the order of 100us) and gives us all of the advantages of a native swapchain.

The code was AI assisted and all reviewed myself before opening for reviews. This description was hand written.

Testing

Did manual testing of the swapchain under various situations. Importantly I testing a gpu-bound scene which caught a few synchronization issues. As this is not the default setting, we don't need to validate that all devices work perfectly with this scheme as the point is to get this onto trunk/into a release so we can test it out before potentially making it default.

Squash or Rebase?

Rebase

Checklist

  • I self-reviewed and fully understand this PR.
  • WebGPU implementations built with wgpu may be affected behaviorally.
  • Validation and feature gates are in place to confine behavioral changes.
  • Tests demonstrate the validation and altered logic works.
  • CHANGELOG.md entries for the user-facing effects of this change are present.
  • The PR is minimal, and doesn't make sense to land as multiple PRs.
  • Commits are logically scoped and individually reviewable.
  • The PR description has enough context to understand the motivation and solution implemented.

@cwfitzgerald
cwfitzgerald force-pushed the cw/dxgi-on-vulkan branch 7 times, most recently from 48007b9 to ace10d7 Compare June 29, 2026 21:42
@cwfitzgerald
cwfitzgerald force-pushed the cw/dxgi-on-vulkan branch 2 times, most recently from ff41c4c to fa9ddce Compare June 29, 2026 22:37
Comment thread wgpu-types/src/backend.rs Outdated
Comment thread wgpu-hal/Cargo.toml Outdated
Comment thread wgpu-hal/src/auxil/dxgi/swapchain.rs Outdated
Comment thread wgpu-hal/src/auxil/dxgi/library.rs Outdated
Comment thread wgpu-hal/src/auxil/dxgi/library.rs Outdated
Comment thread wgpu-hal/src/vulkan/swapchain/dxgi.rs Outdated
Comment thread wgpu-hal/src/vulkan/swapchain/dxgi.rs
Comment thread wgpu-hal/src/vulkan/swapchain/dxgi.rs Outdated
Comment thread wgpu-hal/src/vulkan/swapchain/dxgi.rs Outdated
Comment thread wgpu-hal/src/vulkan/swapchain/dxgi.rs Outdated
@cwfitzgerald
cwfitzgerald force-pushed the cw/dxgi-on-vulkan branch 2 times, most recently from ae13a73 to 28452b4 Compare July 1, 2026 03:00
@cwfitzgerald
cwfitzgerald force-pushed the cw/dxgi-on-vulkan branch 3 times, most recently from 7b15171 to 71ba098 Compare July 8, 2026 01:37
@cwfitzgerald
cwfitzgerald marked this pull request as ready for review July 8, 2026 01:42
@inner-daemons
inner-daemons self-requested a review July 8, 2026 15:05
@inner-daemons inner-daemons self-assigned this Jul 8, 2026
@cwfitzgerald
cwfitzgerald force-pushed the cw/dxgi-on-vulkan branch 3 times, most recently from 268951b to bf32abd Compare July 14, 2026 19:21
…2 through them

Adds a dxgi build cfg (dx12 || vulkan+windows), widens the vulkan feature with the
Windows deps, moves DynLib/DxgiLib (library.rs), dcomp, ISwapChainPanelNative (types.rs)
and SurfaceTarget into auxil::dxgi, and extracts the swapchain descriptor/flags/present/
waitable/colorspace/tearing helpers. DX12 now calls the shared helpers (proven by deleting
its copies). Resolves the frame-latency-waitable inconsistency: the swapchain flag,
SetMaximumFrameLatency and the waitable handle are now coupled, so None honors its
documented no-waitable behavior.
The DX12 backend's d3d12.dll loader (D3D12Lib) and its error types move to auxil::dxgi::library so the Vulkan DXGI interop path can create its interop device through the same runtime-loaded entry points. Each entry point resolves against the windows-crate PFN_* alias. DX12 keeps using the loader via a re-export, so its call sites and public API are unchanged.

Enable Win32_Graphics_Direct3D12 for the vulkan feature on Windows (replacing Win32_Graphics_Direct3D11) so the shared loader compiles in vulkan-only builds.
…uffer sharing (Windows)

Vulkan renders directly into the DXGI flip-model back buffers, which are created on a LUID-matched interop D3D12 device and shared into Vulkan as external-memory images (no copy). A shared D3D12 fence orders Vulkan rendering ahead of a no-op present command list that binds each back buffer and transitions it to PRESENT. Opt-in via VulkanSwapchainKind / WGPU_VULKAN_SWAPCHAIN_KIND; the native VK_KHR_swapchain path stays the default.
@andyleiserson andyleiserson added the area: presentation Issues related to presentation label Aug 5, 2026
@inner-daemons

Copy link
Copy Markdown
Collaborator

Been "busy" for a while, I want to get to this in the next week or two but I can't make promises.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: presentation Issues related to presentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants