QVulkanDeviceFunctions Class

QVulkanDeviceFunctions 类提供对设备级核心 Vulkan 1.3 API 的跨平台访问。更多

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

详细说明

Qt 和 Qt 应用程序默认不链接任何 Vulkan 库。相反,所有函数都是在运行时动态解析的。每个QVulkanInstance 都提供了一个QVulkanFunctions 对象,可通过QVulkanInstance::functions() 检索。该对象不包含设备级函数,以避免内部分派的潜在开销。相反,依赖于设备或设备的可调度子对象的函数通过 QVulkanDeviceFunctions 和QVulkanInstance::deviceFunctions() 公开。QVulkanFunctions 和 QVulkanDeviceFunctions 一起提供了对完整核心 Vulkan API 的访问,不包括任何扩展。

注意: QVulkanDeviceFunctions 实例不能直接构建。

典型的用法如下:

void Window::render()
{
    QVulkanInstance *inst = vulkanInstance();
    QVulkanDeviceFunctions *df = inst->deviceFunctions(device);
    VkResult err = df->vkAllocateCommandBuffers(device, &cmdBufInfo, &cmdBuf);
    // ...
}

QVulkanInstance::deviceFunctions() 首次被调用时,针对所提供的 VkDevice 创建 QVulkanDeviceFunctions 对象。然后在内部缓存该对象。

要访问其他功能,应用程序可以使用QVulkanInstance::getInstanceProcAddr() 和 vkGetDeviceProcAddr()。应用程序还可以决定直接链接到 Vulkan 库,因为许多实现都为核心命令导出了函数符号。更多信息请参见vkGetInstanceProcAddr 的手册

另请参见 QVulkanInstance,QVulkanFunctions,QWindow::setVulkanInstance() 和QWindow::setSurfaceType()。

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.