[Intel-gfx] [PATCH igt 8/8] tests/kms_fb_crc: fix the reference CRC checking

Paulo Zanoni przanoni at gmail.com
Thu May 7 11:56:36 PDT 2015


From: Paulo Zanoni <paulo.r.zanoni at intel.com>

Now we get the reference CRCs on separate untiled FBs just to make
sure FBC is not there to mess the CRC computation. We also get the
reference CRCs for buffers that were drawn in the same way that we
draw them during the tests, so we can finally get rid of that FIXME
comment we have!

With this, kms_fbc_crc now actually tests something instead of just
wasting CPU cycles...

Fixes regression introduced by:

commit 562bbe12f6fb75811a746c742a28d32a17b26aa9
Author: Daniel Vetter <daniel.vetter at ffwll.ch>
Date:   Fri Feb 27 22:04:18 2015 +0100
    tests: Remove usage of igt_crc_equal and _non_null

Cc: Daniel Vetter <daniel.vetter at ffwll.ch>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni at intel.com>
---
 tests/kms_fbc_crc.c | 117 ++++++++++++++++++++++++++++++++++++----------------
 1 file changed, 82 insertions(+), 35 deletions(-)

diff --git a/tests/kms_fbc_crc.c b/tests/kms_fbc_crc.c
index b52ac29..37221ac 100644
--- a/tests/kms_fbc_crc.c
+++ b/tests/kms_fbc_crc.c
@@ -56,7 +56,7 @@ enum test_mode {
 
 typedef struct {
 	int drm_fd;
-	igt_crc_t ref_crc[2];
+	igt_crc_t ref_crc[4];
 	igt_pipe_crc_t *pipe_crc;
 	drm_intel_bufmgr *bufmgr;
 	drm_intel_context *ctx[2];
@@ -234,13 +234,32 @@ static bool wait_for_fbc_enabled(data_t *data)
 static void check_crc(data_t *data, enum test_mode mode)
 {
 	igt_pipe_crc_t *pipe_crc = data->pipe_crc;
-	igt_crc_t crc;
+	igt_crc_t crc, *ref_crc;
+
+	switch (mode) {
+	case TEST_PAGE_FLIP:
+		ref_crc = &data->ref_crc[1];
+		break;
+	case TEST_MMAP_CPU:
+	case TEST_MMAP_GTT:
+	case TEST_BLT:
+	case TEST_RENDER:
+	case TEST_CONTEXT:
+		ref_crc = &data->ref_crc[2];
+		break;
+	case TEST_PAGE_FLIP_AND_MMAP_CPU:
+	case TEST_PAGE_FLIP_AND_MMAP_GTT:
+	case TEST_PAGE_FLIP_AND_BLT:
+	case TEST_PAGE_FLIP_AND_RENDER:
+	case TEST_PAGE_FLIP_AND_CONTEXT:
+		ref_crc = &data->ref_crc[3];
+		break;
+	default:
+		igt_assert(false);
+	}
 
 	igt_pipe_crc_collect_crc(pipe_crc, &crc);
-	if (mode == TEST_PAGE_FLIP)
-		igt_assert_crc_equal(&crc, &data->ref_crc[1]);
-	else
-		;/* FIXME: missing reference CRCs */
+	igt_assert_crc_equal(&crc, ref_crc);
 }
 
 static void test_crc(data_t *data, enum test_mode mode)
@@ -321,27 +340,71 @@ static bool prepare_crtc(data_t *data)
 	return true;
 }
 
+static void create_fbs(data_t *data, bool tiled, struct igt_fb *fbs)
+{
+	int rc;
+	drmModeModeInfo *mode = igt_output_get_mode(data->output);
+	uint64_t tiling = tiled ? LOCAL_I915_FORMAT_MOD_X_TILED :
+				  LOCAL_DRM_FORMAT_MOD_NONE;
+
+	rc = igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay,
+				 DRM_FORMAT_XRGB8888, tiling,
+				 0.0, 0.0, 0.0, &fbs[0]);
+	igt_assert(rc);
+	rc = igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay,
+				 DRM_FORMAT_XRGB8888, tiling,
+				 0.1, 0.1, 0.1, &fbs[1]);
+	igt_assert(rc);
+}
+
+/* Since we want to be really safe that the CRCs are actually what we really
+ * want, use untiled FBs, so FBC won't happen to disrupt things. Also do the
+ * drawing before setting the modes, just to be sure. */
+static void get_ref_crcs(data_t *data)
+{
+	igt_display_t *display = &data->display;
+	struct igt_fb fbs[4];
+	int i;
+
+	create_fbs(data, false, &fbs[0]);
+	create_fbs(data, false, &fbs[2]);
+
+	fill_mmap_gtt(data, fbs[2].gem_handle, 0xff);
+	fill_mmap_gtt(data, fbs[3].gem_handle, 0xff);
+
+	for (i = 0; i < 4; i++) {
+		igt_plane_set_fb(data->primary, &fbs[i]);
+		igt_display_commit(display);
+		igt_wait_for_vblank(data->drm_fd, data->pipe);
+		igt_assert(!fbc_enabled(data));
+		igt_pipe_crc_collect_crc(data->pipe_crc, &data->ref_crc[i]);
+		igt_assert(!fbc_enabled(data));
+	}
+
+	igt_plane_set_fb(data->primary, &data->fb[1]);
+	igt_display_commit(display);
+
+	for (i = 0; i < 4; i++)
+		igt_remove_fb(data->drm_fd, &fbs[i]);
+}
+
 static bool prepare_test(data_t *data, enum test_mode test_mode)
 {
 	igt_display_t *display = &data->display;
 	igt_output_t *output = data->output;
-	drmModeModeInfo *mode;
 	igt_pipe_crc_t *pipe_crc;
-	int rc;
 
 	data->primary = igt_output_get_plane(data->output, IGT_PLANE_PRIMARY);
-	mode = igt_output_get_mode(data->output);
 
-	rc = igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay,
-				 DRM_FORMAT_XRGB8888,
-				 LOCAL_I915_FORMAT_MOD_X_TILED,
-				 0.0, 0.0, 0.0, &data->fb[0]);
-	igt_assert(rc);
-	rc = igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay,
-				 DRM_FORMAT_XRGB8888,
-				 LOCAL_I915_FORMAT_MOD_X_TILED,
-				 0.1, 0.1, 0.1, &data->fb[1]);
-	igt_assert(rc);
+	create_fbs(data, true, data->fb);
+
+	igt_pipe_crc_free(data->pipe_crc);
+	data->pipe_crc = NULL;
+	pipe_crc = igt_pipe_crc_new(data->pipe,
+				    INTEL_PIPE_CRC_SOURCE_AUTO);
+	data->pipe_crc = pipe_crc;
+
+	get_ref_crcs(data);
 
 	/* scanout = fb[1] */
 	igt_plane_set_fb(data->primary, &data->fb[1]);
