bevy_window: Split RawHandleWrapper
out into Display
wrapper
#20357
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.
Objective
BadDisplay
after winit 0.30 on Wayland OpenGL #13923 and Crash due to wgpu during startup on Wayland #14494 by getting rid of some duplication.Solution
Long ago
raw-window-handle
andwinit
split out aRawDisplayHandle
type and respective traits for dealing with the connection - or at the very least type - of a compositor, and typically implement this for aWindow
directly.wgpu
andbevy
seem to have caught on to the latter and folded the two traits/types together becauseWindow
provides it, but miss a critical goal here: that(Raw)DisplayHandle
is important for initialization of certain graphics APIs. In the case of Wayland all resources are unique per connection, and in general for others it's important to distinguish between Wayland and X11 ifwinit
chose one over the other, even if both are available; currently that's just guesswork insidewgpu
.Newer APIs like Vulkan don't suffer from this, but older graphics APIs like OpenGL and specifically the EGL backend (or GLX for X11) set up their entire state based on the compositor connection (alternatives are available) even if it's ultimately "only" important for the surface that is going to be rendered into.
Note that I haven't yet checked all the safety constraints carefully in this PR; some existing messages seem flawed but I need to perform a clean audit from scratch to denote what limitations should apply to the newly proposed
RawDisplayHandleWrapper
as well.Testing
cargo r --example 3d_bloom -Fwayland
on a Wayland compositor.