pop-os / cosmic-epoch

Next generation Cosmic desktop environment
3.23k stars 88 forks source link

[Feature Request] Select primary GPU #276

Open m1m1k4tz opened 7 months ago

m1m1k4tz commented 7 months ago

It would be nice for laptop users with an iGPU and dedicated GPU, also for double gpu pass through for VMs to be able to select the primary GPU to be used when there two available ones.

Drakulix commented 7 months ago

Cosmic doesn't really have a concept of a primary-gpu.

It has a fallback-gpu that it uses in (very rare) cases, where it cannot determine the appropriate gpu to use and that defaults to the internal gpu / boot gpu / first gpu (in this order) in the system (but is configurable via an environment variable).

In all cases it tries to figure out the appropriate gpu to use for best performance and latency on a case-by-case basis. (E.g. compositing outputs connected to the dedicated gpu and displaying apps running on the dedicated gpu with the dedicated gpu to avoid unnecessary copies.)

So effectively Cosmic will always use all gpus in the system, that are required for a given configuration. But it does so lazily, so there will not be any open resources to e.g. the dedicated gpu, if nothing is using it. And resources will be freed again opportunistically, e.g. to allow the gpu to enter sleep modes. (The desktop also displays gpu-usage by apps in the power applet.)

This should give you all information to be able to re-bind a gpu for gpu-passthrough without any explicit configuration.

Zeioth commented 2 months ago

This is necessary.

I have 6 monitors. 4 of them attached to the main GPU and 2 attached to the secondary GPU.

I need the to be able to choose the main GPU to tell cosmic to use the main GPU for the main 4 monitors, and let the secondary one to display static information (at the 2º GPU performance is halved in wlroots).

Drakulix commented 2 months ago

I need the to be able to choose the main GPU to tell cosmic to use the main GPU for the main 4 monitors, and let the secondary one to display static information (at the 2º GPU performance is halved in wlroots).

This already happens. Cosmic will use the respective gpu connected to each monitor. That doesn't need the concept of a primary gpu.

(Assuming the apps running on said monitor also run on the respective gpu. Otherwise we have to introduce some copies, but be assured we do as much as possible on the gpu connected to each output.)

Zeioth commented 2 months ago

Unlesss I'm wrong, Cosmic is currently ignoring the wlroots env var

WLR_DRM_DEVICES=/dev/dri/card1:/dev/dri/card0

It would be good to respect it, or having a similar one, like hyprland does:

AQ_DRM_DEVICES=/dev/dri/card1:/dev/dri/card0
Drakulix commented 2 months ago

We do have COSMIC_RENDER_DEVICE, which only takes a single render node (so e.g. /dev/dri/renderD128).

The only thing that influences is which GPU is advertised by default to applications, but you can always launch apps on different GPUs using the context menus of the launcher, app-library or dock.

flukejones commented 1 month ago

Cosmic doesn't really have a concept of a primary-gpu.

It has a fallback-gpu that it uses in (very rare) cases, where it cannot determine the appropriate gpu to use and that defaults to the internal gpu / boot gpu / first gpu (in this order) in the system (but is configurable via an environment variable).

I have a very good usecase for forcing selection of GPU now - https://github.com/pop-os/cosmic-comp/issues/913

Ideally we'd want this solved permanently in kernel but for situations such as what I'm now facing this would help a lot. COSMIC_RENDER_DEVICE=/dev/dri/renderD129 doesn't seem to help here though.

gnome has this

KDE uses:

KWIN_DRM_DEVICES=/dev/dri/card1:/dev/dri/card0

and there's the WLR ones above.