<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jan 7, 2015 at 7:55 AM, 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"><span class="">On Tue, Jan 6, 2015 at 6:36 PM, Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>> wrote:<br>
><br>
><br>
> On Mon, Jan 5, 2015 at 10:45 PM, Connor Abbott <<a href="mailto:cwabbott0@gmail.com">cwabbott0@gmail.com</a>> wrote:<br>
>><br>
>> 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>
><br>
><br>
> Sorry, I completely missed that.  My only gripe is that it doesn't really<br>
> follow the rest of our base_offset + indirect philosophy.  Is that the way<br>
> you were intending to use it?  i.e. direct just has sampler_index and<br>
> indirect is sampler_index + nir_tex_src_sampler_index.  If so, maybe we<br>
> 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>
> --Jason<br>
<br>
</span>Well, when I added nir_tex_src_sampler_index, it was more of a "I know<br>
we'll need something like this eventually so I'll stick it here to<br>
remind myself/other people when the time comes" thing, and I wasn't<br>
sure which option would be better. So you can keep it and always set<br>
sampler_index to 0 when it's indirect, or rename it - whatever's<br>
easier to do, so long as it's consistent.<br></blockquote><div><br></div><div>I think I'll go ahead and rename it.  It's more consistent with the rest of the texture instruction stuff to have it in the list and it's more consistent with other things to have it be an offset applied to the index.  It's going to generate the same backend code either way.<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 class="HOEnZb"><div class="h5"><br>
><br>
>><br>
>><br>
>> On Tue, Dec 16, 2014 at 1:13 AM, Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br>
>> 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<br>
>> > 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,<br>
>> > 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<br>
>> > 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<br>
>> > 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,<br>
>> > 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,<br>
>> > 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>
>> > _______________________________________________<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>
><br>
><br>
</div></div></blockquote></div><br></div></div>