HAX v2 tests/kms_draw_crc: Try to emulate kms_frontbuffer_tracking drawing

Submitted by Maarten Lankhorst on May 1, 2019, 11:41 a.m.

Details

Message ID 20190501114155.1939-1-maarten.lankhorst@linux.intel.com
State New
Headers show
Series "HAX v2 tests/kms_draw_crc: Try to emulate kms_frontbuffer_tracking drawing" ( rev: 1 ) in IGT - Trybot

Not browsing as part of any series.

Commit Message

Maarten Lankhorst May 1, 2019, 11:41 a.m.
v2: Try 25 times for good measure!

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 tests/intel-ci/fast-feedback.testlist |  55 ++++++++
 tests/kms_draw_crc.c                  | 190 +++++++++++++++++++++++++-
 2 files changed, 243 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/tests/intel-ci/fast-feedback.testlist b/tests/intel-ci/fast-feedback.testlist
index 40475b1ab361..4e7e5a1b3fcf 100644
--- a/tests/intel-ci/fast-feedback.testlist
+++ b/tests/intel-ci/fast-feedback.testlist
@@ -259,3 +259,58 @@  igt@i915_module_load@reload
 igt@i915_module_load@reload-no-display
 igt@i915_module_load@reload-with-fault-injection
 igt@i915_pm_rpm@module-reload
+
+igt@kms_draw_crc@draw-dirtyfb-xrgb8888-mmap-cpu-untiled
+igt@kms_draw_crc@draw-dirtyfb-xrgb8888-mmap-cpu-xtiled
+igt@kms_draw_crc@draw-dirtyfb-xrgb8888-mmap-cpu-ytiled
+igt@kms_draw_crc@draw-dirtyfb-xrgb8888-mmap-gtt-untiled
+igt@kms_draw_crc@draw-dirtyfb-xrgb8888-mmap-gtt-xtiled
+igt@kms_draw_crc@draw-dirtyfb-xrgb8888-mmap-gtt-ytiled
+igt@kms_draw_crc@draw-dirtyfb-xrgb8888-mmap-wc-untiled
+igt@kms_draw_crc@draw-dirtyfb-xrgb8888-mmap-wc-xtiled
+igt@kms_draw_crc@draw-dirtyfb-xrgb8888-mmap-wc-ytiled
+igt@kms_draw_crc@draw-dirtyfb-xrgb8888-pwrite-untiled
+igt@kms_draw_crc@draw-dirtyfb-xrgb8888-pwrite-xtiled
+igt@kms_draw_crc@draw-dirtyfb-xrgb8888-pwrite-ytiled
+igt@kms_draw_crc@draw-dirtyfb-xrgb8888-blt-untiled
+igt@kms_draw_crc@draw-dirtyfb-xrgb8888-blt-xtiled
+igt@kms_draw_crc@draw-dirtyfb-xrgb8888-blt-ytiled
+igt@kms_draw_crc@draw-dirtyfb-xrgb8888-render-untiled
+igt@kms_draw_crc@draw-dirtyfb-xrgb8888-render-xtiled
+igt@kms_draw_crc@draw-dirtyfb-xrgb8888-render-ytiled
+igt@kms_draw_crc@draw-dirtyfb-rgb565-mmap-cpu-untiled
+igt@kms_draw_crc@draw-dirtyfb-rgb565-mmap-cpu-xtiled
+igt@kms_draw_crc@draw-dirtyfb-rgb565-mmap-cpu-ytiled
+igt@kms_draw_crc@draw-dirtyfb-rgb565-mmap-gtt-untiled
+igt@kms_draw_crc@draw-dirtyfb-rgb565-mmap-gtt-xtiled
+igt@kms_draw_crc@draw-dirtyfb-rgb565-mmap-gtt-ytiled
+igt@kms_draw_crc@draw-dirtyfb-rgb565-mmap-wc-untiled
+igt@kms_draw_crc@draw-dirtyfb-rgb565-mmap-wc-xtiled
+igt@kms_draw_crc@draw-dirtyfb-rgb565-mmap-wc-ytiled
+igt@kms_draw_crc@draw-dirtyfb-rgb565-pwrite-untiled
+igt@kms_draw_crc@draw-dirtyfb-rgb565-pwrite-xtiled
+igt@kms_draw_crc@draw-dirtyfb-rgb565-pwrite-ytiled
+igt@kms_draw_crc@draw-dirtyfb-rgb565-blt-untiled
+igt@kms_draw_crc@draw-dirtyfb-rgb565-blt-xtiled
+igt@kms_draw_crc@draw-dirtyfb-rgb565-blt-ytiled
+igt@kms_draw_crc@draw-dirtyfb-rgb565-render-untiled
+igt@kms_draw_crc@draw-dirtyfb-rgb565-render-xtiled
+igt@kms_draw_crc@draw-dirtyfb-rgb565-render-ytiled
+igt@kms_draw_crc@draw-dirtyfb-xrgb2101010-mmap-cpu-untiled
+igt@kms_draw_crc@draw-dirtyfb-xrgb2101010-mmap-cpu-xtiled
+igt@kms_draw_crc@draw-dirtyfb-xrgb2101010-mmap-cpu-ytiled
+igt@kms_draw_crc@draw-dirtyfb-xrgb2101010-mmap-gtt-untiled
+igt@kms_draw_crc@draw-dirtyfb-xrgb2101010-mmap-gtt-xtiled
+igt@kms_draw_crc@draw-dirtyfb-xrgb2101010-mmap-gtt-ytiled
+igt@kms_draw_crc@draw-dirtyfb-xrgb2101010-mmap-wc-untiled
+igt@kms_draw_crc@draw-dirtyfb-xrgb2101010-mmap-wc-xtiled
+igt@kms_draw_crc@draw-dirtyfb-xrgb2101010-mmap-wc-ytiled
+igt@kms_draw_crc@draw-dirtyfb-xrgb2101010-pwrite-untiled
+igt@kms_draw_crc@draw-dirtyfb-xrgb2101010-pwrite-xtiled
+igt@kms_draw_crc@draw-dirtyfb-xrgb2101010-pwrite-ytiled
+igt@kms_draw_crc@draw-dirtyfb-xrgb2101010-blt-untiled
+igt@kms_draw_crc@draw-dirtyfb-xrgb2101010-blt-xtiled
+igt@kms_draw_crc@draw-dirtyfb-xrgb2101010-blt-ytiled
+igt@kms_draw_crc@draw-dirtyfb-xrgb2101010-render-untiled
+igt@kms_draw_crc@draw-dirtyfb-xrgb2101010-render-xtiled
+igt@kms_draw_crc@draw-dirtyfb-xrgb2101010-render-ytiled
diff --git a/tests/kms_draw_crc.c b/tests/kms_draw_crc.c
index ea14db9a0a26..2dc946328e9c 100644
--- a/tests/kms_draw_crc.c
+++ b/tests/kms_draw_crc.c
@@ -31,6 +31,7 @@ 
 struct modeset_params {
 	uint32_t crtc_id;
 	uint32_t connector_id;
+	enum pipe pipe;
 	drmModeModeInfoPtr mode;
 };
 
