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) |
Related Non-Members
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
Constant | Value | Description |
---|---|---|
QRhiShaderResourceBinding::VertexStage | 1 << 0 | Vertex stage |
QRhiShaderResourceBinding::FragmentStage | 1 << 1 | Fragment (pixel) stage |
QRhiShaderResourceBinding::ComputeStage | 1 << 2 | Compute 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 |
QRhiShaderResourceBinding::ImageLoad | 2 | 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 | 3 | 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 | 4 | Image load and store |
QRhiShaderResourceBinding::BufferLoad | 5 | Storage buffer store (with GLSL this maps to reading from a shader storage buffer) |
QRhiShaderResourceBinding::BufferStore | 6 | Storage buffer store (with GLSL this maps to writing to a shader storage buffer) |
QRhiShaderResourceBinding::BufferLoadStore | 7 | Storage 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.