platforms/drm: Use a heuristic to determine if EGLDevice backend can be used

Currently, in order to use the EGLStreams backend, you need to set a
kernel parameter and an environment variable. If you set only the kernel
parameter, performance-wise, kwin will be unusable.

This change makes using the EGLStreams backend easier by making the env
var optional. If you omit KWIN_DRM_USE_EGL_STREAMS=1, kwin will check the
driver name to determine whether the EGLStreams can be enabled.
icc-effect-5.20.5
Vlad Zahorodnii 2020-10-23 09:53:56 +03:00
parent 853ce5bcb8
commit f6c4cc6b8d
2 changed files with 21 additions and 5 deletions

View File

@ -66,11 +66,6 @@ DrmBackend::DrmBackend(QObject *parent)
, m_udevMonitor(m_udev->monitor())
, m_dpmsFilter()
{
#if HAVE_EGL_STREAMS
if (qEnvironmentVariableIsSet("KWIN_DRM_USE_EGL_STREAMS")) {
m_useEglStreams = true;
}
#endif
setSupportsGammaControl(true);
supportsOutputChanges();
}
@ -271,6 +266,17 @@ void DrmBackend::openDrm()
);
m_drmId = device->sysNum();
#if HAVE_EGL_STREAMS
if (qEnvironmentVariableIsSet("KWIN_DRM_USE_EGL_STREAMS")) {
m_useEglStreams = true;
} else {
// If KWIN_DRM_USE_EGL_STREAMS is not set and we know that we are running with
// the nvidia proprietary driver, enable the EGLStreams backend anyway.
DrmScopedPointer<drmVersion> version(drmGetVersion(fd));
m_useEglStreams = version->name == QByteArrayLiteral("nvidia-drm");
}
#endif
// trying to activate Atomic Mode Setting (this means also Universal Planes)
if (!qEnvironmentVariableIsSet("KWIN_DRM_NO_AMS")) {
if (drmSetClientCap(m_fd, DRM_CLIENT_CAP_ATOMIC, 1) == 0) {

View File

@ -12,6 +12,7 @@
#include <QScopedPointer>
#include <xf86drm.h>
#include <xf86drmMode.h>
namespace KWin
@ -128,6 +129,15 @@ struct DrmDeleter<drmModeRes>
}
};
template <>
struct DrmDeleter<drmVersion>
{
static void cleanup(drmVersion *version)
{
drmFreeVersion(version);
}
};
template <typename T>
using DrmScopedPointer = QScopedPointer<T, DrmDeleter<T>>;