Skip to contentSkip to conversation

kms_cursor_crc enhancements

PATCH Superseded Antti Koskipaa 2 participants 11 messages Apr 2, 2014

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover kms_cursor_crc enhancements

This patch series enhances the cursor test to actually be useful.

The old "black transparent cursor on black background" tests are replaced with a visible cursor and the framework is changed to be more flexible and extendable. This way cursor rotation tests can be added with ease in the future.

Also adds a couple more tests to the current set.

Antti Koskipaa (7):
kms_cursor_crc: Remove some test cases and change cursor to color
kms_cursor_crc: Move cursor enable and disable calls where they belong
kms_cursor_crc: Use a function pointer to call test
kms_cursor_crc: Separate onscreen and offscreen tests
kms_cursor_crc: Add reference software rendering
kms_cursor_crc: Add moving cursor test
kms_cursor_crc: Add random cursor placement test

 tests/kms_cursor_crc.c | 248 +++++++++++++++++++++++++++----------------------
 1 file changed, 139 insertions(+), 109 deletions(-)
Signature · 1 line
1.8.3.2
#1 lore raw

PATCH 1/7 kms_cursor_crc: Remove some test cases and change cursor to color

Currently this test is quite useless, since it only checks for valid CRCs when the correct output from a test is a completely black screen (invisible or visible but black cursor, or cursor is offscreen) and disables the check when anything visible is onscreen.

This patch changes the cursor to a colorful one and removes the test cases that become redundant because of this change. The cursor is designed to be asymmetrical such that future tests involving rotation, mirroring, etc. produce different CRCs and failures can be detected.

This (temporarily) disables CRC testing until the next patch which will add software rendering of the cursor and the CRC generation.

---
 tests/kms_cursor_crc.c | 75 +++++++++++++++++++++-----------------------------
 1 file changed, 32 insertions(+), 43 deletions(-)
tests/kms_cursor_crc.c +32 -43
index fbb5d88..52281d0 100644
@@ -39,19 +39,11 @@
 #define DRM_CAP_CURSOR_HEIGHT 0x9
 #endif
 
-enum cursor_type {
-	WHITE_VISIBLE,
-	WHITE_INVISIBLE,
-	BLACK_VISIBLE,
-	BLACK_INVISIBLE,
-	NUM_CURSOR_TYPES,
-};
-
 typedef struct {
 	int drm_fd;
 	igt_display_t display;
 	struct igt_fb primary_fb;
-	struct igt_fb fb[NUM_CURSOR_TYPES];
+	struct igt_fb fb;
 	igt_pipe_crc_t **pipe_crc;
 } data_t;
 
@@ -64,6 +56,16 @@ typedef struct {
 	int left, right, top, bottom;
 } test_data_t;
 
+static void draw_cursor(cairo_t *cr, int x, int y, int w)
+{
+	w /= 2;
+	cairo_set_antialias(cr, CAIRO_ANTIALIAS_NONE);
+	/* 4 color rectangles in the corners, RGBY */
+	igt_paint_color_alpha(cr, x, y, w, w, 1.0, 0.0, 0.0, 1.0);
+	igt_paint_color_alpha(cr, x + w, y, w, w, 0.0, 1.0, 0.0, 1.0);
+	igt_paint_color_alpha(cr, x, y + w, w, w, 0.0, 0.0, 1.0, 1.0);
+	igt_paint_color_alpha(cr, x + w, y + w, w, w, 0.5, 0.5, 0.5, 1.0);
+}
 
 static igt_pipe_crc_t *create_crc(data_t *data, enum pipe pipe)
 {
@@ -104,7 +106,7 @@ static void do_test(test_data_t *test_data,
 	do_single_test(test_data, left, bottom);
 }
 
-static void cursor_enable(test_data_t *test_data, enum cursor_type cursor_type)
+static void cursor_enable(test_data_t *test_data)
 {
 	data_t *data = test_data->data;
 	igt_display_t *display = &data->display;
@@ -112,7 +114,7 @@ static void cursor_enable(test_data_t *test_data, enum cursor_type cursor_type)
 	igt_plane_t *cursor;
 
 	cursor = igt_output_get_plane(output, IGT_PLANE_CURSOR);
-	igt_plane_set_fb(cursor, &data->fb[cursor_type]);
+	igt_plane_set_fb(cursor, &data->fb);
 	igt_display_commit(display);
 }
 
@@ -128,7 +130,7 @@ static void cursor_disable(test_data_t *test_data)
 	igt_display_commit(display);
 }
 
