gallivm: Add and use lp_build_lerp_3d.
authorJosé Fonseca <jfonseca@vmware.com>
Wed, 17 Apr 2013 17:03:11 +0000 (18:03 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Fri, 17 May 2013 19:22:50 +0000 (20:22 +0100)
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
src/gallium/auxiliary/gallivm/lp_bld_arit.c
src/gallium/auxiliary/gallivm/lp_bld_arit.h
src/gallium/auxiliary/gallivm/lp_bld_sample_aos.c

index 524a8e79a75633279b3a8337b8a56a09a70d7287..8f8410c015bdaf5821f168c3f0808b68b415d3ee 100644 (file)
@@ -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.
index 60b9907e60fe513385c4dfab8ff31a5af422c330..45886d5fd99e9bb68be7dcf434a39a1201219757 100644 (file)
@@ -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,
index 16d57189ed4d8f4745be75a1ebbafc173ab3d1e5..9eaca029fdadf185408b2f65fbcd3e5b0d66f776 100644 (file)
@@ -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]);
       }
    }