QRhiShaderResourceBinding Class

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

Header: #include <QRhiShaderResourceBinding>
qmake: QT += rhi

Public Types

enum StageFlag { VertexStage, FragmentStage, ComputeStage }
flags StageFlags
enum Type { UniformBuffer, SampledTexture, ImageLoad, ImageStore, ..., BufferLoadStore }

Public Functions

~QRhiShaderResourceBinding()
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, int offset, int size)
QRhiShaderResourceBinding bufferLoadStore(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf)
QRhiShaderResourceBinding bufferLoadStore(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf, int offset, int size)
QRhiShaderResourceBinding bufferStore(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf)
QRhiShaderResourceBinding bufferStore(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf, int offset, int 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 uniformBuffer(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf)
QRhiShaderResourceBinding uniformBuffer(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf, int offset, int size)
QRhiShaderResourceBinding uniformBufferWithDynamicOffset(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf, int size)
uint qHash(const QRhiShaderResourceBinding &b, uint seed = 0)
bool operator!=(const QRhiShaderResourceBinding &a, const QRhiShaderResourceBinding &b)
bool operator==(const QRhiShaderResourceBinding &a, const QRhiShaderResourceBinding &b)

Detailed Description

Describes the shader resource for a single binding point.

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

Member Type Documentation

enum QRhiShaderResourceBinding::StageFlag
flags QRhiShaderResourceBinding::StageFlags

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

ConstantValueDescription
QRhiShaderResourceBinding::VertexStage1 << 0Vertex stage
QRhiShaderResourceBinding::FragmentStage1 << 1Fragment (pixel) stage
QRhiShaderResourceBinding::ComputeStage1 << 2Compute 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

ConstantValueDescription
QRhiShaderResourceBinding::UniformBuffer0Uniform buffer
QRhiShaderResourceBinding::SampledTexture1Combined image sampler
QRhiShaderResourceBinding::ImageLoad2Image 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::ImageStore3Image 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::ImageLoadStore4Image load and store
QRhiShaderResourceBinding::BufferLoad5Storage buffer store (with GLSL this maps to reading from a shader storage buffer)
QRhiShaderResourceBinding::BufferStore6Storage buffer store (with GLSL this maps to writing to a shader storage buffer)
QRhiShaderResourceBinding::BufferLoadStore7Storage buffer load and store

Property Documentation

Member Function Documentation

QRhiShaderResourceBinding::~QRhiShaderResourceBinding()

Destructor.

[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: buf must have been created with QRhiBuffer::StorageBuffer.

[static] QRhiShaderResourceBinding QRhiShaderResourceBinding::bufferLoad(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf, int offset, int 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: buf must have been created with QRhiBuffer::StorageBuffer.

[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: buf must have been created with QRhiBuffer::StorageBuffer.

[static] QRhiShaderResourceBinding QRhiShaderResourceBinding::bufferLoadStore(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf, int offset, int 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: buf must have been created with QRhiBuffer::StorageBuffer.

[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: buf must have been created with QRhiBuffer::StorageBuffer.

[static] QRhiShaderResourceBinding QRhiShaderResourceBinding::bufferStore(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf, int offset, int 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: buf must have been created with QRhiBuffer::StorageBuffer.

[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: tex must have been created with QRhiTexture::UsedWithLoadStore.

[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: tex must have been created with QRhiTexture::UsedWithLoadStore.

[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: tex must have been created with QRhiTexture::UsedWithLoadStore.

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.

[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: buf must have been created with QRhiBuffer::UniformBuffer.

[static] QRhiShaderResourceBinding QRhiShaderResourceBinding::uniformBuffer(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf, int offset, int 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: buf must have been created with QRhiBuffer::UniformBuffer.

[static] QRhiShaderResourceBinding QRhiShaderResourceBinding::uniformBufferWithDynamicOffset(int binding, QRhiShaderResourceBinding::StageFlags stage, QRhiBuffer *buf, int 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: buf must have been created with QRhiBuffer::UniformBuffer.

Member Variable Documentation

Related Non-Members

uint qHash(const QRhiShaderResourceBinding &b, uint seed = 0)

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

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.

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.

Macro Documentation