\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
- Since
- 6.6
Describes a texture upload operation.
Used with QRhiResourceUpdateBatch::uploadTexture(). That function has two variants: one taking a QImage and one taking a QRhiTextureUploadDescription. The former is a convenience version, internally creating a QRhiTextureUploadDescription with a single image targeting level 0 for layer 0.
An example of the the common, simple case of wanting to upload the contents of a QImage to a QRhiTexture with a matching pixel size:
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
void uploadTexture(QRhiTexture *tex, const QRhiTextureUploadDescription &desc)
Enqueues uploading the image data for one or more mip levels in one or more layers of the texture tex...
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
When cubemaps, pre-generated mip images, compressed textures, or partial uploads are involved, applications will have to use this class instead.
QRhiTextureUploadDescription also enables specifying batched uploads, which are useful for example when generating an atlas or glyph cache texture: multiple, partial uploads for the same subresource (meaning the same layer and level) are supported, and can be, depending on the backend and the underlying graphics API, more efficient when batched into the same QRhiTextureUploadDescription as opposed to issuing individual \l{QRhiResourceUpdateBatch::uploadTexture()}{uploadTexture()} commands for each of them.
- Note
- Cubemaps have one layer for each of the six faces in the order +X, -X, +Y, -Y, +Z, -Z.
For example, specifying the faces of a cubemap could look like the following:
for (int i = 0; i < 6; ++i)
desc.setEntries(entries.
cbegin(), entries.
cend());
resourceUpdates->uploadTexture(
texture, desc);
QRhiTextureUploadDescription()=default
Constructs an empty texture upload description.
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
const_iterator cbegin() const noexcept
const_iterator cend() const noexcept
Another example that specifies mip images for a compressed texture:
const int mipCount = rhi->mipLevelsForSize(compressedTexture->pixelSize());
}
desc.setEntries(entries.
cbegin(), entries.
cend());
resourceUpdates->uploadTexture(compressedTexture, desc);
const_iterator cend() const noexcept
void append(parameter_type t)
const_iterator cbegin() const noexcept
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
GLenum GLuint GLint level
With partial uploads targeting the same subresource, it is recommended to batch them into a single upload request, whenever possible:
subresDesc.setSourceSize(
QSize(10, 10));
subResDesc.setDestinationTopLeft(
QPoint(50, 40));
subresDesc2.setSourceSize(
QSize(30, 40));
subResDesc2.setDestinationTopLeft(
QPoint(100, 200));
resourceUpdates->uploadTexture(
texture, desc);
\inmodule QtCore\reentrant
\inmodule QtGuiPrivate \inheaderfile rhi/qrhi.h
- Note
- This is a RHI API with limited compatibility guarantees, see \l QRhi for details.
- See also
- QRhiResourceUpdateBatch
Definition at line 720 of file qrhi.h.