@@ -359,19 +422,6 @@ static bool prepare_test(data_t *data, enum test_mode test_mode)
 		return false;
 	}
 
-	igt_pipe_crc_free(data->pipe_crc);
-	data->pipe_crc = NULL;
-
-	pipe_crc = igt_pipe_crc_new(data->pipe,
-				    INTEL_PIPE_CRC_SOURCE_AUTO);
-
-	data->pipe_crc = pipe_crc;
-
-	igt_wait_for_vblank(data->drm_fd, data->pipe);
-
-	/* get reference crc for fb[1] */
-	igt_pipe_crc_collect_crc(pipe_crc, &data->ref_crc[1]);
-
 	if (test_mode == TEST_CONTEXT || test_mode == TEST_PAGE_FLIP_AND_CONTEXT) {
 		data->ctx[0] = drm_intel_gem_context_create(data->bufmgr);
 		igt_assert(data->ctx[0]);
@@ -405,9 +455,6 @@ static bool prepare_test(data_t *data, enum test_mode test_mode)
 
 	igt_wait_for_vblank(data->drm_fd, data->pipe);
 
-	/* get reference crc for fb[0] */
-	igt_pipe_crc_collect_crc(pipe_crc, &data->ref_crc[0]);
-
 	return true;
 }
 
-- 
2.1.4



More information about the Intel-gfx mailing list