vulkan: Add flag to opt out from enumerating Portability phys.devices

Task-number: QTBUG-106912
Change-Id: I1cb4adae4bed62f31d781a89a03b70885411f91f
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
This commit is contained in:
Laszlo Agocs 2022-09-25 11:15:46 +02:00
parent 7fbc741d10
commit b018bc6e2d
3 changed files with 12 additions and 6 deletions

View File

@ -217,7 +217,8 @@ void QBasicPlatformVulkanInstance::initInstance(QVulkanInstance *instance, const
}
m_enabledExtensions.append("VK_KHR_surface");
m_enabledExtensions.append("VK_KHR_portability_enumeration");
if (!flags.testFlag(QVulkanInstance::NoPortabilityDrivers))
m_enabledExtensions.append("VK_KHR_portability_enumeration");
if (!flags.testFlag(QVulkanInstance::NoDebugOutputRedirect))
m_enabledExtensions.append("VK_EXT_debug_utils");
@ -258,7 +259,8 @@ void QBasicPlatformVulkanInstance::initInstance(QVulkanInstance *instance, const
VkInstanceCreateInfo instInfo = {};
instInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
instInfo.pApplicationInfo = &appInfo;
instInfo.flags = 0x00000001; // VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR
if (!flags.testFlag(QVulkanInstance::NoPortabilityDrivers))
instInfo.flags |= 0x00000001; // VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR
QList<const char *> layerNameVec;
for (const QByteArray &ba : qAsConst(m_enabledLayers))

View File

@ -206,6 +206,7 @@ QT_BEGIN_NAMESPACE
the behavior of create().
\value NoDebugOutputRedirect Disables Vulkan debug output (\c{VK_EXT_debug_utils}) redirection to qDebug.
\value NoPortabilityDrivers Disables enumerating physical devices marked as Vulkan Portability.
*/
bool QVulkanInstancePrivate::ensureVulkan()
@ -484,7 +485,8 @@ void QVulkanInstance::setLayers(const QByteArrayList &layers)
VK_KHR_win32_surface) will always be added automatically, no need to
include them in this list.
\note \c VK_KHR_portability_enumeration is added automatically.
\note \c VK_KHR_portability_enumeration is added automatically unless the
NoPortabilityDrivers flag is set. This value was introduced in Qt 6.5.
\note This function can only be called before create() and has no effect if
called afterwards.
@ -543,9 +545,10 @@ void QVulkanInstance::setApiVersion(const QVersionNumber &vulkanVersion)
The Vulkan instance and library is available as long as this
QVulkanInstance exists, or until destroy() is called.
The VkInstance is always created with the flag
By default the VkInstance is created with the flag
\l{https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkInstanceCreateFlagBits.html}{VK_INSTANCE_CREATE_ENUMERATE_PORTABILITY_BIT_KHR}
set. This means that Vulkan Portability physical devices get enumerated as well.
set. This means that Vulkan Portability physical devices get enumerated as
well. If this is not desired, set the NoPortabilityDrivers flag.
*/
bool QVulkanInstance::create()
{

View File

@ -135,7 +135,8 @@ public:
~QVulkanInstance();
enum Flag {
NoDebugOutputRedirect = 0x01
NoDebugOutputRedirect = 0x01,
NoPortabilityDrivers = 0x02
};
Q_DECLARE_FLAGS(Flags, Flag)