platforms/drm: use drm formats instead of gbm formats

There's no need to guard the code, gbm and drm format definitions
are the same. Using GBM_BO_FORMAT_* even caused bugs, as that is
an enum and not a proper format identifier.

BUG: 441253
This commit is contained in:
Xaver Hugl 2021-08-26 18:36:52 +02:00
parent 092660613a
commit d6de38c1d6
5 changed files with 10 additions and 14 deletions

View file

@ -35,6 +35,7 @@
#include <xf86drm.h>
#include <xf86drmMode.h>
#include <libdrm/drm_mode.h>
#include <drm_fourcc.h>
namespace KWin
{
@ -498,13 +499,13 @@ void DrmGpu::removeVirtualOutput(DrmVirtualOutput *output)
}
}
bool DrmGpu::isFormatSupported(uint32_t gbmFormat) const
bool DrmGpu::isFormatSupported(uint32_t drmFormat) const
{
if (!m_atomicModeSetting) {
return gbmFormat == GBM_BO_FORMAT_XRGB8888 || gbmFormat == GBM_BO_FORMAT_ARGB8888;
return drmFormat == DRM_FORMAT_XRGB8888 || drmFormat == DRM_FORMAT_ARGB8888;
} else {
for (const auto &plane : qAsConst(m_planes)) {
if (plane->type() == DrmPlane::TypeIndex::Primary && !plane->formats().contains(gbmFormat)) {
if (plane->type() == DrmPlane::TypeIndex::Primary && !plane->formats().contains(drmFormat)) {
return false;
}
}

View file

@ -98,7 +98,7 @@ public:
void waitIdle();
DrmBackend *platform() const;
const QVector<DrmPipeline*> pipelines() const;
bool isFormatSupported(uint32_t gbmFormat) const;
bool isFormatSupported(uint32_t drmFormat) const;
DrmVirtualOutput *createVirtualOutput();
void removeVirtualOutput(DrmVirtualOutput *output);

View file

@ -13,9 +13,7 @@
#include "logging.h"
#include "config-kwin.h"
#if HAVE_GBM
#include <gbm.h>
#endif
#include <drm_fourcc.h>
namespace KWin
{
@ -101,14 +99,11 @@ bool DrmPlane::init()
m_supportedFormats.insert(p->formats[i], {});
}
}
#if HAVE_GBM
if (m_supportedFormats.isEmpty()) {
qCWarning(KWIN_DRM) << "Driver doesn't advertise any formats for this plane. Falling back to XRGB8888 and ARGB8888 without modifiers";
m_supportedFormats.insert(GBM_BO_FORMAT_XRGB8888, {});
m_supportedFormats.insert(GBM_BO_FORMAT_ARGB8888, {});
m_supportedFormats.insert(DRM_FORMAT_XRGB8888, {});
m_supportedFormats.insert(DRM_FORMAT_ARGB8888, {});
}
#endif
}
return success;
}

View file

@ -414,7 +414,7 @@ bool EglGbmBackend::initBufferConfigs()
eglGetConfigAttrib(eglDisplay(), configs[i], EGL_ALPHA_SIZE, &alphaSize);
// prefer XRGB8888 as it's most likely to be supported by secondary GPUs as well
if (gbmFormat == GBM_BO_FORMAT_XRGB8888) {
if (gbmFormat == GBM_FORMAT_XRGB8888) {
m_gbmFormat = gbmFormat;
setConfig(configs[i]);
return true;

View file

@ -35,7 +35,7 @@ KWin::GbmDmaBuf *GbmDmaBuf::createBuffer(const QSize &size, gbm_device *device)
return nullptr;
}
auto bo = gbm_bo_create(device, size.width(), size.height(), GBM_BO_FORMAT_ARGB8888, GBM_BO_USE_RENDERING | GBM_BO_USE_LINEAR);
auto bo = gbm_bo_create(device, size.width(), size.height(), GBM_FORMAT_ARGB8888, GBM_BO_USE_RENDERING | GBM_BO_USE_LINEAR);
if (!bo) {
gbm_bo_destroy(bo);