diff --git a/reference/shaders-msl-no-opt/packing/struct-packing.comp b/reference/shaders-msl-no-opt/packing/struct-packing.comp new file mode 100644 index 00000000..115e1241 --- /dev/null +++ b/reference/shaders-msl-no-opt/packing/struct-packing.comp @@ -0,0 +1,27 @@ +#include +#include + +using namespace metal; + +struct Foo +{ + packed_float3 a; +}; + +struct Bar +{ + packed_float3 a; +}; + +struct SSBOScalar +{ + Foo foo; + Bar bar; +}; + +kernel void main0(device SSBOScalar& buffer_scalar [[buffer(0)]]) +{ + buffer_scalar.foo.a[0u] = 10.0; + buffer_scalar.bar.a[0u] = 20.0; +} + diff --git a/shaders-msl-no-opt/packing/struct-packing.comp b/shaders-msl-no-opt/packing/struct-packing.comp new file mode 100644 index 00000000..69a80382 --- /dev/null +++ b/shaders-msl-no-opt/packing/struct-packing.comp @@ -0,0 +1,27 @@ +#version 450 +#extension GL_EXT_scalar_block_layout : require +layout(local_size_x = 1) in; + +// Foo will be marked packed_float3 because offset of bar is just 12 bytes after foo. +struct Foo +{ + vec3 a; +}; + +// Bar will be marked as packed due to alignment of the struct itself cannot work without packed. +struct Bar +{ + vec3 a; +}; + +layout(scalar, set = 0, binding = 0) buffer SSBOScalar +{ + Foo foo; + Bar bar; +} buffer_scalar; + +void main() +{ + buffer_scalar.foo.a.x = 10.0; + buffer_scalar.bar.a.x = 20.0; +}