- Qt 6.6
- Qt GUI
- C++ Classes
- QRhiShaderResourceBinding
- Qt 6.6.0 Reference Documentation

# QRhiShaderResourceBinding Class

Describes the shader resource for a single binding point. More...

Header: | #include <QRhiShaderResourceBinding>
CMake: | find_package(Qt6 REQUIRED COMPONENTS Gui) target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: | QT += gui
Since: | Qt 6.6

- List of all members, including inherited members

## Public Types

enum | StageFlag { VertexStage, TessellationControlStage, TessellationEvaluationStage, FragmentStage, ComputeStage, GeometryStage }
flags | StageFlags
enum | Type { UniformBuffer, SampledTexture, Texture, Sampler, ImageLoad, …, BufferLoadStore }

## Public Functions

bool | isLayoutCompatible(const QRhiShaderResourceBinding &other) const

## Static Public Members

QRhiShaderResourceBinding | bufferLoad(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf)
QRhiShaderResourceBinding | bufferLoad(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf, quint32 offset, quint32 size)
QRhiShaderResourceBinding | bufferLoadStore(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf)
QRhiShaderResourceBinding | bufferLoadStore(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf, quint32 offset, quint32 size)
QRhiShaderResourceBinding | bufferStore(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf)
QRhiShaderResourceBinding | bufferStore(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf, quint32 offset, quint32 size)
QRhiShaderResourceBinding | imageLoad(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiTexture *tex, int level)
QRhiShaderResourceBinding | imageLoadStore(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiTexture *tex, int level)
QRhiShaderResourceBinding | imageStore(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiTexture *tex, int level)
QRhiShaderResourceBinding | sampledTexture(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiTexture *tex, QRhiSampler *sampler)
QRhiShaderResourceBinding | sampledTextures(int binding, QRhiShaderResourceBinding::StageFlags stage, int count, const QRhiShaderResourceBinding::TextureAndSampler *texSamplers)
QRhiShaderResourceBinding | sampler(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiSampler *sampler)
QRhiShaderResourceBinding | texture(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiTexture *tex)
QRhiShaderResourceBinding | textures(int binding, QRhiShaderResourceBinding::StageFlags stage, int count, QRhiTexture **tex)
QRhiShaderResourceBinding | uniformBuffer(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf)
QRhiShaderResourceBinding | uniformBuffer(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf, quint32 offset, quint32 size)
QRhiShaderResourceBinding | uniformBufferWithDynamicOffset(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf, quint32 size)

## Related Non-Members

size_t | qHash(const QRhiShaderResourceBinding &b, size_t seed = 0)
bool | operator!=(const QRhiShaderResourceBinding &a, const QRhiShaderResourceBinding &b)
bool | operator==(const QRhiShaderResourceBinding &a, const QRhiShaderResourceBinding &b)

## Detailed Description

A QRhiShaderResourceBinding cannot be constructed directly. Instead, use the static functions such as uniformBuffer() or sampledTexture() to get an instance.

Note: This is a RHI API with limited compatibility guarantees, see QRhi for details.

## Member Type Documentation

### enum QRhiShaderResourceBinding::StageFlag
flags QRhiShaderResourceBinding::StageFlags

Flag values to indicate which stages the shader resource is visible in

Constant | Value | Description
--- | --- | ---
`QRhiShaderResourceBinding::VertexStage` | `1 << 0` | Vertex stage
`QRhiShaderResourceBinding::TessellationControlStage` | `1 << 1` | Tessellation control (hull shader) stage
`QRhiShaderResourceBinding::TessellationEvaluationStage` | `1 << 2` | Tessellation evaluation (domain shader) stage
`QRhiShaderResourceBinding::FragmentStage` | `1 << 4` | Fragment (pixel shader) stage
`QRhiShaderResourceBinding::ComputeStage` | `1 << 5` | Compute stage
`QRhiShaderResourceBinding::GeometryStage` | `1 << 3` | Geometry stage

The StageFlags type is a typedef for QFlags<StageFlag>. It stores an OR combination of StageFlag values.

### enum QRhiShaderResourceBinding::Type

Specifies type of the shader resource bound to a binding point

