Skip to content

Conversation

MarijnS95
Copy link

@MarijnS95 MarijnS95 commented Jul 31, 2025

Objective

Solution

Long ago raw-window-handle and winit split out a RawDisplayHandle type and respective traits for dealing with the connection - or at the very least type - of a compositor, and typically implement this for a Window directly.

wgpu and bevy seem to have caught on to the latter and folded the two traits/types together because Window 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 if winit chose one over the other, even if both are available; currently that's just guesswork inside wgpu.

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.

Copy link
Contributor

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

@alice-i-cecile alice-i-cecile added A-Windowing Platform-agnostic interface layer to run your app in C-Code-Quality A section of code that is hard to understand or change S-Needs-Review Needs reviewer attention (from anyone!) to move forward X-Uncontroversial This work is generally agreed upon D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes D-Unsafe Touches with unsafe code in some way labels Aug 3, 2025
@MarijnS95 MarijnS95 force-pushed the raw-display-handle branch from 88099c6 to 61045bd Compare August 6, 2025 19:22
@alice-i-cecile alice-i-cecile added D-Complex Quite challenging from either a design or technical perspective. Ask for help! and removed D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes labels Aug 6, 2025
Long ago `raw-window-handle` and `winit` split out a `RawDisplayHandle`
type and respective traits for dealing with the connection - or at the
very least type - of a compositor, and typically implement this for a
`Window` directly.

`wgpu` and `bevy` seem to have caught on to the latter and folded
the two traits/types together because `Window` 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 if `winit` chose
one over the other, even if both are available; currently that's just
guesswork inside `wgpu`.

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.
@MarijnS95 MarijnS95 force-pushed the raw-display-handle branch from 61045bd to 4064f7b Compare August 8, 2025 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Windowing Platform-agnostic interface layer to run your app in C-Code-Quality A section of code that is hard to understand or change D-Complex Quite challenging from either a design or technical perspective. Ask for help! D-Unsafe Touches with unsafe code in some way S-Needs-Review Needs reviewer attention (from anyone!) to move forward X-Uncontroversial This work is generally agreed upon

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants