PySide6.QtGui.QRhiTextureSubresourceUploadDescription¶
- class QRhiTextureSubresourceUploadDescription¶
Describes the source for one mip level in a layer in a texture upload operation.
Details
The source content is specified either as a
QImageor as a raw blob. The former is only allowed for uncompressed textures with a format that can be mapped toQImage, while the latter is supported for all formats, including floating point and compressed.destinationTopLeft()specifies the top-left corner of the target rectangle. Defaults to (0, 0).An empty
sourceSize()(the default) indicates that size is assumed to be the size of the subresource. WithQImage-based uploads this implies that the size of the sourceimage()must match the subresource. When providing raw data instead, sufficient number of bytes must be provided indata().sourceTopLeft()is supported only forQImage-based uploads, and specifies the top-left corner of the source rectangle.Note
Setting
sourceSize()orsourceTopLeft()may trigger aQImagecopy internally, depending on the format and the backend.When providing raw data, and the stride is not specified via
setDataStride(), the stride (row pitch, row length in bytes) of the provided data must be equal towidth * pixelSizewherepixelSizeis the number of bytes used for one pixel, and there must be no additional padding between rows. There is no row start alignment requirement.When there is unused data at the end of each row in the input raw data, call
setDataStride()with the total number of bytes per row. The stride must always be a multiple of the number of bytes for one pixel. The row stride is only applicable to image data for textures with an uncompressed format.Note
The format of the source data must be compatible with the texture format. With many graphics APIs the data is copied as-is into a staging buffer, there is no intermediate format conversion provided by
QRhi. This applies to floating point formats as well, with, for example, RGBA16F requiring half floats in the source data.Note
Setting the stride via
setDataStride()is only functional whenImageDataStrideis reported assupported. In practice this can be expected to be supported everywhere except for OpenGL ES 2.0.Note
When a
QImageis given, the stride returned from QImage::bytesPerLine() is taken into account automatically.Warning
When a
QImageis given and theQImagedoes not own the underlying pixel data, it is up to the caller to ensure that the associated data stays valid until the end of the frame. (just submitting the resource update batch is not sufficient, the data must stay valid untilendFrame()is called in order to be portable across all backends) If this cannot be ensured, the caller is strongly encouraged to call QImage::detach() on the image before passing it to uploadTexture().Added in version 6.6.
Synopsis¶
Methods¶
def
__init__()def
data()def
dataStride()def
image()def
setData()def
setDataStride()def
setImage()def
setSourceSize()def
sourceSize()def
sourceTopLeft()
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
- __init__()¶
Constructs an empty subresource description.
Note
an empty
QRhiTextureSubresourceUploadDescriptionis not useful on its own and should not be submitted to aQRhiTextureUploadEntry. At minimum image or data must be set first.- __init__(data)
- Parameters:
data –
QByteArray
Constructs a mip level description with the image data specified by
data. This is suitable for floating point and compressed formats as well.- __init__(image)
- Parameters:
image –
QImage
Constructs a mip level description with a
image.The
sizeofimagemust match the size of the mip level. For level 0 that is thetexture size.The bit depth of
imagemust be compatible with thetexture format.To describe a partial upload, call
setSourceSize(),setSourceTopLeft(), orsetDestinationTopLeft()afterwards.- __init__(data, size)
- Parameters:
data –
voidsize – int
Constructs a mip level description with the image data is specified by
dataandsize. This is suitable for floating point and compressed formats as well.datacan safely be destroyed or changed once this function returns.- data()¶
- Return type:
Returns the currently set raw pixel data.
See also
- dataStride()¶
- Return type:
int
Returns the currently set data stride.
See also
Returns the currently set destination top-left position. Defaults to (0, 0).
See also
Returns the currently set
QImage.See also
- setData(data)¶
- Parameters:
data –
QByteArray
Sets
data.- setDataStride(stride)¶
- Parameters:
stride – int
Sets the data
stridein bytes. By default this is 0 and not always relevant. When providing rawdata(), and the stride is not specified via setDataStride(), the stride (row pitch, row length in bytes) of the provided data must be equal towidth * pixelSizewherepixelSizeis the number of bytes used for one pixel, and there must be no additional padding between rows. Otherwise, if there is additional space between the lines, set a non-zerostride. All this is applicable only when raw image data is provided, and is not necessary when workingQImagesince that has its own stride value.Note
Setting the stride via setDataStride() is only functional when
ImageDataStrideis reported assupported.Note
When a
QImageis given, the stride returned from QImage::bytesPerLine() is taken into account automatically and therefore there is no need to set the data stride manually.See also
Sets the destination top-left position
p.See also
Sets
image. Upon textures loading, the image data will be read as is, with no formats conversions.Sets the source
sizein pixels.Note
Setting
sourceSize()orsourceTopLeft()may trigger aQImagecopy internally, depending on the format and the backend.See also
Sets the source top-left position
p.Note
Setting
sourceSize()orsourceTopLeft()may trigger aQImagecopy internally, depending on the format and the backend.See also
Returns the source size in pixels. Defaults to a default-constructed QSize, which indicates the entire subresource.
See also
Returns the currently set source top-left position. Defaults to (0, 0).
See also