[Piglit] [PATCH] texwrap: fix stencil texturing a bit

sroland at vmware.com sroland at vmware.com
Tue Dec 15 20:38:32 PST 2015


From: Roland Scheidegger <sroland at vmware.com>

Previously, the test was actually using all-zeros in the end for the image,
so unsurprisingly it passed, except when border color was used.
Add the special stencil case handling in a couple more cases.
This will still not test depth/stencil textures in stencil texturing mode, and
furthermore because the spec doesn't seem to say what should happen with all
the channels make it ignore all errors on non-first channel.
---
 tests/texturing/texwrap.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/tests/texturing/texwrap.c b/tests/texturing/texwrap.c
index ffe5e83..e10e6ec 100644
--- a/tests/texturing/texwrap.c
+++ b/tests/texturing/texwrap.c
@@ -724,6 +724,10 @@ static void sample_nearest(int x, int y, int z,
 				image[(coords[2]*size_y*size_x +
 				       coords[1]*size_x + coords[0])];
 		result[3] = 1;
+	} else if (format->stencil) {
+		result[0] = result[1] = result[2] = result[3] =
+				image[(coords[2]*size_y*size_x +
+				       coords[1]*size_x + coords[0])];
 	} else {
 		memcpy(result,
 		       &image[(coords[2]*size_y*size_x +
@@ -1021,6 +1025,16 @@ static GLboolean probe_pixels(const struct format_desc *format, GLboolean npot,
 			for (j = 0; j < 4; j++) {
 				deltamax[j] = deltamax_lut[format->intensity];
 			}
+		} else if (format->stencil && !format->depth) {
+			deltamax[0] = deltamax_lut[format->stencil];
+			/*
+			 * XXX unless someone can figure out what the hell all
+			 * those channels should actually return... Right now
+			 * the test would expect the same value for all channels.
+			 */
+			for (j = 1; j < 4; j++) {
+				deltamax[j] = 255;
+			}
 		} else {
 			if (format->luminance) {
 				for (j = 0; j < 3; j++) {
@@ -1427,7 +1441,7 @@ static void init_int_texture(const struct format_desc *format,
 	black = colors[5];
 
 	/* Set the colors to match the base format. */
-	if (format->intensity) {
+	if (format->intensity || format->stencil) {
 		for (i = 0; i < 7; i++) {
 			colors[i][3] = colors[i][2] = colors[i][1] = colors[i][0];
 		}
-- 
2.1.4



More information about the Piglit mailing list