pop-os / cosmic-epoch

Next generation Cosmic desktop environment
1.72k stars 55 forks source link

Issues with AMD Advantage laptop #210

Open road2react opened 4 months ago

road2react commented 4 months ago

Hardware: ASUS G513QY (G15 Advantage Edition)

CPU: AMD Ryzen 9 5900HX

GPU: AMD Radeon 6800M

Integrated GPU is connected to laptop display, and any external monitor connected using DisplayPort over USB-C is connected to the discrete GPU.

I have tested running cosmic-epoch-git from AUR (version r117.8dec6bd-1) and have experienced some issues. Windows that show on the laptop display work fine, but if I drag it over to the external monitor, the dragging animation becomes laggy (around 10 fps). Additionally, I tested http://vsynctester.com/ on Google Chrome: it runs at 300Hz (full refresh rate) on the laptop screen, but drops to 60Hz if I start moving the cursor on top of the browser window. The cursor itself doesn't lag; only the vsynctester animation. This occurs even if I specifically select a GPU via the right click menu on the application icon on dock.

Is the compositor using a GPU as "primary"? This is how GNOME, KDE, and wlroots render; the compositor renders everything in one place. However, this causes issues with hybrid graphics setups: if an intensive application runs on the discrete GPU, the compositor runs on the integrated GPU, and the monitor is connected to the discrete GPU, the application's graphics need to be copied to the integrated GPU, then copied back to the discrete GPU before being displayed, which greatly reduces the performance.

Drakulix commented 4 months ago

I have just merged a PR into cosmic-comp two days ago that contain a bunch of optimizations for Multi-GPU setups: https://github.com/pop-os/cosmic-comp/pull/278

Although part of the master branch of cosmic-comp, the cosmic-comp submodule in cosmic-epoch hasn't been updated yet, so the AUR won't contain these changes.

Could you possibly compile cosmic-comp from source and see, if that improves things for you? Thanks for the very detailed bug report btw, much appreciated! :)

Drakulix commented 4 months ago

To answer the more technical question of

Is the compositor using a GPU as "primary"?

Yes and no.

The compositor dynamically chooses a GPU to use for compositing per output per frame, different from GNOME/KDE/wlroots.

But the involved wayland protocols currently don't allow us to easily advertise other available GPUs for rendering, so most clients will simply use the integrated GPU.

Even our new support of selecting a GPU in the launcher/app-library/dock will go through DRI_PRIME, which will render on the discrete gpu, then import into the integrated gpu and then pass it to the compositor, causing an unnecessary round-trip for external monitors (except for direct scanout cases). This is the same as GNOME/KDE/wlroots work in that regard.

We are working on bypassing this issue, so that applications running on the discrete gpu and being displayed on an output connected to the discrete gpu can skip doing any copies.

You can already use that by setting WAYLAND_DISPLAY=wayland-1-renderD129 (or whatever render-node in /dev/dri corresponds to the GPU you want to use) instead of using DRI_PRIME before launching the application. However this only works for wayland-native apps right now, which is why we are not using the mechanism from our launcher/app-library/dock yet. (But that will come in a future update, once we have sorted out the Xwayland situation around this.)

road2react commented 4 months ago

Even our new support of selecting a GPU in the launcher/app-library/dock will go through DRI_PRIME, which will render on the discrete gpu, then import into the integrated gpu

Is it possible to treat the discrete GPU as "primary"?

Drakulix commented 4 months ago

Even our new support of selecting a GPU in the launcher/app-library/dock will go through DRI_PRIME, which will render on the discrete gpu, then import into the integrated gpu

Is it possible to treat the discrete GPU as "primary"?

Yes, you can override this by setting COSMIC_RENDER_DEVICE=/dev/dri/renderD129 (for example) as an environment variable before starting cosmic. (E.g. by editing your shell's configuration, e.g. ~/.profile.)

However as stated mid-long term this won't be necessary and cosmic will treat all GPUs in a way, where the correct one is selected automatically without any unnecessary copies being involved. I don't recommend using this setting as it will keep your dedicated gpu turned on all the time causing increase battery usage.