backends/wayland: Check whether it's possible to create a swapchain with the given format+modifier

BUG: 485496
wilder/Plasma/6.2
Vlad Zahorodnii 2 years ago
parent df60eef0db
commit 9af15a979d
  1. 16
      src/backends/wayland/wayland_egl_backend.cpp

@ -66,22 +66,18 @@ std::optional<OutputLayerBeginFrameInfo> WaylandEglPrimaryLayer::doBeginFrame()
const QSize nativeSize = m_output->modeSize();
if (!m_swapchain || m_swapchain->size() != nativeSize) {
const QHash<uint32_t, QList<uint64_t>> formatTable = m_backend->backend()->display()->linuxDmabuf()->formats();
uint32_t format = DRM_FORMAT_INVALID;
QList<uint64_t> modifiers;
for (const uint32_t &candidateFormat : {DRM_FORMAT_XRGB2101010, DRM_FORMAT_XRGB8888}) {
auto it = formatTable.constFind(candidateFormat);
if (it != formatTable.constEnd()) {
format = it.key();
modifiers = it.value();
if (it == formatTable.constEnd()) {
continue;
}
m_swapchain = EglSwapchain::create(m_backend->drmDevice()->allocator(), m_backend->openglContext(), nativeSize, it.key(), it.value());
if (m_swapchain) {
break;
}
}
if (format == DRM_FORMAT_INVALID) {
qCWarning(KWIN_WAYLAND_BACKEND) << "Could not find a suitable render format";
return std::nullopt;
}
m_swapchain = EglSwapchain::create(m_backend->drmDevice()->allocator(), m_backend->openglContext(), nativeSize, format, modifiers);
if (!m_swapchain) {
qCWarning(KWIN_WAYLAND_BACKEND) << "Could not find a suitable render format";
return std::nullopt;
}
}

Loading…
Cancel
Save