OpenImageIO/oiio — pull request #195 by lgritz (2011-11-18 06:40:10+00:00)
Title: Review: Fix aniso footprint estimation for very-small-deriv case.

Fix aniso footprint estimation for very-small-deriv case.

Because the more correct estimate for the filter footprint goes awry if
F is very small (caused by extremely tiny derivatives), we tested this
and if true, set the major axis to the bigger of the two derivative
estimates, and the minor axis to be 1e-8.

The problem is that that the mip level is determined by the minor axis,
so this means that all texture lookups falling into this case end up
sampling the highest-res MIPmap level. That's bad for cache coherence,
and to add insult to injury, even with small derivs, small x 1e-8 makes
for a very anisotropic footprint, so it tended to take the maximum
number of sample probes, yielding very pad performance. Furthermore, in
many scenes you can see a "seam" between where things were humming along
reasonably with normal F, and where F dips below the threshold and thus
switches to a radically different MIPmap level. In any case, we had
thought this case of very small F was rare, but turns out to pop up more
frequently than we thought.

This patch changes the strategy to make the minoraxis be the smaller of
the x and y derivative, clamped at a minimum of 1e-8, but not set
unconditionally to 1e-8. It definitely gets rid of the visual seam I'd
been tracking, and I'm pretty sure will help with the performance cases
that others have seen.