textures and float3

Hello CUDA friends,

I have a problem using float3 for a linear texture in CUDA.

I’m using a linear memory to save a vector of floats that correspond to vertices points, the data structure is as follows:

V0x V0y V0z V1x V1y V1z V2x V2y V2z … Vnx Vny Vnz

So if I need to save n points, I would need to declare n*3 float vector.

I use that appoach and it’s working. Now I saw that fetching to a vector type you could have better fetching than the first approach, So I decided to use float3 and the vector of float3 would be

V0 V1 V2 … Vn

so I just need to declare n elements in the example above. the problem is that when I want to compile I have this compilation error:

error: no instance of overloaded function “tex1Dfetch” matches the argument list

if I change the texture reference from float3 to float, I have no compilation error. So I wonder if someone here could use float3 for linear texture.

I don’t want to waste more time in this, so I’ll continue with another optimization strategy. Please help me!!! I’d appreciate any comment.

Textures can only be 1, 2, or 4 element vector types: not 3. Your best bet is to interleave your data and read it as a float4.

MisterAnderson42, I tried float4 and it works like a charm, thank you very much!!