Buffer Binding resource base class.
Buffer bindings, unlike 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::VertexBufferVec4
or a more complex nap::StructGPUBuffer
.
A single vec4 array can be addressed as a nap::VertexBufferVec4
:
layout(std430) buffer PositionSSBO
{
vec4 positions[100000];
} 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];
};