Commit aa8c9ffc authored by Xaver Hugl's avatar Xaver Hugl
Browse files

platforms/drm: use gbm with NVidia driver 495+

(cherry picked from commit dc56b03d)
parent 4c2a1b13
......@@ -74,7 +74,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);
......@@ -551,4 +558,9 @@ bool DrmGpu::isFormatSupported(uint32_t drmFormat) const
}
}
bool DrmGpu::isNVidia() const
{
return m_isNVidia;
}
}
......@@ -94,6 +94,7 @@ public:
bool addFB2ModifiersSupported() const {
return m_addFB2ModifiersSupported;
}
bool isNVidia() const;
void waitIdle();
DrmBackend *platform() const;
......@@ -131,6 +132,7 @@ private:
const dev_t m_deviceId;
bool m_atomicModeSetting;
bool m_useEglStreams;
bool m_isNVidia;
gbm_device* m_gbmDevice;
EGLDisplay m_eglDisplay = EGL_NO_DISPLAY;
clockid_t m_presentationClock;
......
......@@ -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);
}
......
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