[PATCH i-g-t] [RFC] tests/stridetest_crc.c: Modification for test (not for merge)

Vidya Srinivas vidya.srinivas at intel.com
Tue Aug 3 16:01:49 UTC 2021


Apply on top of https://patchwork.freedesktop.org/series/93317/

With ALIGN of draw_squares, test PASS on 1366x768
Without ALIGN of draw_square, test FAIL on 1366x768

Signed-off-by: Vidya Srinivas <vidya.srinivas at intel.com>
---
 tests/kms_stridetest_crc.c | 105 +++++++++++++++++++++++++++----------
 1 file changed, 78 insertions(+), 27 deletions(-)

diff --git a/tests/kms_stridetest_crc.c b/tests/kms_stridetest_crc.c
index 41fa0dceb0e4..8af087c3a512 100644
--- a/tests/kms_stridetest_crc.c
+++ b/tests/kms_stridetest_crc.c
@@ -11,10 +11,54 @@ typedef struct {
 #define color 0.75, 0.75, 0.75, 0.75
 #define black 0.0, 0.0, 0.0, 1.0
 
+static void draw_squares(struct igt_fb *fb, int w, int h, double a)
+{
+	cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb);
+
+	cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
+	igt_paint_color_alpha(cr, 0, 0,         w / 2, h / 2, 1., 0., 0., a);
+	igt_paint_color_alpha(cr, w / 2, 0,     w / 2, h / 2, 0., 1., 0., a);
+	igt_paint_color_alpha(cr, 0, h / 2,     w / 2, h / 2, 0., 0., 1., a);
+	igt_paint_color_alpha(cr, w / 2, h / 2, w / 4, h / 2, 1., 1., 1., a);
+	igt_paint_color_alpha(cr, 3 * w / 4, h / 2, w / 4, h / 2, 0., 0., 0., a);
+
+	igt_put_cairo_ctx(cr);
+}
+
+static void draw_squares_coverage(struct igt_fb *fb, int w, int h, uint8_t as)
+{
+	cairo_t *cr = igt_get_cairo_ctx(fb->fd, fb);
+	int i, j;
+	uint32_t *data = (void *)cairo_image_surface_get_data(fb->cairo_surface);
+	uint32_t stride = fb->strides[0] / 4;
+	uint32_t a = as << 24;
+
+	for (j = 0; j < h / 2; j++) {
+		for (i = 0; i < w / 2; i++)
+			data[j * stride + i] = a | 0xff0000;
+
+		for (; i < w; i++)
+			data[j * stride + i] = a | 0xff00;
+	}
+
+	for (j = h / 2; j < h; j++) {
+		for (i = 0; i < w / 2; i++)
+			data[j * stride + i] = a | 0xff;
+
+		for (; i < 3 * w / 4; i++)
+			data[j * stride + i] = a | 0xffffff;
+
+		for (; i < w; i++)
+			data[j * stride + i] = a;
+	}
+
+	igt_put_cairo_ctx(cr);
+}
+
 static void test(data_t *data)
 {
-	igt_plane_t* plane;
-	struct igt_fb softabuffa, hwbuffa = {};
+	igt_plane_t *plane, *plane1;
+	struct igt_fb softabuffa, hwbuffa = {}, gray_fb;
 
 	igt_fixture {
 		data->output = igt_get_single_output_for_pipe(&data->display, PIPE_A);
@@ -23,12 +67,16 @@ static void test(data_t *data)
 		igt_display_commit_atomic(&data->display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
 
 		plane = igt_output_get_plane_type(data->output, DRM_PLANE_TYPE_PRIMARY);
+		plane1 = igt_output_get_plane_type(data->output, DRM_PLANE_TYPE_OVERLAY);
 
-		if (igt_plane_has_prop(plane, IGT_PLANE_ALPHA))
-			igt_plane_set_prop_value(plane, IGT_PLANE_ALPHA, 0xbeef);
+		if (igt_plane_has_prop(plane1, IGT_PLANE_ALPHA))
+			igt_plane_set_prop_value(plane1, IGT_PLANE_ALPHA, 0xffff);
 
-		if (igt_plane_has_prop(plane, IGT_PLANE_PIXEL_BLEND_MODE))
-			igt_plane_set_prop_enum(plane, IGT_PLANE_PIXEL_BLEND_MODE, "Coverage");
+		if (igt_plane_has_prop(plane1, IGT_PLANE_ALPHA))
+			igt_plane_set_prop_value(plane1, IGT_PLANE_ALPHA, 0xffff);
+
+		if (igt_plane_has_prop(plane1, IGT_PLANE_PIXEL_BLEND_MODE))
+			igt_plane_set_prop_enum(plane1, IGT_PLANE_PIXEL_BLEND_MODE, "Coverage");
 	}
 
 	igt_subtest_f("stride-test-linearfb") {
@@ -43,38 +91,41 @@ static void test(data_t *data)
 			      DRM_FORMAT_MOD_NONE,
 			      &softabuffa);
 
+		igt_create_color_fb(data->gfx_fd, drm_mode->hdisplay, drm_mode->vdisplay,
+				    DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_NONE,
+				    .5, .5, .5, &gray_fb);
 		igt_plane_set_position(plane, 0, 0);
+		igt_plane_set_position(plane1, 0, 0);
 		data->pipe_crc = igt_pipe_crc_new(data->gfx_fd, PIPE_A, INTEL_PIPE_CRC_SOURCE_AUTO);
-		igt_pipe_crc_start(data->pipe_crc);
 
-		for (int m = 0; m < 32; m++) {
-			cr = igt_get_cairo_ctx(data->gfx_fd, &softabuffa);
-			igt_paint_color_alpha(cr, 0, 0, drm_mode->hdisplay, drm_mode->vdisplay, black);
-			igt_paint_color_alpha(cr, 0, 0, drm_mode->hdisplay - m, drm_mode->vdisplay, color);
-			igt_put_cairo_ctx(cr);
+		igt_pipe_crc_start(data->pipe_crc);
 
-			igt_plane_set_fb(plane, &softabuffa);
-			igt_display_commit_atomic(&data->display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
-			igt_remove_fb(data->gfx_fd, &hwbuffa);
-			igt_pipe_crc_get_current(data->gfx_fd, data->pipe_crc, &softacrc);
+		/* Use ALIGN for PASS */
+		draw_squares_coverage(&softabuffa, ALIGN(drm_mode->hdisplay, 64), drm_mode->vdisplay, 0x7e);
+		//draw_squares_coverage(&softabuffa, drm_mode->hdisplay, drm_mode->vdisplay, 0x7e);
 
-			igt_create_fb(data->gfx_fd, drm_mode->hdisplay - m, drm_mode->vdisplay,
+		igt_plane_set_fb(plane, &gray_fb);
+		igt_plane_set_prop_enum(plane1, IGT_PLANE_PIXEL_BLEND_MODE, "Coverage");
+		igt_plane_set_fb(plane1, &softabuffa);
+		igt_display_commit_atomic(&data->display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
+		igt_remove_fb(data->gfx_fd, &hwbuffa);
+		igt_pipe_crc_get_current(data->gfx_fd, data->pipe_crc, &softacrc);
+		igt_create_fb(data->gfx_fd, drm_mode->hdisplay, drm_mode->vdisplay,
 					 DRM_FORMAT_ARGB8888,
 					 DRM_FORMAT_MOD_NONE,
 					 &hwbuffa);
 
-			cr = igt_get_cairo_ctx(data->gfx_fd, &hwbuffa);
-			igt_paint_color_alpha(cr, 0, 0, drm_mode->hdisplay - m, drm_mode->vdisplay, black);
-			igt_paint_color_alpha(cr, 0, 0, drm_mode->hdisplay - m, drm_mode->vdisplay, color);
-			igt_put_cairo_ctx(cr);
-
-			igt_plane_set_fb(plane, &hwbuffa);
-			igt_display_commit_atomic(&data->display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
-			igt_pipe_crc_get_current(data->gfx_fd, data->pipe_crc, &hardiscrc);
+		/* Use ALIGN for PASS */
+		draw_squares(&hwbuffa, ALIGN(drm_mode->hdisplay, 64), drm_mode->vdisplay, 126. / 255.);
+		//draw_squares(&hwbuffa, drm_mode->hdisplay, drm_mode->vdisplay, 126. / 255.);
 
-			igt_assert_crc_equal(&softacrc, &hardiscrc);
-		}
+		igt_plane_set_fb(plane, &gray_fb);
+		igt_plane_set_prop_enum(plane1, IGT_PLANE_PIXEL_BLEND_MODE, "Pre-multiplied");
+		igt_plane_set_fb(plane1, &hwbuffa);
+		igt_display_commit_atomic(&data->display, DRM_MODE_ATOMIC_ALLOW_MODESET, NULL);
+		igt_pipe_crc_get_current(data->gfx_fd, data->pipe_crc, &hardiscrc);
 
+		igt_assert_crc_equal(&softacrc, &hardiscrc);
 	}
 
 	igt_fixture {
-- 
2.32.0



More information about the Intel-gfx-trybot mailing list