gallivm: remove code to force nearest s/t interpolation
authorErik Faye-Lund <erik.faye-lund@collabora.com>
Fri, 6 Aug 2021 13:09:40 +0000 (15:09 +0200)
committerMarge Bot <eric+marge@anholt.net>
Mon, 9 Aug 2021 06:42:59 +0000 (06:42 +0000)
These two bits were added in 2012, but never got wired up. Let's cut our
losses, and remove them again. 9 years unused seems sufficient.

While we're at it, remove reduction_mode from the hacks-section, because
this isn't a hack at all, rather normal state.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12240>

src/gallium/auxiliary/gallivm/lp_bld_sample.h
src/gallium/auxiliary/gallivm/lp_bld_sample_aos.c

index 580daa8..604b3b0 100644 (file)
@@ -203,10 +203,6 @@ struct lp_static_sampler_state
    unsigned apply_max_lod:1;  /**< max_lod < last_level ? */
    unsigned seamless_cube_map:1;
    unsigned aniso:1;
-
-   /* Hacks */
-   unsigned force_nearest_s:1;
-   unsigned force_nearest_t:1;
    unsigned reduction_mode:2;
 };
 
index 5d501b6..0564b15 100644 (file)
@@ -686,63 +686,46 @@ lp_build_sample_fetch_image_linear(struct lp_build_sample_context *bld,
    /*
     * Linear interpolation with 8.8 fixed point.
     */
-   if (bld->static_sampler_state->force_nearest_s) {
-      /* special case 1-D lerp */
-      packed = lp_build_lerp(&u8n,
-                             t_fpart,
-                             neighbors[0][0][0],
-                             neighbors[0][0][1],
-                             LP_BLD_LERP_PRESCALED_WEIGHTS);
-   }
-   else if (bld->static_sampler_state->force_nearest_t) {
-      /* special case 1-D lerp */
-      packed = lp_build_lerp(&u8n,
-                             s_fpart,
-                             neighbors[0][0][0],
-                             neighbors[0][0][1],
-                             LP_BLD_LERP_PRESCALED_WEIGHTS);
-   }
-   else {
-      /* general 1/2/3-D lerping */
-      if (dims == 1) {
-         lp_build_reduce_filter(&u8n,
-                                bld->static_sampler_state->reduction_mode,
-                                LP_BLD_LERP_PRESCALED_WEIGHTS,
-                                1,
-                                s_fpart,
-                                &neighbors[0][0][0],
-                                &neighbors[0][0][1],
-                                &packed);
-      } else if (dims == 2) {
-         /* 2-D lerp */
-         lp_build_reduce_filter_2d(&u8n,
-                                   bld->static_sampler_state->reduction_mode,
-                                   LP_BLD_LERP_PRESCALED_WEIGHTS,
-                                   1,
-                                   s_fpart, t_fpart,
-                                   &neighbors[0][0][0],
-                                   &neighbors[0][0][1],
-                                   &neighbors[0][1][0],
-                                   &neighbors[0][1][1],
-                                   &packed);
-      } else {
-         /* 3-D lerp */
-         assert(dims == 3);
-         lp_build_reduce_filter_3d(&u8n,
-                                   bld->static_sampler_state->reduction_mode,
-                                   LP_BLD_LERP_PRESCALED_WEIGHTS,
-                                   1,
-                                   s_fpart, t_fpart, r_fpart,
-                                   &neighbors[0][0][0],
-                                   &neighbors[0][0][1],
-                                   &neighbors[0][1][0],
-                                   &neighbors[0][1][1],
-                                   &neighbors[1][0][0],
-                                   &neighbors[1][0][1],
-                                   &neighbors[1][1][0],
-                                   &neighbors[1][1][1],
-                                   &packed);
-      }
+
+   /* general 1/2/3-D lerping */
+   if (dims == 1) {
+      lp_build_reduce_filter(&u8n,
+                              bld->static_sampler_state->reduction_mode,
+                              LP_BLD_LERP_PRESCALED_WEIGHTS,
+                              1,
+                              s_fpart,
+                              &neighbors[0][0][0],
+                              &neighbors[0][0][1],
+                              &packed);
+   } else if (dims == 2) {
+      /* 2-D lerp */
+      lp_build_reduce_filter_2d(&u8n,
+                                 bld->static_sampler_state->reduction_mode,
+                                 LP_BLD_LERP_PRESCALED_WEIGHTS,
+                                 1,
+                                 s_fpart, t_fpart,
+                                 &neighbors[0][0][0],
+                                 &neighbors[0][0][1],
+                                 &neighbors[0][1][0],
+                                 &neighbors[0][1][1],
+                                 &packed);
+   } else {
+      /* 3-D lerp */
+      assert(dims == 3);
+      lp_build_reduce_filter_3d(&u8n,
+                                 bld->static_sampler_state->reduction_mode,
+                                 LP_BLD_LERP_PRESCALED_WEIGHTS,
+                                 1,
+                                 s_fpart, t_fpart, r_fpart,
+                                 &neighbors[0][0][0],
+                                 &neighbors[0][0][1],
+                                 &neighbors[0][1][0],
+                                 &neighbors[0][1][1],
+                                 &neighbors[1][0][0],
+                                 &neighbors[1][0][1],
+                                 &neighbors[1][1][0],
+                                 &neighbors[1][1][1],
+                                 &packed);
    }
 
    *colors = packed;
@@ -827,10 +810,9 @@ lp_build_sample_image_linear(struct lp_build_sample_context *bld,
 
    /* subtract 0.5 (add -128) */
    i32_c128 = lp_build_const_int_vec(bld->gallivm, i32.type, -128);
-   if (!bld->static_sampler_state->force_nearest_s) {
-      s = LLVMBuildAdd(builder, s, i32_c128, "");
-   }
-   if (dims >= 2 && !bld->static_sampler_state->force_nearest_t) {
+
+   s = LLVMBuildAdd(builder, s, i32_c128, "");
+   if (dims >= 2) {
       t = LLVMBuildAdd(builder, t, i32_c128, "");
    }
    if (dims >= 3) {