aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
diff options
context:
space:
mode:
authorRoland Scheidegger <[email protected]>2013-04-18 17:06:43 +0200
committerRoland Scheidegger <[email protected]>2013-04-18 17:06:43 +0200
commit50cbcf0c4680bc13e63fe339ef79ed68b2f33c70 (patch)
tree3aa291fea9ee10d3b3f0385ca3008fb3d7f8332a /src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
parent0d07f05ee87b5446bc3b85fc7be861c4801bb79e (diff)
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 <[email protected]> Reviewed-by: Jose Fonseca <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c')
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
index d2cc0f362a3..ced2103fca2 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_soa.c
@@ -1102,7 +1102,13 @@ lp_build_sample_common(struct lp_build_sample_context *bld,
*/
if (target == PIPE_TEXTURE_CUBE) {
LLVMValueRef face, face_s, face_t;
- lp_build_cube_lookup(bld, *s, *t, *r, derivs, &face, &face_s, &face_t, &cube_rho);
+ boolean need_derivs;
+ need_derivs = ((min_filter != mag_filter ||
+ mip_filter != PIPE_TEX_MIPFILTER_NONE) &&
+ !bld->static_sampler_state->min_max_lod_equal &&
+ !explicit_lod);
+ lp_build_cube_lookup(bld, *s, *t, *r, derivs, &face, &face_s, &face_t,
+ &cube_rho, need_derivs);
*s = face_s; /* vec */
*t = face_t; /* vec */
/* use 'r' to indicate cube face */