3

In the CUDA C Programming Guide Version 5, Appendix E.2 (Linear Filtering), it is stated that:

In this filtering mode, which is only available for floating-point textures, the value returned by the texture fetch is...

The part in bold case is confusing me. Does floating point mean the texel type only, or the return type also? For example, I declare 3 textures as follows.

texture<float,cudaTextureType2D> tex32f;
texture<unsigned char, cudaTextureType2D, cudaReadModeNormalizedFloat> tex8u;
texture<unsigned short, cudaTextureType2D, cudaReadModeNormalizedFloat> tex16u;

Is linear filtering available for tex32f only, or also for tex8u and tex16u?

sgarizvi
  • 16,623
  • 9
  • 64
  • 98
  • Thank you for this post. I wasted most of my day because setting `tex.filterMode = cudaFilterModeLinear;` on an integer texture causes many other things to silently fail. – Meekohi Dec 12 '13 at 23:01

1 Answers1

6

It means that linear filtering is available only when the "read mode" of the texture is cudaReadModeNormalizedFloat, i.e. integer types (such as u8) get promoted to floating point values in the range [0.0, 1.0] (for unsigned integers) or [-1.0, 1.0] (for signed integers).

ArchaeaSoftware
  • 4,332
  • 16
  • 21
  • 2
    My original answer actually wasn't right either... you can, in fact, interpolate with non-normalized texture coordinates (though you have to do an awkward +0.5 offset to get the expected effect). What you cannot do is linearly interpolate from texture references that are set as cudaReadModeElementType. – ArchaeaSoftware Jan 02 '13 at 19:33
  • It means, interpolation is dependent on the return type of the texture? And is possible with all of my example textures? – sgarizvi Jan 02 '13 at 19:38
  • 1
    Yes, all of your example textures can be interpolated with 9 bits of precision and the return value will be float. If you're not getting the expected results, it is probably because your texture coordinates are not being computed correctly (sometimes you have to put awkward-looking casts to float in the expression) or are interacting with the texture addressing mode in an unexpected way. – ArchaeaSoftware Jan 03 '13 at 01:00