Constant | Value | Description
--- | --- | ---
`QRhiShaderResourceBinding::UniformBuffer` | `0` | Uniform buffer
`QRhiShaderResourceBinding::SampledTexture` | `1` | 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::Texture` | `2` | Texture (separate)
`QRhiShaderResourceBinding::Sampler` | `3` | Sampler (separate)
`QRhiShaderResourceBinding::ImageLoad` | `4` | 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::ImageStore` | `5` | 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::ImageLoadStore` | `6` | Image load and store
`QRhiShaderResourceBinding::BufferLoad` | `7` | Storage buffer store (with GLSL this maps to reading from a shader storage buffer)
`QRhiShaderResourceBinding::BufferStore` | `8` | Storage buffer store (with GLSL this maps to writing to a shader storage buffer)
`QRhiShaderResourceBinding::BufferLoadStore` | `9` | Storage buffer load and store

## Member Function Documentation

### `[static]` QRhiShaderResourceBinding QRhiShaderResourceBinding::bufferLoad(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf)

Returns a shader resource binding for a read-only storage buffer with the given binding number and pipeline stage.

Note: When buf is not null, must have been created with QRhiBuffer::StorageBuffer.

Note: buf can be null. It is valid to create a QRhiShaderResourceBindings with unspecified resources, but such an object cannot be used with QRhiCommandBuffer::setShaderResources(). It is however suitable for creating pipelines. Such a pipeline must then always be used together with another, layout compatible QRhiShaderResourceBindings with resources present passed to QRhiCommandBuffer::setShaderResources().

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]` QRhiShaderResourceBinding QRhiShaderResourceBinding::bufferLoad(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf, quint32 offset, quint32 size)

Returns a shader resource binding for a read-only storage buffer with the given binding number and pipeline stage. This overload binds a region only, as specified by offset and size.

Note: When buf is not null, must have been created with QRhiBuffer::StorageBuffer.

Note: buf can be null. It is valid to create a QRhiShaderResourceBindings with unspecified resources, but such an object cannot be used with QRhiCommandBuffer::setShaderResources(). It is however suitable for creating pipelines. Such a pipeline must then always be used together with another, layout compatible QRhiShaderResourceBindings with resources present passed to QRhiCommandBuffer::setShaderResources().

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]` QRhiShaderResourceBinding QRhiShaderResourceBinding::bufferLoadStore(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf)

Returns a shader resource binding for a read-write storage buffer with the given binding number and pipeline stage.

Note: When buf is not null, must have been created with QRhiBuffer::StorageBuffer.

Note: buf can be null. It is valid to create a QRhiShaderResourceBindings with unspecified resources, but such an object cannot be used with QRhiCommandBuffer::setShaderResources(). It is however suitable for creating pipelines. Such a pipeline must then always be used together with another, layout compatible QRhiShaderResourceBindings with resources present passed to QRhiCommandBuffer::setShaderResources().

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]` QRhiShaderResourceBinding QRhiShaderResourceBinding::bufferLoadStore(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf, quint32 offset, quint32 size)

Returns a shader resource binding for a read-write storage buffer with the given binding number and pipeline stage. This overload binds a region only, as specified by offset and size.

Note: When buf is not null, must have been created with QRhiBuffer::StorageBuffer.

Note: buf can be null. It is valid to create a QRhiShaderResourceBindings with unspecified resources, but such an object cannot be used with QRhiCommandBuffer::setShaderResources(). It is however suitable for creating pipelines. Such a pipeline must then always be used together with another, layout compatible QRhiShaderResourceBindings with resources present passed to QRhiCommandBuffer::setShaderResources().

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]` QRhiShaderResourceBinding QRhiShaderResourceBinding::bufferStore(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf)

Returns a shader resource binding for a write-only storage buffer with the given binding number and pipeline stage.

Note: When buf is not null, must have been created with QRhiBuffer::StorageBuffer.

Note: buf can be null. It is valid to create a QRhiShaderResourceBindings with unspecified resources, but such an object cannot be used with QRhiCommandBuffer::setShaderResources(). It is however suitable for creating pipelines. Such a pipeline must then always be used together with another, layout compatible QRhiShaderResourceBindings with resources present passed to QRhiCommandBuffer::setShaderResources().

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]` QRhiShaderResourceBinding QRhiShaderResourceBinding::bufferStore(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf, quint32 offset, quint32 size)

Returns a shader resource binding for a write-only storage buffer with the given binding number and pipeline stage. This overload binds a region only, as specified by offset and size.

Note: When buf is not null, must have been created with QRhiBuffer::StorageBuffer.

Note: buf can be null. It is valid to create a QRhiShaderResourceBindings with unspecified resources, but such an object cannot be used with QRhiCommandBuffer::setShaderResources(). It is however suitable for creating pipelines. Such a pipeline must then always be used together with another, layout compatible QRhiShaderResourceBindings with resources present passed to QRhiCommandBuffer::setShaderResources().

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]` QRhiShaderResourceBinding QRhiShaderResourceBinding::imageLoad(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiTexture *tex, int level)

Returns a shader resource binding for a read-only storage image with the given binding number and pipeline stage. The image load operations will have access to all layers of the specified level. (so if the texture is a cubemap, the shader must use imageCube instead of image2D)

Note: When tex is not null, it must have been created with QRhiTexture::UsedWithLoadStore.

Note: tex can be null. It is valid to create a QRhiShaderResourceBindings with unspecified resources, but such an object cannot be used with QRhiCommandBuffer::setShaderResources(). It is however suitable for creating pipelines. Such a pipeline must then always be used together with another, layout compatible QRhiShaderResourceBindings with resources present passed to QRhiCommandBuffer::setShaderResources().

Note: Image 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]` QRhiShaderResourceBinding QRhiShaderResourceBinding::imageLoadStore(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiTexture *tex, int level)

