<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Feb 27, 2018 at 5:27 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">This helper used to load 16bit components from 32-bits read now allows<br>
skipping components with the new parameter first_component. The semantics<br>
now skip components until we reach the first_component, and then reads the<br>
number of components passed to the function.<br>
<br>
All previous uses of the helper are updated to use 0 as first_component.<br>
This will allow read 16-bit components when the first one is not aligned<br>
32-bit. Enabling more usages of untyped_reads with 16-bit types.<br>
---<br>
 src/intel/compiler/brw_fs.cpp     | 2 +-<br>
 src/intel/compiler/brw_fs.h       | 3 ++-<br>
 src/intel/compiler/brw_fs_nir.<wbr>cpp | 8 +++++---<br>
 3 files changed, 8 insertions(+), 5 deletions(-)<br>
<br>
diff --git a/src/intel/compiler/brw_fs.<wbr>cpp b/src/intel/compiler/brw_fs.<wbr>cpp<br>
index bed632d21b9..e961b76ab61 100644<br>
--- a/src/intel/compiler/brw_fs.<wbr>cpp<br>
+++ b/src/intel/compiler/brw_fs.<wbr>cpp<br>
@@ -194,7 +194,7 @@ fs_visitor::VARYING_PULL_<wbr>CONSTANT_LOAD(const fs_builder &bld,<br>
    fs_reg dw = offset(vec4_result, bld, (const_offset & 0xf) / 4);<br>
    switch (type_sz(dst.type)) {<br>
    case 2:<br>
-      shuffle_32bit_load_result_to_<wbr>16bit_data(bld, dst, dw, 1);<br>
+      shuffle_32bit_load_result_to_<wbr>16bit_data(bld, dst, dw, 1, 0);<br>
       bld.MOV(dst, subscript(dw, dst.type, (const_offset / 2) & 1));<br>
       break;<br>
    case 4:<br>
diff --git a/src/intel/compiler/brw_fs.h b/src/intel/compiler/brw_fs.h<br>
index 63373580ee4..52dd5e1d6bb 100644<br>
--- a/src/intel/compiler/brw_fs.h<br>
+++ b/src/intel/compiler/brw_fs.h<br>
@@ -503,7 +503,8 @@ fs_reg shuffle_64bit_data_for_32bit_<wbr>write(const brw::fs_builder &bld,<br>
 void shuffle_32bit_load_result_to_<wbr>16bit_data(const brw::fs_builder &bld,<br>
                                              const fs_reg &dst,<br>
                                              const fs_reg &src,<br>
-                                             uint32_t components);<br>
+                                             uint32_t components,<br>
+                                             uint32_t first_component);<br></blockquote><div><br></div><div>I hope this doesn't cause too much trouble, but I think it would be better to have first_component come before components in the argument list.  With that changed,<br><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>
 void shuffle_16bit_data_for_32bit_<wbr>write(const brw::fs_builder &bld,<br>
                                         const fs_reg &dst,<br>
diff --git a/src/intel/compiler/brw_fs_<wbr>nir.cpp b/src/intel/compiler/brw_fs_<wbr>nir.cpp<br>
index 4aa411d149f..5567433a19e 100644<br>
--- a/src/intel/compiler/brw_fs_<wbr>nir.cpp<br>
+++ b/src/intel/compiler/brw_fs_<wbr>nir.cpp<br>
@@ -2316,7 +2316,7 @@ do_untyped_vector_read(const fs_builder &bld,<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>
+               num_components, 0);<br>
       } else {<br>
          assert(num_components == 1);<br>
          /* scalar 16-bit are read using one byte_scattered_read message */<br>
@@ -4908,7 +4908,8 @@ void<br>
 shuffle_32bit_load_result_to_<wbr>16bit_data(const fs_builder &bld,<br>
                                         const fs_reg &dst,<br>
                                         const fs_reg &src,<br>
-                                        uint32_t components)<br>
+                                        uint32_t components,<br>
+                                        uint32_t first_component)<br>
 {<br>
    assert(type_sz(src.type) == 4);<br>
    assert(type_sz(dst.type) == 2);<br>
@@ -4922,7 +4923,8 @@ shuffle_32bit_load_result_to_<wbr>16bit_data(const fs_builder &bld,<br>
<br>
    for (unsigned i = 0; i < components; i++) {<br>
       const fs_reg component_i =<br>
-         subscript(offset(src, bld, i / 2), dst.type, i % 2);<br>
+         subscript(offset(src, bld, (first_component + i) / 2), dst.type,<br>
+                   (first_component + i) % 2);<br>
<br>
       bld.MOV(offset(tmp, bld, i % 2), component_i);<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
2.14.3<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>