本页内容

QRhiReadbackDescription Class

描述了一项回读操作(从可能仅限 GPU 访问的内存中读回纹理内容)。更多内容...

标题: #include <rhi/qrhi.h>
CMake: find_package(Qt6 REQUIRED COMPONENTS GuiPrivate)
target_link_libraries(mytarget PRIVATE Qt6::GuiPrivate)
qmake: QT += gui-private
自: Qt 6.6

公共函数

QRhiReadbackDescription()
QRhiReadbackDescription(QRhiTexture *texture)
int layer() const
int level() const
(since 6.10) QRect rect() const
void setLayer(int layer)
void setLevel(int level)
(since 6.10) void setRect(const QRect &rectangle)
void setTexture(QRhiTexture *tex)
QRhiTexture *texture() const

详细说明

回读操作的源要么是QRhiTexture ,要么是当前目标QRhiSwapChain 的当前后缓冲区。当texture()未设置时,将使用交换链。否则,指定的QRhiTexture 将被视为源。

注意: 读回操作中使用的纹理 必须通过QRhiTexture::UsedAsTransferSource 创建。

注意: 读回操作中使用的交换链 必须通过QRhiSwapChain::UsedAsTransferSource 创建。

layer() 和level() 仅在源为QRhiTexture 时才适用。

注意:多采样 纹理无法被读回。不过,多采样交换链缓冲区支持读回操作。

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

成员函数文档

[constexpr noexcept default] QRhiReadbackDescription::QRhiReadbackDescription()

构建一个空的纹理回读描述符。

注意: 源纹理默认设置为 null,这仍然是一个有效的读回操作:它指定应读回当前交换链的后缓冲区。(此处的“当前”指的是在提交包含texture readback 的QRhiResourceUpdateBatch 时,该帧的目标交换链)

QRhiReadbackDescription::QRhiReadbackDescription(QRhiTexture *texture)

构建一个纹理回读描述,指定要回读texture 的第0层第0级。

注意: texture 也可以为空,在这种情况下,该构造函数与无参数版本完全相同。

int QRhiReadbackDescription::layer() const

返回当前设置的数组层(立方贴图面、数组索引)。默认值为 0。

仅当读回的源为QRhiTexture 时才适用。

另请参阅 setLayer()。

int QRhiReadbackDescription::level() const

返回当前设置的MIP级别。默认值为0。

仅当读回源为QRhiTexture 时才适用。

另请参阅 setLevel()。

[since 6.10] QRect QRhiReadbackDescription::rect() const

返回待读取的矩形。默认为一个无效的矩形。

如果该矩形无效,则会读回整个纹理或交换链的后缓冲区。

该函数在 Qt 6.10 中引入。

另请参阅 ` setRect()`。

void QRhiReadbackDescription::setLayer(int layer)

将数组layer 设置为待读取数据。

另请参阅 layer()。

void QRhiReadbackDescription::setLevel(int level)

设置要读取回来的MIPlevel 。

另请参阅 level()。

[since 6.10] void QRhiReadbackDescription::setRect(const QRect &rectangle)

将rectangle 设置为读取模式。

该函数在 Qt 6.10 中引入。

另请参阅 rect()。

void QRhiReadbackDescription::setTexture(QRhiTexture *tex)

将纹理tex 设置为回读操作的源。

设置 `nullptr ` 也是有效的,在这种情况下将使用当前交换链的当前后缓冲区。(但此时无法在非基于交换链的帧中发起读回操作)

注意:多采样 纹理无法进行回读。不过,多采样交换链缓冲区支持回读操作。

注意: 用于回读的纹理 必须使用 `QRhiTexture::UsedAsTransferSource` 创建。

注意: 用于读回操作的交换链 必须通过 `QRhiSwapChain::UsedAsTransferSource` 创建。

另请参阅 texture()。

QRhiTexture *QRhiReadbackDescription::texture() const

返回被读回的QRhiTexture 。可将其保留为nullptr ,这表示应改用当前交换链的后缓冲区。

另请参阅 setTexture()。

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