From f097440eb4cbd2ec184141ac179bf62bc14ee46d Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Wed, 10 Nov 2021 16:18:53 +0100 Subject: [PATCH] backends/drm: don't cache formats While it could be useful with tiled displays, the isFormatSupported and supportedModifier functions can be called before prepareModeset, so where m_formats is still empty. Additionally they're neither in a hot path nor performance critical. --- src/backends/drm/drm_pipeline.cpp | 22 ++++++++++++++-------- src/backends/drm/drm_pipeline.h | 2 -- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/backends/drm/drm_pipeline.cpp b/src/backends/drm/drm_pipeline.cpp index 170e8e63ea..9a166cdb5d 100644 --- a/src/backends/drm/drm_pipeline.cpp +++ b/src/backends/drm/drm_pipeline.cpp @@ -34,10 +34,6 @@ DrmPipeline::DrmPipeline(DrmConnector *conn) : m_output(nullptr) , m_connector(conn) { - if (!gpu()->atomicModeSetting()) { - m_formats.insert(DRM_FORMAT_XRGB8888, {}); - m_formats.insert(DRM_FORMAT_ARGB8888, {}); - } } DrmPipeline::~DrmPipeline() @@ -348,8 +344,6 @@ void DrmPipeline::prepareModeset() pending.crtc->primaryPlane()->setPending(DrmPlane::PropertyIndex::CrtcId, activePending() ? pending.crtc->id() : 0); pending.crtc->primaryPlane()->setTransformation(DrmPlane::Transformation::Rotate0); pending.crtc->primaryPlane()->set(QPoint(0, 0), sourceSize(), QPoint(0, 0), mode->size()); - - m_formats = pending.crtc->primaryPlane()->formats(); } void DrmPipeline::applyPendingChanges() @@ -466,12 +460,24 @@ DrmOutput *DrmPipeline::output() const bool DrmPipeline::isFormatSupported(uint32_t drmFormat) const { - return m_formats.contains(drmFormat); + if (pending.crtc) { + if (pending.crtc->primaryPlane()) { + return pending.crtc->primaryPlane()->formats().contains(drmFormat); + } else { + return drmFormat == DRM_FORMAT_XRGB8888 || drmFormat == DRM_FORMAT_ARGB8888; + } + } else { + return false; + } } QVector DrmPipeline::supportedModifiers(uint32_t drmFormat) const { - return m_formats[drmFormat]; + if (pending.crtc && pending.crtc->primaryPlane()) { + return pending.crtc->primaryPlane()->formats()[drmFormat]; + } else { + return {}; + } } bool DrmPipeline::needsModeset() const diff --git a/src/backends/drm/drm_pipeline.h b/src/backends/drm/drm_pipeline.h index 126fdc3e94..3e57ffb155 100644 --- a/src/backends/drm/drm_pipeline.h +++ b/src/backends/drm/drm_pipeline.h @@ -132,8 +132,6 @@ private: bool m_pageflipPending = false; bool m_modesetPresentPending = false; - QMap> m_formats; - // the state that will be applied at the next real atomic commit State m_next; // the state that is already committed