Commit 361fc0a3 authored by Xaver Hugl's avatar Xaver Hugl
Browse files

backends/drm: remove drm lease layers

They just add more code and more potential problems, and the difference in
VRAM usage is very minimal
parent b7d7a99f
Pipeline #209162 passed with stage
in 22 minutes and 9 seconds
......@@ -13,7 +13,6 @@ target_sources(kwin PRIVATE
drm_gbm_surface.cpp
drm_gpu.cpp
drm_layer.cpp
drm_lease_egl_layer.cpp
drm_logging.cpp
drm_object_connector.cpp
drm_object.cpp
......
......@@ -19,7 +19,6 @@
#include "drm_egl_layer.h"
#include "drm_gbm_surface.h"
#include "drm_gpu.h"
#include "drm_lease_egl_layer.h"
#include "drm_logging.h"
#include "drm_output.h"
#include "drm_pipeline.h"
......@@ -240,11 +239,7 @@ EGLConfig EglGbmBackend::config(uint32_t format) const
std::shared_ptr<DrmPipelineLayer> EglGbmBackend::createPrimaryLayer(DrmPipeline *pipeline)
{
if (!pipeline->output()->isNonDesktop()) {
return std::make_shared<EglGbmLayer>(this, pipeline);
} else {
return std::make_shared<DrmLeaseEglGbmLayer>(pipeline);
}
return std::make_shared<EglGbmLayer>(this, pipeline);
}
std::shared_ptr<DrmOverlayLayer> EglGbmBackend::createCursorLayer(DrmPipeline *pipeline)
......
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2022 Xaver Hugl <xaver.hugl@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "drm_lease_egl_layer.h"
#include "drm_buffer.h"
#include "drm_buffer_gbm.h"
#include "drm_egl_backend.h"
#include "drm_gpu.h"
#include "drm_logging.h"
#include "drm_pipeline.h"
#include <drm_fourcc.h>
#include <gbm.h>
namespace KWin
{
DrmLeaseEglGbmLayer::DrmLeaseEglGbmLayer(DrmPipeline *pipeline)
: DrmPipelineLayer(pipeline)
{
}
bool DrmLeaseEglGbmLayer::checkTestBuffer()
{
const auto mods = m_pipeline->formats().value(DRM_FORMAT_XRGB8888);
const auto size = m_pipeline->bufferSize();
if (!m_framebuffer || m_framebuffer->buffer()->size() != size || !(mods.isEmpty() || mods.contains(m_framebuffer->buffer()->modifier()))) {
gbm_bo *newBo;
if (mods.isEmpty()) {
newBo = gbm_bo_create(m_pipeline->gpu()->gbmDevice(), size.width(), size.height(), DRM_FORMAT_XRGB8888, GBM_BO_USE_SCANOUT);
} else {
newBo = gbm_bo_create_with_modifiers(m_pipeline->gpu()->gbmDevice(), size.width(), size.height(), DRM_FORMAT_XRGB8888, mods.constData(), mods.count());
if (!newBo && errno == ENOSYS) {
// gbm implementation doesn't support modifiers
newBo = gbm_bo_create(m_pipeline->gpu()->gbmDevice(), size.width(), size.height(), DRM_FORMAT_XRGB8888, GBM_BO_USE_SCANOUT);
}
}
if (newBo) {
m_framebuffer = DrmFramebuffer::createFramebuffer(std::make_shared<GbmBuffer>(m_pipeline->gpu(), newBo));
if (!m_framebuffer) {
qCWarning(KWIN_DRM, "Failed to create gbm framebuffer for lease output: %s", strerror(errno));
}
} else {
qCWarning(KWIN_DRM) << "Failed to create gbm_bo for lease output";
}
}
return m_framebuffer != nullptr;
}
std::shared_ptr<DrmFramebuffer> DrmLeaseEglGbmLayer::currentBuffer() const
{
return m_framebuffer;
}
OutputLayerBeginFrameInfo DrmLeaseEglGbmLayer::beginFrame()
{
return {};
}
bool DrmLeaseEglGbmLayer::endFrame(const QRegion &damagedRegion, const QRegion &renderedRegion)
{
Q_UNUSED(damagedRegion)
Q_UNUSED(renderedRegion)
return false;
}
void DrmLeaseEglGbmLayer::releaseBuffers()
{
m_framebuffer.reset();
}
}
/*
KWin - the KDE window manager
This file is part of the KDE project.
SPDX-FileCopyrightText: 2022 Xaver Hugl <xaver.hugl@gmail.com>
SPDX-License-Identifier: GPL-2.0-or-later
*/
#pragma once
#include "drm_layer.h"
namespace KWin
{
class EglGbmBackend;
class DrmLeaseEglGbmLayer : public DrmPipelineLayer
{
public:
DrmLeaseEglGbmLayer(DrmPipeline *pipeline);
OutputLayerBeginFrameInfo beginFrame() override;
bool endFrame(const QRegion &damagedRegion, const QRegion &renderedRegion) override;
bool checkTestBuffer() override;
std::shared_ptr<DrmFramebuffer> currentBuffer() const override;
void releaseBuffers() override;
private:
std::shared_ptr<DrmFramebuffer> m_framebuffer;
};
}
......@@ -46,11 +46,7 @@ OutputLayer *DrmQPainterBackend::primaryLayer(Output *output)
std::shared_ptr<DrmPipelineLayer> DrmQPainterBackend::createPrimaryLayer(DrmPipeline *pipeline)
{
if (!pipeline->output()->isNonDesktop()) {
return std::make_shared<DrmQPainterLayer>(pipeline);
} else {
return std::make_shared<DrmLeaseQPainterLayer>(pipeline);
}
return std::make_shared<DrmQPainterLayer>(pipeline);
}
std::shared_ptr<DrmOverlayLayer> DrmQPainterBackend::createCursorLayer(DrmPipeline *pipeline)
......
......@@ -174,48 +174,4 @@ QRegion DrmVirtualQPainterLayer::currentDamage() const
void DrmVirtualQPainterLayer::releaseBuffers()
{
}
DrmLeaseQPainterLayer::DrmLeaseQPainterLayer(DrmPipeline *pipeline)
: DrmPipelineLayer(pipeline)
{
}
bool DrmLeaseQPainterLayer::checkTestBuffer()
{
const auto size = m_pipeline->bufferSize();
if (!m_framebuffer || m_buffer->size() != size) {
m_buffer = DrmDumbBuffer::createDumbBuffer(m_pipeline->gpu(), size, DRM_FORMAT_XRGB8888);
if (m_buffer) {
m_framebuffer = DrmFramebuffer::createFramebuffer(m_buffer);
if (!m_framebuffer) {
qCWarning(KWIN_DRM, "Failed to create dumb framebuffer for lease output: %s", strerror(errno));
}
} else {
m_framebuffer.reset();
}
}
return m_framebuffer != nullptr;
}
std::shared_ptr<DrmFramebuffer> DrmLeaseQPainterLayer::currentBuffer() const
{
return m_framebuffer;
}
OutputLayerBeginFrameInfo DrmLeaseQPainterLayer::beginFrame()
{
return {};
}
bool DrmLeaseQPainterLayer::endFrame(const QRegion &damagedRegion, const QRegion &renderedRegion)
{
Q_UNUSED(damagedRegion)
Q_UNUSED(renderedRegion)
return false;
}
void DrmLeaseQPainterLayer::releaseBuffers()
{
m_buffer.reset();
}
}
......@@ -75,22 +75,4 @@ private:
QRegion m_currentDamage;
DrmVirtualOutput *const m_output;
};
class DrmLeaseQPainterLayer : public DrmPipelineLayer
{
public:
DrmLeaseQPainterLayer(DrmPipeline *pipeline);
OutputLayerBeginFrameInfo beginFrame() override;
bool endFrame(const QRegion &damagedRegion, const QRegion &renderedRegion) override;
bool checkTestBuffer() override;
std::shared_ptr<DrmFramebuffer> currentBuffer() const override;
void releaseBuffers() override;
private:
std::shared_ptr<DrmFramebuffer> m_framebuffer;
std::shared_ptr<DrmDumbBuffer> m_buffer;
};
}
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