- Qt 6.11
- Qt GUI
- C++ Classes
- QtGuiPrivate
- QRhiReadbackDescription
- Qt 6.11.0 Reference Documentation

# QRhiReadbackDescription Class

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

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

- List of all members, including inherited members

## Public Functions

| 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

## 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().

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

Returns the rectangle to read back. Defaults to an invalid rectangle.

If invalid, the entire texture or swapchain backbuffer is read back.

This function was introduced in Qt 6.10.

See also setRect().

### 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().

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

Sets the rectangle to read back.

This function was introduced in Qt 6.10.

See also rect().

### 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().