Texture filtering

If I create a texture using the high level API like:

texture<uchar4, 2, cudaReadModeNormalizedFloat> texImage;

cudaChannelFormatDesc uchar4tex = cudaCreateChannelDesc<uchar4>();

is the filter mode set to linear by default or do I have to use a low level API and set the textureReference properties manually and the create the texture?

You can just do:

texImage.filterMode = cudaFilterModeLinear;

It looks like the default is point sampling, but I wouldn’t depend on this:

From “cuda_texture_types.h”:

template<class T, int dim = 1, enum cudaTextureReadMode mode = cudaReadModeElementType>

struct texture : public textureReference

{

  __host__ texture(int						 norm  = 0,

				   enum cudaTextureFilterMode  fMode = cudaFilterModePoint,

				   enum cudaTextureAddressMode aMode = cudaAddressModeClamp)

  {

	normalized	 = norm;

	filterMode	 = fMode;

	addressMode[0] = aMode;

	addressMode[1] = aMode;

	addressMode[2] = aMode;

	channelDesc	= cudaCreateChannelDesc<T>();

  }

It doesn’t work

It shows the following errors.

1>c:/Documents and Settings/All Users/Dati applicazioni/NVIDIA Corporation/NVIDIA GPU Computing SDK/C/src/imageUnwarping/imageUnwarp.cu(24): error: this declaration has no storage class or type specifier

1>c:/Documents and Settings/All Users/Dati applicazioni/NVIDIA Corporation/NVIDIA GPU Computing SDK/C/src/imageUnwarping/imageUnwarp.cu(24): error: variable "texImage" has already been defined

1>c:/Documents and Settings/All Users/Dati applicazioni/NVIDIA Corporation/NVIDIA GPU Computing SDK/C/src/imageUnwarping/imageUnwarp.cu(24): error: expected a ";"

EDIT: I solved my problem. It didn’t work because I tried to access the textureReference before allocating the texture in the memory, now it works.

For anyone else who is interested in the matter, the standard value for filterMode in textureReference is 0, which means it does the point interpolation, if you want to use the bilinear interpolation you must use

texImage.filterMode = cudaFilterModeLinear;

as suggested by jgoffeney.