<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Dec 5, 2017 at 1:36 PM, 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">SSBO loads were using byte_scattered read messages as they allow<br>
reading 16-bit size components. byte_scattered messages can only<br>
operate one component at a time so we needed to emit as many messages<br>
as components.<br>
<br>
But for vec2 and vec4 of 16-bit, being multiple of 32-bit we can use the<br>
untyped_surface_read message to read pairs of 16-bit components using<br>
only one message. Once each pair is read it is unshuffled to return the<br>
proper 16-bit components. vec3 case is assimilated to vec4 but the 4th<br>
component is ignored.<br>
<br>
16-bit scalars are read using one byte_scattered_read message.<br>
<br>
v2: Removed use of stride = 2 on sources (Jason Ekstrand)<br>
Rework optimization using unshuffle 16 reads (Chema Casanova)<br>
v3: Use W and D types insead of HF and F in shuffle to avoid rounding<br>
erros (Jason Ekstrand)<br>
Use untyped_surface_read for 16-bit vec3. (Jason Ekstrand)<br>
<br>
CC: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br>
---<br>
src/intel/compiler/brw_fs_nir.<wbr>cpp | 29 ++++++++++++++++++++++-------<br>
1 file changed, 22 insertions(+), 7 deletions(-)<br>
<br>
diff --git a/src/intel/compiler/brw_fs_<wbr>nir.cpp b/src/intel/compiler/brw_fs_<wbr>nir.cpp<br>
index e11e75e6332..8deec082d59 100644<br>
--- a/src/intel/compiler/brw_fs_<wbr>nir.cpp<br>
+++ b/src/intel/compiler/brw_fs_<wbr>nir.cpp<br>
@@ -2303,16 +2303,31 @@ do_untyped_vector_read(const fs_builder &bld,<br>
unsigned num_components)<br>
{<br>
if (type_sz(dest.type) <= 2) {<br>
- fs_reg read_offset = bld.vgrf(BRW_REGISTER_TYPE_UD)<wbr>;<br>
- bld.MOV(read_offset, offset_reg);<br>
- for (unsigned i = 0; i < num_components; i++) {<br>
- fs_reg read_reg =<br>
- emit_byte_scattered_read(bld, surf_index, read_offset,<br>
+ assert(dest.stride == 1);<br>
+<br>
+ if (num_components > 1) {<br>
+ /* Pairs of 16-bit components can be read with untyped read, for 16-bit<br>
+ * vec3 4th component is ignored.<br>
+ */<br>
+ fs_reg read_result =<br>
+ emit_untyped_read(bld, surf_index, offset_reg,<br>
+ 1 /* dims */, DIV_ROUND_UP(num_components, 2),<br>
+ BRW_PREDICATE_NONE);<br>
+ shuffle_32bit_load_result_to_<wbr>16bit_data(bld,<br>
+ retype(dest, BRW_REGISTER_TYPE_W),<br>
+ retype(read_result, BRW_REGISTER_TYPE_D),<br>
+ num_components);<br>
+ } else {<br>
+ assert(num_components == 1);<br>
+ /* scalar 16-bit are read using one byte_scattered_read message */<br>
+ fs_reg read_result =<br>
+ emit_byte_scattered_read(bld, surf_index, offset_reg,<br>
1 /* dims */, 1,<br>
type_sz(dest.type) * 8 /* bit_size */,<br>
BRW_PREDICATE_NONE);<br>
- bld.MOV(offset(dest, bld, i), subscript(read_reg, dest.type, 0));<br>
- bld.ADD(read_offset, read_offset, brw_imm_ud(type_sz(dest.type))<wbr>);<br>
+ read_result.type = dest.type;<br>
+ read_result.stride = 2;<br>
+ bld.MOV(dest, read_result);<br></blockquote><div><br></div><div>If read_reg has a 32-bit type, you could use subscript here. Meh.</div><div><br></div><div>Reviewed-by: Jason Ekstrand <<a href="mailto:jason@jlekstrand.net">jason@jlekstrand.net</a>><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
}<br>
} else if (type_sz(dest.type) == 4) {<br>
fs_reg read_result = emit_untyped_read(bld, surf_index, offset_reg,<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.11.0<br>
<br>
</font></span></blockquote></div><br></div></div>