How to copy float4 data into a 3D cudaArray

Hi guys,
I am working on interpolating a multi-modality image.
The image itself is 3D with 3 channels. Since tex3D doesn’t seem to have a float3 version so
I use float4.

I managed to load the image into a 1D linear float4 array (in typical row major order).
But then I am confused on how to load the float4 array into a 3D cuda array for texture.

My code now looks like

// Load data
float4* image;
cudaExtent extent;
loadImage(“path/to/image”, image, extent);

// Allocate cuda array memory
cudaChannelFormatDesc channelDesc =
cudaCreateChannelDesc(32, 32, 32, 32, cudaChannelFormatKindFloat);
cudaArray* cuArray;
cudaMalloc3DArray(&cuArray,&channelDesc,extent, 0);

// TODO: how to load image into the cuda array?