Bug 1708224 - Make draw_perspective more resilient to NaNs. r=aosmond a=pascalc
authorLee Salzman <lsalzman@mozilla.com>
Wed, 28 Apr 2021 15:54:24 +0000
changeset 648712 20957bf868869d09c8b127d261621d062aadc2dd
parent 648711 dbc25057913f664cbf0d3567c5478b5ad1c0dce6
child 648713 9fcea995d1dabc5a4f4ef3811dc0e6e00d88cbe3
push id2600
push userpchevrel@mozilla.com
push dateTue, 22 Jun 2021 15:56:41 +0000
treeherdermozilla-release@9fcea995d1da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaosmond, pascalc
bugs1708224
milestone89.0.2
Bug 1708224 - Make draw_perspective more resilient to NaNs. r=aosmond a=pascalc Differential Revision: https://phabricator.services.mozilla.com/D113671
gfx/wr/swgl/src/rasterize.h
--- a/gfx/wr/swgl/src/rasterize.h
+++ b/gfx/wr/swgl/src/rasterize.h
@@ -1434,17 +1434,18 @@ static void draw_perspective(int nump, I
   assert(nump >= 3);
   // Convert output of vertex shader to screen space.
   vec4 pos = vertex_shader->gl_Position;
   vec3_scalar scale =
       vec3_scalar(ctx->viewport.width(), ctx->viewport.height(), 1) * 0.5f;
   vec3_scalar offset =
       make_vec3(make_vec2(ctx->viewport.origin() - colortex.offset), 0.0f) +
       scale;
-  if (test_none(pos.z <= -pos.w || pos.z >= pos.w)) {
+  // Verify if point is between near and far planes, rejecting NaN.
+  if (test_all(pos.z > -pos.w && pos.z < pos.w)) {
     // No points cross the near or far planes, so no clipping required.
     // Just divide coords by W and convert to viewport. We assume the W
     // coordinate is non-zero and the reciprocal is finite since it would
     // otherwise fail the test_none condition.
     Float w = 1.0f / pos.w;
     vec3 screen = pos.sel(X, Y, Z) * w * scale + offset;
     Point3D p[4] = {{screen.x.x, screen.y.x, screen.z.x, w.x},
                     {screen.x.y, screen.y.y, screen.z.y, w.y},