![]() |
VPP
0.7
A high-level modern C++ API for Vulkan
|
Template allowing to construct arrays of binding points. More...
#include <vppLangIntBase.hpp>
Public Member Functions | |
arrayOf (unsigned int count, unsigned int set=0, int binding=-1) | |
Constructs array of binding points. More... | |
arrayOf (const std::vector< NormalizedSampler > &samplers, unsigned int count, unsigned int set=0, int binding=-1) | |
Constructs array of binding points. More... | |
arrayOf (const std::vector< UnnormalizedSampler > &samplers, unsigned int count, unsigned int set=0, int binding=-1) | |
Constructs array of binding points. More... | |
auto | operator= (const multi_value_type &value) |
return_type | operator[] (const Int &index) const |
Indexing operator for accessing individual binding points in the array. More... | |
return_type | operator[] (const UInt &index) const |
return_type | operator[] (int index) const |
return_type | operator[] (unsigned int index) const |
Public Attributes | |
typedef< implementation_defined > | return_type |
Type of accessed image resource. More... | |
Template allowing to construct arrays of binding points.
This template is used as a wrapper over binding point classes to create arrays of binding points. The purpose of such arrays is to allow dynamic selection of binding points in shader, based on GPU-level index. Arrays of binding points are static, so their size must be known in advance.
The arrayOf template is applicable for the following binding point classes: inUniformBuffer, inUniformBufferDyn, ioBuffer, ioBufferDyn, ioImageBuffer, inTextureBuffer, ioImage, inSampler, inConstSampler, inTexture, inSampledTexture, inConstSampledTexture.
Arrays of data buffers (inUniformBuffer, inUniformBufferDyn, ioBuffer, ioBufferDyn) are being accessed slightly differently than arrays of images and texel buffers (ioImageBuffer, inTextureBuffer, ioImage, inSampler, inConstSampler, inTexture, inSampledTexture, inConstSampledTexture). These differences will be explained further below.
An array of binding points in VPP corresponds to array of descriptors in Vulkan. That is, it defines proper count
values in descriptor defining structures and generates array types on SPIR-V level.
In order to declare an array of binding points, just wrap the base type inside arrayOf. Examples:
In order to construct arrayOf object, you must provide array size to the constructor. See the docs for individual constructors for more detail.
In order to access an arrayed binding point in your shader code, use one of two methods depending on what kind of binding point is is.
For buffer binding points, i.e. inUniformBuffer, inUniformBufferDyn, ioBuffer, ioBufferDyn, use UniformVar accessor. It is specialized for arrays an provides an operator
[] for additional level of indirection.
Examples:
For image binding points, i.e. ioImageBuffer, inTextureBuffer, ioImage, inSampler, inConstSampler, inTexture, inSampledTexture, inConstSampledTexture, use the indexing operator directly on arrayOf object when supplying an argument to the image manipulation function.
Examples:
vpp::arrayOf< SingleT >::arrayOf | ( | unsigned int | count, |
unsigned int | set = 0 , |
||
int | binding = -1 |
||
) |
Constructs array of binding points.
This constructor is meant to be used with all binding point types except inConstSampler and inConstSampledTexture.
Size of the array is mandatory argument.
Optionally you can force the set and binding index. This feature may be useful if you need to interface VPP binding point with externally supplied shader (written in GLSL and compiled externally to SPIR-V blob).
vpp::arrayOf< SingleT >::arrayOf | ( | const std::vector< NormalizedSampler > & | samplers, |
unsigned int | count, | ||
unsigned int | set = 0 , |
||
int | binding = -1 |
||
) |
Constructs array of binding points.
This constructor is meant to be used with inConstSampler and inConstSampledTexture binding points and normalized samplers.
You must specify a list of samplers to be statically bound to the image.
Size of the array is also mandatory argument. If the size is larger than provided vector of samplers, the last sampler on the list will be duplicated to fill remaining positions.
Optionally you can force the set and binding index. This feature may be useful if you need to interface VPP binding point with externally supplied shader (written in GLSL and compiled externally to SPIR-V blob).
vpp::arrayOf< SingleT >::arrayOf | ( | const std::vector< UnnormalizedSampler > & | samplers, |
unsigned int | count, | ||
unsigned int | set = 0 , |
||
int | binding = -1 |
||
) |
Constructs array of binding points.
This constructor is meant to be used with inConstSampler and inConstSampledTexture binding points and unnormalized samplers.
You must specify a list of samplers to be statically bound to the image.
Size of the array is also mandatory argument. If the size is larger than provided vector of samplers, the last sampler on the list will be duplicated to fill remaining positions.
Optionally you can force the set and binding index. This feature may be useful if you need to interface VPP binding point with externally supplied shader (written in GLSL and compiled externally to SPIR-V blob).
return_type vpp::arrayOf< SingleT >::operator[] | ( | const Int & | index | ) | const |
Indexing operator for accessing individual binding points in the array.
This operator is used only for the following binding point types: ioImage, inSampler, inConstSampler, inTexture, inSampledTexture, inConstSampledTexture, inTextureBuffer, ioImageBuffer.
Use it inside shaders to extract the binding point used as an argument for image or texture manipulation functions.
return_type vpp::arrayOf< SingleT >::operator[] | ( | const UInt & | index | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
return_type vpp::arrayOf< SingleT >::operator[] | ( | int | index | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
return_type vpp::arrayOf< SingleT >::operator[] | ( | unsigned int | index | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
typedef<implementation_defined> vpp::arrayOf< SingleT >::return_type |
Type of accessed image resource.
This type is used only for the following binding point types: ioImage, inSampler, inConstSampler, inTexture, inSampledTexture, inConstSampledTexture, inTextureBuffer, ioImageBuffer.
This is the type of object that goes to image manipulation function inside the shader. The object is obtained by indexing the arrayOf object (by means of operator
[]).