No instance of overloaded function "tex2D" matches the argument list problem using texture

Hey,

I have the following problem:

I would like to acces a 2D texture in cuda using filtering. This texture uses ‘unsigned ints’ because I need atomic operations. Now when I use the following:

texture<unsigned int, 2> gridCountTexture;

cudaChannelFormatDesc descFloat = cudaCreateChannelDesc<float>();

cudaBindTexture2D(NULL, gridCountTexture, gridCountMemory, descFloat, width, height, pitch ));

gridCountTexture.filterMode = cudaFilterModeLinear;

So I want filtered acces and return a float. This gives me the error that “linear filtering is not supported for non-float type”. Now when I normalise the return value, like so:

texture<unsigned int, 2,cudaReadModeNormalizedFloat> gridCountTexture;

I get the following compile error:

no instance of overloaded function “tex2D” matches the argument list. argument types are: (texture<unsigned int, 2, cudaReadModeNormalizedFloat>, float, float)

Does anyone has more insight into this problem or can you point me to relevant information? I can’t seem to find why the tex2D function can’t use a texture with <uint,…,readModeNormFloat>

Thanks in advance!

It seems that using filtering with a 32bit uint is not possible (although I didn’t find any info on this). So using a ushort would solve the filtering problem (same for using float). But then I can’t use atomic operations (need a 32 or 64 bit uint)… There is no way around this I suppose?

It seems that using filtering with a 32bit uint is not possible (although I didn’t find any info on this). So using a ushort would solve the filtering problem (same for using float). But then I can’t use atomic operations (need a 32 or 64 bit uint)… There is no way around this I suppose?

From the docs:

confirming that you can only use cudaReadModeNormalizedFloat with 16 and 8 bit integer types.

You could always use cudaReadModeElementType and perform the filtering “by hand” in software. You likely won’t see a performance degradation (I didn’t when I did this) and you get a full-precision filter to boot (cudaFilterModeLinear only has 255 steps from one value to the next)

From the docs:

confirming that you can only use cudaReadModeNormalizedFloat with 16 and 8 bit integer types.

You could always use cudaReadModeElementType and perform the filtering “by hand” in software. You likely won’t see a performance degradation (I didn’t when I did this) and you get a full-precision filter to boot (cudaFilterModeLinear only has 255 steps from one value to the next)