I need help understanding the alignment of data in OpenCL buffers

Given the following structure

typedef struct { float3 position; float8 position1; } MyStruct; 

I create a buffer to pass it as a pointer to the kernel, the buffer will have the previous buffer format.

I understand that I have to add 4 bytes to the buffer after writing three floats to get the next power of two (16 bytes), but I don't understand why I have to add 16 more bytes before writing bytes to position1. Otherwise, I get the wrong values ​​at position1.

Can someone explain to me why?

+2
opencl
source share

All Articles