[Mesa-dev] [PATCH 9/9] softpipe: Implement and enable textureQueryLod

Brian Paul brianp at vmware.com
Wed Sep 9 08:26:36 PDT 2015


On 09/09/2015 04:35 AM, Krzesimir Nowak wrote:
> Passes the shader piglit tests and introduces no regressions.
>
> This commit finally makes use of the refactoring in previous
> commits.
> ---
>   src/gallium/drivers/softpipe/sp_screen.c     |  2 +-
>   src/gallium/drivers/softpipe/sp_tex_sample.c | 47 +++++++++++++++++++++++++++-
>   2 files changed, 47 insertions(+), 2 deletions(-)
>
> diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c
> index 0bfd9c3..7ca8a67 100644
> --- a/src/gallium/drivers/softpipe/sp_screen.c
> +++ b/src/gallium/drivers/softpipe/sp_screen.c
> @@ -193,9 +193,9 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
>      case PIPE_CAP_MAX_TEXTURE_GATHER_COMPONENTS:
>         return 4;
>      case PIPE_CAP_TEXTURE_GATHER_SM5:
> +   case PIPE_CAP_TEXTURE_QUERY_LOD:
>         return 1;
>      case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT:
> -   case PIPE_CAP_TEXTURE_QUERY_LOD:
>      case PIPE_CAP_SAMPLE_SHADING:
>      case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
>         return 0;
> diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c
> index 6e639e0..499c8f9 100644
> --- a/src/gallium/drivers/softpipe/sp_tex_sample.c
> +++ b/src/gallium/drivers/softpipe/sp_tex_sample.c
> @@ -3566,6 +3566,51 @@ sp_tgsi_get_samples(struct tgsi_sampler *tgsi_sampler,
>      sample_mip(sp_sview, sp_samp, cs, ct, cp, c0, lod, &filt_args, rgba);
>   }
>
> +static void
> +sp_tgsi_query_lod(struct tgsi_sampler *tgsi_sampler,
> +                  const unsigned sview_index,
> +                  const unsigned sampler_index,
> +                  const float s[TGSI_QUAD_SIZE],
> +                  const float t[TGSI_QUAD_SIZE],
> +                  const float p[TGSI_QUAD_SIZE],
> +                  const float c0[TGSI_QUAD_SIZE],
> +                  enum tgsi_sampler_control control,
> +                  float mipmap[TGSI_QUAD_SIZE],
> +                  float lod[TGSI_QUAD_SIZE])
> +{
> +   static const float lod_in[TGSI_QUAD_SIZE] = { 0.0, 0.0, 0.0, 0.0 };
> +
> +   struct sp_tgsi_sampler *sp_tgsi_samp = (struct sp_tgsi_sampler *)tgsi_sampler;

Can that be const-qualified, and the tgsi_sampler function parameter?

Ideally, we'd also have a cast-wrapper function to use instead of an 
inline cast here and elsewhere.  That could be done as a follow-up.


> +   struct sp_sampler_view *sp_sview;
> +   struct sp_sampler *sp_samp;
> +   struct sp_mip *mip;
> +   int i;
> +   float cs[TGSI_QUAD_SIZE];
> +   float ct[TGSI_QUAD_SIZE];
> +   float cp[TGSI_QUAD_SIZE];
> +
> +   assert(sview_index < PIPE_MAX_SHADER_SAMPLER_VIEWS);
> +   assert(sampler_index < PIPE_MAX_SAMPLERS);
> +   assert(sp_tgsi_samp->sp_sampler[sampler_index]);
> +
> +   sp_sview = &sp_tgsi_samp->sp_sview[sview_index];
> +   sp_samp = sp_tgsi_samp->sp_sampler[sampler_index];
> +   /* always have a view here but texture is NULL if no sampler view was set. */
> +   if (!sp_sview->base.texture) {
> +      for (i = 0; i < TGSI_QUAD_SIZE; i++) {
> +         mipmap[i] = 0.0f;
> +         lod[i] = 0.0f;
> +      }
> +      return;
> +   }
> +
> +   sp_sview->convert_coords(sp_sview, sp_samp, s, t, p, c0, cs, ct, cp);
> +
> +   compute_lambda_lod_not_clamped(sp_sview, sp_samp,
> +                                  cs, ct, cp, lod_in, control, lod);
> +   get_filters(sp_sview, sp_samp, control, &mip, NULL, NULL);
> +   mip->level(sp_sview, sp_samp, lod, mipmap);
> +}
>
>   static void
>   sp_tgsi_get_texel(struct tgsi_sampler *tgsi_sampler,
> @@ -3602,7 +3647,7 @@ sp_create_tgsi_sampler(void)
>      samp->base.get_dims = sp_tgsi_get_dims;
>      samp->base.get_samples = sp_tgsi_get_samples;
>      samp->base.get_texel = sp_tgsi_get_texel;
> +   samp->base.query_lod = sp_tgsi_query_lod;
>
>      return samp;
>   }
> -
>

Reviewed-by: Brian Paul <brianp at vmware.com>



More information about the mesa-dev mailing list