The problem probably is that the struct would need to be properly aligned, which it probably isn’t. CPUs nowadays carry extra logic to allow for misaligned accesses, but the GPU (so far) doesn’t.
thank for responding me tera, as fare as I know it about alignement, the structure should be multiple of 2bytes or 4bytes, which is my case, because the size of my structure is 4bytes.
my struct is
struct data {
unsigned int NDatas : 6;
unsigned int Dummy: 2;
unsigned int p1 : 21;
unsigned int p2 : 1;
unsigned int x1 : 1;
unsigned int x2 : 1;
}
those are not 6 unsigned ints?
Also shouldn’t the : sign be = ?
Am i missing something here?
He’s using bitfields there (the ‘:’ means that the unsigned int needs to only take up a specific number of bits), so there are actually (6 + 2 + 21 + 1 + 1 + 1) = 32 bits = 1 unsigned int.
Still I think that tera is right about the misalignment problem. If ‘size’ the in the example is not 4-byte aligned, this will probably silently fail.