<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Oct 12, 2017 at 11:38 AM, Jose Maria Casanova Crespo <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">Signed-off-by: Jose Maria Casanova Crespo <<a href="mailto:jmcasanova@igalia.com">jmcasanova@igalia.com</a>><br>
Signed-off-by: Alejandro Piñeiro <<a href="mailto:apinheiro@igalia.com">apinheiro@igalia.com</a>><br>
---<br>
src/intel/compiler/brw_eu.h | 6 ++<br>
src/intel/compiler/brw_eu_<wbr>defines.h | 17 +++++<br>
src/intel/compiler/brw_eu_<wbr>emit.c | 89 ++++++++++++++++++++++++++<br>
src/intel/compiler/brw_fs.cpp | 10 +++<br>
src/intel/compiler/brw_fs_<wbr>copy_propagation.cpp | 2 +<br>
src/intel/compiler/brw_fs_<wbr>generator.cpp | 5 ++<br>
src/intel/compiler/brw_fs_<wbr>surface_builder.cpp | 17 +++++<br>
src/intel/compiler/brw_fs_<wbr>surface_builder.h | 9 +++<br>
src/intel/compiler/brw_shader.<wbr>cpp | 7 ++<br>
9 files changed, 162 insertions(+)<br>
<br>
diff --git a/src/intel/compiler/brw_eu.h b/src/intel/compiler/brw_eu.h<br>
index 145942a54f..b44ca0f518 100644<br>
--- a/src/intel/compiler/brw_eu.h<br>
+++ b/src/intel/compiler/brw_eu.h<br>
@@ -476,6 +476,12 @@ brw_typed_surface_write(struct brw_codegen *p,<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>
+<br>
+void<br>
brw_memory_fence(struct brw_codegen *p,<br>
struct brw_reg dst);<br>
<br>
diff --git a/src/intel/compiler/brw_eu_<wbr>defines.h b/src/intel/compiler/brw_eu_<wbr>defines.h<br>
index 1751f18293..9aac385ba7 100644<br>
--- a/src/intel/compiler/brw_eu_<wbr>defines.h<br>
+++ b/src/intel/compiler/brw_eu_<wbr>defines.h<br>
@@ -390,6 +390,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 non-LOGICAL<br>
+ * opcode, but instead of taking a single payload blog they expect their<br>
+ * arguments separately as individual sources, like untyped 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>
@@ -1231,4 +1241,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>
+ GEN7_BYTE_SCATTERED_DATA_SIZE_<wbr>BYTE = 0,<br>
+ GEN7_BYTE_SCATTERED_DATA_SIZE_<wbr>WORD = 1,<br>
+ GEN7_BYTE_SCATTERED_DATA_SIZE_<wbr>DWORD = 2<br>
+};<br>
+<br>
#endif /* BRW_EU_DEFINES_H */<br>
diff --git a/src/intel/compiler/brw_eu_<wbr>emit.c b/src/intel/compiler/brw_eu_<wbr>emit.c<br>
index 8c1e4c5eae..84d85be653 100644<br>
--- a/src/intel/compiler/brw_eu_<wbr>emit.c<br>
+++ b/src/intel/compiler/brw_eu_<wbr>emit.c<br>
@@ -2483,6 +2483,49 @@ brw_send_indirect_surface_<wbr>message(struct brw_codegen *p,<br>
return insn;<br>
}<br>
<br>
+<br>
+static struct brw_inst *<br>
+brw_send_indirect_scattered_<wbr>message(struct brw_codegen *p,<br>
+ unsigned sfid,<br>
+ struct brw_reg dst,<br>
+ struct brw_reg payload,<br>
+ struct brw_reg surface,<br>
+ unsigned message_len,<br>
+ unsigned response_len,<br>
+ bool header_present)<br></blockquote><div><br></div><div>How is this any different from brw_send_indirect_surface_message? They look identical except for the fact that this one is missing the explicit brw_set_default_exec_size I added to the other as part of my subgroup series. If there's no real difference, let's delete this one and just use the other. You can make a pretty good case that the scattered byte messages are "surface" messages.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+{<br>
+ const struct gen_device_info *devinfo = p->devinfo;<br>
+ struct brw_inst *insn;<br>
+<br>
+ if (surface.file != BRW_IMMEDIATE_VALUE) {<br>
+ struct brw_reg addr = retype(brw_address_reg(0), BRW_REGISTER_TYPE_UD);<br>
+<br>
+ brw_push_insn_state(p);<br>
+ brw_set_default_access_mode(p, BRW_ALIGN_1);<br>
+ brw_set_default_mask_control(<wbr>p, BRW_MASK_DISABLE);<br>
+ brw_set_default_predicate_<wbr>control(p, BRW_PREDICATE_NONE);<br>
+<br>
+ /* Mask out invalid bits from the surface index to avoid hangs e.g. when<br>
+ * some surface array is accessed out of bounds.<br>
+ */<br>
+ insn = brw_AND(p, addr,<br>
+ suboffset(vec1(retype(surface, BRW_REGISTER_TYPE_UD)),<br>
+ BRW_GET_SWZ(surface.swizzle, 0)),<br>
+ brw_imm_ud(0xff));<br>
+<br>
+ brw_pop_insn_state(p);<br>
+<br>
+ surface = addr;<br>
+ }<br>
+<br>
+ insn = brw_send_indirect_message(p, sfid, dst, payload, surface);<br>
+ brw_inst_set_mlen(devinfo, insn, message_len);<br>
+ brw_inst_set_rlen(devinfo, insn, response_len);<br>
+ brw_inst_set_header_present(<wbr>devinfo, insn, header_present);<br>
+<br>
+ return insn;<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 start_offset)<br>
@@ -2887,6 +2930,52 @@ brw_untyped_surface_write(<wbr>struct brw_codegen *p,<br>
}<br>
<br>
static void<br>
+brw_set_dp_byte_scattered_<wbr>write(struct brw_codegen *p,<br>
+ struct brw_inst *insn)<br>
+{<br>
+ const struct gen_device_info *devinfo = p->devinfo;<br>
+<br>
+ /* Although we could configure this message to write BYTE, WORD, or DWORD,<br>
+ * it was added for the need of writing WORD sizes, so we use directly that<br>
+ * size. This could be revisited on the future.<br>
+ */<br>
+ unsigned msg_control = GEN7_BYTE_SCATTERED_DATA_SIZE_<wbr>WORD << 2; <br></blockquote><div><br></div><div>This doesn't seem like a safe long-term assuption...<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+ assert(brw_inst_access_mode(<wbr>devinfo, p->current) == BRW_ALIGN_1);<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>
+ devinfo->gen >= 8 || devinfo->is_haswell ?<br>
+ HSW_DATAPORT_DC_PORT0_BYTE_<wbr>SCATTERED_WRITE :<br>
+ GEN7_DATAPORT_DC_BYTE_<wbr>SCATTERED_WRITE);<br>
+ brw_inst_set_dp_msg_control(<wbr>devinfo, insn, msg_control);<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>
+{<br>
+ const struct gen_device_info *devinfo = p->devinfo;<br>
+ const unsigned sfid = GEN7_SFID_DATAPORT_DATA_CACHE;<br>
+ const bool align1 = brw_inst_access_mode(devinfo, p->current) == BRW_ALIGN_1;<br>
+ /* Mask out unused components -- See comment in brw_untyped_atomic(). */<br>
+ const unsigned mask = devinfo->gen == 7 && !devinfo->is_haswell && !align1 ?<br>
+ WRITEMASK_X : WRITEMASK_XYZW;<br></blockquote><div><br></div><div>We're only supporting 16-bit storage on gen8+ and not in vec4. I doubt the vec4 back-end is going to get a lot more love, so maybe we should just assert ALIGN1 here and drop the added complexity. That said, it's not actually hurting much.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ struct brw_inst *insn = brw_send_indirect_scattered_<wbr>message(<br>
+ p, sfid, brw_writemask(brw_null_reg(), mask),<br>
+ payload, surface, msg_length, 0, align1);<br>
+<br>
+ brw_set_dp_byte_scattered_<wbr>write(p, insn);<br></blockquote><div><br></div><div>Maybe we should just inline this here instead of having two very small functions?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+}<br>
+<br>
+static void<br>
brw_set_dp_typed_atomic_<wbr>message(struct brw_codegen *p,<br>
struct brw_inst *insn,<br>
unsigned atomic_op,<br>
diff --git a/src/intel/compiler/brw_fs.<wbr>cpp b/src/intel/compiler/brw_fs.<wbr>cpp<br>
index 8da16145dc..e4a94ff053 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>
@@ -744,6 +745,7 @@ fs_inst::components_read(<wbr>unsigned i) const<br>
<br>
case SHADER_OPCODE_UNTYPED_SURFACE_<wbr>WRITE_LOGICAL:<br>
case SHADER_OPCODE_TYPED_SURFACE_<wbr>WRITE_LOGICAL:<br>
+ case SHADER_OPCODE_BYTE_SCATTERED_<wbr>WRITE_LOGICAL:<br>
assert(src[3].file == IMM &&<br>
src[4].file == IMM);<br>
/* Surface coordinates. */<br>
@@ -797,6 +799,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>
@@ -4524,6 +4527,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>
@@ -5008,6 +5017,7 @@ get_lowered_simd_width(const struct 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 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 *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 *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 b/src/intel/compiler/brw_fs_<wbr>generator.cpp<br>
index 9f2e1b3b85..414da81287 100644<br>
--- a/src/intel/compiler/brw_fs_<wbr>generator.cpp<br>
+++ b/src/intel/compiler/brw_fs_<wbr>generator.cpp<br>
@@ -2053,6 +2053,11 @@ fs_generator::generate_code(<wbr>const cfg_t *cfg, 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], inst->mlen);<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 b/src/intel/compiler/brw_fs_<wbr>surface_builder.cpp<br>
index d00d8920b2..5f529e9489 100644<br>
--- a/src/intel/compiler/brw_fs_<wbr>surface_builder.cpp<br>
+++ b/src/intel/compiler/brw_fs_<wbr>surface_builder.cpp<br>
@@ -1192,3 +1192,20 @@ namespace brw {<br>
}<br>
}<br>
}<br>
+<br>
+namespace brw {<br></blockquote><div><br></div><div>Why are we closing the brw namespace and then opening it again. We should be able to drop the above 3 lines.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ namespace scattered_access {<br>
+ void<br>
+ emit_byte_scattered_write(<wbr>const fs_builder &bld, const fs_reg &surface,<br>
+ const fs_reg &addr, const fs_reg &src,<br>
+ unsigned dims, unsigned size,<br>
+ brw_predicate pred)<br>
+ {<br>
+ using namespace surface_access;<br>
+<br>
+ emit_send(bld, SHADER_OPCODE_BYTE_SCATTERED_<wbr>WRITE_LOGICAL,<br>
+ addr, src, surface, dims, size, 0, pred);<br>
+ }<br>
+<br>
+ }<br>
+}<br>
diff --git a/src/intel/compiler/brw_fs_<wbr>surface_builder.h b/src/intel/compiler/brw_fs_<wbr>surface_builder.h<br>
index 32b56d387f..913ffaee72 100644<br>
--- a/src/intel/compiler/brw_fs_<wbr>surface_builder.h<br>
+++ b/src/intel/compiler/brw_fs_<wbr>surface_builder.h<br>
@@ -84,5 +84,14 @@ namespace brw {<br>
unsigned surf_dims, unsigned arr_dims,<br>
unsigned rsize, unsigned op);<br>
}<br>
+<br>
+ namespace scattered_access {<br>
+ void<br>
+ emit_byte_scattered_write(<wbr>const fs_builder &bld, const fs_reg &surface,<br>
+ const fs_reg &addr, const fs_reg &src,<br>
+ unsigned dims, unsigned size,<br>
+ brw_predicate pred = BRW_PREDICATE_NONE);<br>
+<br>
+ }<br>
}<br>
#endif<br>
diff --git a/src/intel/compiler/brw_<wbr>shader.cpp b/src/intel/compiler/brw_<wbr>shader.cpp<br>
index 8ee4d3cef9..ebaf586df4 100644<br>
--- a/src/intel/compiler/brw_<wbr>shader.cpp<br>
+++ b/src/intel/compiler/brw_<wbr>shader.cpp<br>
@@ -297,6 +297,11 @@ brw_instruction_name(const struct 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>
@@ -993,6 +998,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>
<span class="HOEnZb"><font color="#888888">--<br>
2.13.6<br>
<br>
______________________________<wbr>_________________<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" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>