Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QRhiShaderResourceBinding Class Reference

\inmodule QtGui More...

#include <qrhi.h>

+ Collaboration diagram for QRhiShaderResourceBinding:

Classes

struct  Data
 
struct  TextureAndSampler
 

Public Types

enum  Type {
  UniformBuffer , SampledTexture , Texture , Sampler ,
  ImageLoad , ImageStore , ImageLoadStore , BufferLoad ,
  BufferStore , BufferLoadStore
}
 Specifies type of the shader resource bound to a binding point. More...
 
enum  StageFlag {
  VertexStage = 1 << 0 , TessellationControlStage = 1 << 1 , TessellationEvaluationStage = 1 << 2 , GeometryStage = 1 << 3 ,
  FragmentStage = 1 << 4 , ComputeStage = 1 << 5
}
 Flag values to indicate which stages the shader resource is visible in. More...
 

Public Member Functions

 QRhiShaderResourceBinding ()=default
 
bool isLayoutCompatible (const QRhiShaderResourceBinding &other) const
 

Static Public Member Functions

static QRhiShaderResourceBinding uniformBuffer (int binding, StageFlags stage, QRhiBuffer *buf)
 
static QRhiShaderResourceBinding uniformBuffer (int binding, StageFlags stage, QRhiBuffer *buf, quint32 offset, quint32 size)
 
static QRhiShaderResourceBinding uniformBufferWithDynamicOffset (int binding, StageFlags stage, QRhiBuffer *buf, quint32 size)
 
static QRhiShaderResourceBinding sampledTexture (int binding, StageFlags stage, QRhiTexture *tex, QRhiSampler *sampler)
 
static QRhiShaderResourceBinding sampledTextures (int binding, StageFlags stage, int count, const TextureAndSampler *texSamplers)
 
static QRhiShaderResourceBinding texture (int binding, StageFlags stage, QRhiTexture *tex)
 
static QRhiShaderResourceBinding textures (int binding, StageFlags stage, int count, QRhiTexture **tex)
 
static QRhiShaderResourceBinding sampler (int binding, StageFlags stage, QRhiSampler *sampler)
 
static QRhiShaderResourceBinding imageLoad (int binding, StageFlags stage, QRhiTexture *tex, int level)
 
static QRhiShaderResourceBinding imageStore (int binding, StageFlags stage, QRhiTexture *tex, int level)
 
static QRhiShaderResourceBinding imageLoadStore (int binding, StageFlags stage, QRhiTexture *tex, int level)
 
static QRhiShaderResourceBinding bufferLoad (int binding, StageFlags stage, QRhiBuffer *buf)
 
static QRhiShaderResourceBinding bufferLoad (int binding, StageFlags stage, QRhiBuffer *buf, quint32 offset, quint32 size)
 
static QRhiShaderResourceBinding bufferStore (int binding, StageFlags stage, QRhiBuffer *buf)
 
static QRhiShaderResourceBinding bufferStore (int binding, StageFlags stage, QRhiBuffer *buf, quint32 offset, quint32 size)
 
static QRhiShaderResourceBinding bufferLoadStore (int binding, StageFlags stage, QRhiBuffer *buf)
 
static QRhiShaderResourceBinding bufferLoadStore (int binding, StageFlags stage, QRhiBuffer *buf, quint32 offset, quint32 size)
 
template<typename Output >
static void serializeLayoutDescription (const QRhiShaderResourceBinding *first, const QRhiShaderResourceBinding *last, Output dst)
 

Static Public Attributes

static constexpr int LAYOUT_DESC_ENTRIES_PER_BINDING = 4
 

Friends

class QRhiImplementation
 

Related Symbols

(Note that these are not member symbols.)

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

Detailed Description

\inmodule QtGui

Since
6.6

Describes the shader resource for a single binding point.

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 \l QRhi for details.

Definition at line 438 of file qrhi.h.

Member Enumeration Documentation

◆ StageFlag

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

\value VertexStage Vertex stage \value TessellationControlStage Tessellation control (hull shader) stage \value TessellationEvaluationStage Tessellation evaluation (domain shader) stage \value FragmentStage Fragment (pixel shader) stage \value ComputeStage Compute stage \value GeometryStage Geometry stage

Enumerator
VertexStage 
TessellationControlStage 
TessellationEvaluationStage 
GeometryStage 
FragmentStage 
ComputeStage 

Definition at line 454 of file qrhi.h.

◆ Type

Specifies type of the shader resource bound to a binding point.

\value UniformBuffer Uniform buffer

\value 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.

\value Texture Texture (separate)

\value Sampler Sampler (separate)

\value 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)

\value 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)

\value ImageLoadStore Image load and store

\value BufferLoad Storage buffer store (with GLSL this maps to reading from a shader storage buffer)

\value BufferStore Storage buffer store (with GLSL this maps to writing to a shader storage buffer)

