Skip to content

Conversation

cwfitzgerald
Copy link
Member

@cwfitzgerald cwfitzgerald commented Oct 15, 2025

Connections

Part of #8354.

Description

In preparation for having multiple swapchain implementations inside the vulkan backend, this pulls out all of the swapchain code into a dynamically dispatchable interface. The code inside the swapchain was merely moved to the new interface, so bulk additions and removals are just moves.

Notably this new interface supports both Binary and Timeline semaphores in all positions, as DXGI interop will be handing timeline semaphores for submit to deal with. In preparation of this, I have updated SemaphoreList to deal with both wait and signal semaphores, with ample sanity checking and validation in debug.

Testing

Manually ran the examples, resized, and closed the window, all without validation layers.

Squash or Rebase?

Izzacommit

@cwfitzgerald cwfitzgerald changed the title Factor out swapcahin to abstracted interface Factor out swapchain to abstracted interface Oct 15, 2025
@cwfitzgerald cwfitzgerald requested a review from Copilot October 15, 2025 23:22
@cwfitzgerald cwfitzgerald force-pushed the cw/split-out-swapchain branch from ffab8f0 to 27f1286 Compare October 15, 2025 23:26
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR factors Vulkan swapchain handling into an abstracted, dynamically-dispatchable interface to enable multiple swapchain implementations and prepares synchronization to support both binary and timeline semaphores.

  • Introduces swapchain::Surface/Swapchain traits with a native Vulkan implementation.
  • Refactors semaphore handling (SemaphoreList) to support both wait and signal paths, including timeline values and stage masks.
  • Adapts Instance/Adapter/Queue/Surface integration to the new interfaces.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
wgpu-hal/src/vulkan/swapchain/native.rs New native swapchain/surface implementation and related metadata/guards; moved logic from prior monolithic code.
wgpu-hal/src/vulkan/swapchain/mod.rs Defines swapchain interfaces (Surface, Swapchain, SurfaceTextureMetadata, guards).
wgpu-hal/src/vulkan/semaphore_list.rs Reworks SemaphoreList to handle wait/signal modes, timeline values, and stage masks.
wgpu-hal/src/vulkan/mod.rs Wires Surface to trait object, updates Queue submission to use new SemaphoreList, adjusts SurfaceTexture metadata.
wgpu-hal/src/vulkan/instance.rs Creates/destroys surfaces via the new trait; config/unconfigure path updated to call into trait objects.
wgpu-hal/src/vulkan/device.rs Removes old swapchain construction now handled by swapchain/native.
wgpu-hal/src/vulkan/adapter.rs Delegates surface capability queries to the new Surface impl and initializes Queue signal semaphores list.
Comments suppressed due to low confidence (1)

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@cwfitzgerald cwfitzgerald force-pushed the cw/split-out-swapchain branch from 27f1286 to 13feef5 Compare October 21, 2025 00:18
@cwfitzgerald cwfitzgerald requested a review from Copilot October 21, 2025 00:18
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Comments suppressed due to low confidence (1)

wgpu-hal/src/vulkan/adapter.rs:1

  • Corrected spelling of 'trunkating' to 'truncating'.
use alloc::{borrow::ToOwned as _, boxed::Box, collections::BTreeMap, sync::Arc, vec::Vec};

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@cwfitzgerald cwfitzgerald marked this pull request as ready for review October 21, 2025 00:25
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