[Mesa-dev] [PATCH 5/9] softpipe: Split code getting a filter into separate function
Brian Paul
brianp at vmware.com
Wed Sep 9 08:25:26 PDT 2015
On 09/09/2015 04:35 AM, Krzesimir Nowak wrote:
> This function will be later used by textureQueryLod. The
> img_filter_func are optional, because textureQueryLod will not need
> them.
> ---
> src/gallium/drivers/softpipe/sp_tex_sample.c | 53 +++++++++++++++++++---------
> 1 file changed, 37 insertions(+), 16 deletions(-)
>
> diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c
> index cd4a659..0a3fc20 100644
> --- a/src/gallium/drivers/softpipe/sp_tex_sample.c
> +++ b/src/gallium/drivers/softpipe/sp_tex_sample.c
> @@ -2912,6 +2912,42 @@ get_img_filter(const struct sp_sampler_view *sp_sview,
> }
> }
>
> +/**
> + * Get mip filter, and optionally both img min filter and img mag filter
> + */
> +static void
> +get_filters(struct sp_sampler_view *sp_sview,
> + struct sp_sampler *sp_samp,
> + enum tgsi_sampler_control control,
> + struct sp_mip **mip,
> + img_filter_func *min,
> + img_filter_func *mag)
> +{
> + assert(mip);
> + if (control == tgsi_sampler_gather) {
> + *mip = &mip_nearest;
> + if (min)
> + *min = get_img_filter(sp_sview, &sp_samp->base, PIPE_TEX_FILTER_LINEAR, true);
> + } else if (sp_sview->pot2d & sp_samp->min_mag_equal_repeat_linear) {
> + *mip = &mip_linear_2d_linear_repeat_POT;
> + }
> + else {
> + *mip = &sp_samp->mip;
> + if (min || mag) {
> + img_filter_func tmp_filter = get_img_filter(sp_sview, &sp_samp->base, sp_samp->min_img_filter, false);
> + if (min)
> + *min = tmp_filter;
> + if (mag) {
> + if (sp_samp->min_mag_equal) {
> + *mag = tmp_filter;
> + }
> + else {
> + *mag = get_img_filter(sp_sview, &sp_samp->base, sp_samp->base.mag_img_filter, false);
> + }
> + }
> + }
> + }
> +}
>
> static void
> sample_mip(struct sp_sampler_view *sp_sview,
> @@ -2928,22 +2964,7 @@ sample_mip(struct sp_sampler_view *sp_sview,
> img_filter_func min_img_filter = NULL;
> img_filter_func mag_img_filter = NULL;
>
> - if (filt_args->control == tgsi_sampler_gather) {
> - mip = &mip_nearest;
> - min_img_filter = get_img_filter(sp_sview, &sp_samp->base, PIPE_TEX_FILTER_LINEAR, true);
> - } else if (sp_sview->pot2d & sp_samp->min_mag_equal_repeat_linear) {
> - mip = &mip_linear_2d_linear_repeat_POT;
> - }
> - else {
> - mip = &sp_samp->mip;
> - min_img_filter = get_img_filter(sp_sview, &sp_samp->base, sp_samp->min_img_filter, false);
> - if (sp_samp->min_mag_equal) {
> - mag_img_filter = min_img_filter;
> - }
> - else {
> - mag_img_filter = get_img_filter(sp_sview, &sp_samp->base, sp_samp->base.mag_img_filter, false);
> - }
> - }
> + get_filters(sp_sview, sp_samp, filt_args->control, &mip, &min_img_filter, &mag_img_filter);
>
> mip->filter(sp_sview, sp_samp, min_img_filter, mag_img_filter,
> s, t, p, c0, lod, filt_args, rgba);
>
Reviewed-by: Brian Paul <brianp at vmware.com>
More information about the mesa-dev
mailing list