backends/drm: ensure correct format+modifiers pairs for surfaces

When the crtcs get switched around between outputs, their primary
planes and thus the supported formats also get switched around. In
order to make sure that doesn't cause any problems, always check
whether or not the format+modifiers used are supported.
master
Xaver Hugl 3 years ago
parent bd3dd7ce36
commit fe9a3f45c0

@ -552,6 +552,10 @@ bool EglGbmBackend::doesRenderFit(const Output &output, const Output::RenderData
if (output.forceXrgb8888 && render.gbmSurface->format() != DRM_FORMAT_XRGB8888) { if (output.forceXrgb8888 && render.gbmSurface->format() != DRM_FORMAT_XRGB8888) {
return false; return false;
} }
if (!output.output->isFormatSupported(render.gbmSurface->format())
|| output.output->supportedModifiers(render.gbmSurface->format()) != render.gbmSurface->modifiers()) {
return false;
}
QSize surfaceSize = output.output->bufferSize(); QSize surfaceSize = output.output->bufferSize();
if (surfaceSize != render.gbmSurface->size()) { if (surfaceSize != render.gbmSurface->size()) {
return false; return false;

@ -40,6 +40,7 @@ GbmSurface::GbmSurface(DrmGpu *gpu, const QSize &size, uint32_t format, QVector<
, m_gpu(gpu) , m_gpu(gpu)
, m_size(size) , m_size(size)
, m_format(format) , m_format(format)
, m_modifiers(modifiers)
{ {
if (!m_surface) { if (!m_surface) {
qCCritical(KWIN_DRM) << "Could not create gbm surface!" << strerror(errno); qCCritical(KWIN_DRM) << "Could not create gbm surface!" << strerror(errno);
@ -138,4 +139,9 @@ uint32_t GbmSurface::format() const
return m_format; return m_format;
} }
QVector<uint64_t> GbmSurface::modifiers() const
{
return m_modifiers;
}
} }

@ -40,6 +40,7 @@ public:
QSize size() const; QSize size() const;
bool isValid() const; bool isValid() const;
uint32_t format() const; uint32_t format() const;
QVector<uint64_t> modifiers() const;
private: private:
gbm_surface *m_surface; gbm_surface *m_surface;
@ -47,6 +48,7 @@ private:
EGLSurface m_eglSurface = EGL_NO_SURFACE; EGLSurface m_eglSurface = EGL_NO_SURFACE;
QSize m_size; QSize m_size;
const uint32_t m_format; const uint32_t m_format;
const QVector<uint64_t> m_modifiers;
QSharedPointer<GbmBuffer> m_currentBuffer; QSharedPointer<GbmBuffer> m_currentBuffer;
QSharedPointer<DrmGbmBuffer> m_currentDrmBuffer; QSharedPointer<DrmGbmBuffer> m_currentDrmBuffer;

Loading…
Cancel
Save