Describes the shader resource for a single binding point. 更多...
头: | #include <QRhiShaderResourceBinding> |
CMake: |
find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui) |
qmake: | QT += gui |
Since: | Qt 6.6 |
enum | StageFlag { VertexStage, TessellationControlStage, TessellationEvaluationStage, FragmentStage, ComputeStage, GeometryStage } |
flags | StageFlags |
enum | Type { UniformBuffer, SampledTexture, Texture, Sampler, ImageLoad, …, BufferLoadStore } |
bool | isLayoutCompatible (const QRhiShaderResourceBinding & other ) const |
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 ) |
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 ) |
A QRhiShaderResourceBinding cannot be constructed directly. Instead, use the static functions such as uniformBuffer () 或 sampledTexture () to get an instance.
注意: This is a RHI API with limited compatibility guarantees, see QRhi 了解细节。
Flag values to indicate which stages the shader resource is visible in
常量 | 值 | 描述 |
---|---|---|
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.
Specifies type of the shader resource bound to a binding point
常量 | 值 | 描述 |
---|---|---|
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 |
[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 .
注意: 当 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.
[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 .
注意: 当 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.
[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 .
注意: 当 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.
[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 .
注意: 当 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.
[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 .
注意: 当 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.
[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 .
注意: 当 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.
[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)
注意: 当 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.
[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)
注意: 当 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.
[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)
注意: 当 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.
返回
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).
例如,
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 .
注意:
此函数相当于调用
sampledTextures
() 采用
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.
另请参阅 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 ,和 texSamplers .
注意: count must be at least 1, and not larger than 16.
注意: 当 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.
警告: 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).
注意: 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 ().
另请参阅 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 .
注意: 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);
.
注意: 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.
另请参阅 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 .
注意:
此函数相当于调用
textures
() 采用
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;
注意: 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.
另请参阅 textures () 和 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 ,和 tex .
注意: count must be at least 1, and not larger than 16.
注意: 当 count is 1, this function is equivalent to texture ().
警告: All elements of the array must be specified.
注意: 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 ().
[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 ,和 buf .
注意: 当 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.
[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 ,和 buf . This overload binds a region only, as specified by offset and size .
注意: It is up to the user to ensure the offset is aligned to QRhi::ubufAlignment ().
注意: size 必须大于 0。
注意: 当 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 ().
注意: 若 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
,和
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
.
注意: 当 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 ().
注意: 若 size exceeds the limit reported for QRhi::MaxUniformBufferRange , unexpected errors may occur.
[noexcept]
size_t
qHash
(const
QRhiShaderResourceBinding
&
b
,
size_t
seed
= 0)
返回哈希值为 b ,使用 seed 做计算种子。
[noexcept]
bool
operator!=
(const
QRhiShaderResourceBinding
&
a
, const
QRhiShaderResourceBinding
&
b
)
返回
false
if all the bindings in the two
QRhiShaderResourceBinding
对象
a
and
b
相等;否则返回
true
.
[noexcept]
bool
operator==
(const
QRhiShaderResourceBinding
&
a
, const
QRhiShaderResourceBinding
&
b
)
返回
true
if the contents of the two
QRhiShaderResourceBinding
对象
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
() 代替。