The spec says
[140] An array has a base alignment equal to the base alignment of its element type, rounded up to a multiple of 16. .... [430] except for array and structure base alignment which do not need to be rounded up to a multiple of 16.
I assume the size for a static array is trivially size_of(elem_type) * length
but what about a dynamic array?
There are no pointers in the logical mode, does that mean the size of a dynamic array is 0?
I don't know which offsets I should apply to the following struct
struct Data {
float i1;
float[] arr;
float i2;
}
Or in SPIR-V notation
%Data = OpTypeStruct %float %_runtimearr_float %float
Can this be done, or do the same rules of GLSL apply here where you are only allowed to have exactly one dynamic array inside a buffer block, and it has to be the last one?
Vulkan, in Appendix A, defines the execution environment for SPIR-V; as such, it can impose limits on what it allows in shaders beyond that of the SPIR-V specification. In that appendix, it says:
OpTypeRuntimeArray
must only be used for the last member of anOpTypeStruct
that is in theStorageBuffer
storage class decorated asBlock
, or that is in theUniform
storage class decorated asBufferBlock
.