From 8a04657a8ee31bf48d1688be30a7b5ec39047915 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Gu=C3=A9rin?= Date: Sat, 15 Feb 2020 08:14:01 -0800 Subject: [PATCH] renderer-native: Prioritize eGPUs External GPUs typically have a dedicated display and are connected to the computer through a slow link (TB3 is PCIe 3.0 4x), we want to do compositing on that GPU to avoid extra copies and get the best possible performance. To solve this, give priority to any GPU that isn't the one we booted with, is hardware accelerated and has at least one monitor connected. This should play nice with single GPU, traditional dual GPUs, Optimus-like and DisplayLink setups. https://gitlab.gnome.org/GNOME/mutter/merge_requests/1057 --- src/backends/native/meta-renderer-native.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c index e15932526e4..10c6e689ad3 100644 --- a/src/backends/native/meta-renderer-native.c +++ b/src/backends/native/meta-renderer-native.c @@ -4109,6 +4109,19 @@ choose_primary_gpu_unchecked (MetaBackend *backend, */ for (allow_sw = 0; allow_sw < 2; allow_sw++) { + /* First, consider hardware-accelerated secondary GPUs with connected + * outputs (like eGPUs) + */ + for (l = gpus; l; l = l->next) + { + MetaGpuKms *gpu_kms = META_GPU_KMS (l->data); + + if (!meta_gpu_kms_is_boot_vga (gpu_kms) && + meta_gpu_kms_can_have_outputs (gpu_kms) && + gpu_kms_is_hardware_rendering (renderer_native, gpu_kms)) + return gpu_kms; + } + /* Prefer a platform device */ for (l = gpus; l; l = l->next) { -- GitLab