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

[metal] Use raw-window-metal to do layer creation #6210

Open
wants to merge 3 commits into
base: trunk
Choose a base branch
from

Conversation

madsmtm
Copy link
Contributor

@madsmtm madsmtm commented Sep 4, 2024

You know, all that code and documentation I just wrote in #6107? Let's throw it away into a library, so that wgpu, ash, vulkano, i-slint-renderer-skia and so on can all benefit from it.

raw-window-metal is that library (existed previously, I've updated it in rust-windowing/raw-window-metal#19).

This makes Wgpu depend transitively on objc2, so the concerns about doing that apply here as well, see also #5641.

Description
Use the raw-window-metal crate to do layer creation. This uses much the same approach as we do currently, except that it also uses observers internally, which fixes resizing on high DPI screens when using Wgpu together with an NSView using auto-layout.

Though it probably won't matter much, it's also more reliable to update the scale factor this way, rather than haphazardly in configure.

The logic in raw-window-metal could be re-implemented in Wgpu to avoid the dependency, however I deemed it complex enough that I thought it wiser to centralize the implementation in one place.

Testing
See #6107 (comment).

Checklist

This uses observers internally, which fixes resizing when using Wgpu
together with an auto-layout NSView.

Though it probably won't matter much, it's also more reliable to update
the scale factor this way, rather than haphazardly in `configure`.
This is no longer necessary, since Winit can now properly issue redraw
events on resize.
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.

1 participant