[Piglit] [PATCH] arb_texture_query_lod: allow some tolerance for comparisons
Marek Olšák
maraeo at gmail.com
Tue Jun 17 12:49:16 PDT 2014
From: Marek Olšák <marek.olsak at amd.com>
This is required for radeonsi to pass.
---
.../execution/fs-textureQueryLOD-linear.shader_test | 9 +++++++--
.../execution/fs-textureQueryLOD-nearest.shader_test | 6 +++++-
.../execution/fs-textureQueryLOD-no-mipmap.shader_test | 6 +++++-
3 files changed, 17 insertions(+), 4 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 4438951..6afef71 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
@@ -46,11 +46,16 @@ GL_ARB_texture_query_lod
#extension GL_ARB_texture_query_lod : enable
uniform sampler2D tex;
uniform float lod;
+
+#define tolerance (1.0/255.0)
+#define equal_v4(x,y) all(lessThanEqual(abs((x) - (y)), vec4(tolerance)))
+#define equal(x,y) (abs((x) - (y)) <= tolerance)
+
void main()
{
vec4 frag1 = texture(tex, gl_TexCoord[0].st);
vec4 frag2 = textureLod(tex, gl_TexCoord[0].st, lod);
- if (frag1 != frag2) {
+ if (!equal_v4(frag1, frag2)) {
discard;
}
@@ -58,7 +63,7 @@ void main()
if (queried_lod.x != queried_lod.y) {
discard;
}
- if (queried_lod.x != lod) {
+ if (!equal(queried_lod.x, lod)) {
discard;
}
diff --git a/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-nearest.shader_test b/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-nearest.shader_test
index 2c1b62c..a9df764 100644
--- a/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-nearest.shader_test
+++ b/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-nearest.shader_test
@@ -46,6 +46,10 @@ GL_ARB_texture_query_lod
#extension GL_ARB_texture_query_lod : enable
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
@@ -64,7 +68,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 (queried_lod.x != nearest_lod) {
diff --git a/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-no-mipmap.shader_test b/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-no-mipmap.shader_test
index 5f67262..035e2d5 100644
--- a/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-no-mipmap.shader_test
+++ b/tests/spec/arb_texture_query_lod/execution/fs-textureQueryLOD-no-mipmap.shader_test
@@ -51,9 +51,13 @@ GL_ARB_texture_query_lod
#extension GL_ARB_texture_query_lod : enable
uniform sampler2D tex;
uniform float lambda_prime;
+
+#define tolerance (1.0/255.0)
+#define equal_v2(x,y) all(lessThanEqual(abs((x) - (y)), vec2(tolerance)))
+
void main()
{
- if (textureQueryLOD(tex, gl_TexCoord[0].st) != vec2(0.0f, lambda_prime)) {
+ if (!equal_v2(textureQueryLOD(tex, gl_TexCoord[0].st), vec2(0.0f, lambda_prime))) {
discard;
}
--
1.9.1
More information about the Piglit
mailing list