[Piglit] [PATCH] arb_texture_query_lod: add tolerance for some comparisons

sroland at vmware.com sroland at vmware.com
Sat Sep 9 05:31:57 UTC 2017


From: Roland Scheidegger <sroland at vmware.com>

Tolerance was added for the tests a while ago, but it looks like it was
forgotten for the nearest_biased test (the nearest one has it).
Also, for the linear test, add tolerance too when comparing x and y lodq
results - the values should probably be the same mostly, however it's possible
(due to interpolation inaccuracies) to get values just below 0 or above 3, in
which case they will get clamped. (Could just do a clamp instead of allowing
tolerance I suppose, but some tolerance might be allowed in any case there
too.)

This is required for llvmpipe (with a in-progress change) to pass.
---
 .../execution/fs-textureQueryLOD-linear.shader_test                 | 2 +-
 .../execution/fs-textureQueryLOD-nearest-biased.shader_test         | 6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-linear.shader_test b/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-linear.shader_test
index 6afef71..bb2d8ba 100644
--- a/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-linear.shader_test
+++ b/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-linear.shader_test
@@ -60,7 +60,7 @@ void main()
     }
 
     vec2 queried_lod = textureQueryLOD(tex, gl_TexCoord[0].st);
-    if (queried_lod.x != queried_lod.y) {
+    if (!equal(queried_lod.x, queried_lod.y)) {
 	discard;
     }
     if (!equal(queried_lod.x, lod)) {
diff --git a/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-nearest-biased.shader_test b/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-nearest-biased.shader_test
index 1e0c557..4487930 100644
--- a/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-nearest-biased.shader_test
+++ b/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-nearest-biased.shader_test
@@ -51,6 +51,10 @@ GL_ARB_texture_query_lod
 #define MAX_MIPMAP_LEVEL 3
 uniform sampler2D tex;
 uniform float lod;
+
+#define tolerance (1.0/255.0)
+#define equal(x,y) (abs((x) - (y)) <= tolerance)
+
 void main()
 {
     /* The ARB_texture_query_lod spec says that if TEXTURE_MIN_FILTER is set
@@ -69,7 +73,7 @@ void main()
     }
 
     vec2 queried_lod = textureQueryLOD(tex, gl_TexCoord[0].st);
-    if (queried_lod.x != min(queried_lod.y, MAX_MIPMAP_LEVEL)) {
+    if (!equal(queried_lod.x, min(queried_lod.y, MAX_MIPMAP_LEVEL))) {
 	discard;
     }
     if (queried_lod.x != min(nearest_lod + 1, MAX_MIPMAP_LEVEL)) {
-- 
2.7.4



More information about the Piglit mailing list