[metal] Use raw-window-metal
to do layer creation
#6210
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
You know, all that code and documentation I just wrote in #6107? Let's throw it
awayinto a library, so thatwgpu
,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 anNSView
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
cargo fmt
.cargo clippy
.cargo xtask test
to run tests.CHANGELOG.md
. See simple instructions inside file.