backends/drm: if multi-gpu copy fails, disable deep color
The format XRGB8888 is effectively universally supported. If everything else fails, try to fall back to that
This commit is contained in:
parent
0a3922e29d
commit
0ecfbb0d1c
2 changed files with 34 additions and 11 deletions
|
@ -334,8 +334,9 @@ QSharedPointer<DrmBuffer> EglGbmBackend::importFramebuffer(Output &output, const
|
||||||
}
|
}
|
||||||
// ImportMode::DumbBuffer
|
// ImportMode::DumbBuffer
|
||||||
if (!output.current.importSwapchain || output.current.importSwapchain->size() != size) {
|
if (!output.current.importSwapchain || output.current.importSwapchain->size() != size) {
|
||||||
output.current.importSwapchain = QSharedPointer<DumbSwapchain>::create(m_gpu, size, renderingBackend()->drmFormat(output.output));
|
const uint32_t format = renderingBackend()->drmFormat(output.output);
|
||||||
if (output.current.importSwapchain->isEmpty()) {
|
output.current.importSwapchain = QSharedPointer<DumbSwapchain>::create(m_gpu, size, format);
|
||||||
|
if (output.current.importSwapchain->isEmpty() || output.current.importSwapchain->currentBuffer()->format() != format) {
|
||||||
output.current.importSwapchain = nullptr;
|
output.current.importSwapchain = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -346,7 +347,8 @@ QSharedPointer<DrmBuffer> EglGbmBackend::importFramebuffer(Output &output, const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
qCWarning(KWIN_DRM) << "all imports failed on output" << output.output;
|
qCWarning(KWIN_DRM) << "all imports failed on output" << output.output;
|
||||||
// TODO turn off output?
|
// try again with XRGB8888, the most universally supported basic format
|
||||||
|
output.forceXrgb8888 = true;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -542,18 +544,21 @@ QRegion EglGbmBackend::beginFrame(AbstractOutput *drmOutput)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EglGbmBackend::doesRenderFit(DrmAbstractOutput *output, const Output::RenderData &render)
|
bool EglGbmBackend::doesRenderFit(const Output &output, const Output::RenderData &render)
|
||||||
{
|
{
|
||||||
if (!render.gbmSurface) {
|
if (!render.gbmSurface) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
QSize surfaceSize = output->bufferSize();
|
if (output.forceXrgb8888 && render.gbmSurface->format() != DRM_FORMAT_XRGB8888) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
QSize surfaceSize = output.output->bufferSize();
|
||||||
if (surfaceSize != render.gbmSurface->size()) {
|
if (surfaceSize != render.gbmSurface->size()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool needsTexture = output->needsSoftwareTransformation();
|
bool needsTexture = output.output->needsSoftwareTransformation();
|
||||||
if (needsTexture) {
|
if (needsTexture) {
|
||||||
return render.shadowBuffer && render.shadowBuffer->textureSize() == output->sourceSize();
|
return render.shadowBuffer && render.shadowBuffer->textureSize() == output.output->sourceSize();
|
||||||
} else {
|
} else {
|
||||||
return render.shadowBuffer == nullptr;
|
return render.shadowBuffer == nullptr;
|
||||||
}
|
}
|
||||||
|
@ -562,8 +567,8 @@ bool EglGbmBackend::doesRenderFit(DrmAbstractOutput *output, const Output::Rende
|
||||||
QRegion EglGbmBackend::prepareRenderingForOutput(Output &output)
|
QRegion EglGbmBackend::prepareRenderingForOutput(Output &output)
|
||||||
{
|
{
|
||||||
// check if the current surface still fits
|
// check if the current surface still fits
|
||||||
if (!doesRenderFit(output.output, output.current)) {
|
if (!doesRenderFit(output, output.current)) {
|
||||||
if (doesRenderFit(output.output, output.old)) {
|
if (doesRenderFit(output, output.old)) {
|
||||||
cleanupRenderData(output.current);
|
cleanupRenderData(output.current);
|
||||||
output.current = output.old;
|
output.current = output.old;
|
||||||
output.old = {};
|
output.old = {};
|
||||||
|
@ -761,9 +766,17 @@ bool EglGbmBackend::scanout(AbstractOutput *drmOutput, SurfaceItem *surfaceItem)
|
||||||
|
|
||||||
QSharedPointer<DrmBuffer> EglGbmBackend::renderTestFrame(DrmAbstractOutput *output)
|
QSharedPointer<DrmBuffer> EglGbmBackend::renderTestFrame(DrmAbstractOutput *output)
|
||||||
{
|
{
|
||||||
|
beginFrame(output);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
const auto buffer = endFrameWithBuffer(output, output->geometry());
|
||||||
|
if (!buffer && this != renderingBackend()) {
|
||||||
|
// if CPU import fails we might need to try again
|
||||||
beginFrame(output);
|
beginFrame(output);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
return endFrameWithBuffer(output, output->geometry());
|
return endFrameWithBuffer(output, output->geometry());
|
||||||
|
} else {
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer<GLTexture> EglGbmBackend::textureForOutput(AbstractOutput *output) const
|
QSharedPointer<GLTexture> EglGbmBackend::textureForOutput(AbstractOutput *output) const
|
||||||
|
@ -812,6 +825,15 @@ DrmGpu *EglGbmBackend::gpu() const
|
||||||
|
|
||||||
std::optional<GbmFormat> EglGbmBackend::chooseFormat(Output &output) const
|
std::optional<GbmFormat> EglGbmBackend::chooseFormat(Output &output) const
|
||||||
{
|
{
|
||||||
|
if (output.forceXrgb8888) {
|
||||||
|
return GbmFormat {
|
||||||
|
.drmFormat = DRM_FORMAT_XRGB8888,
|
||||||
|
.redSize = 8,
|
||||||
|
.greenSize = 8,
|
||||||
|
.blueSize = 8,
|
||||||
|
.alphaSize = 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
// formats are already sorted by order of preference
|
// formats are already sorted by order of preference
|
||||||
std::optional<GbmFormat> fallback;
|
std::optional<GbmFormat> fallback;
|
||||||
for (const auto &format : qAsConst(m_formats)) {
|
for (const auto &format : qAsConst(m_formats)) {
|
||||||
|
|
|
@ -95,6 +95,7 @@ private:
|
||||||
};
|
};
|
||||||
struct Output {
|
struct Output {
|
||||||
DrmAbstractOutput *output = nullptr;
|
DrmAbstractOutput *output = nullptr;
|
||||||
|
bool forceXrgb8888 = false;
|
||||||
struct RenderData {
|
struct RenderData {
|
||||||
QSharedPointer<ShadowBuffer> shadowBuffer;
|
QSharedPointer<ShadowBuffer> shadowBuffer;
|
||||||
QSharedPointer<GbmSurface> gbmSurface;
|
QSharedPointer<GbmSurface> gbmSurface;
|
||||||
|
@ -115,7 +116,7 @@ private:
|
||||||
QPointer<KWaylandServer::SurfaceInterface> oldScanoutCandidate;
|
QPointer<KWaylandServer::SurfaceInterface> oldScanoutCandidate;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool doesRenderFit(DrmAbstractOutput *output, const Output::RenderData &render);
|
bool doesRenderFit(const Output &output, const Output::RenderData &render);
|
||||||
bool resetOutput(Output &output);
|
bool resetOutput(Output &output);
|
||||||
bool addOutput(DrmAbstractOutput *output);
|
bool addOutput(DrmAbstractOutput *output);
|
||||||
void removeOutput(DrmAbstractOutput *output);
|
void removeOutput(DrmAbstractOutput *output);
|
||||||
|
|
Loading…
Reference in a new issue