SPIRV-Cross/shaders-msl/vulkan/frag/scalar-block-layout-ubo-std430.vk.nocompat.invalid.frag
Chip Davis e5fa7edfd6 MSL: Support scalar block layout.
Relaxed block layout relaxed the restrictions on vector alignment,
allowing them to be aligned on scalar boundaries. Scalar block layout
relaxes this further, allowing *any* member to be aligned on a scalar
boundary. The requirement that a vector not improperly straddle a
16-byte boundary is also relaxed.

I've also added a test showing that `std430` layout works with UBOs.

I'm troubled by the dual meaning of the `Packed` extended decoration. In
some instances (struct, `float[]`, and `vec2[]` members), it actually
means the exact opposite, that the member needs extra padding. This is
especially problematic for `vec2[]`, because now we need to distinguish
the two cases by checking the array stride. I wonder if this should
actually be split into two decorations.
2019-07-09 20:59:32 -05:00

24 lines
391 B
GLSL

#version 450
#extension GL_EXT_scalar_block_layout : require
layout(std430, binding = 0) uniform UBO
{
float a[1];
vec2 b[2];
};
layout(std430, binding = 1) uniform UBOEnhancedLayout
{
float c[1];
vec2 d[2];
layout(offset = 10000) float e;
};
layout(location = 0) flat in int vIndex;
layout(location = 0) out float FragColor;
void main()
{
FragColor = a[vIndex] + c[vIndex] + e;
}