[Mesa-dev] Reworking textureGrad on shadow samplers

Kenneth Graunke kenneth at whitecape.org
Tue Jul 10 11:14:40 PDT 2012

Intel hardware doesn't natively support textureGrad with shadow
comparisons.  This patch series implements a GLSL IR level lowering
pass to compute the LOD level that would be selected based on the
given gradient values, based on the equations on page 205 of the
OpenGL 3.0 specification.  It then simply uses textureLod().

The old method had many problems:
- The shadow comparison was done post-filtering.
- It required state-dependent recompiles whenever the comparison
  function changed.
- It didn't even work: many cases hit assertion failures.
- I never implemented it for the VS.

The new method is not perfect; it only passes 36/45 of oglconform's
shadow-grad tests.  That said, it seems to work a lot better than the
previous method, and the remaining cases are so obscure that I'd like
to just push it as is and fix up the remaining cases sometime in the
future (i.e. bug reports welcome).

One of the main advantages is that this reduces state-dependent
recompiles, and thus increases performance certain applications.
(Said applications aren't actually using TXD - we were just being
 overzealous in our program key handling.)

More information about the mesa-dev mailing list