You define it with the texture syntax:
texture<Type, Dim, ReadMode> Name
Where:
Type is the data type (float, int, ...)
Dim is the number of dimensions 1D, 2D, 3D, represented as just the number 1, 2 or 3
ReadMode is the access allowed. Either
cudaReadModeNormalizedFloat
(a float value in the range [0-1], where
int
s are converted) or
cudaReadModeElementType
(The actual value you store in the memory). Reffer to section 4.3.4 of the
Cuda Programming Guide[
^] for a further explanation.
Name is your variable name
So, say we want a 2D array of integers (to be stored as integers), we would have
texture<int, 2, cudaReadModeElementType> MyIntGrid;