<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Oct 12, 2017 at 11:37 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">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>
v2: Fixed breaking of specialization constants. (Jason Ekstrand)<br>
---<br>
src/compiler/spirv/vtn_alu.c | 32 ++++++++++++++++++++++++++++++<wbr>++<br>
1 file changed, 32 insertions(+)<br>
<br>
diff --git a/src/compiler/spirv/vtn_alu.c b/src/compiler/spirv/vtn_alu.c<br>
index 7ec30b8a63..b7e1b72889 100644<br>
--- a/src/compiler/spirv/vtn_alu.c<br>
+++ b/src/compiler/spirv/vtn_alu.c<br>
@@ -381,6 +381,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></blockquote><div><br></div><div>How about we put</div><div><br></div><div>nir_rounding_mode *out_rounding_mode = _out_rounding_mode;</div><div><br></div><div>here and avoid the cast below.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ 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 +588,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.13.6<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>