how to copy data to float4 texture

Hi!

I’m need to initialize some RGB images as 2D textures (so as float3 is not possible, I should use float4). I know that if I want to use both dimensions for indexing, I’ve to copy data from a cudaArray.

The problem is that I can’t find the right way to copy the data I have to the cudaArray.

I’m working with C++, so suppose that I’ve the data into 3 different arrays data.R(), data.G(), data.B(). Now, how can I do cudaMemcpyToArray???

Did I need to copy first data to a float4 array, float per float, and then use cudaMemcpyToArray?

Isn’t there any other more efficient way to do that?

Thanks in advanced!

Enrique

There’s no other solution?

No, you either need to reformat the data on the CPU (interleaving r,g,b,a) and read it as float4s, or load each color channel as a separate array (which would require three texture reads).

You could do the interleaving in a CUDA kernel, but this probably wouldn’t be much faster.

It’s a little bit dissapointing, taking into account that memory operations are such a expensive task…

Thanks for your help!!

Enrique Oriol

Thanks everyone for your support, you’re the best!!

taux pret auto - taux pret auto differe selon la rise en compte … calculent automatiquement le taux pour un prêt automobile donne.