+
+static void
+compute_gradient_2d(const float s[TGSI_QUAD_SIZE],
+ const float t[TGSI_QUAD_SIZE],
+ const float p[TGSI_QUAD_SIZE],
+ float derivs[3][2][TGSI_QUAD_SIZE])
+{
+ memset(derivs, 0, 6 * TGSI_QUAD_SIZE * sizeof(float));
+ derivs[0][0][0] = s[QUAD_BOTTOM_RIGHT] - s[QUAD_BOTTOM_LEFT];
+ derivs[0][1][0] = s[QUAD_TOP_LEFT] - s[QUAD_BOTTOM_LEFT];
+ derivs[1][0][0] = t[QUAD_BOTTOM_RIGHT] - t[QUAD_BOTTOM_LEFT];
+ derivs[1][1][0] = t[QUAD_TOP_LEFT] - t[QUAD_BOTTOM_LEFT];
+}
+
+static float
+compute_lambda_2d_explicit_gradients(const struct sp_sampler_view *sview,
+ const float derivs[3][2][TGSI_QUAD_SIZE],
+ uint quad)
+{
+ const struct pipe_resource *texture = sview->base.texture;
+ const float dsdx = fabsf(derivs[0][0][quad]);
+ const float dsdy = fabsf(derivs[0][1][quad]);
+ const float dtdx = fabsf(derivs[1][0][quad]);
+ const float dtdy = fabsf(derivs[1][1][quad]);
+ const float maxx = MAX2(dsdx, dsdy) * u_minify(texture->width0, sview->base.u.tex.first_level);
+ const float maxy = MAX2(dtdx, dtdy) * u_minify(texture->height0, sview->base.u.tex.first_level);
+ const float rho = MAX2(maxx, maxy);