Commit f6c4cc6b authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

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.
parent 853ce5bc
......@@ -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) {
......
......@@ -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>>;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment