platforms/drm: use gbm with NVidia driver 495+
This commit is contained in:
parent
866830d5ed
commit
dc56b03df4
4 changed files with 21 additions and 6 deletions
|
@ -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<drmVersion> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<drmModePropertyBlobRes> propertyBlob(drmModeGetPropertyBlob(gpu()->fd(), formatProp->current()));
|
||||
if (propertyBlob && propertyBlob->data) {
|
||||
auto blob = static_cast<drm_format_modifier_blob*>(propertyBlob->data);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue