From: José Fonseca Date: Wed, 17 Apr 2013 17:03:11 +0000 (+0100) Subject: gallivm: Add and use lp_build_lerp_3d. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5aaa4bafe04e601c2e42da76447f2b9297dc3a93;p=mesa.git gallivm: Add and use lp_build_lerp_3d. Reviewed-by: Roland Scheidegger --- diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c index 524a8e79a75..8f8410c015b 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c @@ -1095,6 +1095,26 @@ lp_build_lerp_2d(struct lp_build_context *bld, } +LLVMValueRef +lp_build_lerp_3d(struct lp_build_context *bld, + LLVMValueRef x, + LLVMValueRef y, + LLVMValueRef z, + LLVMValueRef v000, + LLVMValueRef v001, + LLVMValueRef v010, + LLVMValueRef v011, + LLVMValueRef v100, + LLVMValueRef v101, + LLVMValueRef v110, + LLVMValueRef v111) +{ + LLVMValueRef v0 = lp_build_lerp_2d(bld, x, y, v000, v001, v010, v011); + LLVMValueRef v1 = lp_build_lerp_2d(bld, x, y, v100, v101, v110, v111); + return lp_build_lerp(bld, z, v0, v1); +} + + /** * Generate min(a, b) * Do checks for special cases. diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.h b/src/gallium/auxiliary/gallivm/lp_bld_arit.h index 60b9907e60f..45886d5fd99 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_arit.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.h @@ -105,6 +105,21 @@ lp_build_lerp_2d(struct lp_build_context *bld, LLVMValueRef v10, LLVMValueRef v11); +LLVMValueRef +lp_build_lerp_3d(struct lp_build_context *bld, + LLVMValueRef x, + LLVMValueRef y, + LLVMValueRef z, + LLVMValueRef v000, + LLVMValueRef v001, + LLVMValueRef v010, + LLVMValueRef v011, + LLVMValueRef v100, + LLVMValueRef v101, + LLVMValueRef v110, + LLVMValueRef v111); + + LLVMValueRef lp_build_min(struct lp_build_context *bld, LLVMValueRef a, diff --git a/src/gallium/auxiliary/gallivm/lp_bld_sample_aos.c b/src/gallium/auxiliary/gallivm/lp_bld_sample_aos.c index 16d57189ed4..9eaca029fda 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_sample_aos.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_sample_aos.c @@ -982,8 +982,7 @@ lp_build_sample_fetch_image_linear(struct lp_build_sample_context *bld, s_fpart_hi, neighbors_hi[0][0][0], neighbors_hi[0][0][1]); - } - else { + } else if (dims == 2) { /* 2-D lerp */ packed_lo = lp_build_lerp_2d(&h16, s_fpart_lo, t_fpart_lo, @@ -998,30 +997,30 @@ lp_build_sample_fetch_image_linear(struct lp_build_sample_context *bld, neighbors_hi[0][0][1], neighbors_hi[0][1][0], neighbors_hi[0][1][1]); - - if (dims >= 3) { - LLVMValueRef packed_lo2, packed_hi2; - - /* lerp in the second z slice */ - packed_lo2 = lp_build_lerp_2d(&h16, - s_fpart_lo, t_fpart_lo, - neighbors_lo[1][0][0], - neighbors_lo[1][0][1], - neighbors_lo[1][1][0], - neighbors_lo[1][1][1]); - - packed_hi2 = lp_build_lerp_2d(&h16, - s_fpart_hi, t_fpart_hi, - neighbors_hi[1][0][0], - neighbors_hi[1][0][1], - neighbors_hi[1][1][0], - neighbors_hi[1][1][1]); - /* interp between two z slices */ - packed_lo = lp_build_lerp(&h16, r_fpart_lo, - packed_lo, packed_lo2); - packed_hi = lp_build_lerp(&h16, r_fpart_hi, - packed_hi, packed_hi2); - } + } else { + /* 3-D lerp */ + assert(dims == 3); + packed_lo = lp_build_lerp_3d(&h16, + s_fpart_lo, t_fpart_lo, r_fpart_lo, + neighbors_lo[0][0][0], + neighbors_lo[0][0][1], + neighbors_lo[0][1][0], + neighbors_lo[0][1][1], + neighbors_lo[1][0][0], + neighbors_lo[1][0][1], + neighbors_lo[1][1][0], + neighbors_lo[1][1][1]); + + packed_hi = lp_build_lerp_3d(&h16, + s_fpart_hi, t_fpart_hi, r_fpart_hi, + neighbors_hi[0][0][0], + neighbors_hi[0][0][1], + neighbors_hi[0][1][0], + neighbors_hi[0][1][1], + neighbors_hi[1][0][0], + neighbors_hi[1][0][1], + neighbors_hi[1][1][0], + neighbors_hi[1][1][1]); } }