PySide6.QtGui.QRhiShaderResourceBinding¶
- class QRhiShaderResourceBinding¶
Describes the shader resource for a single binding point.
Details
A
QRhiShaderResourceBindingcannot be constructed directly. Instead, use the static functions such asuniformBuffer()orsampledTexture()to get an instance.Note
This is a RHI API with limited compatibility guarantees, see
QRhifor details.Added in version 6.6.
Synopsis¶
Methods¶
def
__init__()def
__ne__()def
__eq__()
Static functions¶
def
bufferLoad()def
bufferStore()def
imageLoad()def
imageLoadStore()def
imageStore()def
sampledTexture()def
sampler()def
texture()def
textures()def
uniformBuffer()
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
- class Type¶
Specifies type of the shader resource bound to a binding point
Constant
Description
QRhiShaderResourceBinding.Type.UniformBuffer
Uniform buffer
QRhiShaderResourceBinding.Type.SampledTexture
Combined image sampler (a texture and sampler pair). Even when the shading language associated with the underlying 3D API has no support for this concept (e.g. D3D and HLSL), this is still supported because the shader translation layer takes care of the appropriate translation and remapping of binding points or shader registers.
QRhiShaderResourceBinding.Type.Texture
Texture (separate)
QRhiShaderResourceBinding.Type.Sampler
Sampler (separate)
QRhiShaderResourceBinding.Type.ImageLoad
Image load (with GLSL this maps to doing
imageLoad()on a single level - and either one or all layers - of a texture exposed to the shader as an image object)QRhiShaderResourceBinding.Type.ImageStore
Image store (with GLSL this maps to doing
imageStore()or imageAtomic*() on a single level - and either one or all layers - of a texture exposed to the shader as an image object)QRhiShaderResourceBinding.Type.ImageLoadStore
Image load and store
QRhiShaderResourceBinding.Type.BufferLoad
Storage buffer load (with GLSL this maps to reading from a shader storage buffer)
QRhiShaderResourceBinding.Type.BufferStore
Storage buffer store (with GLSL this maps to writing to a shader storage buffer)
QRhiShaderResourceBinding.Type.BufferLoadStore
Storage buffer load and store
- class StageFlag¶
(inherits
enum.Flag) Flag values to indicate which stages the shader resource is visible inConstant
Description
QRhiShaderResourceBinding.StageFlag.VertexStage
Vertex stage
QRhiShaderResourceBinding.StageFlag.TessellationControlStage
Tessellation control (hull shader) stage
QRhiShaderResourceBinding.StageFlag.TessellationEvaluationStage
Tessellation evaluation (domain shader) stage
QRhiShaderResourceBinding.StageFlag.FragmentStage
Fragment (pixel shader) stage
QRhiShaderResourceBinding.StageFlag.ComputeStage
Compute stage
QRhiShaderResourceBinding.StageFlag.GeometryStage
Geometry stage
- PySide6.QtGui.QRhiShaderResourceBinding.LAYOUT_DESC_ENTRIES_PER_BINDING¶
- __init__()¶
- static bufferLoad(binding, stage, buf)¶
- Parameters:
binding – int
stage – Combination of
StageFlagbuf –
QRhiBuffer
- Return type:
Returns a shader resource binding for a read-only storage buffer with the given
bindingnumber and pipelinestage.Note
When
bufis not null, must have been created withStorageBuffer.Note
bufcan be null. It is valid to create aQRhiShaderResourceBindingswith unspecified resources, but such an object cannot be used withsetShaderResources(). It is however suitable for creating pipelines. Such a pipeline must then always be used together with another, layout compatibleQRhiShaderResourceBindingswith resources present passed tosetShaderResources().Note
Buffer load/store is only guaranteed to be available within a compute pipeline. While some backends may support using these resources in a graphics pipeline as well, this is not universally supported, and even when it is, unexpected problems may arise when it comes to barriers and synchronization. Therefore, avoid using such resources with shaders other than compute.
- static bufferLoad(binding, stage, buf, offset, size)
- Parameters:
binding – int
stage – Combination of
StageFlagbuf –
QRhiBufferoffset – int
size – int
- Return type:
Returns a shader resource binding for a read-only storage buffer with the given
bindingnumber and pipelinestage. This overload binds a region only, as specified byoffsetandsize.Note
When
bufis not null, must have been created withStorageBuffer.Note
bufcan be null. It is valid to create aQRhiShaderResourceBindingswith unspecified resources, but such an object cannot be used withsetShaderResources(). It is however suitable for creating pipelines. Such a pipeline must then always be used together with another, layout compatibleQRhiShaderResourceBindingswith resources present passed tosetShaderResources().Note
Buffer load/store is only guaranteed to be available within a compute pipeline. While some backends may support using these resources in a graphics pipeline as well, this is not universally supported, and even when it is, unexpected problems may arise when it comes to barriers and synchronization. Therefore, avoid using such resources with shaders other than compute.
- static bufferLoadStore(binding, stage, buf)¶
- Parameters:
binding – int
stage – Combination of
StageFlagbuf –
QRhiBuffer
- Return type:
Returns a shader resource binding for a read-write storage buffer with the given
bindingnumber and pipelinestage.Note
When
bufis not null, must have been created withStorageBuffer.Note
bufcan be null. It is valid to create aQRhiShaderResourceBindingswith unspecified resources, but such an object cannot be used withsetShaderResources(). It is however suitable for creating pipelines. Such a pipeline must then always be used together with another, layout compatibleQRhiShaderResourceBindingswith resources present passed tosetShaderResources().Note
Buffer load/store is only guaranteed to be available within a compute pipeline. While some backends may support using these resources in a graphics pipeline as well, this is not universally supported, and even when it is, unexpected problems may arise when it comes to barriers and synchronization. Therefore, avoid using such resources with shaders other than compute.
- static bufferLoadStore(binding, stage, buf, offset, size)
- Parameters:
binding – int
stage – Combination of
StageFlagbuf –
QRhiBufferoffset – int
size – int
- Return type:
Returns a shader resource binding for a read-write storage buffer with the given
bindingnumber and pipelinestage. This overload binds a region only, as specified byoffsetandsize.Note
When
bufis not null, must have been created withStorageBuffer.Note
bufcan be null. It is valid to create aQRhiShaderResourceBindingswith unspecified resources, but such an object cannot be used withsetShaderResources(). It is however suitable for creating pipelines. Such a pipeline must then always be used together with another, layout compatibleQRhiShaderResourceBindingswith resources present passed tosetShaderResources().Note
Buffer load/store is only guaranteed to be available within a compute pipeline. While some backends may support using these resources in a graphics pipeline as well, this is not universally supported, and even when it is, unexpected problems may arise when it comes to barriers and synchronization. Therefore, avoid using such resources with shaders other than compute.
- static bufferStore(binding, stage, buf)¶
- Parameters:
binding – int
stage – Combination of
StageFlagbuf –
QRhiBuffer
- Return type:
Returns a shader resource binding for a write-only storage buffer with the given
bindingnumber and pipelinestage.Note
When
bufis not null, must have been created withStorageBuffer.Note
bufcan be null. It is valid to create aQRhiShaderResourceBindingswith unspecified resources, but such an object cannot be used withsetShaderResources(). It is however suitable for creating pipelines. Such a pipeline must then always be used together with another, layout compatibleQRhiShaderResourceBindingswith resources present passed tosetShaderResources().Note
Buffer load/store is only guaranteed to be available within a compute pipeline. While some backends may support using these resources in a graphics pipeline as well, this is not universally supported, and even when it is, unexpected problems may arise when it comes to barriers and synchronization. Therefore, avoid using such resources with shaders other than compute.
- static bufferStore(binding, stage, buf, offset, size)
- Parameters:
binding – int
stage – Combination of
StageFlagbuf –
QRhiBufferoffset – int
size – int
- Return type:
Returns a shader resource binding for a write-only storage buffer with the given
bindingnumber and pipelinestage. This overload binds a region only, as specified byoffsetandsize.Note
When
bufis not null, must have been created withStorageBuffer.Note
bufcan be null. It is valid to create aQRhiShaderResourceBindingswith unspecified resources, but such an object cannot be used withsetShaderResources(). It is however suitable for creating pipelines. Such a pipeline must then always be used together with another, layout compatibleQRhiShaderResourceBindingswith resources present passed tosetShaderResources().Note
Buffer load/store is only guaranteed to be available within a compute pipeline. While some backends may support using these resources in a graphics pipeline as well, this is not universally supported, and even when it is, unexpected problems may arise when it comes to barriers and synchronization. Therefore, avoid using such resources with shaders other than compute.
- static imageLoad(binding, stage, tex, level)¶
- Parameters:
binding – int
stage – Combination of
StageFlagtex –
QRhiTexturelevel – int
- Return type:
Returns a shader resource binding for a read-only storage image with the given
bindingnumber and pipelinestage. The image load operations will have access to all layers of the specifiedlevel. (so if the texture is a cubemap, the shader must use imageCube instead of image2D)Note
When
texis not null, it must have been created withUsedWithLoadStore.Note
texcan be null. It is valid to create aQRhiShaderResourceBindingswith unspecified resources, but such an object cannot be used withsetShaderResources(). It is however suitable for creating pipelines. Such a pipeline must then always be used together with another, layout compatibleQRhiShaderResourceBindingswith resources present passed tosetShaderResources().Note
Image load/store is only available within the compute and fragment stages.
- static imageLoadStore(binding, stage, tex, level)¶
- Parameters:
binding – int
stage – Combination of
StageFlagtex –
QRhiTexturelevel – int
- Return type:
Returns a shader resource binding for a read/write storage image with the given
bindingnumber and pipelinestage. The image load/store operations will have access to all layers of the specifiedlevel. (so if the texture is a cubemap, the shader must use imageCube instead of image2D)Note
When
texis not null, it must have been created withUsedWithLoadStore.Note
texcan be null. It is valid to create aQRhiShaderResourceBindingswith unspecified resources, but such an object cannot be used withsetShaderResources(). It is however suitable for creating pipelines. Such a pipeline must then always be used together with another, layout compatibleQRhiShaderResourceBindingswith resources present passed tosetShaderResources().Note
Image load/store is only available within the compute and fragment stages.
- static imageStore(binding, stage, tex, level)¶
- Parameters:
binding – int
stage – Combination of
StageFlagtex –
QRhiTexturelevel – int
- Return type:
Returns a shader resource binding for a write-only storage image with the given
bindingnumber and pipelinestage. The image store operations will have access to all layers of the specifiedlevel. (so if the texture is a cubemap, the shader must use imageCube instead of image2D)Note
When
texis not null, it must have been created withUsedWithLoadStore.Note
texcan be null. It is valid to create aQRhiShaderResourceBindingswith unspecified resources, but such an object cannot be used withsetShaderResources(). It is however suitable for creating pipelines. Such a pipeline must then always be used together with another, layout compatibleQRhiShaderResourceBindingswith resources present passed tosetShaderResources().Note
Image load/store is only available within the compute and fragment stages.
- isLayoutCompatible(other)¶
- Parameters:
other –
QRhiShaderResourceBinding- Return type:
bool
Returns
trueif the layout is compatible withother. The layout does not include the actual resource (such as, buffer or texture) and related parameters (such as, offset or size).For example,
aandbbelow are not equal, but are compatible layout-wise:auto a = QRhiShaderResourceBinding::uniformBuffer(0, QRhiShaderResourceBinding::VertexStage, buffer); auto b = QRhiShaderResourceBinding::uniformBuffer(0, QRhiShaderResourceBinding::VertexStage, someOtherBuffer, 256);
- __ne__(b)¶
- Parameters:
- Return type:
bool
- __eq__(b)¶
- Parameters:
- Return type:
bool
- static sampledTexture(binding, stage, tex, sampler)¶
- Parameters:
binding – int
stage – Combination of
StageFlagtex –
QRhiTexturesampler –
QRhiSampler
- Return type:
Returns a shader resource binding for the given binding number, pipeline stages, texture, and sampler specified by
binding,stage,tex,sampler.Note
This function is equivalent to calling
sampledTextures()with acountof 1.Note
texandsamplercan be null. It is valid to create aQRhiShaderResourceBindingswith unspecified resources, but such an object cannot be used withsetShaderResources(). It is however suitable for creating pipelines. Such a pipeline must then always be used together with another, layout compatibleQRhiShaderResourceBindingswith resources present passed tosetShaderResources().Note
A shader may not be able to consume more than 16 textures/samplers, depending on the underlying graphics API. This hard limit must be kept in mind in renderer design. This does not apply to texture arrays which consume a single binding point (shader register) and can contain 256-2048 textures, depending on the underlying graphics API. Arrays of textures (see
sampledTextures()) are however no different in this regard than using the same number of individual textures.See also
- static sampledTextures(binding, stage, count, texSamplers)¶
- Parameters:
binding – int
stage – Combination of
StageFlagcount – int
texSamplers –
TextureAndSampler
- Return type:
Returns a shader resource binding for the given binding number, pipeline stages, and the array of texture-sampler pairs specified by
binding,stage,count, andtexSamplers.Note
countmust be at least 1, and not larger than 16.Note
When
countis 1, this function is equivalent tosampledTexture().This function is relevant when arrays of combined image samplers are involved. For example, in GLSL
layout(binding = 5) uniform sampler2D shadowMaps[8];declares an array of combined image samplers. The application is then expected provide aQRhiShaderResourceBindingfor binding point 5, set up by calling this function withcountset to 8 and a valid texture and sampler for each element of the array.Warning
All elements of the array must be specified. With the above example, the only valid, portable approach is calling this function with a
countof 8. Additionally, allQRhiTextureandQRhiSamplerinstances must be valid, meaning nullptr is not an accepted value. This is due to some of the underlying APIs, such as, Vulkan, that require a valid image and sampler object for each element in descriptor arrays. Applications are advised to provide “dummy” samplers and textures if some array elements are not relevant (due to not being accessed in the shader).Note
texSamplerscan be null. It is valid to create aQRhiShaderResourceBindingswith unspecified resources, but such an object cannot be used withsetShaderResources(). It is however suitable for creating pipelines. Such a pipeline must then always be used together with another, layout compatibleQRhiShaderResourceBindingswith resources present passed tosetShaderResources().See also
- static sampler(binding, stage, sampler)¶
- Parameters:
binding – int
stage – Combination of
StageFlagsampler –
QRhiSampler
- Return type:
Returns a shader resource binding for the given binding number, pipeline stages, and sampler specified by
binding,stage,sampler.Note
samplercan be null. It is valid to create aQRhiShaderResourceBindingswith unspecified resources, but such an object cannot be used withsetShaderResources(). It is however suitable for creating pipelines. Such a pipeline must then always be used together with another, layout compatibleQRhiShaderResourceBindingswith resources present passed tosetShaderResources().Arrays of separate samplers are not supported.
This creates a binding for a separate sampler object, whereas
sampledTexture()is suitable for combined image samplers. In Vulkan-compatible GLSL code separate samplers are declared assampleras opposed tosampler2D:layout(binding = 2) uniform sampler samp;With both a
texture2Dandsamplerpresent, they can be used together to sample the texture:fragColor = texture(sampler2D(tex, samp), texcoord);.Note
A shader may not be able to consume more than 16 samplers, depending on the underlying graphics API. This hard limit must be kept in mind in renderer design.
See also
- static texture(binding, stage, tex)¶
- Parameters:
binding – int
stage – Combination of
StageFlagtex –
QRhiTexture
- Return type:
Returns a shader resource binding for the given binding number, pipeline stages, and texture specified by
binding,stage,tex.Note
This function is equivalent to calling
textures()with acountof 1.Note
texcan be null. It is valid to create aQRhiShaderResourceBindingswith unspecified resources, but such an object cannot be used withsetShaderResources(). It is however suitable for creating pipelines. Such a pipeline must then always be used together with another, layout compatibleQRhiShaderResourceBindingswith resources present passed tosetShaderResources().This creates a binding for a separate texture (image) object, whereas
sampledTexture()is suitable for combined image samplers. In Vulkan-compatible GLSL code separate textures are declared astexture2Das opposed tosampler2D:layout(binding = 1) uniform texture2D tex;Note
A shader may not be able to consume more than 16 textures, depending on the underlying graphics API. This hard limit must be kept in mind in renderer design. This does not apply to texture arrays which consume a single binding point (shader register) and can contain 256-2048 textures, depending on the underlying graphics API. Arrays of textures (see
sampledTextures()) are however no different in this regard than using the same number of individual textures.See also
- static textures(binding, stage, count, tex)¶
- Parameters:
binding – int
stage – Combination of
StageFlagcount – int
tex –
QRhiTexture
- Return type:
Returns a shader resource binding for the given binding number, pipeline stages, and the array of (separate) textures specified by
binding,stage,count, andtex.Note
countmust be at least 1, and not larger than 16.Note
When
countis 1, this function is equivalent totexture().Warning
All elements of the array must be specified.
Note
texcan be null. It is valid to create aQRhiShaderResourceBindingswith unspecified resources, but such an object cannot be used withsetShaderResources(). It is however suitable for creating pipelines. Such a pipeline must then always be used together with another, layout compatibleQRhiShaderResourceBindingswith resources present passed tosetShaderResources().- static uniformBuffer(binding, stage, buf)¶
- Parameters:
binding – int
stage – Combination of
StageFlagbuf –
QRhiBuffer
- Return type:
Returns a shader resource binding for the given binding number, pipeline stages, and buffer specified by
binding,stage, andbuf.Note
When
bufis not null, it must have been created withUniformBuffer.Note
bufcan be null. It is valid to create aQRhiShaderResourceBindingswith unspecified resources, but such an object cannot be used withsetShaderResources(). It is however suitable for creating pipelines. Such a pipeline must then always be used together with another, layout compatibleQRhiShaderResourceBindingswith resources present passed tosetShaderResources().Note
If the size of
bufexceeds the limit reported forMaxUniformBufferRange, unexpected errors may occur.- static uniformBuffer(binding, stage, buf, offset, size)
- Parameters:
binding – int
stage – Combination of
StageFlagbuf –
QRhiBufferoffset – int
size – int
- Return type:
Returns a shader resource binding for the given binding number, pipeline stages, and buffer specified by
binding,stage, andbuf. This overload binds a region only, as specified byoffsetandsize.Note
It is up to the user to ensure the offset is aligned to
ubufAlignment().Note
sizemust be greater than 0.Note
When
bufis not null, it must have been created withUniformBuffer.Note
bufcan be null. It is valid to create aQRhiShaderResourceBindingswith unspecified resources, but such an object cannot be used withsetShaderResources(). It is however suitable for creating pipelines. Such a pipeline must then always be used together with another, layout compatibleQRhiShaderResourceBindingswith resources present passed tosetShaderResources().Note
If
sizeexceeds the limit reported forMaxUniformBufferRange, unexpected errors may occur.- static uniformBufferWithDynamicOffset(binding, stage, buf, size)¶
- Parameters:
binding – int
stage – Combination of
StageFlagbuf –
QRhiBuffersize – int
- Return type:
Returns a shader resource binding for the given binding number, pipeline stages, and buffer specified by
binding,stage, andbuf. The uniform buffer is assumed to have dynamic offset. The dynamic offset can be specified insetShaderResources(), thus allowing using varying offset values without creating new bindings for the buffer. The size of the bound region is specified bysize. Like with non-dynamic offsets,offset + sizecannot exceed the size ofbuf.Note
When
bufis not null, it must have been created withUniformBuffer.Note
bufcan be null. It is valid to create aQRhiShaderResourceBindingswith unspecified resources, but such an object cannot be used withsetShaderResources(). It is however suitable for creating pipelines. Such a pipeline must then always be used together with another, layout compatibleQRhiShaderResourceBindingswith resources present passed tosetShaderResources().Note
If
sizeexceeds the limit reported forMaxUniformBufferRange, unexpected errors may occur.- class Data¶
Synopsis¶
Methods¶
def
arraySize()
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
- PySide6.QtGui.QRhiShaderResourceBinding.Data.binding¶
- PySide6.QtGui.QRhiShaderResourceBinding.Data.stage¶
- PySide6.QtGui.QRhiShaderResourceBinding.Data.type¶
- PySide6.QtGui.QRhiShaderResourceBinding.Data.MAX_TEX_SAMPLER_ARRAY_SIZE¶
- arraySize()¶
- Return type:
int
- class StorageImageData¶
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
- PySide6.QtGui.QRhiShaderResourceBinding.Data.StorageImageData.tex¶
- PySide6.QtGui.QRhiShaderResourceBinding.Data.StorageImageData.level¶
- class StorageBufferData¶
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
- PySide6.QtGui.QRhiShaderResourceBinding.Data.StorageBufferData.buf¶
- PySide6.QtGui.QRhiShaderResourceBinding.Data.StorageBufferData.offset¶
- PySide6.QtGui.QRhiShaderResourceBinding.Data.StorageBufferData.maybeSize¶
- class TextureAndSampler¶
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
- PySide6.QtGui.QRhiShaderResourceBinding.TextureAndSampler.tex¶
- PySide6.QtGui.QRhiShaderResourceBinding.TextureAndSampler.sampler¶