diff --git a/src/backends/drm/drm_egl_layer_surface.cpp b/src/backends/drm/drm_egl_layer_surface.cpp index 6d9fde7e38..0f2caf40de 100644 --- a/src/backends/drm/drm_egl_layer_surface.cpp +++ b/src/backends/drm/drm_egl_layer_surface.cpp @@ -241,25 +241,24 @@ std::optional EglGbmLayerSurface::createSurface(con }; const auto testFormats = [this, &sort, &doTestFormats](QVector &formats) -> std::optional { std::sort(formats.begin(), formats.end(), sort); - if (const auto surface = doTestFormats(formats, MultiGpuImportMode::Dmabuf)) { - if (m_gpu != m_eglBackend->gpu()) { - qCDebug(KWIN_DRM) << "chose dmabuf import with format" << formatName(surface->gbmSwapchain->format()).name << "and modifier" << surface->gbmSwapchain->modifier(); - } + if (m_gpu == m_eglBackend->gpu()) { + return doTestFormats(formats, MultiGpuImportMode::None); + } + if (const auto surface = doTestFormats(formats, MultiGpuImportMode::Egl)) { + qCDebug(KWIN_DRM) << "chose egl import with format" << formatName(surface->gbmSwapchain->format()).name << "and modifier" << surface->gbmSwapchain->modifier(); return surface; } - if (m_gpu != m_eglBackend->gpu()) { - if (const auto surface = doTestFormats(formats, MultiGpuImportMode::LinearDmabuf)) { - qCDebug(KWIN_DRM) << "chose linear dmabuf import with format" << formatName(surface->gbmSwapchain->format()).name << "and modifier" << surface->gbmSwapchain->modifier(); - return surface; - } - if (const auto surface = doTestFormats(formats, MultiGpuImportMode::Egl)) { - qCDebug(KWIN_DRM) << "chose egl import with format" << formatName(surface->gbmSwapchain->format()).name << "and modifier" << surface->gbmSwapchain->modifier(); - return surface; - } - if (const auto surface = doTestFormats(formats, MultiGpuImportMode::DumbBuffer)) { - qCDebug(KWIN_DRM) << "chose cpu import with format" << formatName(surface->gbmSwapchain->format()).name << "and modifier" << surface->gbmSwapchain->modifier(); - return surface; - } + if (const auto surface = doTestFormats(formats, MultiGpuImportMode::Dmabuf)) { + qCDebug(KWIN_DRM) << "chose dmabuf import with format" << formatName(surface->gbmSwapchain->format()).name << "and modifier" << surface->gbmSwapchain->modifier(); + return surface; + } + if (const auto surface = doTestFormats(formats, MultiGpuImportMode::LinearDmabuf)) { + qCDebug(KWIN_DRM) << "chose linear dmabuf import with format" << formatName(surface->gbmSwapchain->format()).name << "and modifier" << surface->gbmSwapchain->modifier(); + return surface; + } + if (const auto surface = doTestFormats(formats, MultiGpuImportMode::DumbBuffer)) { + qCDebug(KWIN_DRM) << "chose cpu import with format" << formatName(surface->gbmSwapchain->format()).name << "and modifier" << surface->gbmSwapchain->modifier(); + return surface; } return std::nullopt; }; diff --git a/src/backends/drm/drm_egl_layer_surface.h b/src/backends/drm/drm_egl_layer_surface.h index 2b46bff126..b7561e5456 100644 --- a/src/backends/drm/drm_egl_layer_surface.h +++ b/src/backends/drm/drm_egl_layer_surface.h @@ -65,6 +65,7 @@ public: private: enum class MultiGpuImportMode { + None, Dmabuf, LinearDmabuf, Egl,