<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Feb 27, 2018 at 7:20 PM, Timothy Arceri <span dir="ltr"><<a href="mailto:tarceri@itsqueeze.com" target="_blank">tarceri@itsqueeze.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">On 28/02/18 14:13, Jason Ekstrand wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
On February 27, 2018 19:11:49 Jason Ekstrand <<a href="mailto:jason@jlekstrand.net" target="_blank">jason@jlekstrand.net</a>> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
On February 27, 2018 19:07:43 Timothy Arceri <<a href="mailto:tarceri@itsqueeze.com" target="_blank">tarceri@itsqueeze.com</a>> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
>From the GLSL 4.60 spec Section 5.9 (Expressions):<br>
<br>
   "Dividing by zero does not cause an exception but does result in<br>
    an unspecified value."<br>
<br>
Fixes: 89285e4d47a6 "nir: add new constant folding infrastructure"<br>
<br>
Bugzilla: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=105271" rel="noreferrer" target="_blank">https://bugs.freedesktop.org/s<wbr>how_bug.cgi?id=105271</a><br>
---<br>
 src/compiler/nir/nir_opcodes.<wbr>py | 6 +++---<br>
 1 file changed, 3 insertions(+), 3 deletions(-)<br>
<br>
diff --git a/src/compiler/nir/nir_opcodes<wbr>.py b/src/compiler/nir/nir_opcodes<wbr>.py<br>
index 278562b2bd..dcc5b07d05 100644<br>
--- a/src/compiler/nir/nir_opcodes<wbr>.py<br>
+++ b/src/compiler/nir/nir_opcodes<wbr>.py<br>
@@ -403,9 +403,9 @@ binop("imul_high", tint32, commutative,<br>
 binop("umul_high", tuint32, commutative,<br>
       "(uint32_t)(((uint64_t) src0 * (uint64_t) src1) >> 32)")<br>
<br>
-binop("fdiv", tfloat, "", "src0 / src1")<br>
-binop("idiv", tint, "", "src0 / src1")<br>
-binop("udiv", tuint, "", "src0 / src1")<br>
+binop("fdiv", tfloat, "", "src1 == 0 ? 0 : (src0 / src1)")<br>
</blockquote>
<br>
Should this return inf?<br>
</blockquote>
<br>
Or maybe an unsignaling NaN?  I'm not really sure.<br>
</blockquote>
<br></span>
I'm not sure. GLSL IR doesn't even try to catch this currently.<br>
</blockquote><div><br></div><div>According to wikipedia, it's supposed to result in +-inf:<br><br><a href="https://en.wikipedia.org/wiki/IEEE_754#Exception_handling">https://en.wikipedia.org/wiki/IEEE_754#Exception_handling</a><br><br></div><div>The D3D10 docs say:<br><br>"Divide by 0 produces +/- INF, except 0/0 which results in NaN."<br><br><a href="https://msdn.microsoft.com/en-us/library/windows/desktop/cc308050(v=vs.85).aspx">https://msdn.microsoft.com/en-us/library/windows/desktop/cc308050(v=vs.85).aspx</a><br><br></div><div>Another option would be to temporarily disable FP exceptions during constant folding.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail-HOEnZb"><div class="gmail-h5"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+binop("idiv", tint, "", "src1 == 0 ? 0 : (src0 / src1)")<br>
+binop("udiv", tuint, "", "src1 == 0 ? 0 : (src0 / src1)")<br>
<br>
 # returns a boolean representing the carry resulting from the addition of<br>
 # the two unsigned arguments.<br>
-- <br>
2.14.3<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">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>
</blockquote>
<br>
<br>
</blockquote>
<br>
<br>
</blockquote>
</div></div></blockquote></div><br></div></div>