I'm trying to use a simd float2 inside a struct to send to a shader and it works if the receiving struct in the metal file is typed as a packed_float2. Things do not look nice when I try to use a float2 in my receiving struct in metal. I checked the alignment documentation and noticed that the alignment for a packed_float2 is 4 bytes but it's size is 8 bytes. The simd float2 type's size is 8 bytes. Is the simd float2 type not aligned by 8 bytes? Since the sizes are the same what does it matter if the shader reads it 8 bytes at a time or 4 bytes at a time. Why does this generate garbage?
Also I'm having similar problems with float3 simd types. I have structs with just float3 types, not packed_float3 types, and it works fine - I can send data from my swift program to the shader without problems, but then I have a separate struct with mixed types (float, float2 and float3, the one mentioned above for the float2 problems actually), but everything in this struct needs to be a packed type. I'm trying to follow the documentation as best as possible, but there really isn't much of this that's documented. Is there some useful documentation or resource guide to help me through my alignment issues? Thank you.