Returns a shader resource binding for a read/write storage image with the given binding number and pipeline stage. The image load/store operations will have access to all layers of the specified level. (so if the texture is a cubemap, the shader must use imageCube instead of image2D)

Note: When tex is not null, it must have been created with QRhiTexture::UsedWithLoadStore.

Note: tex can be null. It is valid to create a QRhiShaderResourceBindings with unspecified resources, but such an object cannot be used with QRhiCommandBuffer::setShaderResources(). It is however suitable for creating pipelines. Such a pipeline must then always be used together with another, layout compatible QRhiShaderResourceBindings with resources present passed to QRhiCommandBuffer::setShaderResources().

Note: Image 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]` QRhiShaderResourceBinding QRhiShaderResourceBinding::imageStore(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiTexture *tex, int level)

Returns a shader resource binding for a write-only storage image with the given binding number and pipeline stage. The image store operations will have access to all layers of the specified level. (so if the texture is a cubemap, the shader must use imageCube instead of image2D)

Note: When tex is not null, it must have been created with QRhiTexture::UsedWithLoadStore.

Note: tex can be null. It is valid to create a QRhiShaderResourceBindings with unspecified resources, but such an object cannot be used with QRhiCommandBuffer::setShaderResources(). It is however suitable for creating pipelines. Such a pipeline must then always be used together with another, layout compatible QRhiShaderResourceBindings with resources present passed to QRhiCommandBuffer::setShaderResources().

Note: Image 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.

### bool QRhiShaderResourceBinding::isLayoutCompatible(const QRhiShaderResourceBinding &other) const

Returns `true` if the layout is compatible with other. The layout does not include the actual resource (such as, buffer or texture) and related parameters (such as, offset or size).

For example, `a` and `b` below 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);

### `[static]` QRhiShaderResourceBinding QRhiShaderResourceBinding::sampledTexture(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiTexture *tex, QRhiSampler *sampler)

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 a `count` of 1.

Note: tex and sampler can be null. It is valid to create a QRhiShaderResourceBindings with unspecified resources, but such an object cannot be used with QRhiCommandBuffer::setShaderResources(). It is however suitable for creating pipelines. Such a pipeline must then always be used together with another, layout compatible QRhiShaderResourceBindings with resources present passed to QRhiCommandBuffer::setShaderResources().

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 sampledTextures().

### `[static]` QRhiShaderResourceBinding QRhiShaderResourceBinding::sampledTextures(int binding, QRhiShaderResourceBinding::StageFlags stage, int count, const QRhiShaderResourceBinding::TextureAndSampler *texSamplers)

Returns a shader resource binding for the given binding number, pipeline stages, and the array of texture-sampler pairs specified by binding, stage, count, and texSamplers.

Note: count must be at least 1, and not larger than 16.

Note: When count is 1, this function is equivalent to sampledTexture().

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 a QRhiShaderResourceBinding for binding point 5, set up by calling this function with count set 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 count of 8. Additionally, all QRhiTexture and QRhiSampler instances 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: texSamplers can be null. It is valid to create a QRhiShaderResourceBindings with unspecified resources, but such an object cannot be used with QRhiCommandBuffer::setShaderResources(). It is however suitable for creating pipelines. Such a pipeline must then always be used together with another, layout compatible QRhiShaderResourceBindings with resources present passed to QRhiCommandBuffer::setShaderResources().

See also sampledTexture().

### `[static]` QRhiShaderResourceBinding QRhiShaderResourceBinding::sampler(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiSampler *sampler)

Returns a shader resource binding for the given binding number, pipeline stages, and sampler specified by binding, stage, sampler.

Note: sampler can be null. It is valid to create a QRhiShaderResourceBindings with unspecified resources, but such an object cannot be used with QRhiCommandBuffer::setShaderResources(). It is however suitable for creating pipelines. Such a pipeline must then always be used together with another, layout compatible QRhiShaderResourceBindings with resources present passed to QRhiCommandBuffer::setShaderResources().

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 as `sampler` as opposed to `sampler2D`: `layout(binding = 2) uniform sampler samp;`

With both a `texture2D` and `sampler` present, 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 texture().

### `[static]` QRhiShaderResourceBinding QRhiShaderResourceBinding::texture(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiTexture *tex)

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 a `count` of 1.

Note: tex can be null. It is valid to create a QRhiShaderResourceBindings with unspecified resources, but such an object cannot be used with QRhiCommandBuffer::setShaderResources(). It is however suitable for creating pipelines. Such a pipeline must then always be used together with another, layout compatible QRhiShaderResourceBindings with resources present passed to QRhiCommandBuffer::setShaderResources().

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 as `texture2D` as opposed to `sampler2D`: `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 textures() and sampler().

