rendercheck: 3 commits - doc/AddingNewTests doc/TODO main.c Makefile.am README rendercheck.1 rendercheck.h tests.c TODO t_repeat.c

Eric Anholt anholt at kemper.freedesktop.org
Thu Apr 20 22:47:08 EEST 2006


 Makefile.am        |    4 +
 README             |    2 
 doc/AddingNewTests |    9 +++
 main.c             |    4 +
 rendercheck.1      |    4 -
 rendercheck.h      |    7 ++
 t_repeat.c         |  150 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests.c            |   38 +++++++++++++
 8 files changed, 214 insertions(+), 4 deletions(-)

New commits:
diff-tree 6cfab618fabcc5c4fc86aaeadcd8e6d9255cb6eb (from c862f6285b868435a2780b07a602f57e810e1f96)
Author: Eric Anholt <anholt at FreeBSD.org>
Date:   Thu Apr 20 12:41:29 2006 -0700

    Correct offsets for argb32* convenience colors, so the right colors are used in
    the repeat test.

diff --git a/tests.c b/tests.c
index 0ba80f3..4b3c87f 100644
--- a/tests.c
+++ b/tests.c
@@ -260,10 +260,10 @@ begin_test(Display *dpy, picture_info *w
 		pictures_1x1[i].color = *c;
 		color_correct(&pictures_1x1[i], &pictures_1x1[i].color);
 	}
-	argb32white = &pictures_1x1[0];
-	argb32red = &pictures_1x1[1];
-	argb32green = &pictures_1x1[2];
-	argb32blue = &pictures_1x1[3];
+	argb32white = &pictures_1x1[0 * num_formats];
+	argb32red = &pictures_1x1[1 * num_formats];
+	argb32green = &pictures_1x1[2 * num_formats];
+	argb32blue = &pictures_1x1[3 * num_formats];
 
 	pictures_10x10 = (picture_info *)malloc(num_colors * num_formats *
 	    sizeof(picture_info));
diff-tree c862f6285b868435a2780b07a602f57e810e1f96 (from b26a0acd18aac615a2abc4df5adc888cb3e3714b)
Author: Eric Anholt <anholt at FreeBSD.org>
Date:   Thu Apr 20 12:33:25 2006 -0700

    Add a short doc on the things to do when adding a new test.  Move TODO into the
    doc dir as well.  Also, update README for the new tests.

diff --git a/Makefile.am b/Makefile.am
index fc0d54d..9e2585f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -23,6 +23,7 @@ EXTRA_DIST = \
 	COPYING \
 	INSTALL \
 	README \
-	TODO \
+	doc/AddingNewTests \
+	doc/TODO \
 	autogen.sh \
 	${man_MANS}
diff --git a/README b/README
index 1643001..5e49fcd 100644
--- a/README
+++ b/README
@@ -7,3 +7,5 @@ Tests currently include:
 - Transformed (FilterNearest) source coordinates correctness.
 - Composite with and without mask (with/without component alpha), with 1x1
   repeating Pictures and 10x10 Pictures.
