本页内容

Qt3DRender::QWaitFence Class

class Qt3DRender::QWaitFence

FrameGraphNode 以前是等待图形命令流中的一个栅栏发出信号。更多...

标题: #include <qwaitfence.h>
CMake: find_package(Qt6 REQUIRED COMPONENTS 3drender)
target_link_libraries(mytarget PRIVATE Qt6::3drender)
qmake: QT += 3drender
继承自: Qt3DRender::QFrameGraphNode
状态: 已弃用

该类已弃用。我们强烈建议不要在新代码中使用它。

属性

公共函数

QVariant handle() const
Qt3DRender::QWaitFence::HandleType handleType() const
void setHandle(QVariant handle)
void setHandleType(Qt3DRender::QWaitFence::HandleType type)
void setTimeout(quint64 timeout)
void setWaitOnCPU(bool waitOnCPU)
quint64 timeout() const
bool waitOnCPU() const

信号

void handleChanged(QVariant handle)
void handleTypeChanged(Qt3DRender::QWaitFence::HandleType handleType)
void timeoutChanged(quint64 timeoutChanged)
void waitOnCPUChanged(bool waitOnCPU)

详细说明

栅栏(Fence)可用于同步 GPU 和 CPU 的工作负载。GPU 命令通常是非阻塞的。命令发出后,会被插入到命令缓冲区中,稍后由 GPU 读取。在某些情况下,您可能希望仅在确信某个命令已被硬件执行后,才继续处理或发出特定命令。 栅栏(Fence)正是实现这一目标的手段。当在 Qt3D 中使用第三方引擎时,这一点尤为重要——Qt3D 仅应在确认其他引擎的命令已完成对资源的修改后,才访问共享资源。

QWaitFence 是一个 FrameGraph 节点,它会强制等待该节点被触发后,才允许后续命令插入到命令流中。它可以与QSetFence 配合使用,并包含用于配置等待时长以及是否在 CPU 端阻塞的属性。

注意: Qt 3D 会在发出绘制调用之前上传 GPU 资源(纹理、着色器、缓冲区)。

属性文档

handle : QVariant

保存一个被QVariant 包装的底层围栏句柄。

访问函数:

QVariant handle() const
void setHandle(QVariant handle)

通知器信号:

void handleChanged(QVariant handle)

handleType : HandleType

指定所使用的句柄类型。目前仅支持 OpenGL Fence ID。

访问函数:

Qt3DRender::QWaitFence::HandleType handleType() const
void setHandleType(Qt3DRender::QWaitFence::HandleType type)

通知器信号:

void handleTypeChanged(Qt3DRender::QWaitFence::HandleType handleType)

timeout : quint64

指定等待栅栏发出信号的最大时间(单位为纳秒)。

访问函数:

quint64 timeout() const
void setTimeout(quint64 timeout)

通知器信号:

void timeoutChanged(quint64 timeoutChanged)

waitOnCPU : bool

指定 CPU 在等待栅栏发出信号时是否应阻塞。默认值为 false。

访问函数:

bool waitOnCPU() const
void setWaitOnCPU(bool waitOnCPU)

通知器信号:

void waitOnCPUChanged(bool waitOnCPU)

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