Only release shared buffers right before the next frame

BUG: 425586
This commit is contained in:
Xaver Hugl 2021-01-28 23:32:42 +01:00
parent ed793dca21
commit 2c6d19fec1
3 changed files with 8 additions and 26 deletions

View file

@ -35,9 +35,6 @@ public:
Q_UNUSED(stride)
return 0;
}
virtual void cleanupDmabufForSecondaryGpuOutput(AbstractOutput *output) {
Q_UNUSED(output)
}
virtual QRegion beginFrameForSecondaryGpu(AbstractOutput *output) {
Q_UNUSED(output)
return QRegion();

View file

@ -271,6 +271,14 @@ int EglGbmBackend::getDmabufForSecondaryGpuOutput(AbstractOutput *output, uint32
if (it == m_secondaryGpuOutputs.end()) {
return -1;
}
if (it->dmabufFd) {
close(it->dmabufFd);
it->dmabufFd = 0;
}
if (it->secondaryGbmBo) {
it->gbmSurface.get()->releaseBuffer(it->secondaryGbmBo);
it->secondaryGbmBo = nullptr;
}
renderFramebufferToSurface(*it);
auto error = eglSwapBuffers(eglDisplay(), it->eglSurface);
if (error != EGL_TRUE) {
@ -289,27 +297,6 @@ int EglGbmBackend::getDmabufForSecondaryGpuOutput(AbstractOutput *output, uint32
return it->dmabufFd;
}
void EglGbmBackend::cleanupDmabufForSecondaryGpuOutput(AbstractOutput *output)
{
DrmOutput *drmOutput = static_cast<DrmOutput*>(output);
auto it = std::find_if(m_secondaryGpuOutputs.begin(), m_secondaryGpuOutputs.end(),
[drmOutput] (const Output &output) {
return output.output == drmOutput;
}
);
if (it == m_secondaryGpuOutputs.end()) {
return;
}
if (it->dmabufFd) {
close(it->dmabufFd);
it->dmabufFd = 0;
}
if (it->secondaryGbmBo) {
it->gbmSurface.get()->releaseBuffer(it->secondaryGbmBo);
it->secondaryGbmBo = nullptr;
}
}
QRegion EglGbmBackend::beginFrameForSecondaryGpu(AbstractOutput *output)
{
DrmOutput *drmOutput = static_cast<DrmOutput*>(output);
@ -471,7 +458,6 @@ void EglGbmBackend::renderFramebufferToSurface(Output &output)
output.importedGbmBo = importedBuffer;
}
}
renderingBackend()->cleanupDmabufForSecondaryGpuOutput(output.output);
}
}

View file

@ -46,7 +46,6 @@ public:
void addOutput(DrmOutput *output) override;
void removeOutput(DrmOutput *output) override;
int getDmabufForSecondaryGpuOutput(AbstractOutput *output, uint32_t *format, uint32_t *stride) override;
void cleanupDmabufForSecondaryGpuOutput(AbstractOutput *output) override;
QRegion beginFrameForSecondaryGpu(AbstractOutput *output) override;
protected: