QRhiTexture Class
Texture resource. More...
Header: | #include <QRhiTexture> |
qmake: | QT += rhi |
Inherits: | QRhiResource |
Public Types
enum | Flag { RenderTarget, CubeMap, MipMapped, sRGB, ..., UsedWithLoadStore } |
flags | Flags |
enum | Format { UnknownFormat, RGBA8, BGRA8, R8, ..., ASTC_12x12 } |
Public Functions
virtual bool | build() = 0 |
virtual bool | buildFrom(const QRhiNativeHandles *src) |
QRhiTexture::Flags | flags() const |
QRhiTexture::Format | format() const |
virtual const QRhiNativeHandles * | nativeHandles() |
QSize | pixelSize() const |
int | sampleCount() const |
void | setFlags(QRhiTexture::Flags f) |
void | setFormat(QRhiTexture::Format fmt) |
void | setPixelSize(const QSize &sz) |
void | setSampleCount(int s) |
Reimplemented Public Functions
virtual QRhiResource::Type | resourceType() const override |
- 6 public functions inherited from QRhiResource
Protected Variables
QRhiTexture::Flags | m_flags |
QRhiTexture::Format | m_format |
QSize | m_pixelSize |
int | m_sampleCount |
- 3 protected variables inherited from QRhiResource
Additional Inherited Members
- 1 protected function inherited from QRhiResource
Detailed Description
Texture resource.
Member Type Documentation
enum QRhiTexture::Flag
flags QRhiTexture::Flags
Flag values to specify how the texture is going to be used. Not honoring the flags set before build() and attempting to use the texture in ways that was not declared upfront can lead to unspecified behavior or decreased performance depending on the backend and the underlying graphics API.
Constant | Value | Description |
---|---|---|
QRhiTexture::RenderTarget | 1 << 0 | The texture going to be used in combination with QRhiTextureRenderTarget. |
QRhiTexture::CubeMap | 1 << 2 | The texture is a cubemap. Such textures have 6 layers, one for each face in the order of +X, -X, +Y, -Y, +Z, -Z. Cubemap textures cannot be multisample. |
QRhiTexture::MipMapped | 1 << 3 | The texture has mipmaps. The appropriate mip count is calculated automatically and can also be retrieved via QRhi::mipLevelsForSize(). The images for the mip levels have to be provided in the texture uploaded or generated via QRhiResourceUpdateBatch::generateMips(). Multisample textures cannot have mipmaps. |
QRhiTexture::sRGB | 1 << 4 | Use an sRGB format. |
QRhiTexture::UsedAsTransferSource | 1 << 5 | The texture is used as the source of a texture copy or readback, meaning the texture is given as the source in QRhiResourceUpdateBatch::copyTexture() or QRhiResourceUpdateBatch::readBackTexture(). |
QRhiTexture::UsedWithGenerateMips | 1 << 6 | The texture is going to be used with QRhiResourceUpdateBatch::generateMips(). |
QRhiTexture::UsedWithLoadStore | 1 << 7 | The texture is going to be used with image load/store operations, for example, in a compute shader. |
The Flags type is a typedef for QFlags<Flag>. It stores an OR combination of Flag values.
enum QRhiTexture::Format
Specifies the texture format. See also QRhi::isTextureFormatSupported() and note that flags() can modify the format when QRhiTexture::sRGB is set.
Constant | Value | Description |
---|---|---|
QRhiTexture::UnknownFormat | 0 | Not a valid format. This cannot be passed to setFormat(). |
QRhiTexture::RGBA8 | 1 | Four component, unsigned normalized 8 bit per component. Always supported. |
QRhiTexture::BGRA8 | 2 | Four component, unsigned normalized 8 bit per component. |
QRhiTexture::R8 | 3 | One component, unsigned normalized 8 bit. |
QRhiTexture::R16 | 4 | One component, unsigned normalized 16 bit. |
QRhiTexture::RED_OR_ALPHA8 | 5 | Either same as R8, or is a similar format with the component swizzled to alpha, depending on RedOrAlpha8IsRed. |
QRhiTexture::RGBA16F | 6 | Four components, 16-bit float per component. |
QRhiTexture::RGBA32F | 7 | Four components, 32-bit float per component. |
QRhiTexture::D16 | 8 | 16-bit depth (normalized unsigned integer) |
QRhiTexture::D32F | 9 | 32-bit depth (32-bit float) |
QRhiTexture::BC1 | 10 | |
QRhiTexture::BC2 | 11 | |
QRhiTexture::BC3 | 12 | |
QRhiTexture::BC4 | 13 | |
QRhiTexture::BC5 | 14 | |
QRhiTexture::BC6H | 15 | |
QRhiTexture::BC7 | 16 | |
QRhiTexture::ETC2_RGB8 | 17 | |
QRhiTexture::ETC2_RGB8A1 | 18 | |
QRhiTexture::ETC2_RGBA8 | 19 | |
QRhiTexture::ASTC_4x4 | 20 | |
QRhiTexture::ASTC_5x4 | 21 | |
QRhiTexture::ASTC_5x5 | 22 | |
QRhiTexture::ASTC_6x5 | 23 | |
QRhiTexture::ASTC_6x6 | 24 | |
QRhiTexture::ASTC_8x5 | 25 | |
QRhiTexture::ASTC_8x6 | 26 | |
QRhiTexture::ASTC_8x8 | 27 | |
QRhiTexture::ASTC_10x5 | 28 | |
QRhiTexture::ASTC_10x6 | 29 | |
QRhiTexture::ASTC_10x8 | 30 | |
QRhiTexture::ASTC_10x10 | 31 | |
QRhiTexture::ASTC_12x10 | 32 | |
QRhiTexture::ASTC_12x12 | 33 |
Property Documentation
Member Function Documentation
[pure virtual]
bool QRhiTexture::build()
Creates the corresponding native graphics resources. If there are already resources present due to an earlier build() with no corresponding release(), then release() is called implicitly first.
Returns true
when successful, false
when a graphics operation failed. Regardless of the return value, calling release() is always safe.
[virtual]
bool QRhiTexture::buildFrom(const QRhiNativeHandles *src)
Similar to build() except that no new native textures are created. Instead, the texture from src is used.
This allows importing an existing native texture object (which must belong to the same device or sharing context, depending on the graphics API) from an external graphics engine.
Note: format(), pixelSize(), sampleCount(), and flags() must still be set correctly. Passing incorrect sizes and other values to QRhi::newTexture() and then following it with a buildFrom() expecting that the native texture object alone is sufficient to deduce such values is wrong and will lead to problems.
Note: QRhiTexture does not take ownership of the texture object. release() does not free the object or any associated memory.
The opposite of this operation, exposing a QRhiTexture-created native texture object to a foreign engine, is possible via nativeHandles().
See also QRhiVulkanTextureNativeHandles, QRhiD3D11TextureNativeHandles, QRhiMetalTextureNativeHandles, and QRhiGles2TextureNativeHandles.
QRhiTexture::Flags QRhiTexture::flags() const
See also setFlags().
QRhiTexture::Format QRhiTexture::format() const
See also setFormat().
[virtual]
const QRhiNativeHandles *QRhiTexture::nativeHandles()
Returns a pointer to a backend-specific QRhiNativeHandles subclass, such as QRhiVulkanTextureNativeHandles. The returned value is null when exposing the underlying native resources is not supported by the backend.
See also QRhiVulkanTextureNativeHandles, QRhiD3D11TextureNativeHandles, QRhiMetalTextureNativeHandles, and QRhiGles2TextureNativeHandles.
QSize QRhiTexture::pixelSize() const
See also setPixelSize().
[override virtual]
QRhiResource::Type QRhiTexture::resourceType() const
Reimplemented from QRhiResource::resourceType().
Returns the resource type.
int QRhiTexture::sampleCount() const
See also setSampleCount().
void QRhiTexture::setFlags(QRhiTexture::Flags f)
See also flags().
void QRhiTexture::setFormat(QRhiTexture::Format fmt)
See also format().
void QRhiTexture::setPixelSize(const QSize &sz)
See also pixelSize().
void QRhiTexture::setSampleCount(int s)
See also sampleCount().