<p dir="ltr"><br>
On Feb 9, 2016 7:06 PM, "Connor Abbott" <<a href="mailto:cwabbott0@gmail.com">cwabbott0@gmail.com</a>> wrote:<br>
><br>
> Did you make sure the other drivers and ttn don't use this? Assming that,</p>
<p dir="ltr">Well, I deleted it from the header and the other drivers built so...</p>
<p dir="ltr">> Reviewed-by: Connor Abbott <<a href="mailto:cwabbott0@gmail.com">cwabbott0@gmail.com</a>><br>
><br>
> I really should get to your other series, but I've been busy with<br>
> school stuff and whatnot and I've been too lazy -- sorry!<br>
><br>
> On Tue, Feb 9, 2016 at 8:08 PM, Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>> wrote:<br>
> > When NIR was originally drafted, there was no easy way to determine if<br>
> > something was constant or not.  The result was that we had lots of<br>
> > special-casing for constant values such as this.  Now that load_const<br>
> > instructions are SSA-only, it's really easy to find constants and this<br>
> > isn't really needed anymore.<br>
> > ---<br>
> >  src/compiler/nir/glsl_to_nir.cpp                   | 16 +++++--------<br>
> >  src/compiler/nir/nir.h                             |  3 ---<br>
> >  src/compiler/nir/nir_clone.c                       |  1 -<br>
> >  src/compiler/nir/nir_instr_set.c                   |  3 ---<br>
> >  src/compiler/nir/nir_print.c                       | 14 ------------<br>
> >  .../drivers/freedreno/ir3/ir3_compiler_nir.c       | 15 -------------<br>
> >  src/mesa/drivers/dri/i965/brw_fs_nir.cpp           | 26 +++++++++-------------<br>
> >  src/mesa/drivers/dri/i965/brw_vec4_nir.cpp         | 21 ++++++++---------<br>
> >  8 files changed, 27 insertions(+), 72 deletions(-)<br>
> ><br>
> > diff --git a/src/compiler/nir/glsl_to_nir.cpp b/src/compiler/nir/glsl_to_nir.cpp<br>
> > index 3db2775..eaf71d0 100644<br>
> > --- a/src/compiler/nir/glsl_to_nir.cpp<br>
> > +++ b/src/compiler/nir/glsl_to_nir.cpp<br>
> > @@ -1824,7 +1824,7 @@ nir_visitor::visit(ir_texture *ir)<br>
> >        num_srcs++;<br>
> >     if (ir->shadow_comparitor != NULL)<br>
> >        num_srcs++;<br>
> > -   if (ir->offset != NULL && ir->offset->as_constant() == NULL)<br>
> > +   if (ir->offset != NULL)<br>
> >        num_srcs++;<br>
> ><br>
> >     nir_tex_instr *instr = nir_tex_instr_create(this->shader, num_srcs);<br>
> > @@ -1881,16 +1881,10 @@ nir_visitor::visit(ir_texture *ir)<br>
> >        /* we don't support multiple offsets yet */<br>
> >        assert(ir->offset->type->is_vector() || ir->offset->type->is_scalar());<br>
> ><br>
> > -      ir_constant *const_offset = ir->offset->as_constant();<br>
> > -      if (const_offset != NULL) {<br>
> > -         for (unsigned i = 0; i < const_offset->type->vector_elements; i++)<br>
> > -            instr->const_offset[i] = const_offset->value.i[i];<br>
> > -      } else {<br>
> > -         instr->src[src_number].src =<br>
> > -            nir_src_for_ssa(evaluate_rvalue(ir->offset));<br>
> > -         instr->src[src_number].src_type = nir_tex_src_offset;<br>
> > -         src_number++;<br>
> > -      }<br>
> > +      instr->src[src_number].src =<br>
> > +         nir_src_for_ssa(evaluate_rvalue(ir->offset));<br>
> > +      instr->src[src_number].src_type = nir_tex_src_offset;<br>
> > +      src_number++;<br>
> >     }<br>
> ><br>
> >     switch (ir->op) {<br>
> > diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h<br>
> > index a4dbfde..294b18e 100644<br>
> > --- a/src/compiler/nir/nir.h<br>
> > +++ b/src/compiler/nir/nir.h<br>
> > @@ -949,9 +949,6 @@ typedef struct {<br>
> >      */<br>
> >     bool is_new_style_shadow;<br>
> ><br>
> > -   /* constant offset - must be 0 if the offset source is used */<br>
> > -   int const_offset[4];<br>
> > -<br>
> >     /* gather component selector */<br>
> >     unsigned component : 2;<br>
> ><br>
> > diff --git a/src/compiler/nir/nir_clone.c b/src/compiler/nir/nir_clone.c<br>
> > index 5eff743..58ba2eb 100644<br>
> > --- a/src/compiler/nir/nir_clone.c<br>
> > +++ b/src/compiler/nir/nir_clone.c<br>
> > @@ -355,7 +355,6 @@ clone_tex(clone_state *state, const nir_tex_instr *tex)<br>
> >     ntex->is_array = tex->is_array;<br>
> >     ntex->is_shadow = tex->is_shadow;<br>
> >     ntex->is_new_style_shadow = tex->is_new_style_shadow;<br>
> > -   memcpy(ntex->const_offset, tex->const_offset, sizeof(ntex->const_offset));<br>
> >     ntex->component = tex->component;<br>
> >     ntex->sampler_index = tex->sampler_index;<br>
> >     ntex->sampler_array_size = tex->sampler_array_size;<br>
> > diff --git a/src/compiler/nir/nir_instr_set.c b/src/compiler/nir/nir_instr_set.c<br>
> > index d3f939f..880a814 100644<br>
> > --- a/src/compiler/nir/nir_instr_set.c<br>
> > +++ b/src/compiler/nir/nir_instr_set.c<br>
> > @@ -152,7 +152,6 @@ hash_tex(uint32_t hash, const nir_tex_instr *instr)<br>
> >     hash = HASH(hash, instr->is_array);<br>
> >     hash = HASH(hash, instr->is_shadow);<br>
> >     hash = HASH(hash, instr->is_new_style_shadow);<br>
> > -   hash = HASH(hash, instr->const_offset);<br>
> >     unsigned component = instr->component;<br>
> >     hash = HASH(hash, component);<br>
> >     hash = HASH(hash, instr->sampler_index);<br>
> > @@ -302,8 +301,6 @@ nir_instrs_equal(const nir_instr *instr1, const nir_instr *instr2)<br>
> >            tex1->is_array != tex2->is_array ||<br>
> >            tex1->is_shadow != tex2->is_shadow ||<br>
> >            tex1->is_new_style_shadow != tex2->is_new_style_shadow ||<br>
> > -          memcmp(tex1->const_offset, tex2->const_offset,<br>
> > -                 sizeof(tex1->const_offset)) != 0 ||<br>
> >            tex1->component != tex2->component ||<br>
> >           tex1->sampler_index != tex2->sampler_index ||<br>
> >           tex1->sampler_array_size != tex2->sampler_array_size) {<br>
> > diff --git a/src/compiler/nir/nir_print.c b/src/compiler/nir/nir_print.c<br>
> > index 48ecb48..370eb8b 100644<br>
> > --- a/src/compiler/nir/nir_print.c<br>
> > +++ b/src/compiler/nir/nir_print.c<br>
> > @@ -612,20 +612,6 @@ print_tex_instr(nir_tex_instr *instr, print_state *state)<br>
> >        fprintf(fp, ", ");<br>
> >     }<br>
> ><br>
> > -   bool has_nonzero_offset = false;<br>
> > -   for (unsigned i = 0; i < 4; i++) {<br>
> > -      if (instr->const_offset[i] != 0) {<br>
> > -         has_nonzero_offset = true;<br>
> > -         break;<br>
> > -      }<br>
> > -   }<br>
> > -<br>
> > -   if (has_nonzero_offset) {<br>
> > -      fprintf(fp, "[%i %i %i %i] (offset), ",<br>
> > -              instr->const_offset[0], instr->const_offset[1],<br>
> > -              instr->const_offset[2], instr->const_offset[3]);<br>
> > -   }<br>
> > -<br>
> >     if (instr->op == nir_texop_tg4) {<br>
> >        fprintf(fp, "%u (gather_component), ", instr->component);<br>
> >     }<br>
> > diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c<br>
> > index 6eb6a2d..b441f6b 100644<br>
> > --- a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c<br>
> > +++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c<br>
> > @@ -1430,21 +1430,6 @@ emit_tex(struct ir3_compile *ctx, nir_tex_instr *tex)<br>
> ><br>
> >         tex_info(tex, &flags, &coords);<br>
> ><br>
> > -       if (!has_off) {<br>
> > -               /* could still have a constant offset: */<br>
> > -               if (tex->const_offset[0] || tex->const_offset[1] ||<br>
> > -                               tex->const_offset[2] || tex->const_offset[3]) {<br>
> > -                       off = const_off;<br>
> > -<br>
> > -                       off[0] = create_immed(b, tex->const_offset[0]);<br>
> > -                       off[1] = create_immed(b, tex->const_offset[1]);<br>
> > -                       off[2] = create_immed(b, tex->const_offset[2]);<br>
> > -                       off[3] = create_immed(b, tex->const_offset[3]);<br>
> > -<br>
> > -                       has_off = true;<br>
> > -               }<br>
> > -       }<br>
> > -<br>
> >         /* scale up integer coords for TXF based on the LOD */<br>
> >         if (ctx->unminify_coords && (opc == OPC_ISAML)) {<br>
> >                 assert(has_lod);<br>
> > diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp<br>
> > index 0efb2fa..6a27482 100644<br>
> > --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp<br>
> > +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp<br>
> > @@ -2949,7 +2949,6 @@ fs_visitor::nir_emit_texture(const fs_builder &bld, nir_tex_instr *instr)<br>
> >                          instr->is_array;<br>
> ><br>
> >     int lod_components = 0;<br>
> > -   int UNUSED offset_components = 0;<br>
> ><br>
> >     fs_reg coordinate, shadow_comparitor, lod, lod2, sample_index, mcs, tex_offset;<br>
> ><br>
> > @@ -2997,13 +2996,18 @@ fs_visitor::nir_emit_texture(const fs_builder &bld, nir_tex_instr *instr)<br>
> >        case nir_tex_src_ms_index:<br>
> >           sample_index = retype(src, BRW_REGISTER_TYPE_UD);<br>
> >           break;<br>
> > -      case nir_tex_src_offset:<br>
> > -         tex_offset = retype(src, BRW_REGISTER_TYPE_D);<br>
> > -         if (instr->is_array)<br>
> > -            offset_components = instr->coord_components - 1;<br>
> > -         else<br>
> > -            offset_components = instr->coord_components;<br>
> > +<br>
> > +      case nir_tex_src_offset: {<br>
> > +         nir_const_value *const_offset =<br>
> > +            nir_src_as_const_value(instr->src[i].src);<br>
> > +         if (const_offset) {<br>
> > +            tex_offset = brw_imm_ud(brw_texture_offset(const_offset->i, 3));<br>
> > +         } else {<br>
> > +            tex_offset = retype(src, BRW_REGISTER_TYPE_D);<br>
> > +         }<br>
> >           break;<br>
> > +      }<br>
> > +<br>
> >        case nir_tex_src_projector:<br>
> >           unreachable("should be lowered");<br>
> ><br>
> > @@ -3039,14 +3043,6 @@ fs_visitor::nir_emit_texture(const fs_builder &bld, nir_tex_instr *instr)<br>
> >        }<br>
> >     }<br>
> ><br>
> > -   for (unsigned i = 0; i < 3; i++) {<br>
> > -      if (instr->const_offset[i] != 0) {<br>
> > -         assert(offset_components == 0);<br>
> > -         tex_offset = brw_imm_ud(brw_texture_offset(instr->const_offset, 3));<br>
> > -         break;<br>
> > -      }<br>
> > -   }<br>
> > -<br>
> >     enum glsl_base_type dest_base_type =<br>
> >       brw_glsl_base_type_for_nir_type (instr->dest_type);<br>
> ><br>
> > diff --git a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp<br>
> > index d3ac7ab..92349c6 100644<br>
> > --- a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp<br>
> > +++ b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp<br>
> > @@ -1655,6 +1655,7 @@ vec4_visitor::nir_emit_texture(nir_tex_instr *instr)<br>
> >     dst_reg dest = get_nir_dest(instr->dest, instr->dest_type);<br>
> ><br>
> >     /* Load the texture operation sources */<br>
> > +   uint32_t constant_offset = 0;<br>
> >     for (unsigned i = 0; i < instr->num_srcs; i++) {<br>
> >        switch (instr->src[i].src_type) {<br>
> >        case nir_tex_src_comparitor:<br>
> > @@ -1711,9 +1712,17 @@ vec4_visitor::nir_emit_texture(nir_tex_instr *instr)<br>
> >           break;<br>
> >        }<br>
> ><br>
> > -      case nir_tex_src_offset:<br>
> > -         offset_value = get_nir_src(instr->src[i].src, BRW_REGISTER_TYPE_D, 2);<br>
> > +      case nir_tex_src_offset: {<br>
> > +         nir_const_value *const_offset =<br>
> > +            nir_src_as_const_value(instr->src[i].src);<br>
> > +         if (const_offset) {<br>
> > +            constant_offset = brw_texture_offset(const_offset->i, 3);<br>
> > +         } else {<br>
> > +            offset_value =<br>
> > +               get_nir_src(instr->src[i].src, BRW_REGISTER_TYPE_D, 2);<br>
> > +         }<br>
> >           break;<br>
> > +      }<br>
> ><br>
> >        case nir_tex_src_sampler_offset: {<br>
> >           /* The highest sampler which may be used by this operation is<br>
> > @@ -1760,14 +1769,6 @@ vec4_visitor::nir_emit_texture(nir_tex_instr *instr)<br>
> >        }<br>
> >     }<br>
> ><br>
> > -   uint32_t constant_offset = 0;<br>
> > -   for (unsigned i = 0; i < 3; i++) {<br>
> > -      if (instr->const_offset[i] != 0) {<br>
> > -         constant_offset = brw_texture_offset(instr->const_offset, 3);<br>
> > -         break;<br>
> > -      }<br>
> > -   }<br>
> > -<br>
> >     /* Stuff the channel select bits in the top of the texture offset */<br>
> >     if (instr->op == nir_texop_tg4) {<br>
> >        if (instr->component == 1 &&<br>
> > --<br>
> > 2.5.0.400.gff86faf<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="https://lists.freedesktop.org/mailman/listinfo/mesa-dev">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</p>