+- Linear gradients
+- Repeating sources/masks at POT and non-POT sizes
diff --git a/TODO b/TODO
deleted file mode 100644
index e4e68cc..0000000
--- a/TODO
+++ /dev/null
@@ -1,10 +0,0 @@
-- Check bilinear filtering
-- Check repeating transformed sources
-- Check coordinates for more different transformations
-- Get a useful number being produced for error values, and correct eval_diff's
-  limit.
-- Check source/mask pixels falling outside the drawable.
-- Command line args for what tests, move iter, etc.
-- Check repeating of sources with various sizes.
-- Check trapezoids!
-- get_pixel equivalent that doesn't involve round-trips per call.
diff --git a/doc/AddingNewTests b/doc/AddingNewTests
new file mode 100644
index 0000000..08db332
--- /dev/null
+++ b/doc/AddingNewTests
@@ -0,0 +1,9 @@
+- Add your test to rendercheck.h TEST_*
+- Add command line option to main.c case 't'.
+- Add command line option to main.c usage()
+- Add your test loop to the bottom of begin_test().  Looping on ops and dests is
+  highly recommended.
+- Write your test in t_testname.c and add to Makefile.am, with prototype in
+  rendercheck.h
+- Add a note about your test to README
+- Be sure to include your MIT license boilerplate on the new file.
diff --git a/doc/TODO b/doc/TODO
new file mode 100644
index 0000000..e4e68cc
--- /dev/null
+++ b/doc/TODO
@@ -0,0 +1,10 @@
+- Check bilinear filtering
+- Check repeating transformed sources
+- Check coordinates for more different transformations
+- Get a useful number being produced for error values, and correct eval_diff's
+  limit.
+- Check source/mask pixels falling outside the drawable.
+- Command line args for what tests, move iter, etc.
+- Check repeating of sources with various sizes.
+- Check trapezoids!
+- get_pixel equivalent that doesn't involve round-trips per call.
diff-tree b26a0acd18aac615a2abc4df5adc888cb3e3714b (from e5e49a6b67e2e2919d5236583f01088fdecf347b)
Author: Eric Anholt <anholt at FreeBSD.org>
Date:   Thu Apr 20 12:27:17 2006 -0700

    Add a test for various-sized repeating sources.  Reveals issues with EXA Radeon
    render acceleration.  Thanks to frederikh for the testcase that suggested the
    necessity here.

diff --git a/Makefile.am b/Makefile.am
index 41e0957..fc0d54d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -10,6 +10,7 @@ rendercheck_SOURCES = \
 	t_composite.c \
 	t_dstcoords.c \
 	t_fill.c \
+	t_repeat.c \
 	t_srccoords.c \
 	t_tsrccoords.c \
 	t_gradient.c
diff --git a/main.c b/main.c
index 6d25e6a..8c4de3f 100644
--- a/main.c
+++ b/main.c
@@ -108,7 +108,7 @@ usage (char *program)
     fprintf(stderr, "usage: %s [-d|--display display] [-v|--verbose]\n"
 	"\t[-t test1,test2,...] [--sync]\n"
             "\tAvailable tests: dcoors,scoords,mcoords,tscoords,\n"
-            "\t\ttmcoords,blend,composite,cacomposite,gradients\n",
+            "\t\ttmcoords,blend,composite,cacomposite,gradients,repeat\n",
 	program);
     exit(1);
 }
@@ -169,6 +169,8 @@ int main(int argc, char **argv)
 					enabled_tests |= TEST_CACOMPOSITE;
 				} else if (strcmp(test, "gradients") == 0) {
 					enabled_tests |= TEST_GRADIENTS;
+				} else if (strcmp(test, "repeat") == 0) {
+					enabled_tests |= TEST_REPEAT;
 				} else {
 					usage(argv[0]);
 				}
diff --git a/rendercheck.1 b/rendercheck.1
index d89f358..de502a4 100644
--- a/rendercheck.1
+++ b/rendercheck.1
@@ -28,8 +28,8 @@ Enables synchronous xlib operation, for 
 .BI \-t|\-\-tests\ test1,test2,test3...
 Enables only a specific subset of the possible tests.  Test names include 
 fill, dcoords, scoords, mcoords, tscoords, tmcoords, blend, composite,
-cacomposite, and gradients.  Names must be separated by commas and have no
-spaces.
+cacomposite, gradients, and repeat.  Names must be separated by commas and have
+no spaces.
 .TP
 .BI \-v|\-\-verbose
 Enables verbose printing of information on tests run, and successes and
