QRhiMetalInitParams Struct

金属专用初始化参数。更多

头文件 #include <rhi/qrhi.h>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::GuiPrivate)
qmake: QT += gui-private
Qt 6.6
继承于 QRhiInitParams

详细描述

注意: 这是一个 RHI API,具有有限的兼容性保证,详情请参见QRhi

基于 Metal 的QRhi 在初始化时不需要特殊参数。

QRhiMetalInitParams params;
rhi = QRhi::create(QRhi::Metal, &params);

注意: Metal API 验证无法通过QRhi 以编程方式启用。相反,要么在 XCode 中运行应用程序的调试构建,通过cmake -G Xcode 生成.xcodeproj 文件,要么设置环境变量METAL_DEVICE_WRAPPER_TYPE=1 。该变量需要尽早在环境中设置,最好是在启动程序之前设置;试图在创建QRhi 时设置该变量实际上是行不通的。(可能太晚了)

注意: QRhiSwapChain 只能针对表面类型设置为QSurface::MetalSurfaceQWindow 实例。

与现有的 Metal 设备协同工作

与其他图形引擎互操作时,可能需要获取使用相同 Metal 设备的QRhi 实例。这可以通过向QRhi::create() 传递指向QRhiMetalNativeHandles 的指针来实现。设备必须设置为非空值。此外,还可以指定一个命令队列对象。

QRhi 不拥有任何外部对象的所有权。

© 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.