<html>
    <head>
      <base href="https://bugs.freedesktop.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - dEQP-GLES3: modf does not produce correct results with infinities"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=89645">89645</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>dEQP-GLES3: modf does not produce correct results with infinities
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>Mesa
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>git
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Other
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Drivers/DRI/i965
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>idr@freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>itoral@igalia.com
          </td>
        </tr>

        <tr>
          <th>QA Contact</th>
          <td>intel-3d-bugs@lists.freedesktop.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=114429" name="attach_114429" title="Fixes modf with infinities by adding a conditional at the IR level">attachment 114429</a> <a href="attachment.cgi?id=114429&action=edit" title="Fixes modf with infinities by adding a conditional at the IR level">[details]</a></span>
Fixes modf with infinities by adding a conditional at the IR level

List of affected tests:

dEQP-GLES3.functional.shaders.builtin_functions.precision.modf.lowp_vertex
dEQP-GLES3.functional.shaders.builtin_functions.precision.modf.lowp_fragment
dEQP-GLES3.functional.shaders.builtin_functions.precision.modf.mediump_vertex
dEQP-GLES3.functional.shaders.builtin_functions.precision.modf.mediump_fragment
dEQP-GLES3.functional.shaders.builtin_functions.precision.modf.highp_vertex
dEQP-GLES3.functional.shaders.builtin_functions.precision.modf.highp_fragment

The problem is that Mesa implements modf as trunc to get the integer part, then
subtracts that from the parameter to obtain the remainder and that gives a NaN
instead of 0. I tried calculating the remainder directly with ir_unop_fract but
that also gives as NaN as result, so it looks like there is no way around this
issue.

Of course, we can add a conditional check to modf in order to detect this case
specifically and solve it directly, but that would hurt all emissions of the
function, so I am not sure that we want to do this. Attached is a patch that
does this at the IR level (even if we want to do this maybe we want to do it
inside i965, not sure) and fixes the tests.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the QA Contact for the bug.</li>
      </ul>
    </body>
</html>