backends/drm: remove support for transforming the scene with hardware rotation
This feature is no longer needed, as the scene can efficiently do its own transformations now. Support for using hardware rotation to make direct scanout work specifically can be added again later
This commit is contained in:
parent
8ca38fb328
commit
9e3999dc5f
6 changed files with 10 additions and 80 deletions
|
@ -30,7 +30,7 @@ namespace KWin
|
|||
|
||||
static TextureTransforms drmToTextureRotation(DrmPipeline *pipeline)
|
||||
{
|
||||
auto angle = DrmPlane::transformationToDegrees(pipeline->renderOrientation()) - DrmPlane::transformationToDegrees(pipeline->bufferOrientation());
|
||||
auto angle = DrmPlane::transformationToDegrees(pipeline->renderOrientation());
|
||||
if (angle < 0) {
|
||||
angle += 360;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ std::optional<OutputLayerBeginFrameInfo> EglGbmLayer::beginFrame()
|
|||
m_scanoutBuffer.reset();
|
||||
m_dmabufFeedback.renderingSurface();
|
||||
|
||||
return m_surface.startRendering(m_pipeline->bufferSize(), drmToTextureRotation(m_pipeline) | TextureTransform::MirrorY, m_pipeline->formats());
|
||||
return m_surface.startRendering(m_pipeline->mode()->size(), drmToTextureRotation(m_pipeline) | TextureTransform::MirrorY, m_pipeline->formats());
|
||||
}
|
||||
|
||||
bool EglGbmLayer::endFrame(const QRegion &renderedRegion, const QRegion &damagedRegion)
|
||||
|
@ -79,7 +79,7 @@ QRegion EglGbmLayer::currentDamage() const
|
|||
|
||||
bool EglGbmLayer::checkTestBuffer()
|
||||
{
|
||||
return m_surface.renderTestBuffer(m_pipeline->bufferSize(), m_pipeline->formats()) != nullptr;
|
||||
return m_surface.renderTestBuffer(m_pipeline->mode()->size(), m_pipeline->formats()) != nullptr;
|
||||
}
|
||||
|
||||
std::shared_ptr<GLTexture> EglGbmLayer::texture() const
|
||||
|
@ -106,7 +106,7 @@ bool EglGbmLayer::scanout(SurfaceItem *surfaceItem)
|
|||
return false;
|
||||
}
|
||||
const auto surface = item->surface();
|
||||
if (m_pipeline->bufferOrientation() != DrmPlane::Transformation::Rotate0 || surface->bufferTransform() != m_pipeline->output()->transform()) {
|
||||
if (surface->bufferTransform() != m_pipeline->output()->transform()) {
|
||||
return false;
|
||||
}
|
||||
const auto buffer = qobject_cast<KWaylandServer::LinuxDmaBufV1ClientBuffer *>(surface->buffer());
|
||||
|
|
|
@ -435,21 +435,7 @@ DrmPipeline::Error DrmGpu::testPendingConfiguration()
|
|||
return c1->getProp(DrmConnector::PropertyIndex::CrtcId)->current() > c2->getProp(DrmConnector::PropertyIndex::CrtcId)->current();
|
||||
});
|
||||
}
|
||||
DrmPipeline::Error err = checkCrtcAssignment(connectors, crtcs);
|
||||
if (err == DrmPipeline::Error::None || err == DrmPipeline::Error::NoPermission || err == DrmPipeline::Error::FramePending) {
|
||||
return err;
|
||||
} else {
|
||||
// try again without hw rotation
|
||||
bool hwRotationUsed = false;
|
||||
for (const auto &pipeline : std::as_const(m_pipelines)) {
|
||||
hwRotationUsed |= (pipeline->bufferOrientation() != DrmPlane::Transformations(DrmPlane::Transformation::Rotate0));
|
||||
pipeline->setBufferOrientation(DrmPlane::Transformation::Rotate0);
|
||||
}
|
||||
if (hwRotationUsed) {
|
||||
err = checkCrtcAssignment(connectors, crtcs);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
return checkCrtcAssignment(connectors, crtcs);
|
||||
}
|
||||
|
||||
DrmPipeline::Error DrmGpu::testPipelines()
|
||||
|
|
|
@ -400,9 +400,6 @@ DrmPipeline *DrmOutput::pipeline() const
|
|||
|
||||
bool DrmOutput::queueChanges(const std::shared_ptr<OutputChangeSet> &props)
|
||||
{
|
||||
static bool valid;
|
||||
static int envOnlySoftwareRotations = qEnvironmentVariableIntValue("KWIN_DRM_SW_ROTATIONS_ONLY", &valid) == 1 || !valid;
|
||||
|
||||
const auto mode = props->mode.value_or(currentMode()).lock();
|
||||
if (!mode) {
|
||||
return false;
|
||||
|
@ -411,9 +408,6 @@ bool DrmOutput::queueChanges(const std::shared_ptr<OutputChangeSet> &props)
|
|||
m_pipeline->setOverscan(props->overscan.value_or(m_pipeline->overscan()));
|
||||
m_pipeline->setRgbRange(props->rgbRange.value_or(m_pipeline->rgbRange()));
|
||||
m_pipeline->setRenderOrientation(outputToPlaneTransform(props->transform.value_or(transform())));
|
||||
if (!envOnlySoftwareRotations && m_gpu->atomicModeSetting()) {
|
||||
m_pipeline->setBufferOrientation(m_pipeline->renderOrientation());
|
||||
}
|
||||
m_pipeline->setEnable(props->enabled.value_or(m_pipeline->enabled()));
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -99,7 +99,6 @@ DrmPipeline::Error DrmPipeline::commitPipelinesAtomic(const QVector<DrmPipeline
|
|||
{
|
||||
auto commit = std::make_unique<DrmAtomicCommit>(pipelines.front()->gpu());
|
||||
for (const auto &pipeline : pipelines) {
|
||||
pipeline->checkHardwareRotation();
|
||||
if (pipeline->activePending()) {
|
||||
if (!pipeline->m_pending.layer->checkTestBuffer()) {
|
||||
qCWarning(KWIN_DRM) << "Checking test buffer failed for" << mode;
|
||||
|
@ -170,15 +169,6 @@ DrmPipeline::Error DrmPipeline::commitPipelinesAtomic(const QVector<DrmPipeline
|
|||
}
|
||||
}
|
||||
|
||||
static QSize orientateSize(const QSize &size, DrmPlane::Transformations transforms)
|
||||
{
|
||||
if (transforms & (DrmPlane::Transformation::Rotate90 | DrmPlane::Transformation::Rotate270)) {
|
||||
return size.transposed();
|
||||
} else {
|
||||
return size;
|
||||
}
|
||||
}
|
||||
|
||||
static QRect centerBuffer(const QSize &bufferSize, const QSize &modeSize)
|
||||
{
|
||||
const double widthScale = bufferSize.width() / double(modeSize.width());
|
||||
|
@ -213,7 +203,7 @@ bool DrmPipeline::prepareAtomicPresentation(DrmAtomicCommit *commit)
|
|||
}
|
||||
|
||||
const auto fb = m_pending.layer->currentBuffer().get();
|
||||
m_pending.crtc->primaryPlane()->set(commit, QPoint(0, 0), fb->buffer()->size(), centerBuffer(orientateSize(fb->buffer()->size(), m_pending.bufferOrientation), m_pending.mode->size()));
|
||||
m_pending.crtc->primaryPlane()->set(commit, QPoint(0, 0), fb->buffer()->size(), centerBuffer(fb->buffer()->size(), m_pending.mode->size()));
|
||||
commit->addProperty(m_pending.crtc->primaryPlane()->getProp(DrmPlane::PropertyIndex::FbId), fb->framebufferId());
|
||||
|
||||
if (auto plane = m_pending.crtc->cursorPlane()) {
|
||||
|
@ -273,7 +263,7 @@ void DrmPipeline::prepareAtomicModeset(DrmAtomicCommit *commit)
|
|||
|
||||
commit->addProperty(m_pending.crtc->primaryPlane()->getProp(DrmPlane::PropertyIndex::CrtcId), m_pending.crtc->id());
|
||||
if (const auto rotation = m_pending.crtc->primaryPlane()->getProp(DrmPlane::PropertyIndex::Rotation)) {
|
||||
commit->addEnum(rotation, m_pending.bufferOrientation);
|
||||
commit->addEnum(rotation, DrmPlane::Transformation::Rotate0);
|
||||
}
|
||||
if (m_pending.crtc->cursorPlane()) {
|
||||
if (const auto rotation = m_pending.crtc->cursorPlane()->getProp(DrmPlane::PropertyIndex::Rotation)) {
|
||||
|
@ -282,18 +272,6 @@ void DrmPipeline::prepareAtomicModeset(DrmAtomicCommit *commit)
|
|||
}
|
||||
}
|
||||
|
||||
void DrmPipeline::checkHardwareRotation()
|
||||
{
|
||||
if (m_pending.crtc && m_pending.crtc->primaryPlane()) {
|
||||
const bool supported = (m_pending.bufferOrientation & m_pending.crtc->primaryPlane()->supportedTransformations());
|
||||
if (!supported) {
|
||||
m_pending.bufferOrientation = DrmPlane::Transformation::Rotate0;
|
||||
}
|
||||
} else {
|
||||
m_pending.bufferOrientation = DrmPlane::Transformation::Rotate0;
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t DrmPipeline::calculateUnderscan()
|
||||
{
|
||||
const auto size = m_pending.mode->size();
|
||||
|
@ -393,15 +371,6 @@ void DrmPipeline::applyPendingChanges()
|
|||
m_next = m_pending;
|
||||
}
|
||||
|
||||
QSize DrmPipeline::bufferSize() const
|
||||
{
|
||||
const auto modeSize = m_pending.mode->size();
|
||||
if (m_pending.bufferOrientation & (DrmPlane::Transformation::Rotate90 | DrmPlane::Transformation::Rotate270)) {
|
||||
return modeSize.transposed();
|
||||
}
|
||||
return modeSize;
|
||||
}
|
||||
|
||||
DrmConnector *DrmPipeline::connector() const
|
||||
{
|
||||
return m_connector;
|
||||
|
@ -561,11 +530,6 @@ DrmPlane::Transformations DrmPipeline::renderOrientation() const
|
|||
return m_pending.renderOrientation;
|
||||
}
|
||||
|
||||
DrmPlane::Transformations DrmPipeline::bufferOrientation() const
|
||||
{
|
||||
return m_pending.bufferOrientation;
|
||||
}
|
||||
|
||||
RenderLoopPrivate::SyncMode DrmPipeline::syncMode() const
|
||||
{
|
||||
return m_pending.syncMode;
|
||||
|
@ -625,11 +589,6 @@ void DrmPipeline::setRenderOrientation(DrmPlane::Transformations orientation)
|
|||
m_pending.renderOrientation = orientation;
|
||||
}
|
||||
|
||||
void DrmPipeline::setBufferOrientation(DrmPlane::Transformations orientation)
|
||||
{
|
||||
m_pending.bufferOrientation = orientation;
|
||||
}
|
||||
|
||||
void DrmPipeline::setSyncMode(RenderLoopPrivate::SyncMode mode)
|
||||
{
|
||||
m_pending.syncMode = mode;
|
||||
|
|
|
@ -87,10 +87,6 @@ public:
|
|||
bool pageflipPending() const;
|
||||
bool modesetPresentPending() const;
|
||||
void resetModesetPresentPending();
|
||||
/**
|
||||
* what size buffers submitted to this pipeline should have
|
||||
*/
|
||||
QSize bufferSize() const;
|
||||
|
||||
QMap<uint32_t, QVector<uint64_t>> formats() const;
|
||||
QMap<uint32_t, QVector<uint64_t>> cursorFormats() const;
|
||||
|
@ -107,7 +103,6 @@ public:
|
|||
DrmPipelineLayer *primaryLayer() const;
|
||||
DrmOverlayLayer *cursorLayer() const;
|
||||
DrmPlane::Transformations renderOrientation() const;
|
||||
DrmPlane::Transformations bufferOrientation() const;
|
||||
RenderLoopPrivate::SyncMode syncMode() const;
|
||||
uint32_t overscan() const;
|
||||
Output::RgbRange rgbRange() const;
|
||||
|
@ -119,7 +114,6 @@ public:
|
|||
void setEnable(bool enable);
|
||||
void setLayers(const std::shared_ptr<DrmPipelineLayer> &primaryLayer, const std::shared_ptr<DrmOverlayLayer> &cursorLayer);
|
||||
void setRenderOrientation(DrmPlane::Transformations orientation);
|
||||
void setBufferOrientation(DrmPlane::Transformations orientation);
|
||||
void setSyncMode(RenderLoopPrivate::SyncMode mode);
|
||||
void setOverscan(uint32_t overscan);
|
||||
void setRgbRange(Output::RgbRange range);
|
||||
|
@ -140,7 +134,6 @@ private:
|
|||
bool isBufferForDirectScanout() const;
|
||||
uint32_t calculateUnderscan();
|
||||
static Error errnoToError();
|
||||
void checkHardwareRotation();
|
||||
|
||||
// legacy only
|
||||
Error presentLegacy();
|
||||
|
@ -184,8 +177,6 @@ private:
|
|||
std::shared_ptr<DrmOverlayLayer> cursorLayer;
|
||||
QPoint cursorHotspot;
|
||||
|
||||
// the transformation that this pipeline will apply to submitted buffers
|
||||
DrmPlane::Transformations bufferOrientation = DrmPlane::Transformation::Rotate0;
|
||||
// the transformation that buffers submitted to the pipeline should have
|
||||
DrmPlane::Transformations renderOrientation = DrmPlane::Transformation::Rotate0;
|
||||
};
|
||||
|
|
|
@ -33,7 +33,7 @@ DrmQPainterLayer::DrmQPainterLayer(DrmPipeline *pipeline)
|
|||
std::optional<OutputLayerBeginFrameInfo> DrmQPainterLayer::beginFrame()
|
||||
{
|
||||
if (!doesSwapchainFit()) {
|
||||
m_swapchain = std::make_shared<DumbSwapchain>(m_pipeline->gpu(), m_pipeline->bufferSize(), DRM_FORMAT_XRGB8888);
|
||||
m_swapchain = std::make_shared<DumbSwapchain>(m_pipeline->gpu(), m_pipeline->mode()->size(), DRM_FORMAT_XRGB8888);
|
||||
}
|
||||
QRegion needsRepaint;
|
||||
if (!m_swapchain->acquireBuffer(&needsRepaint)) {
|
||||
|
@ -59,7 +59,7 @@ bool DrmQPainterLayer::endFrame(const QRegion &renderedRegion, const QRegion &da
|
|||
bool DrmQPainterLayer::checkTestBuffer()
|
||||
{
|
||||
if (!doesSwapchainFit()) {
|
||||
m_swapchain = std::make_shared<DumbSwapchain>(m_pipeline->gpu(), m_pipeline->bufferSize(), DRM_FORMAT_XRGB8888);
|
||||
m_swapchain = std::make_shared<DumbSwapchain>(m_pipeline->gpu(), m_pipeline->mode()->size(), DRM_FORMAT_XRGB8888);
|
||||
if (!m_swapchain->isEmpty()) {
|
||||
m_currentFramebuffer = DrmFramebuffer::createFramebuffer(m_swapchain->currentBuffer());
|
||||
if (!m_currentFramebuffer) {
|
||||
|
@ -74,7 +74,7 @@ bool DrmQPainterLayer::checkTestBuffer()
|
|||
|
||||
bool DrmQPainterLayer::doesSwapchainFit() const
|
||||
{
|
||||
return m_swapchain && m_swapchain->size() == m_pipeline->bufferSize();
|
||||
return m_swapchain && m_swapchain->size() == m_pipeline->mode()->size();
|
||||
}
|
||||
|
||||
std::shared_ptr<DrmFramebuffer> DrmQPainterLayer::currentBuffer() const
|
||||
|
|
Loading…
Reference in a new issue