Instantiated version of nap::BufferBinding. Every buffer binding 'resource' has an associative 'instance', ie: nap::BufferBindingNumeric -> nap::BufferBindingNumericInstance. An instance can be updated / inspected at run-time and is associated with a declaration.
Buffer bindings, unlike standard uniforms, store a reference to the underlying data as opposed to the data itself. This allows for any compute shader to read from and write to the same data storage. Buffer bindings always refer to a single nap::GPUBuffer, whether this is simple a nap::GPUBufferNumeric
or a more complex nap::StructGPUBuffer
.
A single vec4 array can be addressed as a nap::VertexBufferVec4
:
layout(std430) buffer PositionSSBO //<- binding name
{
vec4 positions[100000]; //<- buffer declaration name
} pos_ssbo;
layout(std430) buffer NormalSSBO
{
vec4 normals[100000];
} norm_ssbo;
If you intend to pack some data types together, you can do so with a nap::StructGPUBuffer
:
struct Item
{
vec4 position;
vec4 normal;
};
layout(std430) buffer ItemSSBO
{
Item items[100000];
} item_ssbo;
Declaring multiple shader variables outside of a struct is currently not supported:
// ERROR
layout(std430) buffer ExampleComputeBuffer
{
vec4 positions[100000];
vec4 normals[100000];
};