1

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?

4

1 回答 1

2

Vulkan 在附录 A 中定义了 SPIR-V 的执行环境;因此,它可以对着色器中允许的内容施加超出 SPIR-V 规范的限制。在该附录中,它说:

OpTypeRuntimeArray只能用于修饰为 的存储类中的最后一个成员,或者修饰为OpTypeStruct的存储类中的最后一个成员。StorageBufferBlockUniformBufferBlock

于 2018-06-18T13:17:14.770 回答