From ef4f5b391e560e535b25b372f797e41edeef09f1 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 5 Dec 2001 10:24:31 +0000 Subject: [PATCH] add inf and nan tests to swrast functions --- src/mesa/swrast/s_aalinetemp.h | 4 ++-- src/mesa/swrast/s_aatritemp.h | 4 ++-- src/mesa/swrast/s_linetemp.h | 9 ++++++++- src/mesa/swrast/s_pointtemp.h | 10 +++++++++- src/mesa/swrast/s_tritemp.h | 4 ++-- 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/mesa/swrast/s_aalinetemp.h b/src/mesa/swrast/s_aalinetemp.h index 2d8f849..f645e55 100644 --- a/src/mesa/swrast/s_aalinetemp.h +++ b/src/mesa/swrast/s_aalinetemp.h @@ -1,4 +1,4 @@ -/* $Id: s_aalinetemp.h,v 1.14 2001/09/19 20:30:44 kschultz Exp $ */ +/* $Id: s_aalinetemp.h,v 1.15 2001/12/05 10:24:31 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -162,7 +162,7 @@ NAME(line)(GLcontext *ctx, const SWvertex *v0, const SWvertex *v1) line.len = (GLfloat) sqrt(line.dx * line.dx + line.dy * line.dy); line.halfWidth = 0.5F * ctx->Line.Width; - if (line.len == 0.0) + if (line.len == 0.0 || IS_INF_OR_NAN(line.len)) return; line.xAdj = line.dx / line.len * line.halfWidth; diff --git a/src/mesa/swrast/s_aatritemp.h b/src/mesa/swrast/s_aatritemp.h index 69f1028..dac2111 100644 --- a/src/mesa/swrast/s_aatritemp.h +++ b/src/mesa/swrast/s_aatritemp.h @@ -1,4 +1,4 @@ -/* $Id: s_aatritemp.h,v 1.21 2001/09/19 20:30:44 kschultz Exp $ */ +/* $Id: s_aatritemp.h,v 1.22 2001/12/05 10:24:31 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -149,7 +149,7 @@ const GLfloat area = majDx * botDy - botDx * majDy; ltor = (GLboolean) (area < 0.0F); /* Do backface culling */ - if (area * bf < 0 || area * area < .0025) + if (area * bf < 0 || area == 0 || IS_INF_OR_NAN(area)) return; } diff --git a/src/mesa/swrast/s_linetemp.h b/src/mesa/swrast/s_linetemp.h index 0635694..a305a45 100644 --- a/src/mesa/swrast/s_linetemp.h +++ b/src/mesa/swrast/s_linetemp.h @@ -1,4 +1,4 @@ -/* $Id: s_linetemp.h,v 1.9 2001/07/13 20:07:37 brianp Exp $ */ +/* $Id: s_linetemp.h,v 1.10 2001/12/05 10:24:31 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -180,6 +180,13 @@ } #endif + /* Cull primitives with malformed coordinates. + */ + { + float tmp = vert0->win[0] + vert0->win[1] + vert1->win[0] + vert1->win[1]; + if (IS_INF_OR_NAN(tmp)) + return; + } /* * Despite being clipped to the view volume, the line's window coordinates diff --git a/src/mesa/swrast/s_pointtemp.h b/src/mesa/swrast/s_pointtemp.h index 482f42b..4c843b3 100644 --- a/src/mesa/swrast/s_pointtemp.h +++ b/src/mesa/swrast/s_pointtemp.h @@ -1,4 +1,4 @@ -/* $Id: s_pointtemp.h,v 1.10 2001/09/19 20:30:44 kschultz Exp $ */ +/* $Id: s_pointtemp.h,v 1.11 2001/12/05 10:24:31 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -119,6 +119,14 @@ NAME ( GLcontext *ctx, const SWvertex *vert ) size = ctx->Point._Size; #endif + /* Cull primitives with malformed coordinates. + */ + { + float tmp = vert->win[0] + vert->win[1]; + if (IS_INF_OR_NAN(tmp)) + return; + } + #if FLAGS & SPRITE { SWcontext *swctx = SWRAST_CONTEXT(ctx); diff --git a/src/mesa/swrast/s_tritemp.h b/src/mesa/swrast/s_tritemp.h index 5c9d79d..4940dab 100644 --- a/src/mesa/swrast/s_tritemp.h +++ b/src/mesa/swrast/s_tritemp.h @@ -1,4 +1,4 @@ -/* $Id: s_tritemp.h,v 1.27 2001/09/19 20:30:44 kschultz Exp $ */ +/* $Id: s_tritemp.h,v 1.28 2001/12/05 10:24:31 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -199,7 +199,7 @@ if (area * bf < 0.0) return; - if (area == 0.0F) + if (area == 0.0F || IS_INF_OR_NAN(area)) return; oneOverArea = 1.0F / area; -- 2.7.4