<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 5, 2015 at 10:45 PM, Connor Abbott <span dir="ltr"><<a href="mailto:cwabbott0@gmail.com" target="_blank">cwabbott0@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I created nir_tex_src_sampler_index for exactly this purpose, which<br>
fits in with the "stick all the sources in an array so we can easily<br>
iterate over them" philosophy. If you decide to keep with this<br>
solution, though, at least remove that.<br></blockquote><div><br></div><div>Sorry, I completely missed that.  My only gripe is that it doesn't really follow the rest of our base_offset + indirect philosophy.  Is that the way you were intending to use it?  i.e. direct just has sampler_index and indirect is sampler_index + nir_tex_src_sampler_index.  If so, maybe we should rename it to nir_tex_src_sampler_indirect.<br><br>I'm 100% ok with that, It just isn't at all clear how the two work together.<br></div><div>--Jason<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div class="h5"><br>
On Tue, Dec 16, 2014 at 1:13 AM, Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>> wrote:<br>
> ---<br>
>  src/glsl/nir/nir.c          | 11 +++++++++++<br>
>  src/glsl/nir/nir.h          | 10 ++++++++++<br>
>  src/glsl/nir/nir_print.c    |  4 ++++<br>
>  src/glsl/nir/nir_validate.c |  3 +++<br>
>  4 files changed, 28 insertions(+)<br>
><br>
> diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c<br>
> index 60c9cff..8bcc64a 100644<br>
> --- a/src/glsl/nir/nir.c<br>
> +++ b/src/glsl/nir/nir.c<br>
> @@ -461,6 +461,13 @@ nir_tex_instr_create(void *mem_ctx, unsigned num_srcs)<br>
>     instr->has_predicate = false;<br>
>     src_init(&instr->predicate);<br>
><br>
> +   instr->sampler_index = 0;<br>
> +   instr->has_sampler_indirect = false;<br>
> +   src_init(&instr->sampler_indirect);<br>
> +   instr->sampler_indirect_max = 0;<br>
> +<br>
> +   instr->sampler = NULL;<br>
> +<br>
>     return instr;<br>
>  }<br>
><br>
> @@ -1529,6 +1536,10 @@ visit_tex_src(nir_tex_instr *instr, nir_foreach_src_cb cb, void *state)<br>
>        if (!visit_src(&instr->predicate, cb, state))<br>
>           return false;<br>
><br>
> +   if (instr->has_sampler_indirect)<br>
> +      if (!visit_src(&instr->sampler_indirect, cb, state))<br>
> +         return false;<br>
> +<br>
>     if (instr->sampler != NULL)<br>
>        if (!visit_deref_src(instr->sampler, cb, state))<br>
>           return false;<br>
> diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h<br>
> index 32bf634..bc7a226 100644<br>
> --- a/src/glsl/nir/nir.h<br>
> +++ b/src/glsl/nir/nir.h<br>
> @@ -838,7 +838,17 @@ typedef struct {<br>
>     /* gather component selector */<br>
>     unsigned component : 2;<br>
><br>
> +   /** The sampler index<br>
> +    *<br>
> +    * If has_indirect is true, then the sampler index is given by<br>
> +    * sampler_index + sampler_indirect where sampler_indirect has a maximum<br>
> +    * possible value of sampler_indirect_max.<br>
> +    */<br>
>     unsigned sampler_index;<br>
> +   bool has_sampler_indirect;<br>
> +   nir_src sampler_indirect;<br>
> +   unsigned sampler_indirect_max;<br>
> +<br>
>     nir_deref_var *sampler; /* if this is NULL, use sampler_index instead */<br>
>  } nir_tex_instr;<br>
><br>
> diff --git a/src/glsl/nir/nir_print.c b/src/glsl/nir/nir_print.c<br>
> index 962e408..67df9a5 100644<br>
> --- a/src/glsl/nir/nir_print.c<br>
> +++ b/src/glsl/nir/nir_print.c<br>
> @@ -498,6 +498,10 @@ print_tex_instr(nir_tex_instr *instr, print_var_state *state, FILE *fp)<br>
>        print_deref(instr->sampler, state, fp);<br>
>     } else {<br>
>        fprintf(fp, "%u", instr->sampler_index);<br>
> +      if (instr->has_sampler_indirect) {<br>
> +         fprintf(fp, " + ");<br>
> +         print_src(&instr->sampler_indirect, fp);<br>
> +      }<br>
>     }<br>
><br>
>     fprintf(fp, " (sampler)");<br>
> diff --git a/src/glsl/nir/nir_validate.c b/src/glsl/nir/nir_validate.c<br>
> index e565b3c..ed6e482 100644<br>
> --- a/src/glsl/nir/nir_validate.c<br>
> +++ b/src/glsl/nir/nir_validate.c<br>
> @@ -399,6 +399,9 @@ validate_tex_instr(nir_tex_instr *instr, validate_state *state)<br>
>        validate_src(&instr->src[i], state);<br>
>     }<br>
><br>
> +   if (instr->has_sampler_indirect)<br>
> +      validate_src(&instr->sampler_indirect, state);<br>
> +<br>
>     if (instr->sampler != NULL)<br>
>        validate_deref_var(instr->sampler, state);<br>
>  }<br>
> --<br>
> 2.2.0<br>
><br>
</div></div>> _______________________________________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> <a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div><br></div></div>