<div dir="ltr"><div><div><div>Assuming the changes you describe below, this patch would get a<br><br></div>Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br><br></div>I think that's enough for you to land the UBO/SSBO portion of 16bit storage.  Feel free to send v2 versions of any patches you want me to look at again before you push but I think it's in pretty good shape.<br><br></div>--Jason<br><div><div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Dec 1, 2017 at 1:21 PM, Chema Casanova <span dir="ltr"><<a href="mailto:jmcasanova@igalia.com" target="_blank">jmcasanova@igalia.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 30/11/17 21:42, Jason Ekstrand wrote:<br>
> On Wed, Nov 29, 2017 at 6:08 PM, Jose Maria Casanova Crespo<br>
</span><span class="">> <<a href="mailto:jmcasanova@igalia.com">jmcasanova@igalia.com</a> <mailto:<a href="mailto:jmcasanova@igalia.com">jmcasanova@igalia.com</a>><wbr>> wrote:<br>
><br>
>     v2: (Jason Ekstrand)<br>
>         - Enable bit_size parameter to scattered messages to enable<br>
>     different<br>
>           bitsizes byte/word/dword.<br>
>         - Remove use of brw_send_indirect_scattered_<wbr>message in favor of<br>
>           brw_send_indirect_surface_<wbr>message.<br>
>         - Move scattered messages to surface messages namespace.<br>
>         - Assert align1 for scattered messages and assume Gen8+.<br>
>         - Inline brw_set_dp_byte_scattered_<wbr>write.<br>
><br>
>     Signed-off-by: Jose Maria Casanova Crespo <<a href="mailto:jmcasanova@igalia.com">jmcasanova@igalia.com</a><br>
</span>>     <mailto:<a href="mailto:jmcasanova@igalia.com">jmcasanova@igalia.com</a>><wbr>><br>
>     Signed-off-by: Alejandro Piñeiro <<a href="mailto:apinheiro@igalia.com">apinheiro@igalia.com</a><br>
>     <mailto:<a href="mailto:apinheiro@igalia.com">apinheiro@igalia.com</a>>><br>
<div><div class="h5">>     ---<br>
>      src/intel/compiler/brw_eu.h                    |  7 +++++<br>
>      src/intel/compiler/brw_eu_<wbr>defines.h            | 17 +++++++++++<br>
>      src/intel/compiler/brw_eu_<wbr>emit.c               | 42<br>
>     ++++++++++++++++++++++++++<br>
>      src/intel/compiler/brw_fs.<wbr>cpp                  | 14 +++++++++<br>
>      src/intel/compiler/brw_fs_<wbr>copy_propagation.cpp |  2 ++<br>
>      src/intel/compiler/brw_fs_<wbr>generator.cpp        |  6 ++++<br>
>      src/intel/compiler/brw_fs_<wbr>surface_builder.cpp  | 11 +++++++<br>
>      src/intel/compiler/brw_fs_<wbr>surface_builder.h    |  7 +++++<br>
>      src/intel/compiler/brw_<wbr>shader.cpp              |  7 +++++<br>
>      9 files changed, 113 insertions(+)<br>
><br>
>     diff --git a/src/intel/compiler/brw_eu.h b/src/intel/compiler/brw_eu.h<br>
>     index 343dcd867d..3ac3b4342a 100644<br>
>     --- a/src/intel/compiler/brw_eu.h<br>
>     +++ b/src/intel/compiler/brw_eu.h<br>
>     @@ -485,6 +485,13 @@ brw_typed_surface_write(struct brw_codegen *p,<br>
>                              unsigned msg_length,<br>
>                              unsigned num_channels);<br>
><br>
>     +void<br>
>     +brw_byte_scattered_write(<wbr>struct brw_codegen *p,<br>
>     +                         struct brw_reg payload,<br>
>     +                         struct brw_reg surface,<br>
>     +                         unsigned msg_length,<br>
>     +                         unsigned bit_size);<br>
>     +<br>
>      void<br>
>      brw_memory_fence(struct brw_codegen *p,<br>
>                       struct brw_reg dst);<br>
>     diff --git a/src/intel/compiler/brw_eu_<wbr>defines.h<br>
>     b/src/intel/compiler/brw_eu_<wbr>defines.h<br>
>     index 9d5cf05c86..de6330ee54 100644<br>
>     --- a/src/intel/compiler/brw_eu_<wbr>defines.h<br>
>     +++ b/src/intel/compiler/brw_eu_<wbr>defines.h<br>
>     @@ -402,6 +402,16 @@ enum opcode {<br>
><br>
>         SHADER_OPCODE_RND_MODE,<br>
><br>
>     +   /**<br>
>     +    * Byte scattered write/read opcodes.<br>
>     +    *<br>
>     +    * LOGICAL opcodes are eventually translated to the matching<br>
>     non-LOGICAL<br>
>     +    * opcode, but instead of taking a single payload blog they<br>
>     expect their<br>
>     +    * arguments separately as individual sources, like untyped<br>
>     write/read.<br>
>     +    */<br>
>     +   SHADER_OPCODE_BYTE_SCATTERED_<wbr>WRITE,<br>
>     +   SHADER_OPCODE_BYTE_SCATTERED_<wbr>WRITE_LOGICAL,<br>
>     +<br>
>         SHADER_OPCODE_MEMORY_FENCE,<br>
><br>
>         SHADER_OPCODE_GEN4_SCRATCH_<wbr>READ,<br>
>     @@ -1255,4 +1265,11 @@ enum PACKED brw_rnd_mode {<br>
>         BRW_RND_MODE_UNSPECIFIED,  /* Unspecified rounding mode */<br>
>      };<br>
><br>
>     +/* MDC_DS - Data Size Message Descriptor Control Field */<br>
>     +enum PACKED brw_data_size {<br>
><br>
><br>
> I'm not sure how I feel about this being an enum with such a generic name.<br>
<br>
</div></div>Right, PRM use a more exactly "Data Elements" but this field only used<br>
byte_scattered/scaled writes/reads. As I will follow your next<br>
suggestion of using #define, I'm chaging the name to:<br>
<br>
#define GEN7_BYTE_SCATTERED_DATA_<wbr>ELEMENT_BYTE  0<br>
#define GEN7_BYTE_SCATTERED_DATA_<wbr>ELEMENT_WORD  1<br>
#define GEN7_BYTE_SCATTERED_DATA_<wbr>ELEMENT_DWORD 2<br>
<br>
I'll include in the comment about MSC_DS<br>
"Specifies the number of Bytes to be read or written per Dword used at<br>
byte_scattered read/write and byte_scaled read/write messages."<br>
<span class=""><br>
>  <br>
><br>
>     +   GEN7_BYTE_SCATTERED_DATA_<wbr>SIZE_BYTE = 0,<br>
>     +   GEN7_BYTE_SCATTERED_DATA_<wbr>SIZE_WORD = 1,<br>
>     +   GEN7_BYTE_SCATTERED_DATA_<wbr>SIZE_DWORD = 2<br>
>     +};<br>
>     +<br>
>      #endif /* BRW_EU_DEFINES_H */<br>
>     diff --git a/src/intel/compiler/brw_eu_<wbr>emit.c<br>
>     b/src/intel/compiler/brw_eu_<wbr>emit.c<br>
>     index ca97ff7325..ded7e228cf 100644<br>
>     --- a/src/intel/compiler/brw_eu_<wbr>emit.c<br>
>     +++ b/src/intel/compiler/brw_eu_<wbr>emit.c<br>
>     @@ -2580,6 +2580,7 @@ brw_send_indirect_surface_<wbr>message(struct<br>
>     brw_codegen *p,<br>
>         return insn;<br>
>      }<br>
><br>
>     +<br>
>      static bool<br>
>      while_jumps_before_offset(<wbr>const struct gen_device_info *devinfo,<br>
>                                brw_inst *insn, int while_offset, int<br>
>     start_offset)<br>
>     @@ -2983,6 +2984,47 @@ brw_untyped_surface_write(<wbr>struct brw_codegen *p,<br>
>            p, insn, num_channels);<br>
>      }<br>
><br>
>     +static enum brw_data_size brw_data_size_from_bit_size(<wbr>unsigned<br>
>     bit_size)<br>
><br>
><br>
> Please put the return type on it's own line.<br>
<br>
</span>OK. It will be unsigned. and I'm changing the name of the function<br>
according to brw_scattered_data_element_<wbr>from_bit_size to maintain<br>
coherence with "enum" values.<br>
<div><div class="h5"><br>
<br>
>     +{<br>
>     +   switch (bit_size) {<br>
>     +   case 8:<br>
>     +      return GEN7_BYTE_SCATTERED_DATA_SIZE_<wbr>BYTE;<br>
>     +   case 16:<br>
>     +      return GEN7_BYTE_SCATTERED_DATA_SIZE_<wbr>WORD;<br>
>     +   case 32:<br>
>     +      return GEN7_BYTE_SCATTERED_DATA_SIZE_<wbr>DWORD;<br>
>     +   default:<br>
>     +      unreachable("Unsupported bit_size for byte scattered messages");<br>
>     +   }<br>
>     +}<br>
>     +<br>
>     +void<br>
>     +brw_byte_scattered_write(<wbr>struct brw_codegen *p,<br>
>     +                         struct brw_reg payload,<br>
>     +                         struct brw_reg surface,<br>
>     +                         unsigned msg_length,<br>
>     +                         unsigned bit_size)<br>
>     +{<br>
>     +   assert(brw_inst_access_mode(<wbr>p->devinfo, p->current) == BRW_ALIGN_1);<br>
>     +   const struct gen_device_info *devinfo = p->devinfo;<br>
>     +   const unsigned sfid = GEN7_SFID_DATAPORT_DATA_CACHE;<br>
>     +<br>
>     +   struct brw_inst *insn = brw_send_indirect_surface_<wbr>message(<br>
>     +      p, sfid, brw_writemask(brw_null_reg(), WRITEMASK_XYZW),<br>
>     +      payload, surface, msg_length, 0, true);<br>
>     +<br>
>     +   unsigned msg_control = brw_data_size_from_bit_size(<wbr>bit_size) << 2;<br>
><br>
><br>
> I have no idea what C is going to do with types when you have a packed<br>
> enum and you then provide a shift.  I think I would be more comfortable<br>
> if you used #defines and had brw_data_size_from_bit_size return an unsigned.<br>
<br>
</div></div>If packed enum uses a char as type, it this emum has only 0,1,2 values<br>
the shiff would fit in the char, and then it would be converted to<br>
uint32. But I can not confirm what each different compiler would do. So<br>
let's go with the simple choice and use #defines, what about changing<br>
the name of the function brw_byte_scattered_data_<wbr>element_from_bit_size.<br>
<span class=""><br>
>     +<br>
>     +   if (brw_inst_exec_size(devinfo, p->current) == BRW_EXECUTE_16)<br>
>     +      msg_control |= 1;<br>
>     +   else<br>
>     +      msg_control |= 0;<br>
>     +<br>
>     +   brw_inst_set_dp_msg_type(<wbr>devinfo, insn,<br>
>     +                           <br>
>     HSW_DATAPORT_DC_PORT0_BYTE_<wbr>SCATTERED_WRITE);<br>
><br>
><br>
> Should we assert at the top that devinfo->gen > 7 || devinfo->is_haswell?<br>
<br>
</span>Yes, I thought that when asserting for ALIGN1 we were already limitting<br>
that really. But yes, I'll include it.<br>
<div><div class="h5"><br>
>     +   brw_inst_set_dp_msg_control(<wbr>devinfo, insn, msg_control);<br>
>     +}<br>
>     +<br>
>      static void<br>
>      brw_set_dp_typed_atomic_<wbr>message(struct brw_codegen *p,<br>
>                                      struct brw_inst *insn,<br>
>     diff --git a/src/intel/compiler/brw_fs.<wbr>cpp<br>
>     b/src/intel/compiler/brw_fs.<wbr>cpp<br>
>     index 36fb337c62..32f1d757f0 100644<br>
>     --- a/src/intel/compiler/brw_fs.<wbr>cpp<br>
>     +++ b/src/intel/compiler/brw_fs.<wbr>cpp<br>
>     @@ -250,6 +250,7 @@ fs_inst::is_send_from_grf() const<br>
>         case SHADER_OPCODE_UNTYPED_ATOMIC:<br>
>         case SHADER_OPCODE_UNTYPED_SURFACE_<wbr>READ:<br>
>         case SHADER_OPCODE_UNTYPED_SURFACE_<wbr>WRITE:<br>
>     +   case SHADER_OPCODE_BYTE_SCATTERED_<wbr>WRITE:<br>
>         case SHADER_OPCODE_TYPED_ATOMIC:<br>
>         case SHADER_OPCODE_TYPED_SURFACE_<wbr>READ:<br>
>         case SHADER_OPCODE_TYPED_SURFACE_<wbr>WRITE:<br>
>     @@ -749,6 +750,11 @@ fs_inst::components_read(<wbr>unsigned i) const<br>
>            else<br>
>               return 1;<br>
><br>
>     +   case SHADER_OPCODE_BYTE_SCATTERED_<wbr>WRITE_LOGICAL:<br>
>     +      assert(src[3].file == IMM &&<br>
>     +             src[4].file == IMM);<br>
>     +      return 1;<br>
>     +<br>
>         case SHADER_OPCODE_UNTYPED_ATOMIC_<wbr>LOGICAL:<br>
>         case SHADER_OPCODE_TYPED_ATOMIC_<wbr>LOGICAL: {<br>
>            assert(src[3].file == IMM &&<br>
>     @@ -791,6 +797,7 @@ fs_inst::size_read(int arg) const<br>
>         case SHADER_OPCODE_TYPED_SURFACE_<wbr>READ:<br>
>         case SHADER_OPCODE_TYPED_SURFACE_<wbr>WRITE:<br>
>         case FS_OPCODE_INTERPOLATE_AT_PER_<wbr>SLOT_OFFSET:<br>
>     +   case SHADER_OPCODE_BYTE_SCATTERED_<wbr>WRITE:<br>
>            if (arg == 0)<br>
>               return mlen * REG_SIZE;<br>
>            break;<br>
>     @@ -4538,6 +4545,12 @@ fs_visitor::lower_logical_<wbr>sends()<br>
>                                          ibld.sample_mask_reg());<br>
>               break;<br>
><br>
>     +      case SHADER_OPCODE_BYTE_SCATTERED_<wbr>WRITE_LOGICAL:<br>
>     +         lower_surface_logical_send(<wbr>ibld, inst,<br>
>     +                                    SHADER_OPCODE_BYTE_SCATTERED_<wbr>WRITE,<br>
>     +                                    ibld.sample_mask_reg());<br>
>     +         break;<br>
>     +<br>
>            case SHADER_OPCODE_UNTYPED_ATOMIC_<wbr>LOGICAL:<br>
>               lower_surface_logical_send(<wbr>ibld, inst,<br>
>                                          SHADER_OPCODE_UNTYPED_ATOMIC,<br>
>     @@ -5022,6 +5035,7 @@ get_lowered_simd_width(const struct<br>
>     gen_device_info *devinfo,<br>
>         case SHADER_OPCODE_UNTYPED_ATOMIC_<wbr>LOGICAL:<br>
>         case SHADER_OPCODE_UNTYPED_SURFACE_<wbr>READ_LOGICAL:<br>
>         case SHADER_OPCODE_UNTYPED_SURFACE_<wbr>WRITE_LOGICAL:<br>
>     +   case SHADER_OPCODE_BYTE_SCATTERED_<wbr>WRITE_LOGICAL:<br>
>            return MIN2(16, inst->exec_size);<br>
><br>
>         case SHADER_OPCODE_URB_READ_SIMD8:<br>
>     diff --git a/src/intel/compiler/brw_fs_<wbr>copy_propagation.cpp<br>
>     b/src/intel/compiler/brw_fs_<wbr>copy_propagation.cpp<br>
>     index cb11739608..fcf4706b7a 100644<br>
>     --- a/src/intel/compiler/brw_fs_<wbr>copy_propagation.cpp<br>
>     +++ b/src/intel/compiler/brw_fs_<wbr>copy_propagation.cpp<br>
>     @@ -655,6 +655,7 @@ fs_visitor::try_constant_<wbr>propagate(fs_inst<br>
>     *inst, acp_entry *entry)<br>
>            case SHADER_OPCODE_TYPED_ATOMIC:<br>
>            case SHADER_OPCODE_TYPED_SURFACE_<wbr>READ:<br>
>            case SHADER_OPCODE_TYPED_SURFACE_<wbr>WRITE:<br>
>     +      case SHADER_OPCODE_BYTE_SCATTERED_<wbr>WRITE:<br>
>               /* We only propagate into the surface argument of the<br>
>                * instruction. Everything else goes through LOAD_PAYLOAD.<br>
>                */<br>
>     @@ -694,6 +695,7 @@ fs_visitor::try_constant_<wbr>propagate(fs_inst<br>
>     *inst, acp_entry *entry)<br>
>            case SHADER_OPCODE_TYPED_ATOMIC_<wbr>LOGICAL:<br>
>            case SHADER_OPCODE_TYPED_SURFACE_<wbr>READ_LOGICAL:<br>
>            case SHADER_OPCODE_TYPED_SURFACE_<wbr>WRITE_LOGICAL:<br>
>     +      case SHADER_OPCODE_BYTE_SCATTERED_<wbr>WRITE_LOGICAL:<br>
>               inst->src[i] = val;<br>
>               progress = true;<br>
>               break;<br>
>     diff --git a/src/intel/compiler/brw_fs_<wbr>generator.cpp<br>
>     b/src/intel/compiler/brw_fs_<wbr>generator.cpp<br>
>     index 1835c4bf72..fedc9acf97 100644<br>
>     --- a/src/intel/compiler/brw_fs_<wbr>generator.cpp<br>
>     +++ b/src/intel/compiler/brw_fs_<wbr>generator.cpp<br>
>     @@ -2073,6 +2073,12 @@ fs_generator::generate_code(<wbr>const cfg_t *cfg,<br>
>     int dispatch_width)<br>
>                                         inst->mlen, src[2].ud);<br>
>               break;<br>
><br>
>     +      case SHADER_OPCODE_BYTE_SCATTERED_<wbr>WRITE:<br>
>     +         assert(src[2].file == BRW_IMMEDIATE_VALUE);<br>
>     +         brw_byte_scattered_write(p, src[0], src[1],<br>
>     +                                  inst->mlen, src[2].ud);<br>
>     +         break;<br>
>     +<br>
>            case SHADER_OPCODE_TYPED_ATOMIC:<br>
>               assert(src[2].file == BRW_IMMEDIATE_VALUE);<br>
>               brw_typed_atomic(p, dst, src[0], src[1],<br>
>     diff --git a/src/intel/compiler/brw_fs_<wbr>surface_builder.cpp<br>
>     b/src/intel/compiler/brw_fs_<wbr>surface_builder.cpp<br>
>     index d00d8920b2..37cc29e361 100644<br>
>     --- a/src/intel/compiler/brw_fs_<wbr>surface_builder.cpp<br>
>     +++ b/src/intel/compiler/brw_fs_<wbr>surface_builder.cpp<br>
>     @@ -160,6 +160,16 @@ namespace brw {<br>
>               return emit_send(bld, SHADER_OPCODE_TYPED_ATOMIC_<wbr>LOGICAL,<br>
>                                addr, tmp, surface, dims, op, rsize);<br>
>            }<br>
>     +<br>
>     +      void<br>
>     +      emit_byte_scattered_write(<wbr>const fs_builder &bld, const fs_reg<br>
>     &surface,<br>
>     +                                const fs_reg &addr, const fs_reg &src,<br>
>     +                                unsigned dims, unsigned size,<br>
>     +                                unsigned bit_size, brw_predicate pred)<br>
>     +      {<br>
>     +         emit_send(bld, SHADER_OPCODE_BYTE_SCATTERED_<wbr>WRITE_LOGICAL,<br>
>     +                   addr, src, surface, dims, bit_size, 0, pred);<br>
>     +      }<br>
>         }<br>
>      }<br>
><br>
>     @@ -1192,3 +1202,4 @@ namespace brw {<br>
>            }<br>
>         }<br>
>      }<br>
>     +<br>
>     diff --git a/src/intel/compiler/brw_fs_<wbr>surface_builder.h<br>
>     b/src/intel/compiler/brw_fs_<wbr>surface_builder.h<br>
>     index 32b56d387f..bf9a8c68c8 100644<br>
>     --- a/src/intel/compiler/brw_fs_<wbr>surface_builder.h<br>
>     +++ b/src/intel/compiler/brw_fs_<wbr>surface_builder.h<br>
>     @@ -63,6 +63,13 @@ namespace brw {<br>
>                              const fs_reg &src0, const fs_reg &src1,<br>
>                              unsigned dims, unsigned rsize, unsigned op,<br>
>                              brw_predicate pred = BRW_PREDICATE_NONE);<br>
>     +<br>
>     +      void<br>
>     +      emit_byte_scattered_write(<wbr>const fs_builder &bld, const fs_reg<br>
>     &surface,<br>
>     +                                const fs_reg &addr, const fs_reg &src,<br>
>     +                                unsigned dims, unsigned size,<br>
>     +                                unsigned bit_size,<br>
>     +                                brw_predicate pred =<br>
>     BRW_PREDICATE_NONE);<br>
>         }<br>
><br>
>         namespace image_access {<br>
>     diff --git a/src/intel/compiler/brw_<wbr>shader.cpp<br>
>     b/src/intel/compiler/brw_<wbr>shader.cpp<br>
>     index d7d7616cf4..209552e1b2 100644<br>
>     --- a/src/intel/compiler/brw_<wbr>shader.cpp<br>
>     +++ b/src/intel/compiler/brw_<wbr>shader.cpp<br>
>     @@ -293,6 +293,11 @@ brw_instruction_name(const struct<br>
>     gen_device_info *devinfo, enum opcode op)<br>
>         case SHADER_OPCODE_MEMORY_FENCE:<br>
>            return "memory_fence";<br>
><br>
>     +   case SHADER_OPCODE_BYTE_SCATTERED_<wbr>WRITE:<br>
>     +      return "byte_scattered_write";<br>
>     +   case SHADER_OPCODE_BYTE_SCATTERED_<wbr>WRITE_LOGICAL:<br>
>     +      return "byte_scattered_write_logical"<wbr>;<br>
>     +<br>
>         case SHADER_OPCODE_LOAD_PAYLOAD:<br>
>            return "load_payload";<br>
>         case FS_OPCODE_PACK:<br>
>     @@ -963,6 +968,8 @@ backend_instruction::has_side_<wbr>effects() const<br>
>         case SHADER_OPCODE_GEN4_SCRATCH_<wbr>WRITE:<br>
>         case SHADER_OPCODE_UNTYPED_SURFACE_<wbr>WRITE:<br>
>         case SHADER_OPCODE_UNTYPED_SURFACE_<wbr>WRITE_LOGICAL:<br>
>     +   case SHADER_OPCODE_BYTE_SCATTERED_<wbr>WRITE:<br>
>     +   case SHADER_OPCODE_BYTE_SCATTERED_<wbr>WRITE_LOGICAL:<br>
>         case SHADER_OPCODE_TYPED_ATOMIC:<br>
>         case SHADER_OPCODE_TYPED_ATOMIC_<wbr>LOGICAL:<br>
>         case SHADER_OPCODE_TYPED_SURFACE_<wbr>WRITE:<br>
>     --<br>
>     2.14.3<br>
><br>
>     ______________________________<wbr>_________________<br>
>     mesa-dev mailing list<br>
</div></div>>     <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a> <mailto:<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.<wbr>freedesktop.org</a>><br>
>     <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
>     <<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.<wbr>org/mailman/listinfo/mesa-dev</a>><br>
><br>
><br>
</blockquote></div><br></div></div></div></div></div></div>