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 <laszlo.agocs@qt.io>
This commit is contained in:
JiDe Zhang 2023-06-02 10:12:16 +08:00 committed by Laszlo Agocs
parent 08f3aa32b7
commit 71bf2a3a32

View File

@ -714,13 +714,6 @@ bool QRhiVulkan::create(QRhi::Flags flags)
inst->getInstanceProcAddr("vkGetPhysicalDeviceSurfaceFormatsKHR"));
vkGetPhysicalDeviceSurfacePresentModesKHR = reinterpret_cast<PFN_vkGetPhysicalDeviceSurfacePresentModesKHR>(
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);
}