<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Nov 29, 2017 at 6:50 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">This helpers are used to load/store 16-bit types from/to 32-bit<br>
components.<br>
<br>
The functions shuffle_32bit_load_result_to_<wbr>16bit_data and<br>
shuffle_16bit_data_for_32bit_<wbr>write are implemented in a similar<br>
way than the analogous functions for handling 64-bit types.<br>
---<br>
src/intel/compiler/brw_fs.h | 11 +++++++++<br>
src/intel/compiler/brw_fs_nir.<wbr>cpp | 51 ++++++++++++++++++++++++++++++<wbr>+++++++++<br>
2 files changed, 62 insertions(+)<br>
<br>
diff --git a/src/intel/compiler/brw_fs.h b/src/intel/compiler/brw_fs.h<br>
index 19b897e7a9..30557324d5 100644<br>
--- a/src/intel/compiler/brw_fs.h<br>
+++ b/src/intel/compiler/brw_fs.h<br>
@@ -497,6 +497,17 @@ void shuffle_32bit_load_result_to_<wbr>64bit_data(const brw::fs_builder &bld,<br>
fs_reg shuffle_64bit_data_for_32bit_<wbr>write(const brw::fs_builder &bld,<br>
const fs_reg &src,<br>
uint32_t components);<br>
+<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>
+<br>
+void shuffle_16bit_data_for_32bit_<wbr>write(const brw::fs_builder &bld,<br>
+ const fs_reg &dst,<br>
+ const fs_reg &src,<br>
+ uint32_t components);<br>
+<br>
fs_reg setup_imm_df(const brw::fs_builder &bld,<br>
double v);<br>
<br>
diff --git a/src/intel/compiler/brw_fs_<wbr>nir.cpp b/src/intel/compiler/brw_fs_<wbr>nir.cpp<br>
index 726b2fcee7..c091241132 100644<br>
--- a/src/intel/compiler/brw_fs_<wbr>nir.cpp<br>
+++ b/src/intel/compiler/brw_fs_<wbr>nir.cpp<br>
@@ -4828,6 +4828,33 @@ shuffle_32bit_load_result_to_<wbr>64bit_data(const fs_builder &bld,<br>
}<br>
}<br>
<br>
+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>
+{<br>
+ assert(type_sz(src.type) == 4);<br>
+ assert(type_sz(dst.type) == 2);<br>
+<br>
+ fs_reg tmp = retype(bld.vgrf(src.type), dst.type);<br>
+<br>
+ for (unsigned i = 0; i < components; i++) {<br>
+ const fs_reg component_i = subscript(offset(src, bld, i / 2), dst.type, i % 2);<br>
+<br>
+ bld.MOV(offset(tmp, bld, i % 2), component_i);<br>
+<br>
+ if (i % 2) {<br>
+ bld.MOV(offset(dst, bld, i -1), offset(tmp, bld, 0));<br>
+ bld.MOV(offset(dst, bld, i), offset(tmp, bld, 1));<br>
+ }<br></blockquote><div><br></div><div>I'm very confused by this extra moving. Why can't we just do</div><div><br></div><div>bld.MOV(offset(dst, bld, i), component_i);</div><div><br></div><div>above? Maybe I'm missing something but I don't see why the extra moves are needed.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ }<br>
+ if (components % 2) {<br>
+ bld.MOV(offset(dst, bld, components - 1), tmp);<br>
+ }<br>
+}<br>
+<br>
+<br>
/**<br>
* This helper does the inverse operation of<br>
* SHUFFLE_32BIT_LOAD_RESULT_TO_<wbr>64BIT_DATA.<br>
@@ -4860,6 +4887,30 @@ shuffle_64bit_data_for_32bit_<wbr>write(const fs_builder &bld,<br>
return dst;<br>
}<br>
<br>
+void<br>
+shuffle_16bit_data_for_32bit_<wbr>write(const fs_builder &bld,<br>
+ const fs_reg &dst,<br>
+ const fs_reg &src,<br>
+ uint32_t components)<br>
+{<br>
+ assert(type_sz(src.type) == 2);<br>
+ assert(type_sz(dst.type) == 4);<br>
+<br>
+ fs_reg tmp = bld.vgrf(dst.type);<br>
+<br>
+ for (unsigned i = 0; i < components; i++) {<br>
+ const fs_reg component_i = offset(src, bld, i);<br>
+ bld.MOV(subscript(tmp, src.type, i % 2), component_i);<br>
+ if (i % 2) {<br>
+ bld.MOV(offset(dst, bld, i / 2), tmp);<br>
+ }<br></blockquote><div><br></div><div>Again, why the extra MOVs? Why not</div><div><br></div><div>bld.MOV(subscript(offset(tmp, bld, i / 2), src.type, i % 2), component_i);</div><div><br></div><div>instead of the extra MOVs?</div><div><br></div><div>--Jason<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ }<br>
+ if (components % 2) {<br>
+ bld.MOV(offset(dst, bld, components / 2), tmp);<br>
+ }<br>
+}<br>
+<br>
+<br>
fs_reg<br>
setup_imm_df(const fs_builder &bld, double v)<br>
{<br>
<span class="HOEnZb"><font color="#888888">--<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>