Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PhysicalDevice::presentation_support #2562

Merged
merged 1 commit into from
Sep 11, 2024

Conversation

marc0246
Copy link
Contributor

@marc0246 marc0246 commented Sep 8, 2024

This adds a function that abstracts away the platform-specific presentation support calls akin to Surface::from_window, allowing you to determine presentation support to the surface of any window of a given event loop. This addresses two issues:

  • There are cases where you don't have a window to test for support with. For instance, ever since winit 0.30 you can only create a surface in the Resumed callback, which makes people think that you have to create the whole device in that callback, when that's not the case. This addition is going to make updating to winit 0.30 easier.
  • There are cases where you have multiple windows, or you could be creating additional windows at the user's request. This too is impractical with PhysicalDevice::surface_support. This also fixes the issues that the multi-window example was having.

PhysicalDevice::surface_support is essentially only usable if you have a window since right after the creation of the event loop and when the window exists for the app's lifetime. Therefore, I replaced all PhysicalDevice::surface_support calls in the examples with PhysicalDevice::presentation_support to promote the better alternative (and for the future when we update to winit 0.30).

Unfortunately, this function was not implementable without adding dependencies for X11 libraries on X11 platforms. I added a default feature same as winit does, so the user can disable the dependencies if they e.g. only support Wayland.

Changelog:

### Additions
- Added `PhysicalDevice::presentation_support` for determining presentation support to the surface of any window of a given event loop.

@marc0246 marc0246 marked this pull request as ready for review September 8, 2024 17:06
@marc0246 marc0246 force-pushed the presentation-support branch 3 times, most recently from 2d8e44b to be5fa57 Compare September 10, 2024 23:43
@@ -34,6 +34,10 @@ vulkano-macros = { workspace = true, optional = true }
objc = { workspace = true }
core-graphics-types = { workspace = true }

[target.'cfg(any(target_os = "dragonfly", target_os = "freebsd", target_os = "hurd", target_os = "illumos", target_os = "linux", target_os = "netbsd", target_os = "openbsd", target_os = "solaris"))'.dependencies]
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't it be easier to write something like:
cfg(all(unix, not(target_os = "foo"), not(target_os = "bar")))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Easier in what way? The list would be longer. But that's besides the point. I explicitly did not want to do that because I really don't like the idea of opt-out conditional compilation, as new targets can always be added.

@Rua
Copy link
Contributor

Rua commented Sep 11, 2024

Looks good! Can you fix the conflict, then I'll merge.

@marc0246
Copy link
Contributor Author

Rebased.

@marc0246
Copy link
Contributor Author

I should have merged... that compare is useless to see what changed. Sorry about that.

@Rua Rua merged commit e8ddaef into vulkano-rs:master Sep 11, 2024
5 of 6 checks passed
@marc0246 marc0246 deleted the presentation-support branch September 11, 2024 15:02
Rua added a commit that referenced this pull request Sep 11, 2024
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