So I've read about Storage Buffers being able to contain a variable length array at end:
SSBOs can have variable storage, up to whatever buffer range was bound for that particular buffer; UBOs must have a specific, fixed storage size. This means that you can have an array of arbitrary length in an SSBO (at the end, rather). The actual size of the array, based on the range of the buffer bound, can be queried at runtime in the shader using the length function on the unbounded array variable
I know how to pass a storage buffer as a struct with simple fields like this:
struct GPUStorage {
glm::vec3 mesh_pos;
glm::vec4 mesh_rot;
};
And know how to pass a storage buffer as an array of structs by shoving them into a vector
and do memcpy
on vector.data()
with copy length as sizeof(GPUStorage) * vector.size()
.
But I haven't found anywhere how does the C++ syntax look for a struct containing a variable length array ?
struct GPUMesh {
glm::vec3 mesh_pos;
glm::vec4 mesh_rot;
};
struct GPUStorage {
??? // variable length array of GPUMesh
};