summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/plugins/platforms/xcb/qxcbvulkanwindow.cpp11
-rw-r--r--src/plugins/platforms/xcb/qxcbwindow.cpp13
2 files changed, 21 insertions, 3 deletions
diff --git a/src/plugins/platforms/xcb/qxcbvulkanwindow.cpp b/src/plugins/platforms/xcb/qxcbvulkanwindow.cpp
index f9136c8b72..25bc340f97 100644
--- a/src/plugins/platforms/xcb/qxcbvulkanwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbvulkanwindow.cpp
@@ -59,11 +59,16 @@ QXcbVulkanWindow::~QXcbVulkanWindow()
void QXcbVulkanWindow::resolveFormat(const QSurfaceFormat &format)
{
m_format = format;
- m_format.setRedBufferSize(8);
- m_format.setGreenBufferSize(8);
- m_format.setBlueBufferSize(8);
+ if (m_format.redBufferSize() <= 0)
+ m_format.setRedBufferSize(8);
+ if (m_format.greenBufferSize() <= 0)
+ m_format.setGreenBufferSize(8);
+ if (m_format.blueBufferSize() <= 0)
+ m_format.setBlueBufferSize(8);
}
+// No createVisual() needed, use the default that picks one based on the R/G/B/A size.
+
VkSurfaceKHR *QXcbVulkanWindow::surface()
{
if (m_surface)
diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp
index e15c22b690..16e579b79f 100644
--- a/src/plugins/platforms/xcb/qxcbwindow.cpp
+++ b/src/plugins/platforms/xcb/qxcbwindow.cpp
@@ -410,6 +410,19 @@ void QXcbWindow::create()
qWarning() << "Failed to use requested visual id.";
}
+ if (parent()) {
+ // When using a Vulkan QWindow via QWidget::createWindowContainer() we
+ // must make sure the visuals are compatible. Now, the parent will be
+ // of RasterGLSurface which typically chooses a GLX/EGL compatible
+ // visual which may not be what the Vulkan window would choose.
+ // Therefore, take the parent's visual.
+ if (window()->surfaceType() == QSurface::VulkanSurface
+ && parent()->window()->surfaceType() != QSurface::VulkanSurface)
+ {
+ visual = platformScreen->visualForId(static_cast<QXcbWindow *>(parent())->visualId());
+ }
+ }
+
if (!visual)
visual = createVisual();