Skip to content

Conversation

@mahkoh
Copy link
Contributor

@mahkoh mahkoh commented Jul 12, 2025

This extension trait allows general-purpose applications to query the preferred GPU device so that they do not engage the dedicated GPU unnecessarily.

Without such a hint, applications are likely to choose the first available device which will always be the dedicated GPU which is undesirable on mobile devices.

Similarly, on desktop dual-GPU systems where the integrated GPU is otherwise unused, it is preferred for all applications to use the dedicated GPU.

  • Tested on all platforms changed
  • Added an entry to the changelog module if knowledge of this change could be valuable to users
  • Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
  • Created or updated an example program if it would help users understand this functionality

@mahkoh mahkoh force-pushed the jorth/main-gpu-device branch from e220333 to ce36a9c Compare July 12, 2025 12:49
pub fn main_drm_device(&self) -> Option<dev_t> {
match self {
EventLoop::Wayland(evlp) => evlp.main_drm_device(),
EventLoop::X(_) => None,
Copy link
Contributor Author

@mahkoh mahkoh Jul 12, 2025

Choose a reason for hiding this comment

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

I don't care enough about X to implement this. But it is possible by using the Dri3Open request to get a DRM fd and then calling stat on it.

@mahkoh mahkoh force-pushed the jorth/main-gpu-device branch from ce36a9c to 1e002f5 Compare July 12, 2025 12:54
This extension trait allows general-purpose applications to query the
preferred GPU device so that they do not engage the dedicated GPU
unnecessarily.

Without such a hint, applications are likely to choose the first
available device which will always be the dedicated GPU which is
undesirable on mobile devices.

Similarly, on desktop dual-GPU systems where the integrated GPU is
otherwise unused, it is preferred for all applications to use the
dedicated GPU.
@mahkoh mahkoh force-pushed the jorth/main-gpu-device branch from 1e002f5 to 5b1e433 Compare July 12, 2025 12:54
@mahkoh mahkoh marked this pull request as ready for review July 12, 2025 13:05
@mahkoh mahkoh requested a review from kchibisov as a code owner July 12, 2025 13:05
Copy link
Member

@kchibisov kchibisov left a comment

Choose a reason for hiding this comment

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

Do we need it on EventLoop itself? In general though, we can just have it entirely in winit-wayland, I also don't care about X11 and not even sure if touching DRI on it is a good idea.

@mahkoh
Copy link
Contributor Author

mahkoh commented Jul 12, 2025

In general though, we can just have it entirely in winit-wayland

What would the API look like?

@kchibisov
Copy link
Member

I guess pretty much the same as of now, just entirely inside the winit-wayland, so user would get API from the winit-wayland directly and it wouldn't reside in winit.

@mahkoh
Copy link
Contributor Author

mahkoh commented Jul 12, 2025

I still don't see how that would work unless you're saying that winit should create a whole separate connection just to fetch this property.

@kchibisov
Copy link
Member

Do you need it on EventLoop itself? I'll add that myself if that wasn't clear, but basically, what I want is to have API in winit-wayland not in winit itself, so user after downcasting to winit-wayland's type can invoke the API they want, etc, etc.

@mahkoh
Copy link
Contributor Author

mahkoh commented Jul 12, 2025

That would be possible but it is not in sync with the rest of the API as they are right now. Currently the extensions look like this:

pub trait EventLoopExtWayland {
    fn is_wayland(&self) -> bool;
}

pub trait WindowExtWayland {
    fn xdg_toplevel(&self) -> Option<NonNull<c_void>>;
}

If they were changed to

pub trait EventLoopExtWayland {
    fn as_wayland_event_loop(&self) -> Option<&WaylandEventLoop>;
}

pub trait WindowExtWayland {
    fn as_wayland_window(&self) -> Option<&WaylandWindow>;
}

then it would make sense to define this on WaylandEventLoop directly.

@kchibisov
Copy link
Member

Yeah, that's the end intent for those things, I'm just busy with other things to finish, though, I can just do it later on myself and we leave this PR as is pretty much.

@mahkoh
Copy link
Contributor Author

mahkoh commented Jul 12, 2025

I agree that that design would ultimately be better because the individual functions (xdg_toplevel, etc.) don't have to return Options then.

This PR can wait until the new design is fleshed out.

@madsmtm madsmtm added the DS - wayland Affects the Wayland backend, or generally free Unix platforms label Sep 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DS - wayland Affects the Wayland backend, or generally free Unix platforms

Development

Successfully merging this pull request may close these issues.

3 participants