<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Jul 13, 2017 at 7:35 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">From: Jose Maria Casanova Crespo <<a href="mailto:jmcasanova@igalia.com">jmcasanova@igalia.com</a>><br>
<br>
SpvOpFConvert now manages the FPRoundingMode decorator for the<br>
returning values enabling the nir_rounding_mode in the conversion<br>
operation to fp16 values.<br>
---<br>
 src/compiler/spirv/vtn_alu.c | 33 ++++++++++++++++++++++++++++++<wbr>++-<br>
 1 file changed, 32 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/src/compiler/spirv/vtn_alu.c b/src/compiler/spirv/vtn_alu.c<br>
index 7ec30b8..5a6cc1b 100644<br>
--- a/src/compiler/spirv/vtn_alu.c<br>
+++ b/src/compiler/spirv/vtn_alu.c<br>
@@ -354,7 +354,6 @@ vtn_nir_alu_op_for_spirv_<wbr>opcode(SpvOp opcode, bool *swap,<br>
    case SpvOpConvertSToF:<br>
    case SpvOpConvertUToF:<br>
    case SpvOpSConvert:<br>
-   case SpvOpFConvert:<br></blockquote><div><br></div><div>Getting rid of this will break specialization constants.  Also, can you apply a rounding mode to an OpSpecConstantOp?  I'm guessing the spec doesn't say...<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
       return nir_type_conversion_op(src, dst, nir_rounding_mode_undef);<br>
<br>
    /* Derivatives: */<br>
@@ -381,6 +380,26 @@ handle_no_contraction(struct vtn_builder *b, struct vtn_value *val, int member,<br>
    b->nb.exact = true;<br>
 }<br>
<br>
+static void<br>
+handle_rounding_mode(struct vtn_builder *b, struct vtn_value *val, int member,<br>
+                     const struct vtn_decoration *dec, void *_out_rounding_mode)<br>
+{<br>
+    assert(dec->scope == VTN_DEC_DECORATION);<br>
+    if (dec->decoration != SpvDecorationFPRoundingMode)<br>
+       return;<br>
+    switch (dec->literals[0]) {<br>
+    case SpvFPRoundingModeRTE:<br>
+       *((nir_rounding_mode *) _out_rounding_mode) = nir_rounding_mode_rtne;<br>
+       break;<br>
+    case SpvFPRoundingModeRTZ:<br>
+       *((nir_rounding_mode *) _out_rounding_mode) = nir_rounding_mode_rtz;<br>
+       break;<br>
+    default:<br>
+       unreachable("Not supported rounding mode");<br>
+       break;<br>
+    }<br>
+}<br>
+<br>
 void<br>
 vtn_handle_alu(struct vtn_builder *b, SpvOp opcode,<br>
                const uint32_t *w, unsigned count)<br>
@@ -568,6 +587,18 @@ vtn_handle_alu(struct vtn_builder *b, SpvOp opcode,<br>
       vtn_handle_bitcast(b, val->ssa, src[0]);<br>
       break;<br>
<br>
+   case SpvOpFConvert: {<br>
+      nir_alu_type src_alu_type = nir_get_nir_type_for_glsl_<wbr>type(vtn_src[0]->type);<br>
+      nir_alu_type dst_alu_type = nir_get_nir_type_for_glsl_<wbr>type(type);<br>
+      nir_rounding_mode rounding_mode = nir_rounding_mode_undef;<br>
+<br>
+      vtn_foreach_decoration(b, val, handle_rounding_mode, &rounding_mode);<br>
+      nir_op op = nir_type_conversion_op(src_<wbr>alu_type, dst_alu_type, rounding_mode);<br>
+<br>
+      val->ssa->def = nir_build_alu(&b->nb, op, src[0], src[1], NULL, NULL);<br>
+      break;<br>
+   }<br>
+<br>
    default: {<br>
       bool swap;<br>
       nir_alu_type src_alu_type = nir_get_nir_type_for_glsl_<wbr>type(vtn_src[0]->type);<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.9.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>