QVulkanFunctions 类

The QVulkanFunctions class provides cross-platform access to the instance level core Vulkan 1.3 API. 更多...

头: #include <QVulkanFunctions>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui

详细描述

默认情况下,Qt 和 Qt 应用程序未链接到任何 Vulkan 库。相反,在运行时动态解析所有函数。每个 QVulkanInstance 提供 QVulkanFunctions 可检索对象凭借 QVulkanInstance::functions (). This does not contain device level functions in order to avoid the potential overhead of an internal dispatching. Instead, functions that rely on a device, or a dispatchable child object of a device, are exposed via QVulkanDeviceFunctions and QVulkanInstance::deviceFunctions ()。QVulkanFunctions 和 QVulkanDeviceFunctions together provides access to the full core Vulkan API, excluding any extensions.

注意: 不可以直接构造 QVulkanFunctions 实例。

典型用法如下:

void Window::init()
{
    QVulkanInstance *inst = vulkanInstance();
    QVulkanFunctions *f = inst->functions();
    // ...
    uint32_t count = 0;
    VkResult err = f->vkEnumeratePhysicalDevices(inst->vkInstance(), &count, nullptr);
    // ...
}
						

注意: Windowing system interface (WSI) specifics and extensions are excluded. This class only covers core Vulkan commands, with the exception of instance creation, destruction, and function resolving, since such functionality is covered by QVulkanInstance 本身。

要访问额外功能,应用程序可以使用 QVulkanInstance::getInstanceProcAddr () and vkGetDeviceProcAddr(). Applications can also decide to link to a Vulkan library directly, as platforms with an appropriate loader will typically export function symbols for the core commands. See vkGetInstanceProcAddr 手册页 了解更多信息。

注意: The member function prototypes for Vulkan 1.1, 1.2, and 1.3 commands are ifdefed with the appropriate VK_VERSION_1_x that is defined by the Vulkan headers. As such, these functions will only be callable by an application when the system's (on which the application is built) Vulkan header is new enough and it contains 1.1, 1.2, or 1.3 Vulkan API definitions. When building Qt from source, this has an additional consequence: the Vulkan headers on the build environment must also be 1.1, 1.2, and 1.3 compatible to get a Qt build that supports resolving the 1.1, 1.2, and 1.3 API commands. If neither of these conditions is met, applications will only be able to call the Vulkan 1.0 commands through QVulkanFunctions and QVulkanDeviceFunctions .

另请参阅 QVulkanInstance , QVulkanDeviceFunctions , QWindow::setVulkanInstance (),和 QWindow::setSurfaceType ().