### `[static]` QRhiShaderResourceBinding QRhiShaderResourceBinding::textures(int binding, QRhiShaderResourceBinding::StageFlags stage, int count, QRhiTexture **tex)

Returns a shader resource binding for the given binding number, pipeline stages, and the array of (separate) textures specified by binding, stage, count, and tex.

Note: count must be at least 1, and not larger than 16.

Note: When count is 1, this function is equivalent to texture().

Warning: All elements of the array must be specified.

Note: tex can be null. It is valid to create a QRhiShaderResourceBindings with unspecified resources, but such an object cannot be used with QRhiCommandBuffer::setShaderResources(). It is however suitable for creating pipelines. Such a pipeline must then always be used together with another, layout compatible QRhiShaderResourceBindings with resources present passed to QRhiCommandBuffer::setShaderResources().

See also texture() and sampler().

### `[static]` QRhiShaderResourceBinding QRhiShaderResourceBinding::uniformBuffer(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf)

Returns a shader resource binding for the given binding number, pipeline stages, and buffer specified by binding, stage, and buf.

Note: When buf is not null, it must have been created with QRhiBuffer::UniformBuffer.

Note: buf can be null. It is valid to create a QRhiShaderResourceBindings with unspecified resources, but such an object cannot be used with QRhiCommandBuffer::setShaderResources(). It is however suitable for creating pipelines. Such a pipeline must then always be used together with another, layout compatible QRhiShaderResourceBindings with resources present passed to QRhiCommandBuffer::setShaderResources().

Note: If the size of buf exceeds the limit reported for QRhi::MaxUniformBufferRange, unexpected errors may occur.

### `[static]` QRhiShaderResourceBinding QRhiShaderResourceBinding::uniformBuffer(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf, quint32 offset, quint32 size)

Returns a shader resource binding for the given binding number, pipeline stages, and buffer specified by binding, stage, and buf. This overload binds a region only, as specified by offset and size.

Note: It is up to the user to ensure the offset is aligned to QRhi::ubufAlignment().

Note: size must be greater than 0.

Note: When buf is not null, it must have been created with QRhiBuffer::UniformBuffer.

Note: buf can be null. It is valid to create a QRhiShaderResourceBindings with unspecified resources, but such an object cannot be used with QRhiCommandBuffer::setShaderResources(). It is however suitable for creating pipelines. Such a pipeline must then always be used together with another, layout compatible QRhiShaderResourceBindings with resources present passed to QRhiCommandBuffer::setShaderResources().

Note: If size exceeds the limit reported for QRhi::MaxUniformBufferRange, unexpected errors may occur.

### `[static]` QRhiShaderResourceBinding QRhiShaderResourceBinding::uniformBufferWithDynamicOffset(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf, quint32 size)

Returns a shader resource binding for the given binding number, pipeline stages, and buffer specified by binding, stage, and buf. The uniform buffer is assumed to have dynamic offset. The dynamic offset can be specified in QRhiCommandBuffer::setShaderResources(), thus allowing using varying offset values without creating new bindings for the buffer. The size of the bound region is specified by size. Like with non-dynamic offsets, `offset + size` cannot exceed the size of buf.

Note: When buf is not null, it must have been created with QRhiBuffer::UniformBuffer.

Note: buf can be null. It is valid to create a QRhiShaderResourceBindings with unspecified resources, but such an object cannot be used with QRhiCommandBuffer::setShaderResources(). It is however suitable for creating pipelines. Such a pipeline must then always be used together with another, layout compatible QRhiShaderResourceBindings with resources present passed to QRhiCommandBuffer::setShaderResources().

Note: If size exceeds the limit reported for QRhi::MaxUniformBufferRange, unexpected errors may occur.

## Related Non-Members

### `[noexcept]` size_t qHash(const QRhiShaderResourceBinding &b, size_t seed = 0)

Returns the hash value for b, using seed to seed the calculation.

### `[noexcept]` bool operator!=(const QRhiShaderResourceBinding &a, const QRhiShaderResourceBinding &b)

Returns `false` if all the bindings in the two QRhiShaderResourceBinding objects a and b are equal; otherwise returns `true`.

### `[noexcept]` bool operator==(const QRhiShaderResourceBinding &a, const QRhiShaderResourceBinding &b)

Returns `true` if the contents of the two QRhiShaderResourceBinding objects a and b are equal. This includes the resources (buffer, texture) and related parameters (offset, size) as well. To only compare layouts (binding point, pipeline stage, resource type), use isLayoutCompatible() instead.