backends/drm: only update modes if actually necessary

This prevents some unneeded modesets
This commit is contained in:
Xaver Hugl 2022-02-25 18:04:01 +01:00
parent 72d9711e5d
commit 907cf72bb0
2 changed files with 15 additions and 8 deletions

View file

@ -263,9 +263,7 @@ bool DrmGpu::updateOutputs()
conn->updateProperties(); conn->updateProperties();
} }
if (conn->isConnected()) { if (conn->isConnected()) {
if (auto output = findOutput(conn->id())) { if (conn->isNonDesktop() ? !findLeaseOutput(conn->id()) : !findOutput(conn->id())) {
output->updateModes();
} else if (!findLeaseOutput(conn->id())) {
qCDebug(KWIN_DRM, "New %soutput on GPU %s: %s", conn->isNonDesktop() ? "non-desktop " : "", qPrintable(m_devNode), qPrintable(conn->modelName())); qCDebug(KWIN_DRM, "New %soutput on GPU %s: %s", conn->isNonDesktop() ? "non-desktop " : "", qPrintable(m_devNode), qPrintable(conn->modelName()));
m_pipelines << conn->pipeline(); m_pipelines << conn->pipeline();
if (conn->isNonDesktop()) { if (conn->isNonDesktop()) {

View file

@ -13,6 +13,7 @@
#include "logging.h" #include "logging.h"
#include "drm_pipeline.h" #include "drm_pipeline.h"
#include "drm_object_crtc.h" #include "drm_object_crtc.h"
#include "drm_output.h"
#include <main.h> #include <main.h>
// frameworks // frameworks
@ -286,11 +287,19 @@ bool DrmConnector::needsModeset() const
void DrmConnector::updateModes() void DrmConnector::updateModes()
{ {
m_modes.clear(); bool equal = m_conn->count_modes == m_modes.count();
for (int i = 0; equal && i < m_conn->count_modes; i++) {
// reload modes equal &= checkIfEqual(m_modes[i]->nativeMode(), &m_conn->modes[i]);
for (int i = 0; i < m_conn->count_modes; i++) { }
m_modes.append(QSharedPointer<DrmConnectorMode>::create(this, m_conn->modes[i])); if (!equal) {
// reload modes
m_modes.clear();
for (int i = 0; i < m_conn->count_modes; i++) {
m_modes.append(QSharedPointer<DrmConnectorMode>::create(this, m_conn->modes[i]));
}
if (const auto output = dynamic_cast<DrmOutput*>(m_pipeline->displayDevice())) {
output->updateModes();
}
} }
} }