Qt3DRender::QComputeCommand Class
class Qt3DRender::QComputeCommandQComponent 用于向 GPU 上的计算着色器分发任务。更多内容...
| 标题: | #include <qcomputecommand.h> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS 3drender) target_link_libraries(mytarget PRIVATE Qt6::3drender) |
| qmake: | QT += 3drender |
| 在 QML 中: | ComputeCommand |
| 继承自: | Qt3DCore::QComponent |
| 状态: | 已弃用 |
该类已弃用。我们强烈建议不要在新代码中使用它。
属性
- runType : RunType
- workGroupX : int
- workGroupY : int
- workGroupZ : int
公共函数
| 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) |
信号
| void | runTypeChanged() |
| void | workGroupXChanged() |
| void | workGroupYChanged() |
| void | workGroupZChanged() |
详细说明
Qt3DRender::QComputeCommand 用于向计算着色器分发任务。计算着色器在与 QComputeCommand 所属同一实体的QMaterial 组件中进行指定。workGroupX 、workGroupY 和workGroupZ 属性用于指定计算着色器调用的工作组大小。FrameGraph 中必须存在Qt3DRender::QDispatchCompute 节点,才能实际分发这些命令。
ComputeCommand 注意:如果 渲染策略设置为“Qt3DRender::QRenderSettings::OnDemand ”,且场景未发生变化,则不会反复调用ComputeCommand 。若场景中没有其他变化触发新帧的渲染,必须将渲染策略设置为Qt3DRender::QRenderSettings::Always ,才能使 被反复调用。
属性文档
runType : RunType
指定计算命令是应每帧执行一次,还是手动触发。
如果设置为“连续”,则计算命令将在每帧执行。这是默认设置。
如果设置为“手动”,则“计算”命令将执行指定帧数,之后该组件将自动停用。
访问函数:
| 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 帧内执行。执行完成后,enabled属性将被设置为false。
注意:此 插槽为重载插槽。要连接到此插槽:
// Connect using qOverload:
connect(sender, &SenderClass::signal,
computeCommand, qOverload(&QComputeCommand::trigger));
// Or using a lambda as wrapper:
connect(sender, &SenderClass::signal,
computeCommand, [receiver = computeCommand](int frameCount) { receiver->trigger(frameCount); }); [slot] void QComputeCommand::trigger(int workGroupX, int workGroupY, int workGroupZ, int frameCount = 1)
当运行类型设置为“手动”时,调用触发器将使计算命令在接下来的frameCount 帧内执行。执行完成后,enabled属性将被设置为false。此前设置的工作组大小将被workGroupX 、workGroupY 、workGroupZ 覆盖。
注意:此 插槽已被重载。若要连接到此插槽:
// Connect using qOverload:
connect(sender, &SenderClass::signal,
computeCommand, qOverload(&QComputeCommand::trigger));
// Or using a lambda as wrapper:
connect(sender, &SenderClass::signal,
computeCommand, [receiver = computeCommand](int workGroupX, int workGroupY, int workGroupZ, int frameCount) { receiver->trigger(workGroupX, workGroupY, workGroupZ, frameCount); }); © 2026 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.