Commit b7a3a028 authored by Xaver Hugl's avatar Xaver Hugl
Browse files

backends/drm: fix recording with direct scanout

Backported from 72d9711e

BUG: 450943
FIXED-IN: 5.24.3
parent 85558234
Pipeline #143523 passed with stage
in 24 minutes and 59 seconds
......@@ -529,6 +529,7 @@ QRegion EglGbmBackend::beginFrame(AbstractOutput *drmOutput)
qCDebug(KWIN_DRM) << "Direct scanout stopped on output" << output.output->name();
}
output.scanoutSurface = nullptr;
output.scanoutBuffer = nullptr;
if (output.scanoutCandidate.surface) {
output.oldScanoutCandidate = output.scanoutCandidate.surface;
output.scanoutCandidate = {};
......@@ -768,6 +769,7 @@ bool EglGbmBackend::scanout(AbstractOutput *drmOutput, SurfaceItem *surfaceItem)
qCDebug(KWIN_DRM).nospace() << "Direct scanout starting on output " << output.output->name() << " for application \"" << path << "\"";
}
output.scanoutSurface = surface;
output.scanoutBuffer = bo;
return true;
} else {
// TODO clean the modeset and direct scanout code paths up
......@@ -796,7 +798,18 @@ QSharedPointer<DrmBuffer> EglGbmBackend::renderTestFrame(DrmAbstractOutput *outp
QSharedPointer<GLTexture> EglGbmBackend::textureForOutput(AbstractOutput *output) const
{
Q_ASSERT(m_outputs.contains(output));
const auto createImage = [this, output](GbmBuffer *buffer) {
EGLImageKHR image = eglCreateImageKHR(eglDisplay(), nullptr, EGL_NATIVE_PIXMAP_KHR, buffer->getBo(), nullptr);
if (image == EGL_NO_IMAGE_KHR) {
qCWarning(KWIN_DRM) << "Failed to record frame: Error creating EGLImageKHR - " << glGetError();
return QSharedPointer<EGLImageTexture>(nullptr);
}
return QSharedPointer<EGLImageTexture>::create(eglDisplay(), image, GL_RGBA8, static_cast<DrmAbstractOutput*>(output)->modeSize());
};
auto &renderOutput = m_outputs[output];
if (renderOutput.scanoutBuffer) {
return createImage(dynamic_cast<GbmBuffer*>(renderOutput.scanoutBuffer.data()));
}
if (renderOutput.current.shadowBuffer) {
const auto glTexture = QSharedPointer<KWin::GLTexture>::create(renderOutput.current.shadowBuffer->texture(), GL_RGBA8, renderOutput.output->sourceSize());
glTexture->setYInverted(true);
......@@ -807,13 +820,7 @@ QSharedPointer<GLTexture> EglGbmBackend::textureForOutput(AbstractOutput *output
qCWarning(KWIN_DRM) << "Failed to record frame: No gbm buffer!";
return {};
}
EGLImageKHR image = eglCreateImageKHR(eglDisplay(), nullptr, EGL_NATIVE_PIXMAP_KHR, gbmBuffer->getBo(), nullptr);
if (image == EGL_NO_IMAGE_KHR) {
qCWarning(KWIN_DRM) << "Failed to record frame: Error creating EGLImageKHR - " << glGetError();
return {};
}
return QSharedPointer<EGLImageTexture>::create(eglDisplay(), image, GL_RGBA8, static_cast<DrmAbstractOutput*>(output)->modeSize());
return createImage(gbmBuffer);
}
bool EglGbmBackend::directScanoutAllowed(AbstractOutput *output) const
......
......@@ -113,6 +113,7 @@ private:
QPointer<KWaylandServer::SurfaceInterface> surface;
QMap<uint32_t, QVector<uint64_t>> attemptedFormats;
} scanoutCandidate;
QSharedPointer<DrmBuffer> scanoutBuffer;
QPointer<KWaylandServer::SurfaceInterface> oldScanoutCandidate;
};
......
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