SPIRV-Cross/reference/shaders-msl-no-opt/packing/struct-alignment.comp
Hans-Kristian Arntzen fa5b206d97 MSL: Workaround broken vector -> scalar access chain in MSL.
On MSL, the compiler refuses to allow access chains into a normal vector type.
What happens in practice instead is a read-modify-write where a vector type is
loaded, modified and written back.

The workaround is to convert a vector into a pointer-to-scalar before
the access chain continues to add the scalar index.
2020-07-06 10:03:44 +02:00

28 lines
378 B
Plaintext

#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct Foo
{
packed_float3 a;
float b;
};
struct SSBO
{
float2 a;
float b;
char _m2_pad[4];
Foo foo;
};
constant uint3 gl_WorkGroupSize [[maybe_unused]] = uint3(1u);
kernel void main0(device SSBO& _12 [[buffer(0)]])
{
((device float*)&_12.a)[0u] = 10.0;
_12.b = 20.0;
}