\value BufferLoadStore Storage buffer load and store

Enumerator
UniformBuffer 
SampledTexture 
Texture 
Sampler 
ImageLoad 
ImageStore 
ImageLoadStore 
BufferLoad 
BufferStore 
BufferLoadStore 

Definition at line 441 of file qrhi.h.

Constructor & Destructor Documentation

◆ QRhiShaderResourceBinding()

QRhiShaderResourceBinding::QRhiShaderResourceBinding ( )
default

Member Function Documentation

◆ bufferLoad() [1/2]

QRhiShaderResourceBinding QRhiShaderResourceBinding::bufferLoad ( int binding,
StageFlags stage,
QRhiBuffer * buf )
static
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.
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().
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.

Definition at line 5946 of file qrhi.cpp.

References QRhiShaderResourceBinding::Data::binding, and BufferLoad.

Referenced by QRhiMetal::setShaderResources().

+ Here is the caller graph for this function:

◆ bufferLoad() [2/2]

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

Definition at line 5981 of file qrhi.cpp.

References QRhiShaderResourceBinding::Data::binding, BufferLoad, and Q_ASSERT.

◆ bufferLoadStore() [1/2]

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

Definition at line 6086 of file qrhi.cpp.

References QRhiShaderResourceBinding::Data::binding, and BufferLoadStore.

◆ bufferLoadStore() [2/2]

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

Definition at line 6121 of file qrhi.cpp.

References QRhiShaderResourceBinding::Data::binding, BufferLoadStore, and Q_ASSERT.

◆ bufferStore() [1/2]

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

Definition at line 6016 of file qrhi.cpp.

References QRhiShaderResourceBinding::Data::binding, and BufferStore.

◆ bufferStore() [2/2]

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

Definition at line 6051 of file qrhi.cpp.

References QRhiShaderResourceBinding::Data::binding, BufferStore, and Q_ASSERT.

◆ imageLoad()

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

Definition at line 5843 of file qrhi.cpp.

References QRhiShaderResourceBinding::Data::binding, and ImageLoad.

◆ imageLoadStore()

QRhiShaderResourceBinding QRhiShaderResourceBinding::imageLoadStore ( int binding,
StageFlags stage,
QRhiTexture * tex,
int level )
static
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.
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().
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.

Definition at line 5913 of file qrhi.cpp.

References QRhiShaderResourceBinding::Data::binding, and ImageLoadStore.

◆ imageStore()

QRhiShaderResourceBinding QRhiShaderResourceBinding::imageStore ( int binding,
StageFlags stage,
QRhiTexture * tex,
int level )
static
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.
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().
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.

Definition at line 5878 of file qrhi.cpp.

References QRhiShaderResourceBinding::Data::binding, and ImageStore.

◆ isLayoutCompatible()

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:

static QRhiShaderResourceBinding uniformBuffer(int binding, StageFlags stage, QRhiBuffer *buf)
Definition qrhi.cpp:5526
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint buffer

Definition at line 5500 of file qrhi.cpp.

References QRhiShaderResourceBinding::Data::arraySize(), QRhiShaderResourceBinding::Data::binding, other(), QRhiShaderResourceBinding::Data::stage, and QRhiShaderResourceBinding::Data::type.

+ Here is the call graph for this function:

◆ sampledTexture()

QRhiShaderResourceBinding QRhiShaderResourceBinding::sampledTexture ( int binding,
StageFlags stage,
QRhiTexture * tex,
QRhiSampler * sampler )
static
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.
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().
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()

Definition at line 5640 of file qrhi.cpp.

References QRhiShaderResourceBinding::Data::binding, and SampledTexture.

Referenced by TextureCopy::TextureCopy(), QSSGRenderReflectionMap::addReflectionMapEntry(), renderToKTXFileInternal(), QVideoWindowPrivate::updateSubtitle(), updateTextures(), and QVideoWindowPrivate::updateTextures().

+ Here is the caller graph for this function:

◆ sampledTextures()

QRhiShaderResourceBinding QRhiShaderResourceBinding::sampledTextures ( int binding,
StageFlags stage,
int count,
const TextureAndSampler * texSamplers )
static
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.
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()

Definition at line 5686 of file qrhi.cpp.

References QRhiShaderResourceBinding::Data::binding, i, QRhiShaderResourceBinding::Data::MAX_TEX_SAMPLER_ARRAY_SIZE, Q_ASSERT, and SampledTexture.

◆ sampler()

QRhiShaderResourceBinding QRhiShaderResourceBinding::sampler ( int binding,
StageFlags stage,
QRhiSampler * sampler )
static
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()

Definition at line 5809 of file qrhi.cpp.

References QRhiShaderResourceBinding::Data::binding, and Sampler.

◆ serializeLayoutDescription()

