softpipe: Prepare handling explicit gradients
authorGert Wollny <gert.wollny@collabora.com>
Fri, 19 Apr 2019 06:43:05 +0000 (08:43 +0200)
committerGert Wollny <gert.wollny@collabora.com>
Wed, 1 May 2019 06:22:47 +0000 (08:22 +0200)
This only adds corde that is not yet enabled.

Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
src/gallium/drivers/softpipe/sp_state_sampler.c
src/gallium/drivers/softpipe/sp_tex_sample.c
src/gallium/drivers/softpipe/sp_tex_sample.h

index 751eb76e84b667821dca096ed6e71beb12c91bd8..356196c1917aa1359b59fb33118412ace014dcf9 100644 (file)
@@ -127,6 +127,7 @@ softpipe_set_sampler_views(struct pipe_context *pipe,
       if (sp_sviewsrc) {
          memcpy(sp_sviewdst, sp_sviewsrc, sizeof(*sp_sviewsrc));
          sp_sviewdst->compute_lambda = softpipe_get_lambda_func(&sp_sviewdst->base, shader);
+         sp_sviewdst->compute_lambda_from_grad = softpipe_get_lambda_from_grad_func(&sp_sviewdst->base, shader);
          sp_sviewdst->cache = softpipe->tex_cache[shader][start + i];
       }
       else {
index ce702c9bb78852ff8de5d5703cd757a58409b668..bfd10b0736d8ca25816ce0938202017ce3bf4570 100644 (file)
@@ -659,6 +659,39 @@ compute_lambda_vert(const struct sp_sampler_view *sview,
 }
 
 
+static float
+compute_lambda_vert_explicite_gradients(UNUSED const struct sp_sampler_view *sview,
+                                        UNUSED const float derivs[3][2][TGSI_QUAD_SIZE],
+                                        UNUSED int quad)
+{
+   return 0.0f;
+}
+
+
+compute_lambda_from_grad_func
+softpipe_get_lambda_from_grad_func(const struct pipe_sampler_view *view,
+                                   enum pipe_shader_type shader)
+{
+   switch (view->target) {
+   case PIPE_BUFFER:
+   case PIPE_TEXTURE_1D:
+   case PIPE_TEXTURE_1D_ARRAY:
+      return compute_lambda_1d_explicit_gradients;
+   case PIPE_TEXTURE_2D:
+   case PIPE_TEXTURE_2D_ARRAY:
+   case PIPE_TEXTURE_RECT:
+      return compute_lambda_2d_explicit_gradients;
+   case PIPE_TEXTURE_CUBE:
+   case PIPE_TEXTURE_CUBE_ARRAY:
+      return compute_lambda_cube_explicit_gradients;
+   case PIPE_TEXTURE_3D:
+      return compute_lambda_3d_explicit_gradients;
+   default:
+      assert(0);
+      return compute_lambda_1d_explicit_gradients;
+   }
+}
+
 
 /**
  * Get a texel from a texture, using the texture tile cache.
index f7774f5e88363f50d2edcc52cc3788d792d359b2..44853b3b529b86d545b9d1f12c134d74dd1e317e 100644 (file)
@@ -53,6 +53,10 @@ typedef float (*compute_lambda_func)(const struct sp_sampler_view *sp_sview,
                                      const float t[TGSI_QUAD_SIZE],
                                      const float p[TGSI_QUAD_SIZE]);
 
+typedef float (*compute_lambda_from_grad_func)(const struct sp_sampler_view *sp_sview,
+                                               const float derivs[3][2][TGSI_QUAD_SIZE],
+                                               uint quad);
+
 struct img_filter_args {
    float s;
    float t;
@@ -116,7 +120,7 @@ struct sp_sampler_view
    /* these are different per shader type */
    struct softpipe_tex_tile_cache *cache;
    compute_lambda_func compute_lambda;
-
+   compute_lambda_from_grad_func compute_lambda_from_grad;
 };
 
 struct sp_filter_funcs {
@@ -158,6 +162,9 @@ compute_lambda_func
 softpipe_get_lambda_func(const struct pipe_sampler_view *view,
                          enum pipe_shader_type shader);
 
+compute_lambda_from_grad_func
+softpipe_get_lambda_from_grad_func(const struct pipe_sampler_view *view,
+                                   enum pipe_shader_type shader);
 
 void *
 softpipe_create_sampler_state(struct pipe_context *pipe,