<p dir="ltr">I was a little concerned when I first looked at this as to how simple it was but I think lower_logical_send should handle it ok.</p>
<p dir="ltr">Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>></p>
<p dir="ltr">On May 20, 2016 10:49 PM, "Francisco Jerez" <<a href="mailto:currojerez@riseup.net">currojerez@riseup.net</a>> wrote:<br>
><br>
> Seems like this texturing opcode was missing its logical counterpart<br>
> which would prevent it from taking advantage of the SIMD lowering<br>
> infrastructure, define it and plumb it through the back-end.  At some<br>
> point we'll likely want to emit a single SAMPLEINFO message shared<br>
> among all channels irrespective of this change, but for the moment<br>
> this should be enough to get the intrinsic working in SIMD32 mode.<br>
> ---<br>
>  src/mesa/drivers/dri/i965/brw_defines.h  |  1 +<br>
>  src/mesa/drivers/dri/i965/brw_fs.cpp     |  9 +++++++++<br>
>  src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 20 +++-----------------<br>
>  src/mesa/drivers/dri/i965/brw_shader.cpp |  2 ++<br>
>  4 files changed, 15 insertions(+), 17 deletions(-)<br>
><br>
> diff --git a/src/mesa/drivers/dri/i965/brw_defines.h b/src/mesa/drivers/dri/i965/brw_defines.h<br>
> index 458d690..b3075a6 100644<br>
> --- a/src/mesa/drivers/dri/i965/brw_defines.h<br>
> +++ b/src/mesa/drivers/dri/i965/brw_defines.h<br>
> @@ -998,6 +998,7 @@ enum opcode {<br>
>     SHADER_OPCODE_TG4_OFFSET,<br>
>     SHADER_OPCODE_TG4_OFFSET_LOGICAL,<br>
>     SHADER_OPCODE_SAMPLEINFO,<br>
> +   SHADER_OPCODE_SAMPLEINFO_LOGICAL,<br>
><br>
>     /**<br>
>      * Combines multiple sources of size 1 into a larger virtual GRF.<br>
> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp<br>
> index c176807..0049334 100644<br>
> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp<br>
> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp<br>
> @@ -742,6 +742,7 @@ fs_inst::components_read(unsigned i) const<br>
>     case SHADER_OPCODE_LOD_LOGICAL:<br>
>     case SHADER_OPCODE_TG4_LOGICAL:<br>
>     case SHADER_OPCODE_TG4_OFFSET_LOGICAL:<br>
> +   case SHADER_OPCODE_SAMPLEINFO_LOGICAL:<br>
>        assert(src[TEX_LOGICAL_SRC_COORD_COMPONENTS].file == IMM &&<br>
>               src[TEX_LOGICAL_SRC_GRAD_COMPONENTS].file == IMM);<br>
>        /* Texture coordinates. */<br>
> @@ -4113,6 +4114,7 @@ lower_sampler_logical_send_gen7(const fs_builder &bld, fs_inst *inst, opcode op,<br>
><br>
>     if (op == SHADER_OPCODE_TG4 || op == SHADER_OPCODE_TG4_OFFSET ||<br>
>         offset_value.file != BAD_FILE ||<br>
> +       op == SHADER_OPCODE_SAMPLEINFO ||<br>
>         is_high_sampler(devinfo, sampler)) {<br>
>        /* For general texture offsets (no txf workaround), we need a header to<br>
>         * put them in.  Note that we're only reserving space for it in the<br>
> @@ -4541,6 +4543,10 @@ fs_visitor::lower_logical_sends()<br>
>           lower_sampler_logical_send(ibld, inst, SHADER_OPCODE_TG4_OFFSET);<br>
>           break;<br>
><br>
> +      case SHADER_OPCODE_SAMPLEINFO_LOGICAL:<br>
> +         lower_sampler_logical_send(ibld, inst, SHADER_OPCODE_SAMPLEINFO);<br>
> +         break;<br>
> +<br>
>        case SHADER_OPCODE_UNTYPED_SURFACE_READ_LOGICAL:<br>
>           lower_surface_logical_send(ibld, inst,<br>
>                                      SHADER_OPCODE_UNTYPED_SURFACE_READ,<br>
> @@ -4720,6 +4726,9 @@ get_lowered_simd_width(const struct brw_device_info *devinfo,<br>
>        return (inst->src[FB_WRITE_LOGICAL_SRC_COLOR1].file != BAD_FILE ?<br>
>                8 : inst->exec_size);<br>
><br>
> +   case SHADER_OPCODE_SAMPLEINFO_LOGICAL:<br>
> +      return MIN2(16, inst->exec_size);<br>
> +<br>
>     case SHADER_OPCODE_TXD_LOGICAL:<br>
>        /* TXD is unsupported in SIMD16 mode. */<br>
>        return 8;<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 530184a..c236eb2 100644<br>
> --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp<br>
> +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp<br>
> @@ -4168,23 +4168,9 @@ fs_visitor::nir_emit_texture(const fs_builder &bld, nir_tex_instr *instr)<br>
>        else<br>
>           opcode = SHADER_OPCODE_TG4_LOGICAL;<br>
>        break;<br>
> -   case nir_texop_texture_samples: {<br>
> -      fs_reg dst = retype(get_nir_dest(instr->dest), BRW_REGISTER_TYPE_D);<br>
> -<br>
> -      fs_reg tmp = bld.vgrf(BRW_REGISTER_TYPE_D, 4);<br>
> -      fs_inst *inst = bld.emit(SHADER_OPCODE_SAMPLEINFO, tmp,<br>
> -                               bld.vgrf(BRW_REGISTER_TYPE_D, 1),<br>
> -                               srcs[TEX_LOGICAL_SRC_SURFACE],<br>
> -                               srcs[TEX_LOGICAL_SRC_SURFACE]);<br>
> -      inst->mlen = 1;<br>
> -      inst->header_size = 1;<br>
> -      inst->base_mrf = -1;<br>
> -      inst->regs_written = 4 * (dispatch_width / 8);<br>
> -<br>
> -      /* Pick off the one component we care about */<br>
> -      bld.MOV(dst, tmp);<br>
> -      return;<br>
> -   }<br>
> +   case nir_texop_texture_samples:<br>
> +      opcode = SHADER_OPCODE_SAMPLEINFO_LOGICAL;<br>
> +      break;<br>
>     case nir_texop_samples_identical: {<br>
>        fs_reg dst = retype(get_nir_dest(instr->dest), BRW_REGISTER_TYPE_D);<br>
><br>
> diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp<br>
> index 18242ba..b615528 100644<br>
> --- a/src/mesa/drivers/dri/i965/brw_shader.cpp<br>
> +++ b/src/mesa/drivers/dri/i965/brw_shader.cpp<br>
> @@ -260,6 +260,8 @@ brw_instruction_name(const struct brw_device_info *devinfo, enum opcode op)<br>
>        return "tg4_offset_logical";<br>
>     case SHADER_OPCODE_SAMPLEINFO:<br>
>        return "sampleinfo";<br>
> +   case SHADER_OPCODE_SAMPLEINFO_LOGICAL:<br>
> +      return "sampleinfo_logical";<br>
><br>
>     case SHADER_OPCODE_SHADER_TIME_ADD:<br>
>        return "shader_time_add";<br>
> --<br>
> 2.7.3<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>