Qt3DRender::QComputeCommand Class

class Qt3DRender::QComputeCommand

为 GPU 上的计算着色器发布工作的 QComponent。更多

头文件: #include <QComputeCommand>
CMake: find_package(Qt6 REQUIRED COMPONENTS 3drender)
target_link_libraries(mytarget PRIVATE Qt6::3drender)
qmake: QT += 3drender
在 QML 中: ComputeCommand
继承: Qt3DCore::QComponent
状态:已废弃

属性

公共功能

QComputeCommand(Qt3DCore::QNode *parent = nullptr)
Qt3DRender::QComputeCommand::RunType runType() const
int workGroupX() const
int workGroupY() const
int workGroupZ() const

公共插槽

void setRunType(Qt3DRender::QComputeCommand::RunType runType)
void setWorkGroupX(int workGroupX)
void setWorkGroupY(int workGroupY)
void setWorkGroupZ(int workGroupZ)
void trigger(int frameCount = 1)
void trigger(int workGroupX, int workGroupY, int workGroupZ, int frameCount = 1)

信号

详细说明

Qt3DRender::QComputeCommand 用于为计算着色器发布工作。计算着色器是在添加 QComputeCommand 的同一实体的QMaterial 组件中指定的。workGroupXworkGroupYworkGroupZ 属性指定了调用计算着色器的工作组大小。Qt3DRender::QDispatchCompute 节点需要存在于 FrameGraph 中,以便实际发出命令。

注意: 如果渲染策略设置为Qt3DRender::QRenderSettings::OnDemand ,且场景没有任何变化,则不会重复调用ComputeCommand 。如果场景中没有其他变化触发渲染新帧,则必须设置Qt3DRender::QRenderSettings::Always 渲染策略才能重复调用ComputeCommand

属性文档

runType : RunType

指定计算命令是每帧执行还是手动触发。

如果设置为 "连续",则每帧都执行计算命令。这是默认设置。

如果设置为 Manual(手动),计算命令会在给定帧数内执行,然后组件会自行禁用。

访问功能:

Qt3DRender::QComputeCommand::RunType runType() const
void setRunType(Qt3DRender::QComputeCommand::RunType runType)

通知信号:

void runTypeChanged()

workGroupX : int

指定 X 工作组的大小。

访问功能:

int workGroupX() const
void setWorkGroupX(int workGroupX)

通知信号:

void workGroupXChanged()

workGroupY : int

指定 Y 工作组大小。

访问功能:

int workGroupY() const
void setWorkGroupY(int workGroupY)

通知信号:

void workGroupYChanged()

workGroupZ : int

指定 Z 工作组大小。

访问功能:

int workGroupZ() const
void setWorkGroupZ(int workGroupZ)

通知信号:

void workGroupZChanged()

成员函数 文档

[explicit] QComputeCommand::QComputeCommand(Qt3DCore::QNode *parent = nullptr)

构造函数使用指定的parent 创建一个新的Qt3DRender::QComputeCommand 实例。

[slot] void QComputeCommand::setWorkGroupX(int workGroupX)

将第一个维度的工作组设置为workGroupX

注: 属性workGroupX 的设置函数。

另请参阅 workGroupX() 。

[slot] void QComputeCommand::setWorkGroupY(int workGroupY)

将第二个维度的工作组设置为workGroupY

注: 属性workGroupY 的设置函数。

另请参阅 workGroupY() 。

[slot] void QComputeCommand::setWorkGroupZ(int workGroupZ)

将第三个维度的工作组设置为workGroupZ

注: 属性workGroupZ 的设置函数。

另请参阅 workGroupZ() 。

[slot] void QComputeCommand::trigger(int frameCount = 1)

当运行类型设置为手动时,调用触发器将使计算命令在接下来的frameCount 帧中执行。执行完成后,启用属性将被设置为 false。

[slot] void QComputeCommand::trigger(int workGroupX, int workGroupY, int workGroupZ, int frameCount = 1)

当运行类型设置为手动时,调用触发器将使计算命令在接下来的frameCount 帧中执行。执行完成后,启用属性将被设置为 false。之前设置的工作组大小将被workGroupX,workGroupY,workGroupZ 所覆盖。

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