gallivm: change cubemaps / derivatives handling, take 55
authorRoland Scheidegger <sroland@vmware.com>
Thu, 18 Apr 2013 15:06:43 +0000 (17:06 +0200)
committerRoland Scheidegger <sroland@vmware.com>
Thu, 18 Apr 2013 15:06:43 +0000 (17:06 +0200)
commit50cbcf0c4680bc13e63fe339ef79ed68b2f33c70
tree3aa291fea9ee10d3b3f0385ca3008fb3d7f8332a
parent0d07f05ee87b5446bc3b85fc7be861c4801bb79e
gallivm: change cubemaps / derivatives handling, take 55

Turns out the previous "fix" for handling per-pixel face selection and
derivatives didn't work out that well - the derivatives were wrong by
quite a bit, in theory transformation of the derivatives into cube space
should work, but would be _a lot_ more work than the "simplified" transform
used.
So, for explicit derivatives, I'm just giving up and go back to not honoring
them.
For implicit derivatives (and the fake explicit ones) however we try
something a little different, we just calculate rho as we would for a 3d
texture, that is after scaling the coords by the inverse major axis.
This gives the same results as calculating the derivs after projection of
the coords to the same face as long as all pixels hit the same face (and
only without rho_no_opt, otherwise it should be a bit worse). And when
not all pixels are hitting the same face, the results aren't so hot but
not catastrophically bad (I believe not off by more than a factor of 2 without
no_rho_approx and not more than sqrt(2) with no_rho_approx). I think this is
better than just picking the wrong face but who knows...

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
src/gallium/auxiliary/gallivm/lp_bld_sample.c
src/gallium/auxiliary/gallivm/lp_bld_sample.h
src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c