Commit 907cf72b authored by Xaver Hugl's avatar Xaver Hugl
Browse files

backends/drm: only update modes if actually necessary

This prevents some unneeded modesets
parent 72d9711e
......@@ -263,9 +263,7 @@ bool DrmGpu::updateOutputs()
conn->updateProperties();
}
if (conn->isConnected()) {
if (auto output = findOutput(conn->id())) {
output->updateModes();
} else if (!findLeaseOutput(conn->id())) {
if (conn->isNonDesktop() ? !findLeaseOutput(conn->id()) : !findOutput(conn->id())) {
qCDebug(KWIN_DRM, "New %soutput on GPU %s: %s", conn->isNonDesktop() ? "non-desktop " : "", qPrintable(m_devNode), qPrintable(conn->modelName()));
m_pipelines << conn->pipeline();
if (conn->isNonDesktop()) {
......
......@@ -13,6 +13,7 @@
#include "logging.h"
#include "drm_pipeline.h"
#include "drm_object_crtc.h"
#include "drm_output.h"
#include <main.h>
// frameworks
......@@ -286,11 +287,19 @@ bool DrmConnector::needsModeset() const
void DrmConnector::updateModes()
{
m_modes.clear();
// reload modes
for (int i = 0; i < m_conn->count_modes; i++) {
m_modes.append(QSharedPointer<DrmConnectorMode>::create(this, m_conn->modes[i]));
bool equal = m_conn->count_modes == m_modes.count();
for (int i = 0; equal && i < m_conn->count_modes; i++) {
equal &= checkIfEqual(m_modes[i]->nativeMode(), &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();
}
}
}
......
Supports Markdown
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