I am trying to write to a 2-dimensional cudaArray through a surface<void, 2>.
The array has a channel format {32, 32, 0, 0, cudaChannelFormatKindFloat} or to put it more simply, holds vector2s.
I am trying to write a vector2 to the surface at the position indicated by integer coordinates (x, y). The following works well:
// write the float2 vector d to outSurf
surf2Dwrite(d.x, outSurf, x * sizeof(float2), y);
surf2Dwrite(d.y, outSurf, x * sizeof(float2) + sizeof(float), y);
However, if I do
surf2Dwrite(d, outSurf, x * sizeof(float2), y);
only the x component of the vector is being written. What is the reason for this slightly unintuitive behaviour?
I find it hard to believe that any of those surf2Dwrite calls actually do what you think they do. To write a
float2I would use this:The x and y arguments are the coordinates on the surface you are writing to and the template parameter tells the call the size of the type being accessed.