PySide6.QtGui.QRhiColorAttachment¶
- class QRhiColorAttachment¶
Describes the a single color attachment of a render target.
Details
A color attachment is either a
QRhiTextureor aQRhiRenderBuffer. The former, i.e. whentexture()is set, is used in most cases.QRhiColorAttachmentis commonly used in combination withQRhiTextureRenderTargetDescription.Note
texture()andrenderBuffer()cannot be both set (be non-null at the same time).Setting
renderBufferinstead is recommended only when multisampling is needed. Relying onMultisampleRenderBufferis a better choice thanMultisampleTexturein practice since the former is available in more run time configurations (e.g. when running on OpenGL ES 3.0 which has no support for multisample textures, but does support multisample renderbuffers).When targeting a non-multisample texture, the
layer()andlevel()indicate the targeted layer (face index0-5for cubemaps) and mip level. For 3D textureslayer()specifies the slice (one 2D image within the 3D texture) to render to. For texture arrayslayer()is the array index.When
texture()orrenderBuffer()is multisample,resolveTexture()can be set optionally. When set, samples are resolved automatically into that (non-multisample) texture at the end of the render pass. When rendering into a multisample renderbuffers, this is the only way to get resolved, non-multisample content out of them. Multisample textures allow sampling in shaders so for them this is just one option.Note
when resolving is enabled, the multisample data may not be written out at all. This means that the multisample
texture()must not be used afterwards with shaders for sampling whenresolveTexture()is set.Added in version 6.6.
Synopsis¶
Methods¶
def
__init__()def
layer()def
level()def
multiViewCount()def
renderBuffer()def
resolveLayer()def
resolveLevel()def
resolveTexture()def
setLayer()def
setLevel()def
setTexture()def
texture()
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 color attachment description.
- __init__(renderBuffer)
- Parameters:
renderBuffer –
QRhiRenderBuffer
Constructs a color attachment description that specifies
renderBufferas the associated color buffer.- __init__(texture)
- Parameters:
texture –
QRhiTexture
Constructs a color attachment description that specifies
textureas the associated color buffer.- layer()¶
- Return type:
int
Returns the layer index (cubemap face or array layer). 0 by default.
See also
- level()¶
- Return type:
int
Returns the mip level. 0 by default.
See also
- multiViewCount()¶
- Return type:
int
Returns the currently set number of views. Defaults to 0 which indicates the render target with this color attachment is not going to be used with multiview rendering.
See also
- renderBuffer()¶
- Return type:
Returns the renderbuffer this attachment description references, or
Noneif there is none.In practice associating a
QRhiRenderBufferwith aQRhiColorAttachmentmakes the most sense when setting up multisample rendering via a multisamplecolorrenderbuffer that is then resolved into a non-multisample texture at the end of the render pass.See also
- resolveLayer()¶
- Return type:
int
Returns the currently set resolve texture layer. Defaults to 0.
See also
- resolveLevel()¶
- Return type:
int
Returns the currently set resolve texture mip level. Defaults to 0.
See also
- resolveTexture()¶
- Return type:
Returns the resolve texture this attachment description references, or
Noneif there is none.Setting a non-null resolve texture is applicable when the attachment references a multisample texture or renderbuffer. The
QRhiTexturein the resolveTexture() is then a non-multisample 2D texture (or texture array) with the same size (but a sample count of 1). The multisample content is automatically resolved into this texture at the end of each render pass.See also
- setLayer(layer)¶
- Parameters:
layer – int
Sets the
layerindex.See also
- setLevel(level)¶
- Parameters:
level – int
Sets the mip
level.See also
- setMultiViewCount(count)¶
- Parameters:
count – int
Sets the view
count. Setting a value larger than 1 indicates that the render target with this color attachment is going to be used with multiview rendering. The default value is 0. Values smaller than 2 indicate no multiview rendering.When
countis set to2or greater, the color attachment must be associated with a 2D texture array.layer()andmultiViewCount()together define the range of texture array elements that are targeted during multiview rendering.For example, if
layeris0andmultiViewCountis2, the texture array must have 2 (or more) elements, and the multiview rendering will target elements 0 and 1. Thegl_ViewIndexvariable in the shaders has a value of0or1then, where view0corresponds to the texture array element0, and view1to the array element1.Note
Setting a
countlarger than 1, using a texture array astexture(), and callingbeginPass()on aQRhiTextureRenderTargetwith this color attachment implies multiview rendering for the entire render pass.multiViewCount()should not be set unless multiview rendering is wanted. Multiview cannot be used with texture types other than 2D texture arrays. (although 3D textures may work, depending on the graphics API and backend; applications are nonetheless advised not to rely on that and only use 2D texture arrays as the render targets of multiview rendering)See GL_OVR_multiview for more details regarding multiview rendering. Do note that Qt requires GL_OVR_multiview2 as well, when running on OpenGL (ES).
Multiview rendering is available only when the
MultiViewfeature is reported as supported fromisFeatureSupported().Note
For portability, be aware of limitations that exist for multiview rendering with some of the graphics APIs. It is recommended that multiview render passes do not rely on any of the features that GL_OVR_multiview declares as unsupported. The one exception is shader stage outputs other than
gl_Positiondepending ongl_ViewIndex: that can be relied on (even with OpenGL) becauseQRhinever reports multiview as supported withoutGL_OVR_multiview2also being present.Note
Multiview rendering is not supported in combination with tessellation or geometry shaders, even though some implementations of some graphics APIs may allow this.
See also
- setRenderBuffer(rb)¶
- Parameters:
rb –
QRhiRenderBuffer
Sets the renderbuffer
rb.- setResolveLayer(layer)¶
- Parameters:
layer – int
Sets the resolve texture
layerto use.See also
- setResolveLevel(level)¶
- Parameters:
level – int
Sets the resolve texture mip
levelto use.See also
- setResolveTexture(tex)¶
- Parameters:
tex –
QRhiTexture
Sets the resolve texture
tex.texis expected to be a 2D texture or a 2D texture array. In either case, resolving targets a single mip level of a single layer (array element) oftex. The mip level and array layer are specified byresolveLevel()andresolveLayer().An exception is
multiview: when the color attachment is associated with a texture array and multiview is enabled, the resolve texture must also be a texture array with sufficient elements for all views. In this case all elements that correspond to views are resolved automatically; the behavior is similar to the following pseudo-code:for (i = 0; i < multiViewCount(); ++i) resolve texture's layer() + i into resolveTexture's resolveLayer() + i
Setting a non-multisample texture to resolve a multisample texture or renderbuffer automatically at the end of the render pass is often preferable to working with multisample textures (and not setting a resolve texture), because it avoids the need for writing dedicated fragment shaders that work exclusively with multisample textures (
sampler2DMS,texelFetch, etc.), and rather allows using the same shader as one would if the attachment’s texture was not multisampled to begin with. This comes at the expense of an additional resource (the non-multisampletex).See also
- setTexture(tex)¶
- Parameters:
tex –
QRhiTexture
Sets the texture
tex.- texture()¶
- Return type:
Returns the texture this attachment description references, or
Noneif there is none.See also