-static void test_crc(test_data_t *test_data, enum cursor_type cursor_type,
+static void test_crc(test_data_t *test_data,
 		     bool onscreen, int cursor_w, int cursor_h)
 {
 	int left = test_data->left;
@@ -136,11 +138,11 @@ static void test_crc(test_data_t *test_data, enum cursor_type cursor_type,
 	int top = test_data->top;
 	int bottom = test_data->bottom;
 
-	cursor_enable(test_data, cursor_type);
+	cursor_enable(test_data);
 
 	if (onscreen) {
 		/* cursor onscreen, crc should match, except when white visible cursor is used */
-		test_data->crc_must_match = (cursor_type != WHITE_VISIBLE);
+		test_data->crc_must_match = false;
 
 		/* fully inside  */
 		do_test(test_data, left, right, top, bottom);
@@ -156,7 +158,7 @@ static void test_crc(test_data_t *test_data, enum cursor_type cursor_type,
 		do_test(test_data, left - (cursor_w-1), right + (cursor_w-1), top - (cursor_h-1), bottom + (cursor_h-1));
 	} else {
 		/* cursor offscreen, crc should always match */
-		test_data->crc_must_match = true;
+		test_data->crc_must_match = false;
 
 		/* fully outside */
 		do_test(test_data, left - (cursor_w), right + (cursor_w), top             , bottom             );
@@ -255,8 +257,7 @@ static void cleanup_crtc(test_data_t *test_data, igt_output_t *output)
 	igt_output_set_pipe(output, PIPE_ANY);
 }
 
-static void run_test(data_t *data, enum cursor_type cursor_type, bool onscreen,
-		     int cursor_w, int cursor_h)
+static void run_test(data_t *data, bool onscreen, int cursor_w, int cursor_h)
 {
 	igt_display_t *display = &data->display;
 	igt_output_t *output;
@@ -280,7 +281,7 @@ static void run_test(data_t *data, enum cursor_type cursor_type, bool onscreen,
 				igt_subtest_name(), pipe_name(test_data.pipe),
 				igt_output_name(output));
 
-			test_crc(&test_data, cursor_type, onscreen, cursor_w, cursor_h);
+			test_crc(&test_data, onscreen, cursor_w, cursor_h);
 
 			fprintf(stdout, "\n%s on pipe %c, connector %s: PASSED\n\n",
 				igt_subtest_name(), pipe_name(test_data.pipe),
@@ -294,22 +295,18 @@ static void run_test(data_t *data, enum cursor_type cursor_type, bool onscreen,
 	igt_require_f(valid_tests, "no valid crtc/connector combinations found\n");
 }
 
-static void create_cursor_fb(data_t *data,
-			     enum cursor_type cursor_type,
-			     double r, double g, double b, double a,
-			     int cur_w, int cur_h)
+static void create_cursor_fb(data_t *data, int cur_w, int cur_h)
 {
 	cairo_t *cr;
-	uint32_t fb_id[NUM_CURSOR_TYPES];
+	uint32_t fb_id;
 
-	fb_id[cursor_type] = igt_create_fb(data->drm_fd, cur_w, cur_h,
-					       DRM_FORMAT_ARGB8888, false,
-					       &data->fb[cursor_type]);
-	igt_assert(fb_id[cursor_type]);
+	fb_id = igt_create_fb(data->drm_fd, cur_w, cur_h,
+			      DRM_FORMAT_ARGB8888, false,
+			      &data->fb);
+	igt_assert(fb_id);
 
-	cr = igt_get_cairo_ctx(data->drm_fd,
-				   &data->fb[cursor_type]);
-	igt_paint_color_alpha(cr, 0, 0, cur_w, cur_h, r, g, b, a);
+	cr = igt_get_cairo_ctx(data->drm_fd, &data->fb);
+	draw_cursor(cr, 0, 0, cur_w);
 	igt_assert(cairo_status(cr) == 0);
 }
 
@@ -322,21 +319,13 @@ static void run_test_generic(data_t *data, int cursor_max_size)
 		igt_require(cursor_max_size >= cursor_size);
 		sprintf(c_size, "%d", cursor_size);
 
-		/* Creating cursor framebuffers */
-		create_cursor_fb(data, WHITE_VISIBLE, 1.0, 1.0, 1.0, 1.0, cursor_size, cursor_size);
-		create_cursor_fb(data, WHITE_INVISIBLE, 1.0, 1.0, 1.0, 0.0, cursor_size, cursor_size);
-		create_cursor_fb(data, BLACK_VISIBLE, 0.0, 0.0, 0.0, 1.0, cursor_size, cursor_size);
-		create_cursor_fb(data, BLACK_INVISIBLE, 0.0, 0.0, 0.0, 0.0, cursor_size, cursor_size);
+		create_cursor_fb(data, cursor_size, cursor_size);
 
 		/* Using created cursor FBs to test cursor support */
-		igt_subtest_f("white-visible-cursor-%s-onscreen", c_size)
-			run_test(data, WHITE_VISIBLE, true, cursor_size, cursor_size);
-		igt_subtest_f("white-invisible-cursor-%s-offscreen", c_size)
-			run_test(data, WHITE_INVISIBLE, false, cursor_size, cursor_size);
-                igt_subtest_f("black-visible-cursor-%s-onscreen", c_size)
-                        run_test(data, BLACK_VISIBLE, true, cursor_size, cursor_size);
-                igt_subtest_f("black-invisible-cursor-%s-offscreen", c_size)
-                        run_test(data, BLACK_INVISIBLE, false, cursor_size, cursor_size);
+		igt_subtest_f("cursor-%s-onscreen", c_size)
+			run_test(data, true, cursor_size, cursor_size);
+		igt_subtest_f("cursor-%s-offscreen", c_size)
+			run_test(data, false, cursor_size, cursor_size);
 	}
 
 }
Signature · 1 line
1.8.3.2
#2 lore raw

PATCH 2/7 kms_cursor_crc: Move cursor enable and disable calls where they belong

In reply to Antti Koskipaa

We can't have the hw cursor enabled during software render tests.

---
 tests/kms_cursor_crc.c | 54 ++++++++++++++++++++++++--------------------------
 1 file changed, 26 insertions(+), 28 deletions(-)
tests/kms_cursor_crc.c +26 -28
index 52281d0..8802da6 100644
@@ -67,6 +67,30 @@ static void draw_cursor(cairo_t *cr, int x, int y, int w)
 	igt_paint_color_alpha(cr, x + w, y + w, w, w, 0.5, 0.5, 0.5, 1.0);
 }
 
+static void cursor_enable(test_data_t *test_data)
+{
+	data_t *data = test_data->data;
+	igt_display_t *display = &data->display;
+	igt_output_t *output = test_data->output;
+	igt_plane_t *cursor;
+
+	cursor = igt_output_get_plane(output, IGT_PLANE_CURSOR);
+	igt_plane_set_fb(cursor, &data->fb);
+	igt_display_commit(display);
+}
+
+static void cursor_disable(test_data_t *test_data)
+{
+	data_t *data = test_data->data;
+	igt_display_t *display = &data->display;
+	igt_output_t *output = test_data->output;
+	igt_plane_t *cursor;
+
+	cursor = igt_output_get_plane(output, IGT_PLANE_CURSOR);
+	igt_plane_set_fb(cursor, NULL);
+	igt_display_commit(display);
+}
+
 static igt_pipe_crc_t *create_crc(data_t *data, enum pipe pipe)
 {
 	igt_pipe_crc_t *crc;
@@ -85,10 +109,12 @@ static void do_single_test(test_data_t *test_data, int x, int y)
 
 	printf("."); fflush(stdout);
 
+	cursor_enable(test_data);
 	cursor = igt_output_get_plane(test_data->output, IGT_PLANE_CURSOR);
 	igt_plane_set_position(cursor, x, y);
 	igt_display_commit(display);
 	igt_wait_for_vblank(data->drm_fd, test_data->pipe);
+	cursor_disable(test_data);
 
 	igt_pipe_crc_collect_crc(pipe_crc, &crc);
 	if (test_data->crc_must_match)
@@ -106,30 +132,6 @@ static void do_test(test_data_t *test_data,
 	do_single_test(test_data, left, bottom);
 }
 
-static void cursor_enable(test_data_t *test_data)
-{
-	data_t *data = test_data->data;
-	igt_display_t *display = &data->display;
-	igt_output_t *output = test_data->output;
-	igt_plane_t *cursor;
-
-	cursor = igt_output_get_plane(output, IGT_PLANE_CURSOR);
-	igt_plane_set_fb(cursor, &data->fb);
-	igt_display_commit(display);
-}
-
-static void cursor_disable(test_data_t *test_data)
-{
-	data_t *data = test_data->data;
-	igt_display_t *display = &data->display;
-	igt_output_t *output = test_data->output;
-	igt_plane_t *cursor;
-
-	cursor = igt_output_get_plane(output, IGT_PLANE_CURSOR);
-	igt_plane_set_fb(cursor, NULL);
-	igt_display_commit(display);
-}
-
 static void test_crc(test_data_t *test_data,
 		     bool onscreen, int cursor_w, int cursor_h)
 {
@@ -138,8 +140,6 @@ static void test_crc(test_data_t *test_data,
 	int top = test_data->top;
 	int bottom = test_data->bottom;
 
-	cursor_enable(test_data);
-
 	if (onscreen) {
 		/* cursor onscreen, crc should match, except when white visible cursor is used */
 		test_data->crc_must_match = false;
@@ -183,8 +183,6 @@ static void test_crc(test_data_t *test_data,
 		/* go nuts */
 		do_test(test_data, INT_MIN, INT_MAX, INT_MIN, INT_MAX);
 	}
-
-	cursor_disable(test_data);
 }
 
 static bool prepare_crtc(test_data_t *test_data, igt_output_t *output,
Signature · 1 line
1.8.3.2
#3 lore raw

PATCH 3/7 kms_cursor_crc: Use a function pointer to call test

In reply to Antti Koskipaa

More tests are coming, and this allows us to not repeat the boilerplate code in run_test() for each subtest.

---
 tests/kms_cursor_crc.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
tests/kms_cursor_crc.c +10 -5
index 8802da6..60b50b5 100644
@@ -54,6 +54,7 @@ typedef struct {
 	igt_crc_t ref_crc;
 	bool crc_must_match;
 	int left, right, top, bottom;
+	int curw, curh; /* cursor size */
 } test_data_t;
 
 static void draw_cursor(cairo_t *cr, int x, int y, int w)
@@ -133,12 +134,14 @@ static void do_test(test_data_t *test_data,
 }
 
 static void test_crc(test_data_t *test_data,
-		     bool onscreen, int cursor_w, int cursor_h)
+		     bool onscreen)
 {
 	int left = test_data->left;
 	int right = test_data->right;
 	int top = test_data->top;
 	int bottom = test_data->bottom;
+	int cursor_w = test_data->curw;
+	int cursor_h = test_data->curh;
 
 	if (onscreen) {
 		/* cursor onscreen, crc should match, except when white visible cursor is used */
@@ -228,6 +231,8 @@ static bool prepare_crtc(test_data_t *test_data, igt_output_t *output,
 	test_data->right = mode->hdisplay - cursor_w;
 	test_data->top = 0;
 	test_data->bottom = mode->vdisplay - cursor_h;
+	test_data->curw = cursor_w;
+	test_data->curh = cursor_h;
 
 	/* make sure cursor is disabled */
 	cursor_disable(test_data);
@@ -255,7 +260,7 @@ static void cleanup_crtc(test_data_t *test_data, igt_output_t *output)
 	igt_output_set_pipe(output, PIPE_ANY);
 }
 
-static void run_test(data_t *data, bool onscreen, int cursor_w, int cursor_h)
+static void run_test(data_t *data, void (*testfunc)(test_data_t *, bool), bool onscreen, int cursor_w, int cursor_h)
 {
 	igt_display_t *display = &data->display;
 	igt_output_t *output;
@@ -279,7 +284,7 @@ static void run_test(data_t *data, bool onscreen, int cursor_w, int cursor_h)
 				igt_subtest_name(), pipe_name(test_data.pipe),
 				igt_output_name(output));
 
-			test_crc(&test_data, onscreen, cursor_w, cursor_h);
+			testfunc(&test_data, onscreen);
 
 			fprintf(stdout, "\n%s on pipe %c, connector %s: PASSED\n\n",
 				igt_subtest_name(), pipe_name(test_data.pipe),
@@ -321,9 +326,9 @@ static void run_test_generic(data_t *data, int cursor_max_size)
 
 		/* Using created cursor FBs to test cursor support */
 		igt_subtest_f("cursor-%s-onscreen", c_size)
-			run_test(data, true, cursor_size, cursor_size);
+			run_test(data, test_crc, true, cursor_size, cursor_size);
 		igt_subtest_f("cursor-%s-offscreen", c_size)
-			run_test(data, false, cursor_size, cursor_size);
+			run_test(data, test_crc, false, cursor_size, cursor_size);
 	}
 
 }
Signature · 1 line
1.8.3.2
#4 lore raw

PATCH 4/7 kms_cursor_crc: Separate onscreen and offscreen tests

In reply to Antti Koskipaa

Also remove onscreen boolean from parameter list. All test-related data should be put into test_data from now.

---
 tests/kms_cursor_crc.c | 99 +++++++++++++++++++++++++-------------------------
 1 file changed, 50 insertions(+), 49 deletions(-)
tests/kms_cursor_crc.c +50 -49
index 60b50b5..94baa94 100644
@@ -133,8 +133,7 @@ static void do_test(test_data_t *test_data,
 	do_single_test(test_data, left, bottom);
 }
 
-static void test_crc(test_data_t *test_data,
-		     bool onscreen)
+static void test_crc_onscreen(test_data_t *test_data)
 {
 	int left = test_data->left;
 	int right = test_data->right;
@@ -143,49 +142,51 @@ static void test_crc(test_data_t *test_data,
 	int cursor_w = test_data->curw;
 	int cursor_h = test_data->curh;
 
-	if (onscreen) {
-		/* cursor onscreen, crc should match, except when white visible cursor is used */
-		test_data->crc_must_match = false;
-
-		/* fully inside  */
-		do_test(test_data, left, right, top, bottom);
-
-		/* 2 pixels inside */
-		do_test(test_data, left - (cursor_w-2), right + (cursor_w-2), top               , bottom               );
-		do_test(test_data, left               , right               , top - (cursor_h-2), bottom + (cursor_h-2));
-		do_test(test_data, left - (cursor_w-2), right + (cursor_w-2), top - (cursor_h-2), bottom + (cursor_h-2));
-
-		/* 1 pixel inside */
-		do_test(test_data, left - (cursor_w-1), right + (cursor_w-1), top               , bottom               );
-		do_test(test_data, left               , right               , top - (cursor_h-1), bottom + (cursor_h-1));
-		do_test(test_data, left - (cursor_w-1), right + (cursor_w-1), top - (cursor_h-1), bottom + (cursor_h-1));
-	} else {
-		/* cursor offscreen, crc should always match */
-		test_data->crc_must_match = false;
-
-		/* fully outside */
-		do_test(test_data, left - (cursor_w), right + (cursor_w), top             , bottom             );
-		do_test(test_data, left             , right             , top - (cursor_h), bottom + (cursor_h));
-		do_test(test_data, left - (cursor_w), right + (cursor_w), top - (cursor_h), bottom + (cursor_h));
-
-		/* fully outside by 1 extra pixels */
-		do_test(test_data, left - (cursor_w+1), right + (cursor_w+1), top               , bottom               );
-		do_test(test_data, left               , right               , top - (cursor_h+1), bottom + (cursor_h+1));
-		do_test(test_data, left - (cursor_w+1), right + (cursor_w+1), top - (cursor_h+1), bottom + (cursor_h+1));
-
-		/* fully outside by 2 extra pixels */
-		do_test(test_data, left - (cursor_w+2), right + (cursor_w+2), top               , bottom               );
-		do_test(test_data, left               , right               , top - (cursor_h+2), bottom + (cursor_h+2));
-		do_test(test_data, left - (cursor_w+2), right + (cursor_w+2), top - (cursor_h+2), bottom + (cursor_h+2));
-
-		/* fully outside by a lot of extra pixels */
-		do_test(test_data, left - (cursor_w+512), right + (cursor_w+512), top                 , bottom                 );
-		do_test(test_data, left                 , right                 , top - (cursor_h+512), bottom + (cursor_h+512));
-		do_test(test_data, left - (cursor_w+512), right + (cursor_w+512), top - (cursor_h+512), bottom + (cursor_h+512));
-
-		/* go nuts */
-		do_test(test_data, INT_MIN, INT_MAX, INT_MIN, INT_MAX);
-	}
+	/* fully inside  */
+	do_test(test_data, left, right, top, bottom);
+
+	/* 2 pixels inside */
+	do_test(test_data, left - (cursor_w-2), right + (cursor_w-2), top               , bottom               );
+	do_test(test_data, left               , right               , top - (cursor_h-2), bottom + (cursor_h-2));
+	do_test(test_data, left - (cursor_w-2), right + (cursor_w-2), top - (cursor_h-2), bottom + (cursor_h-2));
+
+	/* 1 pixel inside */
+	do_test(test_data, left - (cursor_w-1), right + (cursor_w-1), top               , bottom               );
+	do_test(test_data, left               , right               , top - (cursor_h-1), bottom + (cursor_h-1));
+	do_test(test_data, left - (cursor_w-1), right + (cursor_w-1), top - (cursor_h-1), bottom + (cursor_h-1));
+}
+
+static void test_crc_offscreen(test_data_t *test_data)
+{
+	int left = test_data->left;
+	int right = test_data->right;
+	int top = test_data->top;
+	int bottom = test_data->bottom;
+	int cursor_w = test_data->curw;
+	int cursor_h = test_data->curh;
+
+	/* fully outside */
+	do_test(test_data, left - (cursor_w), right + (cursor_w), top             , bottom             );
+	do_test(test_data, left             , right             , top - (cursor_h), bottom + (cursor_h));
+	do_test(test_data, left - (cursor_w), right + (cursor_w), top - (cursor_h), bottom + (cursor_h));
+
+	/* fully outside by 1 extra pixels */
+	do_test(test_data, left - (cursor_w+1), right + (cursor_w+1), top               , bottom               );
+	do_test(test_data, left               , right               , top - (cursor_h+1), bottom + (cursor_h+1));
+	do_test(test_data, left - (cursor_w+1), right + (cursor_w+1), top - (cursor_h+1), bottom + (cursor_h+1));
+
+	/* fully outside by 2 extra pixels */
+	do_test(test_data, left - (cursor_w+2), right + (cursor_w+2), top               , bottom               );
+	do_test(test_data, left               , right               , top - (cursor_h+2), bottom + (cursor_h+2));
+	do_test(test_data, left - (cursor_w+2), right + (cursor_w+2), top - (cursor_h+2), bottom + (cursor_h+2));
+
+	/* fully outside by a lot of extra pixels */
+	do_test(test_data, left - (cursor_w+512), right + (cursor_w+512), top                 , bottom                 );
+	do_test(test_data, left                 , right                 , top - (cursor_h+512), bottom + (cursor_h+512));
+	do_test(test_data, left - (cursor_w+512), right + (cursor_w+512), top - (cursor_h+512), bottom + (cursor_h+512));
+
+	/* go nuts */
+	do_test(test_data, INT_MIN, INT_MAX, INT_MIN, INT_MAX);
 }
 
 static bool prepare_crtc(test_data_t *test_data, igt_output_t *output,
@@ -260,7 +261,7 @@ static void cleanup_crtc(test_data_t *test_data, igt_output_t *output)
 	igt_output_set_pipe(output, PIPE_ANY);
 }
 
-static void run_test(data_t *data, void (*testfunc)(test_data_t *, bool), bool onscreen, int cursor_w, int cursor_h)
+static void run_test(data_t *data, void (*testfunc)(test_data_t *), int cursor_w, int cursor_h)
 {
 	igt_display_t *display = &data->display;
 	igt_output_t *output;
@@ -284,7 +285,7 @@ static void run_test(data_t *data, void (*testfunc)(test_data_t *, bool), bool o
 				igt_subtest_name(), pipe_name(test_data.pipe),
 				igt_output_name(output));
 
-			testfunc(&test_data, onscreen);
+			testfunc(&test_data);
 
 			fprintf(stdout, "\n%s on pipe %c, connector %s: PASSED\n\n",
 				igt_subtest_name(), pipe_name(test_data.pipe),
@@ -326,9 +327,9 @@ static void run_test_generic(data_t *data, int cursor_max_size)
 
 		/* Using created cursor FBs to test cursor support */
 		igt_subtest_f("cursor-%s-onscreen", c_size)
-			run_test(data, test_crc, true, cursor_size, cursor_size);
+			run_test(data, test_crc_onscreen, cursor_size, cursor_size);
 		igt_subtest_f("cursor-%s-offscreen", c_size)
-			run_test(data, test_crc, false, cursor_size, cursor_size);
+			run_test(data, test_crc_offscreen, cursor_size, cursor_size);
 	}
 
 }
Signature · 1 line
1.8.3.2
#5 lore raw

PATCH 5/7 kms_cursor_crc: Add reference software rendering

In reply to Antti Koskipaa

This patch first render the cursor with hardware rendering and then with software, acquiring the CRC in both cases so they can be properly compared. Say goodbye to crc_must_match variable.

---
 tests/kms_cursor_crc.c | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)
tests/kms_cursor_crc.c +17 -10
index 94baa94..021d58a 100644
@@ -52,8 +52,8 @@ typedef struct {
 	igt_output_t *output;
 	enum pipe pipe;
 	igt_crc_t ref_crc;
-	bool crc_must_match;
 	int left, right, top, bottom;
+	int screenw, screenh;
 	int curw, curh; /* cursor size */
 } test_data_t;
 
@@ -105,23 +105,31 @@ static void do_single_test(test_data_t *test_data, int x, int y)
 	data_t *data = test_data->data;
 	igt_display_t *display = &data->display;
 	igt_pipe_crc_t *pipe_crc = data->pipe_crc[test_data->pipe];
-	igt_crc_t crc;
+	igt_crc_t crc, ref_crc;
 	igt_plane_t *cursor;
+	cairo_t *cr = igt_get_cairo_ctx(data->drm_fd, &data->primary_fb);
 
 	printf("."); fflush(stdout);
 
+	/* Hardware test */
 	cursor_enable(test_data);
 	cursor = igt_output_get_plane(test_data->output, IGT_PLANE_CURSOR);
 	igt_plane_set_position(cursor, x, y);
 	igt_display_commit(display);
 	igt_wait_for_vblank(data->drm_fd, test_data->pipe);
+	igt_pipe_crc_collect_crc(pipe_crc, &crc);
 	cursor_disable(test_data);
 
-	igt_pipe_crc_collect_crc(pipe_crc, &crc);
-	if (test_data->crc_must_match)
-		igt_assert(igt_crc_equal(&crc, &test_data->ref_crc));
-	else
-		igt_assert(!igt_crc_equal(&crc, &test_data->ref_crc));
+	/* Now render the same in software and collect crc */
+	draw_cursor(cr, x, y, test_data->curw);
+	igt_display_commit(display);
+	igt_wait_for_vblank(data->drm_fd, test_data->pipe);
+	igt_pipe_crc_collect_crc(pipe_crc, &ref_crc);
+	/* Clear screen afterwards */
+	igt_paint_color(cr, 0, 0, test_data->screenw, test_data->screenh,
+			    0.0, 0.0, 0.0);
+
+	igt_assert(igt_crc_equal(&crc, &ref_crc));
 }
 
 static void do_test(test_data_t *test_data,
@@ -184,9 +192,6 @@ static void test_crc_offscreen(test_data_t *test_data)
 	do_test(test_data, left - (cursor_w+512), right + (cursor_w+512), top                 , bottom                 );
 	do_test(test_data, left                 , right                 , top - (cursor_h+512), bottom + (cursor_h+512));
 	do_test(test_data, left - (cursor_w+512), right + (cursor_w+512), top - (cursor_h+512), bottom + (cursor_h+512));
-
-	/* go nuts */
-	do_test(test_data, INT_MIN, INT_MAX, INT_MIN, INT_MAX);
 }
 
 static bool prepare_crtc(test_data_t *test_data, igt_output_t *output,
@@ -232,6 +237,8 @@ static bool prepare_crtc(test_data_t *test_data, igt_output_t *output,
 	test_data->right = mode->hdisplay - cursor_w;
 	test_data->top = 0;
 	test_data->bottom = mode->vdisplay - cursor_h;
+	test_data->screenw = mode->hdisplay;
+	test_data->screenh = mode->vdisplay;
 	test_data->curw = cursor_w;
 	test_data->curh = cursor_h;
 
Signature · 1 line
1.8.3.2
#6 lore raw

Re: [PATCH i-g-t 5/7] kms_cursor_crc: Add reference software rendering

On Wed, Apr 02, 2014 at 02:06:28PM +0300, Antti Koskipaa wrote:
<snip>

tests/kms_cursor_crc.c static void test_crc_offscreen(test_data_t *test_data) · line 189

Quoted 7 lines
tests/kms_cursor_crc.c +0 -3
@@ -184,9 +192,6 @@ static void test_crc_offscreen(test_data_t *test_data)
 	do_test(test_data, left - (cursor_w+512), right + (cursor_w+512), top                 , bottom                 );
 	do_test(test_data, left                 , right                 , top - (cursor_h+512), bottom + (cursor_h+512));
 	do_test(test_data, left - (cursor_w+512), right + (cursor_w+512), top - (cursor_h+512), bottom + (cursor_h+512));
-
-	/* go nuts */
-	do_test(test_data, INT_MIN, INT_MAX, INT_MIN, INT_MAX);

Why are you dropping the go nuts test? We had an actual bug in the driver that this managed to hit. We should keep this test to avoid regressions.

Signature · 2 lines
Ville Syrjälä
Intel OTC
#7 lore raw

Re: [PATCH i-g-t 5/7] kms_cursor_crc: Add reference software rendering

Quoted 13 lines · Ville Syrjälä

On Wed, Apr 02, 2014 at 02:06:28PM +0300, Antti Koskipaa wrote:
<snip>

tests/kms_cursor_crc.c static void test_crc_offscreen(test_data_t *test_data) · line 189

Quoted 7 lines
tests/kms_cursor_crc.c +0 -3
@@ -184,9 +192,6 @@ static void test_crc_offscreen(test_data_t *test_data)
 	do_test(test_data, left - (cursor_w+512), right + (cursor_w+512), top                 , bottom                 );
 	do_test(test_data, left                 , right                 , top - (cursor_h+512), bottom + (cursor_h+512));
 	do_test(test_data, left - (cursor_w+512), right + (cursor_w+512), top - (cursor_h+512), bottom + (cursor_h+512));
-
-	/* go nuts */
-	do_test(test_data, INT_MIN, INT_MAX, INT_MIN, INT_MAX);

Why are you dropping the go nuts test? We had an actual bug in the driver that this managed to hit. We should keep this test to avoid regressions.

Link please. Cairo went nuts with that one, but if there is a case for the test, I'll work around Cairo to keep it.

Signature · 1 line
- Antti
#8 lore raw

Re: [PATCH i-g-t 5/7] kms_cursor_crc: Add reference software rendering

Quoted 15 lines · Antti Koskipää
Quoted 13 lines · Ville Syrjälä

On Wed, Apr 02, 2014 at 02:06:28PM +0300, Antti Koskipaa wrote:
<snip>

tests/kms_cursor_crc.c static void test_crc_offscreen(test_data_t *test_data) · line 189

Quoted 7 lines
tests/kms_cursor_crc.c +0 -3
@@ -184,9 +192,6 @@ static void test_crc_offscreen(test_data_t *test_data)
 	do_test(test_data, left - (cursor_w+512), right + (cursor_w+512), top                 , bottom                 );
 	do_test(test_data, left                 , right                 , top - (cursor_h+512), bottom + (cursor_h+512));
 	do_test(test_data, left - (cursor_w+512), right + (cursor_w+512), top - (cursor_h+512), bottom + (cursor_h+512));
-
-	/* go nuts */
-	do_test(test_data, INT_MIN, INT_MAX, INT_MIN, INT_MAX);

Why are you dropping the go nuts test? We had an actual bug in the driver that this managed to hit. We should keep this test to avoid regressions.

Quoted 2 lines

Link please. Cairo went nuts with that one, but if there is a case for the test, I'll work around Cairo to keep it.

commit 92e76c8c7e436a07af3e0b594480ff8689add078

Author: Ville Syrjälä <[email protected]>
Date:   Mon Oct 21 19:01:58 2013 +0300

drm/i915: Clamp cursor coordinates to int16_t range

is the commit that fixed the bug.

Signature · 2 lines
Ville Syrjälä
Intel OTC
#9 lore raw

PATCH 6/7 kms_cursor_crc: Add moving cursor test

In reply to Antti Koskipaa
---
 tests/kms_cursor_crc.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
tests/kms_cursor_crc.c +16 -0
index 021d58a..1e1d348 100644
@@ -194,6 +194,20 @@ static void test_crc_offscreen(test_data_t *test_data)
 	do_test(test_data, left - (cursor_w+512), right + (cursor_w+512), top - (cursor_h+512), bottom + (cursor_h+512));
 }
 
+static void test_crc_sliding(test_data_t *test_data)
+{
+	int i;
+
+	/* Make sure cursor moves smoothly and pixel-by-pixel, and that there are
+	 * no alignment issues. Horizontal, vertical and diagonal test.
+	 */
+	for (i = 0; i < 16; i++) {
+		do_single_test(test_data, i, 0);
+		do_single_test(test_data, 0, i);
+		do_single_test(test_data, i, i);
+	}
+}
+
 static bool prepare_crtc(test_data_t *test_data, igt_output_t *output,
 			 int cursor_w, int cursor_h)
 {
@@ -337,6 +351,8 @@ static void run_test_generic(data_t *data, int cursor_max_size)
 			run_test(data, test_crc_onscreen, cursor_size, cursor_size);
 		igt_subtest_f("cursor-%s-offscreen", c_size)
 			run_test(data, test_crc_offscreen, cursor_size, cursor_size);
+		igt_subtest_f("cursor-%s-sliding", c_size)
+			run_test(data, test_crc_sliding, cursor_size, cursor_size);
 	}
 
 }
Signature · 1 line
1.8.3.2
#10 lore raw

PATCH 7/7 kms_cursor_crc: Add random cursor placement test

In reply to Antti Koskipaa
---
 tests/kms_cursor_crc.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
tests/kms_cursor_crc.c +14 -0
index 1e1d348..d461d72 100644
@@ -208,6 +208,18 @@ static void test_crc_sliding(test_data_t *test_data)
 	}
 }
 
+static void test_crc_random(test_data_t *test_data)
+{
+	int i;
+
+	/* Random cursor placement */
+	for (i = 0; i < 50; i++) {
+		int x = rand() % (test_data->screenw + test_data->curw * 2) - test_data->curw;
+		int y = rand() % (test_data->screenh + test_data->curh * 2) - test_data->curh;
+		do_single_test(test_data, x, y);
+	}
+}
+
 static bool prepare_crtc(test_data_t *test_data, igt_output_t *output,
 			 int cursor_w, int cursor_h)
 {
@@ -353,6 +365,8 @@ static void run_test_generic(data_t *data, int cursor_max_size)
 			run_test(data, test_crc_offscreen, cursor_size, cursor_size);
 		igt_subtest_f("cursor-%s-sliding", c_size)
 			run_test(data, test_crc_sliding, cursor_size, cursor_size);
+		igt_subtest_f("cursor-%s-random", c_size)
+			run_test(data, test_crc_random, cursor_size, cursor_size);
 	}
 
 }
Signature · 1 line
1.8.3.2