Skip to content

Conversation

@IsaacMarovitz
Copy link

@IsaacMarovitz IsaacMarovitz commented Nov 21, 2025

Connections
Attempts to fix #8555.

Description
Currently, it is impossible to create a MoltenVK-backed surface when using wgpu-native bindings as the RawWindowHandle API is not available. This PR attempts to extend create_surface_metal to allow the creation of Vulkan backends when requested.

Testing
I don't have an easy way to test this PR, so help in this area would be appreciated.

Squash or Rebase?
Rebase

Checklist

  • Run cargo fmt.
  • Run taplo format.
  • Run cargo clippy --tests. If applicable, add:
    • --target wasm32-unknown-unknown
  • Run cargo xtask test to run tests.
  • If this contains user-facing changes, add a CHANGELOG.md entry.

@IsaacMarovitz IsaacMarovitz changed the title Provide a vulkan path for create_surface_metal Provide a Vulkan path for create_surface_metal Nov 21, 2025
Copy link
Member

@Wumpf Wumpf left a comment

Choose a reason for hiding this comment

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

Looking good, but feature flags need fixing and I think we should adjust naming to mirror semantics better.

I don't have an easy way to test this PR, so help in this area would be appreciated.

We unfortunately don't have great coverage for a lot of surface things. And afaik moltenvk is particularly poorly tested. I trust you ran it yourself locally?

/// # Safety
///
/// `layer` must be a valid pointer.
#[cfg(metal)]
Copy link
Member

Choose a reason for hiding this comment

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

this being now for metal & vulkan @ mac means that the feature cfg is now incorrect. this is also true for callsites

Copy link
Author

Choose a reason for hiding this comment

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

This codepath should still work in cases of only Metal enabled so I wasn't sure what the best combination was for this case.

Copy link
Member

Choose a reason for hiding this comment

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

well but it should also work now if only vulkan was enabled on mac

///
/// `layer` must be a valid pointer.
#[cfg(metal)]
pub unsafe fn create_surface_metal(
Copy link
Member

Choose a reason for hiding this comment

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

this method working with both metal & vulkan is a bit strange with the current name. I initially figured that we may want to split this up into three methods - layer @ metal, layer @ vulkan, layer @ either - but I figure the combined one is the only meaningful one practically speaking. So I suggest rather to clean this up and call this create_surface_core_animation_layer instead. The change should be trickled up the chain so that wgpu_core then calls into instance_create_core_animation_layer when encountering a layer. (care need to be taken to do this under the right feature flags)

@Wumpf Wumpf self-assigned this Nov 23, 2025
@IsaacMarovitz
Copy link
Author

I trust you ran it yourself locally?

I built it locally, but I don't have a proper test case for this right now. I'll try and make one.

@IsaacMarovitz
Copy link
Author

@Wumpf It seems I'm running into Error: Unsupported Surface not matter what I do

@IsaacMarovitz
Copy link
Author

As of right now my only test case for this is building wgpu-native based on this branch and plugging the final dylib into the application I need this Vulkan path which I realise has quite a few added variables of potential problems.

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.

Impossible to create MoltenVK backed surface outside of Rust environment

2 participants