diff --git a/src/plugins/platforms/drm/drm_gpu.cpp b/src/plugins/platforms/drm/drm_gpu.cpp index db396fd40f..88bcfadc83 100644 --- a/src/plugins/platforms/drm/drm_gpu.cpp +++ b/src/plugins/platforms/drm/drm_gpu.cpp @@ -79,7 +79,14 @@ DrmGpu::DrmGpu(DrmBackend *backend, const QString &devNode, int fd, dev_t device // find out if this GPU is using the NVidia proprietary driver DrmScopedPointer version(drmGetVersion(fd)); - m_useEglStreams = strstr(version->name, "nvidia-drm"); + m_isNVidia = strstr(version->name, "nvidia-drm"); + m_useEglStreams = m_isNVidia; +#if HAVE_GBM + m_gbmDevice = gbm_create_device(m_fd); + if (m_gbmDevice) { + m_useEglStreams = m_isNVidia && strcmp(gbm_device_get_backend_name(m_gbmDevice), "nvidia") != 0; + } +#endif m_socketNotifier = new QSocketNotifier(fd, QSocketNotifier::Read, this); connect(m_socketNotifier, &QSocketNotifier::activated, this, &DrmGpu::dispatchEvents); @@ -751,4 +758,9 @@ bool DrmGpu::addFB2ModifiersSupported() const return m_addFB2ModifiersSupported; } +bool DrmGpu::isNVidia() const +{ + return m_isNVidia; +} + } diff --git a/src/plugins/platforms/drm/drm_gpu.h b/src/plugins/platforms/drm/drm_gpu.h index 72d6ac3a13..f5183ed9a3 100644 --- a/src/plugins/platforms/drm/drm_gpu.h +++ b/src/plugins/platforms/drm/drm_gpu.h @@ -55,6 +55,7 @@ public: bool atomicModeSetting() const; bool addFB2ModifiersSupported() const; bool useEglStreams() const; + bool isNVidia() const; bool isFormatSupported(uint32_t drmFormat) const; gbm_device *gbmDevice() const; EGLDisplay eglDisplay() const; @@ -104,6 +105,7 @@ private: bool m_atomicModeSetting; bool m_useEglStreams; bool m_addFB2ModifiersSupported = false; + bool m_isNVidia; clockid_t m_presentationClock; gbm_device* m_gbmDevice; EGLDisplay m_eglDisplay = EGL_NO_DISPLAY; diff --git a/src/plugins/platforms/drm/drm_object_plane.cpp b/src/plugins/platforms/drm/drm_object_plane.cpp index ffa433c582..c432d8b87f 100644 --- a/src/plugins/platforms/drm/drm_object_plane.cpp +++ b/src/plugins/platforms/drm/drm_object_plane.cpp @@ -73,7 +73,10 @@ bool DrmPlane::init() checkSupport(5, Transformation::ReflectY); // read formats from blob if available and if modifiers are supported, and from the plane object if not - if (auto formatProp = getProp(PropertyIndex::In_Formats); formatProp && gpu()->addFB2ModifiersSupported() && qEnvironmentVariableIntValue("KWIN_DRM_USE_MODIFIERS") == 1) { + bool modifiersEnvSet = false; + bool modifiersEnv = qEnvironmentVariableIntValue("KWIN_DRM_USE_MODIFIERS", &modifiersEnvSet) != 0; + bool allowModifiers = (gpu()->isNVidia() && !modifiersEnvSet) || (modifiersEnvSet && modifiersEnv); + if (auto formatProp = getProp(PropertyIndex::In_Formats); formatProp && gpu()->addFB2ModifiersSupported() && allowModifiers) { DrmScopedPointer propertyBlob(drmModeGetPropertyBlob(gpu()->fd(), formatProp->current())); if (propertyBlob && propertyBlob->data) { auto blob = static_cast(propertyBlob->data); diff --git a/src/plugins/platforms/drm/egl_gbm_backend.cpp b/src/plugins/platforms/drm/egl_gbm_backend.cpp index 147f3fdaf6..2bbbb034b5 100644 --- a/src/plugins/platforms/drm/egl_gbm_backend.cpp +++ b/src/plugins/platforms/drm/egl_gbm_backend.cpp @@ -88,14 +88,12 @@ bool EglGbmBackend::initializeEgl() return false; } - auto device = gbm_create_device(m_gpu->fd()); - if (!device) { + if (!m_gpu->gbmDevice()) { setFailed("Could not create gbm device"); return false; } - m_gpu->setGbmDevice(device); - display = eglGetPlatformDisplayEXT(platform, device, nullptr); + display = eglGetPlatformDisplayEXT(platform, m_gpu->gbmDevice(), nullptr); m_gpu->setEglDisplay(display); }