QRhiReadbackDescription Class

Describes a readback (reading back texture contents from possibly GPU-only memory) operation. More...

Header: #include <QRhiReadbackDescription>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui
Since: Qt 6.6

Public Functions

QRhiReadbackDescription()
QRhiReadbackDescription(QRhiTexture *texture)
int layer() const
int level() const
void setLayer(int layer)
void setLevel(int level)
void setTexture(QRhiTexture *tex)
QRhiTexture *texture() const

Detailed Description

The source of the readback operation is either a QRhiTexture or the current backbuffer of the currently targeted QRhiSwapChain. When texture() is not set, the swapchain is used. Otherwise the specified QRhiTexture is treated as the source.

Note: Textures used in readbacks must be created with QRhiTexture::UsedAsTransferSource.

Note: Swapchains used in readbacks must be created with QRhiSwapChain::UsedAsTransferSource.

layer() and level() are only applicable when the source is a QRhiTexture.

Note: Multisample textures cannot be read back. Readbacks are supported for multisample swapchain buffers however.

Note: This is a RHI API with limited compatibility guarantees, see QRhi for details.

Member Function Documentation

[constexpr noexcept] QRhiReadbackDescription::QRhiReadbackDescription()

Constructs an empty texture readback description.

Note: The source texture is set to null by default, which is still a valid readback: it specifies that the backbuffer of the current swapchain is to be read back. (current meaning the frame's target swapchain at the time of committing the QRhiResourceUpdateBatch with the texture readback on it)

QRhiReadbackDescription::QRhiReadbackDescription(QRhiTexture *texture)

Constructs an texture readback description that specifies that level 0 of layer 0 of texture is to be read back.

Note: texture can also be null in which case this constructor is identical to the argumentless variant.

int QRhiReadbackDescription::layer() const

Returns the currently set array layer (cubemap face, array index). Defaults to 0.

Applicable only when the source of the readback is a QRhiTexture.

See also setLayer().

int QRhiReadbackDescription::level() const

Returns the currently set mip level. Defaults to 0.

Applicable only when the source of the readback is a QRhiTexture.

See also setLevel().

void QRhiReadbackDescription::setLayer(int layer)

Sets the array layer to read back.

See also layer().

void QRhiReadbackDescription::setLevel(int level)

Sets the mip level to read back.

See also level().

void QRhiReadbackDescription::setTexture(QRhiTexture *tex)

Sets the texture tex as the source of the readback operation.

Setting nullptr is valid too, in which case the current swapchain's current backbuffer is used. (but then the readback cannot be issued in a non-swapchain-based frame)

Note: Multisample textures cannot be read back. Readbacks are supported for multisample swapchain buffers however.

Note: Textures used in readbacks must be created with QRhiTexture::UsedAsTransferSource.

Note: Swapchains used in readbacks must be created with QRhiSwapChain::UsedAsTransferSource.

See also texture().

QRhiTexture *QRhiReadbackDescription::texture() const

Returns the QRhiTexture that is read back. Can be left set to nullptr which indicates that the backbuffer of the current swapchain is to be used instead.

See also setTexture().