@@ -87,7 +88,7 @@  static void find_modeset_params(void)
 	ms.connector_id = connector->connector_id;
 	ms.crtc_id = crtc_id;
 	ms.mode = mode;
-
+	ms.pipe = kmstest_get_crtc_idx(drm_res, crtc_id);
 }
 
 static uint32_t get_color(uint32_t drm_format, bool r, bool g, bool b)
@@ -246,6 +247,184 @@  static void fill_fb_subtest(void)
 	igt_remove_fb(drm_fd, &fb);
 }
 
+enum color {
+	COLOR_RED,
+	COLOR_GREEN,
+	COLOR_BLUE,
+	COLOR_MAGENTA,
+	COLOR_CYAN,
+	COLOR_SCND_BG,
+	COLOR_PRIM_BG = COLOR_BLUE,
+	COLOR_OFFSCREEN_BG = COLOR_SCND_BG,
+};
+
+static uint32_t pick_color(struct igt_fb *fb, enum color ecolor)
+{
+	uint32_t color, r, g, b, b2, a;
+	bool alpha = false;
+
+	switch (fb->drm_format) {
+	case DRM_FORMAT_RGB565:
+		a =  0x0;
+		r =  0x1F << 11;
+		g =  0x3F << 5;
+		b =  0x1F;
+		b2 = 0x10;
+		break;
+	case DRM_FORMAT_ARGB8888:
+		alpha = true;
+	case DRM_FORMAT_XRGB8888:
+		a =  0xFF << 24;
+		r =  0xFF << 16;
+		g =  0xFF << 8;
+		b =  0xFF;
+		b2 = 0x80;
+		break;
+	case DRM_FORMAT_ARGB2101010:
+		alpha = true;
+	case DRM_FORMAT_XRGB2101010:
+		a = 0x3 << 30;
+		r = 0x3FF << 20;
+		g = 0x3FF << 10;
+		b = 0x3FF;
+		b2 = 0x200;
+		break;
+	default:
+		igt_assert(false);
+	}
+
+	switch (ecolor) {
+	case COLOR_RED:
+		color = r;
+		break;
+	case COLOR_GREEN:
+		color = g;
+		break;
+	case COLOR_BLUE:
+		color = b;
+		break;
+	case COLOR_MAGENTA:
+		color = r | b;
+		break;
+	case COLOR_CYAN:
+		color = g | b;
+		break;
+	case COLOR_SCND_BG:
+		color = b2;
+		break;
+	default:
+		igt_assert(false);
+	}
+
+	if (alpha)
+		color |= a;
+
+	return color;
+}
+
+struct rect {
+	int x;
+	int y;
+	int w;
+	int h;
+	uint32_t color;
+};
+
+static struct rect pat1_get_rect(struct igt_fb *fb, int r)
+{
+	struct rect rect;
+
+	switch (r) {
+	case 0:
+		rect.x = 0;
+		rect.y = 0;
+		rect.w = fb->width;
+		rect.h = fb->height;
+		rect.color = pick_color(fb, COLOR_BLUE);
+		break;
+	case 1:
+		rect.x = 0;
+		rect.y = 0;
+		rect.w = fb->width / 8;
+		rect.h = fb->height / 8;
+		rect.color = pick_color(fb, COLOR_GREEN);
+		break;
+	case 2:
+		rect.x = fb->width / 8 * 4;
+		rect.y = fb->height / 8 * 4;
+		rect.w = fb->width / 8 * 2;
+		rect.h = fb->height / 8 * 2;
+		rect.color = pick_color(fb, COLOR_RED);
+		break;
+	case 3:
+		rect.x = fb->width / 16 + 1;
+		rect.y = fb->height / 16 + 1;
+		rect.w = fb->width / 8 + 1;
+		rect.h = fb->height / 8 + 1;
+		rect.color = pick_color(fb, COLOR_MAGENTA);
+		break;
+	case 4:
+		rect.x = fb->width - 1;
+		rect.y = fb->height - 1;
+		rect.w = 1;
+		rect.h = 1;
+		rect.color = pick_color(fb, COLOR_CYAN);
+		break;
+	default:
+		igt_assert(false);
+	}
+
+	return rect;
+}
+
+static void draw_dirtyfb_subtest(enum igt_draw_method method,
+				 uint32_t format_index, uint64_t tiling)
+{
+	struct igt_fb fb_ref[5], fb;
+	int i, j;
+	uint32_t drm_format = formats[format_index];
+	struct rect rect;
+	igt_crc_t ref_crc[5], crc;
+
+	for (i = 0; i < 5; i++) {
+		igt_create_fb(drm_fd, ms.mode->hdisplay, ms.mode->vdisplay,
+			      drm_format, tiling, &fb_ref[i]);
+
+		for (j = 0; j <= i; j++) {
+			rect = pat1_get_rect(&fb_ref[i], j);
+
+			igt_draw_rect_fb(drm_fd, bufmgr, NULL, &fb_ref[i], IGT_DRAW_MMAP_GTT,
+					 rect.x, rect.y, rect.w, rect.h, rect.color);
+		}
+
+		igt_assert_eq(0, drmModeSetCrtc(drm_fd, ms.crtc_id, fb_ref[i].fb_id, 0, 0,
+						&ms.connector_id, 1, ms.mode));
+
+		igt_pipe_crc_collect_crc(pipe_crc, &ref_crc[i]);
+	}
+
+	for (j = 0; j < 25; j++) {
+	igt_create_fb(drm_fd, ms.mode->hdisplay, ms.mode->vdisplay,
+		      drm_format, tiling, &fb);
+
+	igt_assert_eq(0, drmModeSetCrtc(drm_fd, ms.crtc_id, fb.fb_id, 0, 0,
+					&ms.connector_id, 1, ms.mode));
+
+	for (i = 0; i < 5; i++) {
+		rect = pat1_get_rect(&fb, i);
+
+		igt_draw_rect_fb(drm_fd, bufmgr, NULL, &fb, method,
+				 rect.x, rect.y, rect.w, rect.h, rect.color);
+		igt_dirty_fb(drm_fd, &fb);
+		igt_wait_for_vblank(drm_fd, ms.pipe);
+
+		igt_pipe_crc_collect_crc(pipe_crc, &crc);
+		igt_assert_crc_equal(&crc, &ref_crc[i]);
+	}
+	igt_remove_fb(drm_fd, &fb);
+	}
+}
+
 static void setup_environment(void)
 {
 	int i;
@@ -268,7 +447,7 @@  static void setup_environment(void)
 	drm_intel_bufmgr_gem_enable_reuse(bufmgr);
 
 	find_modeset_params();
-	pipe_crc = igt_pipe_crc_new(drm_fd, kmstest_get_crtc_idx(drm_res, ms.crtc_id),
+	pipe_crc = igt_pipe_crc_new(drm_fd, ms.pipe,
 				    INTEL_PIPE_CRC_SOURCE_AUTO);
 }
 
@@ -332,6 +511,13 @@  igt_main
 			      tiling_str(tiling_idx))
 			draw_method_subtest(method, format_idx,
 					    tilings[tiling_idx]);
+
+		igt_subtest_f("draw-dirtyfb-%s-%s-%s",
+			      format_str(format_idx),
+			      igt_draw_get_method_name(method),
+			      tiling_str(tiling_idx))
+			draw_dirtyfb_subtest(method, format_idx,
+					     tilings[tiling_idx]);
 	} } }
 
 	igt_subtest("fill-fb")