[Mesa-dev] [PATCH 3/3] nir/inline: Also rewrite param derefs for texture instructions

Connor Abbott cwabbott0 at gmail.com
Fri May 27 04:45:51 UTC 2016


On Wed, May 25, 2016 at 1:53 PM, Jason Ekstrand <jason at jlekstrand.net> wrote:
> ---
>  src/compiler/nir/nir_inline_functions.c | 26 ++++++++++++++++++++------
>  1 file changed, 20 insertions(+), 6 deletions(-)
>
> diff --git a/src/compiler/nir/nir_inline_functions.c b/src/compiler/nir/nir_inline_functions.c
> index af9a781..d1b80f6 100644
> --- a/src/compiler/nir/nir_inline_functions.c
> +++ b/src/compiler/nir/nir_inline_functions.c
> @@ -59,14 +59,28 @@ convert_deref_to_param_deref(nir_instr *instr, nir_deref_var **deref,
>  static void
>  rewrite_param_derefs(nir_instr *instr, nir_call_instr *call)
>  {
> -   if (instr->type != nir_instr_type_intrinsic)
> -      return;
> +   switch (instr->type) {
> +   case nir_instr_type_intrinsic: {
> +      nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
> +
> +      for (unsigned i = 0;
> +           i < nir_intrinsic_infos[intrin->intrinsic].num_variables; i++) {
> +         convert_deref_to_param_deref(instr, &intrin->variables[i], call);
> +      }
> +      break;
> +   }
>
> -   nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
> +   case nir_instr_type_tex: {
> +      nir_tex_instr *tex = nir_instr_as_tex(instr);
> +      if (tex->texture)
> +         convert_deref_to_param_deref(&tex->instr, &tex->texture, call);
> +      if (tex->sampler)
> +         convert_deref_to_param_deref(&tex->instr, &tex->sampler, call);
> +      break;
> +   }
>
> -   for (unsigned i = 0;
> -        i < nir_intrinsic_infos[intrin->intrinsic].num_variables; i++) {
> -      convert_deref_to_param_deref(instr, &intrin->variables[i], call);
> +   default:
> +      break; /* Nothing else has derefs */

Well, call instructions also have derefs... I think we shouldn't see
any here since we only call this on already-inlined functions, but it
would be nice to add an unreachable() documenting that. Other than
that the series has my r-b.

>     }
>  }
>
> --
> 2.5.0.400.gff86faf
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list