Why are sizes and strides of SIMD3<Float> and SCNVector different?

127 Views Asked by At

So when I was working with buffers I was having something like UnsafeRawPointer (which consisted of SCNVector3) and I was casting it to UnsafeBufferPointer<SIMD3<Float>>. And then I saw that my function that reads information from that produces wrong results.

Then I've tried that:

MemoryLayout<SCNVector3>.size // 12
MemoryLayout<SCNVector3>.stride // 12

MemoryLayout<SIMD3<Float>>.size //16
MemoryLayout<SIMD3<Float>>.stride //16

And I don't get it why SIMD3 is 16 if it's only consists of 3 Floats.

Also found this on official docs but it seems wrong 'cuz it produces 12 on iPhone and M1 Important

SCNVector3. In macOS, the x, y, and z fields in this structure are CGFloat values. In iOS, tvOS, and watchOS, these fields are Float values.

0

There are 0 best solutions below