[Piglit] [PATCH] textureGather: add new options for testing mirror address modes

sroland at vmware.com sroland at vmware.com
Sun Dec 10 04:48:50 UTC 2017


From: Roland Scheidegger <sroland at vmware.com>

The existing repeat and clamp modes are easy to implement. The
mirror_repeat (GL_MIRRORED_REPEAT) and mirror_clamp
(GL_MIRROR_CLAMP_TO_EDGE) modes however have some very interesting
differences to "gather is just the same as bilinear filtering without
the actual filtering". In particular, a bilinear filter implementation
can cut a lot of corners wrt texel selection as it doesn't need to
maintain texel order (as long as the weights follow the same order) and
can even pick different samples (as long as they have weight 0).
So, test these modes too. I used this for fixing llvmpipe, passes with
nvidia blob too (the test actually always hits exactly the cases where
one texel would have weight 0).
---
 tests/texturing/shaders/textureGather.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/tests/texturing/shaders/textureGather.c b/tests/texturing/shaders/textureGather.c
index f364c5c..8ea94b6 100644
--- a/tests/texturing/shaders/textureGather.c
+++ b/tests/texturing/shaders/textureGather.c
@@ -135,6 +135,23 @@ pixel_value(int i, int j, int offset_sel)
 		if (i > texture_width - 1) i = texture_width - 1;
 		if (j > texture_height - 1) j = texture_height - 1;
 	}
+	else if (address_mode == GL_MIRRORED_REPEAT) {
+		bool isOdd;
+		if (i < 0) i = -i - 1;
+		isOdd = (i / texture_width) & 1;
+		i = i % texture_width;
+		if (isOdd) i = texture_width - i - 1;
+		if (j < 0) j = -j - 1;
+		isOdd = (j / texture_height) & 1;
+		j = j % texture_height;
+		if (isOdd) j = texture_height - j - 1;
+	}
+	else if (address_mode == GL_MIRROR_CLAMP_TO_EDGE) {
+		if (i < 0) i = -i - 1;
+		if (j < 0) j = -j - 1;
+		if (i > texture_width - 1) i = texture_width - 1;
+		if (j > texture_height - 1) j = texture_height - 1;
+	}
 
 	return i + j * texture_width;
 }
@@ -555,7 +572,7 @@ fail_with_usage(void)
 	       "	comptype = unorm|float|uint|int|shadow\n"
 	       "	sampler = 2D|2DArray|Cube|CubeArray|2DRect\n"
 	       "	compselect = 0|1|2|3\n"
-	       "	addressmode = repeat|clamp\n");
+	       "	addressmode = repeat|clamp|mirror_repeat|mirror_clamp\n");
 	piglit_report_result(PIGLIT_SKIP);
 }
 
@@ -596,6 +613,8 @@ piglit_init(int argc, char **argv)
 		else if (!strcmp(opt, "3")) comp_select = 3;
 		else if (!strcmp(opt, "repeat")) address_mode = GL_REPEAT;
 		else if (!strcmp(opt, "clamp")) address_mode = GL_CLAMP_TO_EDGE;
+		else if (!strcmp(opt, "mirror_repeat")) address_mode = GL_MIRRORED_REPEAT;
+		else if (!strcmp(opt, "mirror_clamp")) address_mode = GL_MIRROR_CLAMP_TO_EDGE;
 	}
 
 	if (stage == NOSTAGE) fail_with_usage();
-- 
2.7.4



More information about the Piglit mailing list