<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Aug 24, 2017 at 6:54 AM, Alejandro Piñeiro <span dir="ltr"><<a href="mailto:apinheiro@igalia.com" target="_blank">apinheiro@igalia.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Returns the brw_type for a given ssa.bit_size, and a reference type.<br>
So if bit_size is 64, and the reference type is BRW_REGISTER_TYPE_F,<br>
it returns BRW_REGISTER_TYPE_DF. The same applies if bit_size is 32<br>
and reference type is BRW_REGISTER_TYPE_HF it returns BRW_REGISTER_TYPE_F<br>
<br>
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_fs_nir.<wbr>cpp | 67 ++++++++++++++++++++++++++++++<wbr>++++++---<br>
 1 file changed, 62 insertions(+), 5 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 d760946e624..e4eba1401f8 100644<br>
--- a/src/intel/compiler/brw_fs_<wbr>nir.cpp<br>
+++ b/src/intel/compiler/brw_fs_<wbr>nir.cpp<br>
@@ -214,6 +214,63 @@ fs_visitor::nir_emit_system_<wbr>values()<br>
    }<br>
 }<br>
<br>
+/*<br>
+ * Returns a type based on a reference_type (word, float, half-float) and a<br>
+ * given bit_size.<br>
+ *<br>
+ * Reference BRW_REGISTER_TYPE are HF,F,DF,W,D,UW,UD.<br>
+ *<br>
+ * @FIXME: 64-bit return types are always DF on integer types to maintain<br>
+ * compability with uses of DF previously to the introduction of int64<br>
+ * support.<br>
+ */<br>
+static brw_reg_type<br>
+brw_reg_type_from_bit_size(<wbr>const unsigned bit_size,<br>
+                           const brw_reg_type reference_type)<br>
+{<br>
+   switch(reference_type) {<br>
+   case BRW_REGISTER_TYPE_HF:<br>
+   case BRW_REGISTER_TYPE_F:<br>
+   case BRW_REGISTER_TYPE_DF:<br>
+      switch(bit_size) {<br>
+      case 16:<br>
+         return BRW_REGISTER_TYPE_HF;<br>
+      case 32:<br>
+         return BRW_REGISTER_TYPE_F;<br>
+      case 64:<br>
+         return BRW_REGISTER_TYPE_DF;<br>
+      default:<br>
+         unreachable("Not reached");<br></blockquote><div><br></div><div>Please add something more descriptive here such as "Invalid bit size"<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+      }<br>
+   case BRW_REGISTER_TYPE_W:<br>
+   case BRW_REGISTER_TYPE_D:<br></blockquote><div><br></div><div>Please add the Q type<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+      switch(bit_size) {<br>
+      case 16:<br>
+         return BRW_REGISTER_TYPE_W;<br>
+      case 32:<br>
+         return BRW_REGISTER_TYPE_D;<br>
+      case 64:<br>
+         return BRW_REGISTER_TYPE_DF;<br>
+      default:<br>
+         unreachable("Not reached");<br></blockquote><div><br></div><div>Better message<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+      }<br>
+   case BRW_REGISTER_TYPE_UW:<br>
+   case BRW_REGISTER_TYPE_UD:<br></blockquote><div><br></div><div>Please add the UQ type<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+      switch(bit_size) {<br>
+      case 16:<br>
+         return BRW_REGISTER_TYPE_UW;<br>
+      case 32:<br>
+         return BRW_REGISTER_TYPE_UD;<br>
+      case 64:<br>
+         return BRW_REGISTER_TYPE_DF;<br>
+      default:<br>
+         unreachable("Not reached");<br></blockquote><div><br></div>better message<br><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+      }<br>
+   default:<br>
+      unreachable("Not reached");<br></blockquote><div><br></div>better message</div><div class="gmail_quote"><br></div><div class="gmail_quote">I've got all those fixes in a version of this patch I pulled into my subgroups tree.<br></div><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+   }<br>
+}<br>
+<br>
 void<br>
 fs_visitor::nir_emit_impl(nir_<wbr>function_impl *impl)<br>
 {<br>
@@ -227,7 +284,7 @@ fs_visitor::nir_emit_impl(nir_<wbr>function_impl *impl)<br>
          reg->num_array_elems == 0 ? 1 : reg->num_array_elems;<br>
       unsigned size = array_elems * reg->num_components;<br>
       const brw_reg_type reg_type =<br>
-         reg->bit_size == 32 ? BRW_REGISTER_TYPE_F : BRW_REGISTER_TYPE_DF;<br>
+         brw_reg_type_from_bit_size(<wbr>reg->bit_size, BRW_REGISTER_TYPE_F);<br>
       nir_locals[reg->index] = bld.vgrf(reg_type, size);<br>
    }<br>
<br>
@@ -1338,7 +1395,7 @@ fs_visitor::nir_emit_load_<wbr>const(const fs_builder &bld,<br>
                                 nir_load_const_instr *instr)<br>
 {<br>
    const brw_reg_type reg_type =<br>
-      instr->def.bit_size == 32 ? BRW_REGISTER_TYPE_D : BRW_REGISTER_TYPE_DF;<br>
+      brw_reg_type_from_bit_size(<wbr>instr->def.bit_size, BRW_REGISTER_TYPE_D);<br>
    fs_reg reg = bld.vgrf(reg_type, instr->def.num_components);<br>
<br>
    switch (instr->def.bit_size) {<br>
@@ -1366,8 +1423,8 @@ fs_visitor::get_nir_src(const nir_src &src)<br>
    fs_reg reg;<br>
    if (src.is_ssa) {<br>
       if (src.ssa->parent_instr->type == nir_instr_type_ssa_undef) {<br>
-         const brw_reg_type reg_type = src.ssa->bit_size == 32 ?<br>
-            BRW_REGISTER_TYPE_D : BRW_REGISTER_TYPE_DF;<br>
+         const brw_reg_type reg_type =<br>
+            brw_reg_type_from_bit_size(<wbr>src.ssa->bit_size, BRW_REGISTER_TYPE_D);<br>
          reg = bld.vgrf(reg_type, src.ssa->num_components);<br>
       } else {<br>
          reg = nir_ssa_values[src.ssa->index]<wbr>;<br>
@@ -1401,7 +1458,7 @@ fs_visitor::get_nir_dest(const nir_dest &dest)<br>
 {<br>
    if (dest.is_ssa) {<br>
       const brw_reg_type reg_type =<br>
-         dest.ssa.bit_size == 32 ? BRW_REGISTER_TYPE_F : BRW_REGISTER_TYPE_DF;<br>
+         brw_reg_type_from_bit_size(<wbr>dest.ssa.bit_size, BRW_REGISTER_TYPE_F);<br>
       nir_ssa_values[dest.ssa.index] =<br>
          bld.vgrf(reg_type, dest.ssa.num_components);<br>
       return nir_ssa_values[dest.ssa.index]<wbr>;<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.11.0<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>