Array of storage buffers in GLSL

How can I declare an array of storage buffers?

layout(binding = 0) readonly buffer BoneMatricesBlock[2] { uvec4 bonematrices[]; };

The GLSL compiler does not like my syntax above. I want to switch these back and forth each time the data is updated, something like this:

boneinfo = bonematrices[currentindex][boneID];
buffer BoneMatricesBlock { uvec4 bonematrices[]; } bonematricesblocks[2];

Accessed as

boneinfo = bonematricesblocks[currentindex].bonematrices[boneID];

The instance name isn’t optional for arrays of blocks. The subscript is actually part of the instance name, so any declaration without an instance name can only declare a single block.

1 Like

Thanks, I figured there must be a way. :slight_smile: