diff options
author | JiDe Zhang <zhangjide@uniontech.com> | 2023-06-02 10:12:16 +0800 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2023-06-06 14:09:02 +0000 |
commit | 71bf2a3a321d5d3bb7b7869f412178bb5328b167 (patch) | |
tree | 030a5c7c3bccff83477bdbd26c0ee950c69a6279 /src/gui/rhi/qrhivulkan.cpp | |
parent | 08f3aa32b768afc73b067b4f9e60c4ea5199cdac (diff) |
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>
Diffstat (limited to 'src/gui/rhi/qrhivulkan.cpp')
-rw-r--r-- | src/gui/rhi/qrhivulkan.cpp | 15 |
1 files 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<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); } |