tex1Dfetch How does it work?

Hi there,

I am learning how to use the texture Memory.

I have some trouble understanding the tex1Dfetch function.

The fisrt argument stands for the texture, but for what is the second argument purpose?

If someone have any idea, he is welcome :)



It’s the index of the element you want to read.

Hum, Index.

Then I didn’t understand how this function works.

I might have more than one element in the texture?

Is a Texture a kind of array?

Yes. It is a read-only array which uses dedicated hardware to speed up reading from it.


Is there any possibilities to put an array in a texture?
If yes, how may I do it?



Yes. Note that this applies to arrays in the C language sense, since CUDA arrays are 2-dimensional and thus incompatible with tex1Dfetch().

Also read the section about textures in the CUDA C Programming Guide.