[Piglit] [PATCH] isinf-and-isnan: add clamp / min / max tests
sroland at vmware.com
sroland at vmware.com
Thu Nov 9 18:11:22 UTC 2017
From: Roland Scheidegger <sroland at vmware.com>
We expect non-nan results for these (according to d3d10 rules, and at least
for min/max, also according to ieee rules). The tests will not actually fail
with other results (since GL's NaN behavior is all undefined), albeit some
apps may rely on this.
(We'll use clamp to 0/1 on purpose, which may get optimized to a saturate
modifier on some hw, and ideally we'd see a non-nan result there too. The
expected result there is really zero (d3d10 would require this), so if
it gets decomposed into min/max combo the order is actually important.)
On r600, right now all 3 give undesired (NaN) results (pending fixes),
albeit all legal.
---
tests/spec/glsl-1.30/execution/isinf-and-isnan.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/tests/spec/glsl-1.30/execution/isinf-and-isnan.c b/tests/spec/glsl-1.30/execution/isinf-and-isnan.c
index 099b5c2..77a7591 100644
--- a/tests/spec/glsl-1.30/execution/isinf-and-isnan.c
+++ b/tests/spec/glsl-1.30/execution/isinf-and-isnan.c
@@ -340,6 +340,7 @@ enum behavior
B_FINITE = 1, /* Expected to evaluate to a finite value */
B_POSINF = 2, /* Expected to evaluate to +Infinity */
B_NEGINF = 3, /* Expected to evaluate to -Infinity */
+ B_FINITE_NANOK = 4, /* Expected finite value, but NaN ok */
};
struct expression_table_element
@@ -369,6 +370,10 @@ static struct expression_table_element expressions[] = {
{ "log(-1.0+z)", B_NAN },
{ "sqrt(-1.0)", B_NAN },
{ "sqrt(-1.0+z)", B_NAN },
+ { "clamp(u_nan, 0.0, 1.0)", B_FINITE_NANOK },
+ { "min(u_two, u_nan)", B_FINITE_NANOK },
+ { "max(u_two, u_nan)", B_FINITE_NANOK },
+
};
/**
@@ -446,6 +451,7 @@ test_expr(char *expression, int expected_behavior)
"uniform float u_inf;\n" /* Always == +infinity */
"uniform float u_minus_inf;\n" /* Always == -infinity */
"uniform float u_nan;\n" /* Always == NaN */
+ "uniform float u_two = 2.0;\n" /* To defeat constant folding */
"float compute_value() {\n"
" return %s;\n"
"}\n",
@@ -523,6 +529,9 @@ test_expr(char *expression, int expected_behavior)
pass = false;
}
break;
+ case B_FINITE_NANOK:
+ expected_behavior_string = "finite";
+ break;
default:
expected_behavior_string = "NaN";
break;
--
2.7.4
More information about the Piglit
mailing list