From 71bf2a3a321d5d3bb7b7869f412178bb5328b167 Mon Sep 17 00:00:00 2001 From: JiDe Zhang Date: Fri, 2 Jun 2023 10:12:16 +0800 Subject: [PATCH] Fix can't create rhi if VkInstance is not enable VK_KHR_surface The VK_KHR_surface is not need if we not using QRhiSwapChain, such as using QQuickRenderControl on QtQuick, it's using "beginOffscreenFrame" without QRhiSwapChain. It's useful if you using a custom VkInstance to QVulkanInstance, and the VkInstance is not create by other library and isn't enable the VK_KHR_surface extension. Pick-to: 6.6 6.5 Change-Id: I7623630adea9c933f38c180d4d73044b0e88f5b8 Reviewed-by: Laszlo Agocs --- src/gui/rhi/qrhivulkan.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index 822e71647b..197b077990 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -714,13 +714,6 @@ bool QRhiVulkan::create(QRhi::Flags flags) inst->getInstanceProcAddr("vkGetPhysicalDeviceSurfaceFormatsKHR")); vkGetPhysicalDeviceSurfacePresentModesKHR = reinterpret_cast( inst->getInstanceProcAddr("vkGetPhysicalDeviceSurfacePresentModesKHR")); - if (!vkGetPhysicalDeviceSurfaceCapabilitiesKHR - || !vkGetPhysicalDeviceSurfaceFormatsKHR - || !vkGetPhysicalDeviceSurfacePresentModesKHR) - { - qWarning("Physical device surface queries not available"); - return false; - } df = inst->deviceFunctions(dev); @@ -4283,6 +4276,14 @@ void QRhiVulkan::recordTransitionPassResources(QVkCommandBuffer *cbD, const QRhi QRhiSwapChain *QRhiVulkan::createSwapChain() { + if (!vkGetPhysicalDeviceSurfaceCapabilitiesKHR + || !vkGetPhysicalDeviceSurfaceFormatsKHR + || !vkGetPhysicalDeviceSurfacePresentModesKHR) + { + qWarning("Physical device surface queries not available"); + return nullptr; + } + return new QVkSwapChain(this); }