From: Dylan Baker Date: Mon, 10 Sep 2018 18:31:49 +0000 (-0700) Subject: Replace IS_INF_OR_NAN with util_is_inf_or_nan X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9ee6e78a8716eed09a088dad2d6153373423a565;p=mesa.git Replace IS_INF_OR_NAN with util_is_inf_or_nan Reviewed-by: Marek Olšák Reviewed-by: Kristian H. Kristensen Reviewed-by: Matt Turner Part-of: --- diff --git a/src/mesa/main/draw.c b/src/mesa/main/draw.c index a33862f517b..253e2fdbee7 100644 --- a/src/mesa/main/draw.c +++ b/src/mesa/main/draw.c @@ -82,7 +82,7 @@ check_array_data(struct gl_context *ctx, struct gl_vertex_array_object *vao, GLfloat *f = (GLfloat *) ((GLubyte *) data + binding->Stride * j); GLint k; for (k = 0; k < array->Format.Size; k++) { - if (IS_INF_OR_NAN(f[k]) || f[k] >= 1.0e20F || f[k] <= -1.0e10F) { + if (util_is_inf_or_nan(f[k]) || f[k] >= 1.0e20F || f[k] <= -1.0e10F) { printf("Bad array data:\n"); printf(" Element[%u].%u = %f\n", j, k, f[k]); printf(" Array %u at %p\n", attrib, (void *) array); @@ -93,7 +93,7 @@ check_array_data(struct gl_context *ctx, struct gl_vertex_array_object *vao, array->Ptr, bo ? bo->Name : 0); f[k] = 1.0F; /* XXX replace the bad value! */ } - /*assert(!IS_INF_OR_NAN(f[k])); */ + /*assert(!util_is_inf_or_nan(f[k])); */ } } break; diff --git a/src/mesa/program/prog_execute.c b/src/mesa/program/prog_execute.c index 6ada78565cc..956b84a20d6 100644 --- a/src/mesa/program/prog_execute.c +++ b/src/mesa/program/prog_execute.c @@ -213,10 +213,10 @@ fetch_vector4(const struct prog_src_register *source, } #ifdef NAN_CHECK - assert(!IS_INF_OR_NAN(result[0])); - assert(!IS_INF_OR_NAN(result[0])); - assert(!IS_INF_OR_NAN(result[0])); - assert(!IS_INF_OR_NAN(result[0])); + assert(!util_is_inf_or_nan(result[0])); + assert(!util_is_inf_or_nan(result[0])); + assert(!util_is_inf_or_nan(result[0])); + assert(!util_is_inf_or_nan(result[0])); #endif } @@ -332,9 +332,9 @@ store_vector4(const struct prog_instruction *inst, #if 0 if (value[0] > 1.0e10 || - IS_INF_OR_NAN(value[0]) || - IS_INF_OR_NAN(value[1]) || - IS_INF_OR_NAN(value[2]) || IS_INF_OR_NAN(value[3])) + util_is_inf_or_nan(value[0]) || + util_is_inf_or_nan(value[1]) || + util_is_inf_or_nan(value[2]) || util_is_inf_or_nan(value[3])) printf("store %g %g %g %g\n", value[0], value[1], value[2], value[3]); #endif @@ -347,10 +347,10 @@ store_vector4(const struct prog_instruction *inst, } #ifdef NAN_CHECK - assert(!IS_INF_OR_NAN(value[0])); - assert(!IS_INF_OR_NAN(value[0])); - assert(!IS_INF_OR_NAN(value[0])); - assert(!IS_INF_OR_NAN(value[0])); + assert(!util_is_inf_or_nan(value[0])); + assert(!util_is_inf_or_nan(value[0])); + assert(!util_is_inf_or_nan(value[0])); + assert(!util_is_inf_or_nan(value[0])); #endif if (writeMask & WRITEMASK_X) @@ -614,7 +614,7 @@ _mesa_execute_program(struct gl_context * ctx, fetch_vector1(&inst->SrcReg[0], machine, a); val = exp2f(a[0]); /* - if (IS_INF_OR_NAN(val)) + if (util_is_inf_or_nan(val)) val = 1.0e10; */ result[0] = result[1] = result[2] = result[3] = val; @@ -744,7 +744,7 @@ _mesa_execute_program(struct gl_context * ctx, fetch_vector1(&inst->SrcReg[0], machine, t); abs_t0 = fabsf(t[0]); if (abs_t0 != 0.0F) { - if (IS_INF_OR_NAN(abs_t0)) + if (util_is_inf_or_nan(abs_t0)) { SET_POS_INFINITY(q[0]); q[1] = 1.0F; @@ -931,7 +931,7 @@ _mesa_execute_program(struct gl_context * ctx, if (DEBUG_PROG) { if (a[0] == 0) printf("RCP(0)\n"); - else if (IS_INF_OR_NAN(a[0])) + else if (util_is_inf_or_nan(a[0])) printf("RCP(inf)\n"); } result[0] = result[1] = result[2] = result[3] = 1.0F / a[0]; diff --git a/src/mesa/swrast/s_aalinetemp.h b/src/mesa/swrast/s_aalinetemp.h index 64767a3a564..9997d03753a 100644 --- a/src/mesa/swrast/s_aalinetemp.h +++ b/src/mesa/swrast/s_aalinetemp.h @@ -123,7 +123,7 @@ NAME(line)(struct gl_context *ctx, const SWvertex *v0, const SWvertex *v1) ctx->Const.MinLineWidthAA, ctx->Const.MaxLineWidthAA); - if (line.len == 0.0F || IS_INF_OR_NAN(line.len)) + if (line.len == 0.0F || util_is_inf_or_nan(line.len)) return; INIT_SPAN(line.span, GL_LINE); diff --git a/src/mesa/swrast/s_aatritemp.h b/src/mesa/swrast/s_aatritemp.h index 230dab81633..1de627208a1 100644 --- a/src/mesa/swrast/s_aatritemp.h +++ b/src/mesa/swrast/s_aatritemp.h @@ -103,7 +103,7 @@ const GLfloat botDy = vMid->attrib[VARYING_SLOT_POS][1] - vMin->attrib[VARYING_SLOT_POS][1]; const GLfloat area = majDx * botDy - botDx * majDy; /* Do backface culling */ - if (area * bf < 0 || area == 0 || IS_INF_OR_NAN(area)) + if (area * bf < 0 || area == 0 || util_is_inf_or_nan(area)) return; ltor = (GLboolean) (area < 0.0F); diff --git a/src/mesa/swrast/s_linetemp.h b/src/mesa/swrast/s_linetemp.h index 035a1e6409a..6706ec788b1 100644 --- a/src/mesa/swrast/s_linetemp.h +++ b/src/mesa/swrast/s_linetemp.h @@ -101,7 +101,7 @@ NAME( struct gl_context *ctx, const SWvertex *vert0, const SWvertex *vert1 ) { GLfloat tmp = vert0->attrib[VARYING_SLOT_POS][0] + vert0->attrib[VARYING_SLOT_POS][1] + vert1->attrib[VARYING_SLOT_POS][0] + vert1->attrib[VARYING_SLOT_POS][1]; - if (IS_INF_OR_NAN(tmp)) + if (util_is_inf_or_nan(tmp)) return; } diff --git a/src/mesa/swrast/s_points.c b/src/mesa/swrast/s_points.c index de5cd692170..1c6c239042a 100644 --- a/src/mesa/swrast/s_points.c +++ b/src/mesa/swrast/s_points.c @@ -38,7 +38,7 @@ do { \ float tmp = (V)->attrib[VARYING_SLOT_POS][0] \ + (V)->attrib[VARYING_SLOT_POS][1]; \ - if (IS_INF_OR_NAN(tmp)) \ + if (util_is_inf_or_nan(tmp)) \ return; \ } while(0) diff --git a/src/mesa/swrast/s_tritemp.h b/src/mesa/swrast/s_tritemp.h index 1d71839713c..4dc42a80a72 100644 --- a/src/mesa/swrast/s_tritemp.h +++ b/src/mesa/swrast/s_tritemp.h @@ -90,6 +90,7 @@ * SUB_PIXEL_BITS. */ +#include "util/u_math.h" #ifndef MAX_GLUINT #define MAX_GLUINT 0xffffffffu @@ -239,7 +240,7 @@ static void NAME(struct gl_context *ctx, const SWvertex *v0, { const GLfloat area = eMaj.dx * eBot.dy - eBot.dx * eMaj.dy; - if (IS_INF_OR_NAN(area) || area == 0.0F) + if (util_is_inf_or_nan(area) || area == 0.0F) return; if (area * bf * swrast->_BackfaceCullSign < 0.0F) diff --git a/src/mesa/tnl/t_split_copy.c b/src/mesa/tnl/t_split_copy.c index 87c0020e311..f1d8274766a 100644 --- a/src/mesa/tnl/t_split_copy.c +++ b/src/mesa/tnl/t_split_copy.c @@ -267,7 +267,7 @@ elt(struct copy_context *copy, GLuint elt_idx) GLuint k; GLfloat *f = (GLfloat *) srcptr; for (k = 0; k < srcarray->Size; k++) { - assert(!IS_INF_OR_NAN(f[k])); + assert(!util_is_inf_or_nan(f[k])); assert(f[k] <= 1.0e20 && f[k] >= -1.0e20); } } diff --git a/src/mesa/tnl/t_vb_cliptmp.h b/src/mesa/tnl/t_vb_cliptmp.h index c6546668806..9f2d5161d99 100644 --- a/src/mesa/tnl/t_vb_cliptmp.h +++ b/src/mesa/tnl/t_vb_cliptmp.h @@ -206,10 +206,10 @@ TAG(clip_tri)( struct gl_context *ctx, GLuint v0, GLuint v1, GLuint v2, GLubyte printf(" %u: %u: %f, %f, %f, %f\n", i, j, coord[j][0], coord[j][1], coord[j][2], coord[j][3]); - assert(!IS_INF_OR_NAN(coord[j][0])); - assert(!IS_INF_OR_NAN(coord[j][1])); - assert(!IS_INF_OR_NAN(coord[j][2])); - assert(!IS_INF_OR_NAN(coord[j][3])); + assert(!util_is_inf_or_nan(coord[j][0])); + assert(!util_is_inf_or_nan(coord[j][1])); + assert(!util_is_inf_or_nan(coord[j][2])); + assert(!util_is_inf_or_nan(coord[j][3])); } } diff --git a/src/mesa/tnl/t_vb_program.c b/src/mesa/tnl/t_vb_program.c index 099d37eed72..7a49e393464 100644 --- a/src/mesa/tnl/t_vb_program.c +++ b/src/mesa/tnl/t_vb_program.c @@ -53,7 +53,7 @@ static inline void check_float(float x) { - assert(!IS_INF_OR_NAN(x)); + assert(!util_is_inf_or_nan(x)); assert(1.0e-15 <= x && x <= 1.0e15); } #endif diff --git a/src/util/imports.h b/src/util/imports.h index 9556223b3ba..783423bae81 100644 --- a/src/util/imports.h +++ b/src/util/imports.h @@ -73,28 +73,6 @@ typedef union { float f; int i; unsigned u; } fi_type; /*@}*/ -/** - * finite macro. - */ -#if defined(_MSC_VER) -# define finite _finite -#endif - - -/*** - *** IS_INF_OR_NAN: test if float is infinite or NaN - ***/ -#if defined(isfinite) -#define IS_INF_OR_NAN(x) (!isfinite(x)) -#elif defined(finite) -#define IS_INF_OR_NAN(x) (!finite(x)) -#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -#define IS_INF_OR_NAN(x) (!isfinite(x)) -#else -#define IS_INF_OR_NAN(x) (!finite(x)) -#endif - - /********************************************************************** * Functions */