diff --git a/rendercheck.h b/rendercheck.h
index 89590ac..648ef9e 100644
--- a/rendercheck.h
+++ b/rendercheck.h
@@ -58,6 +58,7 @@ struct op_info {
 #define TEST_COMPOSITE		0x0080
 #define TEST_CACOMPOSITE	0x0100
 #define TEST_GRADIENTS  	0x0200
+#define TEST_REPEAT	  	0x0400
 
 extern int pixmap_move_iter;
 extern int win_width, win_height;
@@ -65,6 +66,7 @@ extern struct op_info ops[];
 extern Bool is_verbose;
 extern color4d colors[];
 extern int enabled_tests;
+extern picture_info *argb32white, *argb32red, *argb32green, *argb32blue;
 
 /* main.c */
 void
@@ -120,3 +122,8 @@ trans_coords_test(Display *dpy, picture_
 
 Bool linear_gradient_test(Display *dpy, picture_info *win,
                           picture_info *dst, int op, picture_info *dst_color);
+
+Bool
+repeat_test(Display *dpy, picture_info *win, picture_info *dst, int op,
+    picture_info *dst_color, picture_info *c1, picture_info *c2,
+    Bool test_mask);
diff --git a/t_repeat.c b/t_repeat.c
new file mode 100644
index 0000000..5b65968
--- /dev/null
+++ b/t_repeat.c
@@ -0,0 +1,150 @@
+/*
+ * Copyright © 2006 Eric Anholt
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ * Authors:
+ *    Eric Anholt <anholt at FreeBSD.org>
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "rendercheck.h"
+
+/* We choose some sizes larger than win_width/height because AAs like to turn
+ * off repeating when it's unnecessary and we want to make sure that those paths
+ * are sane.
+ */
+static const int sizes[] = {1, 2, 4, 8, 10, 16, 20, 32, 64, 100};
+
+/* Sets up a repeating picture at various sizes, with the upper-left corner
+ * filled with a different color than the rest.  It tiles this over the whole
+ * destination, then samples the result to see if it tiled appropriately.  If
+ * test_mask is set, the repeating picture is used as a component-alpha mask,
+ * with argb32white as the source.
+ */
+Bool
+repeat_test(Display *dpy, picture_info *win, picture_info *dst, int op,
+    picture_info *dst_color, picture_info *c1, picture_info *c2, Bool test_mask)
+{
+	int wi, hi;
+	Bool failed = FALSE;
+
+	for (wi = 0; wi < sizeof(sizes) / sizeof(int); wi++) {
+	    int w = sizes[wi];
+	    for (hi = 0; hi < sizeof(sizes) / sizeof(int); hi++) {
+		picture_info src;
+		int h = sizes[hi];
+		int c2w = w / 2;
+		int c2h = h / 2;
+		int x, y, i;
+		char name[40];
+		color4d tdst, c1expected, c2expected;
+		XRenderPictureAttributes pa;
+
+		pa.component_alpha = test_mask;
+		pa.repeat = TRUE;
+
+		src.d = XCreatePixmap(dpy, RootWindow(dpy, 0), w, h, 32);
+		src.format = XRenderFindStandardFormat(dpy, PictStandardARGB32);
+		src.pict = XRenderCreatePicture(dpy, src.d, src.format,
+		    CPComponentAlpha | CPRepeat, &pa);
+		src.name = "repeat picture";
+
+		/* Fill to the first color */
+		XRenderComposite(dpy, PictOpSrc, c1->pict, None, src.pict,
+		    0, 0, 0, 0, 0, 0, w, h);
+		/* And set the upper-left to the second color */
+		XRenderComposite(dpy, PictOpSrc, c2->pict, None, src.pict,
+		    0, 0, 0, 0, 0, 0, c2w, c2h);
+
+		for (i = 0; i < pixmap_move_iter; i++) {
+			/* Fill to dst_color */
+			XRenderComposite(dpy, PictOpSrc, dst_color->pict, None,
+			    dst->pict, 0, 0, 0, 0, 0, 0, win_width, win_height);
+ 			/* Composite the repeat picture in. */
+			if (!test_mask) {
+				XRenderComposite(dpy, ops[op].op,
+				    src.pict, None, dst->pict, 0, 0, 0, 0, 0, 0,
+				    win_width, win_height);
+			} else {
+				/* Using PictOpSrc, color 0 (white), and
+				 * component alpha, the mask color should be
+				 * written to the destination.
+				 */
+				XRenderComposite(dpy, ops[op].op,
+				    argb32white->pict, src.pict, dst->pict,
+				    0, 0, 0, 0, 0, 0, win_width, win_height);
+			}
+		}
+		/* Copy the output to the window, so the user sees something
+		 * visual.
+		 */
+		if (win != dst) {
+			XRenderComposite(dpy, PictOpSrc,
+					 dst->pict, None, win->pict,
+					 0, 0, 0, 0, 0, 0,
+					 win_width, win_height);
+		}
+		tdst = dst_color->color;
+		color_correct(dst, &tdst);
+
+		if (!test_mask) {
+			do_composite(ops[op].op, &c1->color, NULL, &tdst,
+			    &c1expected, FALSE);
+			do_composite(ops[op].op, &c2->color, NULL, &tdst,
+			    &c2expected, FALSE);
+		} else {
+			do_composite(ops[op].op, &argb32white->color,
+			    &c1->color, &tdst, &c1expected, TRUE);
+			do_composite(ops[op].op, &argb32white->color,
+			    &c2->color, &tdst, &c2expected, TRUE);
+		}
+		color_correct(dst, &c1expected);
+		color_correct(dst, &c2expected);
+
+		snprintf(name, 40, "%dx%d %s %s-repeat", w, h,
+		    ops[op].name, test_mask ? "mask" : "src");
+		for (x = 0; x < win_width; x++) {
+		    for (y = 0; y < win_height; y++) {
+			int samplex = x % w;
+			int sampley = y % h;
+			color4d *expected, tested;
+
+			if (samplex < c2w && sampley < c2h) {
+				expected = &c2expected;
+			} else {
+				expected = &c1expected;
+			}
+			get_pixel(dpy, dst, x, y, &tested);
+
+			if (!eval_diff(name, expected, &tested, x, y,
+			    is_verbose))
+				failed = TRUE;
+		    }
+		}
+		XRenderFreePicture(dpy, src.pict);
+		XFreePixmap(dpy, src.d);
+	    }
+	}
+	return !failed;
+}
diff --git a/tests.c b/tests.c
index 07a5d0a..0ba80f3 100644
--- a/tests.c
+++ b/tests.c
@@ -28,6 +28,9 @@
 
 #include "rendercheck.h"
 
+/* Note: changing the order of these colors may disrupt tests that depend on
+ * specific colors.  Just add to the end if you need.
+ */
 color4d colors[] = {
 	{1.0, 1.0, 1.0, 1.0},
 	{1.0, 0, 0, 1.0},
@@ -39,6 +42,9 @@ color4d colors[] = {
 	{0.0, .5, 1.0, 0}
 };
 
+/* Convenience pointers to 1x1 repeating colors */
+picture_info *argb32white, *argb32red, *argb32green, *argb32blue;
+
 int num_colors = sizeof(colors) / sizeof(colors[0]);
 
 struct op_info ops[] = {
@@ -254,6 +260,10 @@ begin_test(Display *dpy, picture_info *w
 		pictures_1x1[i].color = *c;
 		color_correct(&pictures_1x1[i], &pictures_1x1[i].color);
 	}
+	argb32white = &pictures_1x1[0];
+	argb32red = &pictures_1x1[1];
+	argb32green = &pictures_1x1[2];
+	argb32blue = &pictures_1x1[3];
 
 	pictures_10x10 = (picture_info *)malloc(num_colors * num_formats *
 	    sizeof(picture_info));
@@ -479,4 +489,32 @@ begin_test(Display *dpy, picture_info *w
                 }
             }
         }
+
+        if (enabled_tests & TEST_REPEAT) {
+            for (i = 0; i < num_ops; i++) {
+                for (j = 0; j <= num_dests; j++) {
+                    picture_info *pi;
+                    
+                    if (j != num_dests)
+                        pi = &dests[j];
+                    else
+                        pi = win;
+                    printf("Beginning %s src repeat test on %s\n",
+                           ops[i].name, pi->name);
+		    /* Test with white dest, and generated repeating src
+		     * consisting of colors 1 and 2 (r, g).
+		     */
+		    repeat_test(dpy, win, pi, i, argb32white, argb32red,
+		        argb32green, FALSE);
+
+                    printf("Beginning %s mask repeat test on %s\n",
+                           ops[i].name, pi->name);
+		    /* Test with white dest, translucent red src, and generated
+		     * repeating mask consisting of colors 1 and 2 (r, g).
+		     */
+		    repeat_test(dpy, win, pi, i, argb32white, argb32red,
+		        argb32green, TRUE);
+                }
+            }
+        }
 }



More information about the xorg-commit mailing list