copy struct ? Can i copy a struct from PC side to GPU?


i wonder if i can copy a struct from the CPU side to the GPU and keep the layout of the struct?

Are there data types available on the CPU side that have the same size on the GPU?
And is it guaranteed that the layout of the struct is the same on CPU and GPU?

Or do i need to pack the struct into an array of unsigned char, copy that and unpack it on the GPU?

Thanks for any hints,

You can just do a direct copy. Arrangement of elements inside a struct follow the order in which they appear in the source code.

For performance’s sake, it would be better to group things by name/type, though, just like the packing you mentioned.