tex1D accuracy

Hi,

I have been using tex1D and I found the function has pretty low accuracy.

Here is a simplified example, considering a table with N=2 points, t[0]=1.0, t[1]=2.0,

the following are the results I got by using tex1D() and a CPU implementation of the interpolation

as specified at the end of CUDA programming guide

key		  tex1D(key)					  the_CPU_value   

0			1								1

0.050000001	1								1

0.100000002	1								0.99999994

0.150000006	1								1

0.200000003	1								1

0.25			1								1

0.300000012	1.1015625						1.100000024

0.349999994	1.19921875				1.200000048

0.400000006	1.30078125				1.299999952

0.449999988	1.3984375						1.399999976

0.5			1.5								1.5

0.550000012	1.6015625						1.600000024

0.600000024	1.69921875				1.700000048

0.649999976	1.80078125				1.799999952

0.699999988	1.8984375						1.899999976

0.75			2								2

0.800000012	2								2

0.850000024	2								2

0.899999976	2								2

0.949999988	2								2

The error is close to 0.1%. Is tex1D supposed to be this inaccurate?

thanks

See this post: [url=“http://forums.nvidia.com/index.php?showtopic=83403”]http://forums.nvidia.com/index.php?showtopic=83403[/url]

Section 4.3.4.2 of the programming guide stats:
“Linear texture filtering may be done only for textures that are configured to return
floating-point data. It performs low-precision interpolation between neighboring
texels.”

I’m not sure how low the precision is, but I’m assuming it uses half-floats (for what stage of the lerp process, I’m not sure - possible all of it, maybe just the actual sampling part - anyone able to shed some light on this?)

See Appendix D of the programming guide. Section D.2 says that the interpolation coefficients are computed with only 8 bits of fractional value. I think this means you will only see 256 discrete values between samples in your texture (in 1D, that is).

That is correct. AFAIR the interpolation is actually precise in terms of number of correct significant digits at those 256 points between samples, ie. if you’d interpolate between 0 and 1, you’d get precisely computed 1/256, 2/256 etc. but a value between those points will be snapped to nearest. This means the maximum interpolation error introduced by tex1d filtering will be (1/512)*range (where range is the distance between the two points in the lookup table).

I attach a piece of code that shows this.
sample.txt (3.95 KB)