template<typename Output >
static void QRhiShaderResourceBinding::serializeLayoutDescription ( const QRhiShaderResourceBinding * first,
const QRhiShaderResourceBinding * last,
Output dst )
inlinestatic

Definition at line 549 of file qrhi.h.

◆ texture()

QRhiShaderResourceBinding QRhiShaderResourceBinding::texture ( int binding,
StageFlags stage,
QRhiTexture * tex )
static
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.
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(), sampler()

Definition at line 5733 of file qrhi.cpp.

References QRhiShaderResourceBinding::Data::binding, and Texture.

◆ textures()

QRhiShaderResourceBinding QRhiShaderResourceBinding::textures ( int binding,
StageFlags stage,
int count,
QRhiTexture ** tex )
static
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.
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(), sampler()

Definition at line 5764 of file qrhi.cpp.

References QRhiShaderResourceBinding::Data::binding, i, QRhiShaderResourceBinding::Data::MAX_TEX_SAMPLER_ARRAY_SIZE, Q_ASSERT, and Texture.

◆ uniformBuffer() [1/2]

QRhiShaderResourceBinding QRhiShaderResourceBinding::uniformBuffer ( int binding,
StageFlags stage,
QRhiBuffer * buf )
static
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.
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().
If the size of buf exceeds the limit reported for QRhi::MaxUniformBufferRange, unexpected errors may occur.

Definition at line 5526 of file qrhi.cpp.

References QRhiShaderResourceBinding::Data::binding, and UniformBuffer.

Referenced by TextureCopy::TextureCopy(), ExampleRhiWidget::initialize(), ExampleRhiItemRenderer::initialize(), main(), QVideoWindowPrivate::updateSubtitle(), updateTextures(), and QVideoWindowPrivate::updateTextures().

+ Here is the caller graph for this function:

◆ uniformBuffer() [2/2]

QRhiShaderResourceBinding QRhiShaderResourceBinding::uniformBuffer ( int binding,
StageFlags stage,
QRhiBuffer * buf,
quint32 offset,
quint32 size )
static
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().
size must be greater than 0.
When buf is not null, it must have been created with QRhiBuffer::UniformBuffer.
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().
If size exceeds the limit reported for QRhi::MaxUniformBufferRange, unexpected errors may occur.

Definition at line 5563 of file qrhi.cpp.

References QRhiShaderResourceBinding::Data::binding, Q_ASSERT, and UniformBuffer.

◆ uniformBufferWithDynamicOffset()

QRhiShaderResourceBinding QRhiShaderResourceBinding::uniformBufferWithDynamicOffset ( int binding,
StageFlags stage,
QRhiBuffer * buf,
quint32 size )
static
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.
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().
If size exceeds the limit reported for QRhi::MaxUniformBufferRange, unexpected errors may occur.

Definition at line 5600 of file qrhi.cpp.

References QRhiShaderResourceBinding::Data::binding, Q_ASSERT, and UniformBuffer.

Referenced by QSSGRenderReflectionMap::addReflectionMapEntry(), and renderToKTXFileInternal().

+ Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ operator!=()

bool operator!= ( const QRhiShaderResourceBinding & a,
const QRhiShaderResourceBinding & b )
related
Returns
false if all the bindings in the two QRhiShaderResourceBinding objects a and b are equal; otherwise returns true.

Definition at line 6225 of file qrhi.cpp.

◆ operator==()

bool operator== ( const QRhiShaderResourceBinding & a,
const QRhiShaderResourceBinding & b )
related
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 \l{QRhiShaderResourceBinding::isLayoutCompatible()}{isLayoutCompatible()} instead.

Definition at line 6145 of file qrhi.cpp.

References BufferLoad, BufferLoadStore, BufferStore, db, i, ImageLoad, ImageLoadStore, ImageStore, SampledTexture, Sampler, QRhiImplementation::shaderResourceBindingData(), Texture, and UniformBuffer.

+ Here is the call graph for this function:

◆ qHash()

size_t qHash ( const QRhiShaderResourceBinding & b,
size_t seed )
related
Returns
the hash value for b, using seed to seed the calculation.

Definition at line 6235 of file qrhi.cpp.

References BufferLoad, BufferLoadStore, BufferStore, d, hash, ImageLoad, ImageLoadStore, ImageStore, SampledTexture, Sampler, seed, QRhiImplementation::shaderResourceBindingData(), Texture, and UniformBuffer.

+ Here is the call graph for this function:

◆ QRhiImplementation

friend class QRhiImplementation
friend

Definition at line 561 of file qrhi.h.

Member Data Documentation

◆ LAYOUT_DESC_ENTRIES_PER_BINDING

constexpr int QRhiShaderResourceBinding::LAYOUT_DESC_ENTRIES_PER_BINDING = 4
staticconstexpr

Definition at line 546 of file qrhi.h.

Referenced by QRhiShaderResourceBindings::QRhiShaderResourceBindings().


The documentation for this class was generated from the following files: