[Intel-gfx] [PATCH 6/7] tests/kms_fbc_crc: remove redundant information from data_t

Paulo Zanoni przanoni at gmail.com
Wed Mar 25 14:50:38 PDT 2015


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

While it is nice to have shorter names for the most-accessed
variables, it makes the code more difficult to read since it's not
clear to the code reader whether that "gem_handle" is from some FB or
something else. The reader also has to audit the code to see if, for
example, the value of data->handle[0] stays consistent with
data->fb[0].gem_handle all the tame or if at some point the value is
replaced with something else. So remove the redundant information,
making it explicit that we're using the gem handles and FB IDs of the
framebuffers all the time.

Signed-off-by: Paulo Zanoni <paulo.r.zanoni at intel.com>
---
 tests/kms_fbc_crc.c | 43 +++++++++++++++++++------------------------
 1 file changed, 19 insertions(+), 24 deletions(-)

diff --git a/tests/kms_fbc_crc.c b/tests/kms_fbc_crc.c
index f1888c4..abdc065 100644
--- a/tests/kms_fbc_crc.c
+++ b/tests/kms_fbc_crc.c
@@ -61,13 +61,11 @@ typedef struct {
 	drm_intel_bufmgr *bufmgr;
 	drm_intel_context *ctx[2];
 	uint32_t devid;
-	uint32_t handle[2];
 	igt_display_t display;
 	igt_output_t *output;
 	enum pipe pipe;
 	igt_plane_t *primary;
 	struct igt_fb fb[2];
-	uint32_t fb_id[2];
 } data_t;
 
 static const char *test_mode_str(enum test_mode mode)
@@ -216,14 +214,14 @@ static void test_crc(data_t *data, enum test_mode mode)
 	uint32_t crtc_id = data->output->config.crtc->crtc_id;
 	igt_pipe_crc_t *pipe_crc = data->pipe_crc;
 	igt_crc_t crc;
-	uint32_t handle = data->handle[0];
+	uint32_t handle = data->fb[0].gem_handle;
 
 	igt_assert(fbc_enabled(data));
 
 	if (mode >= TEST_PAGE_FLIP_AND_MMAP_CPU) {
-		handle = data->handle[1];
+		handle = data->fb[1].gem_handle;
 		igt_assert(drmModePageFlip(data->drm_fd, crtc_id,
-					   data->fb_id[1], 0, NULL) == 0);
+					   data->fb[1].fb_id, 0, NULL) == 0);
 
 		igt_assert(wait_for_fbc_enabled(data));
 	}
@@ -232,7 +230,7 @@ static void test_crc(data_t *data, enum test_mode mode)
 		void *ptr;
 	case TEST_PAGE_FLIP:
 		igt_assert(drmModePageFlip(data->drm_fd, crtc_id,
-					   data->fb_id[1], 0, NULL) == 0);
+					   data->fb[1].fb_id, 0, NULL) == 0);
 		break;
 	case TEST_MMAP_CPU:
 	case TEST_PAGE_FLIP_AND_MMAP_CPU:
@@ -314,24 +312,21 @@ static bool prepare_test(data_t *data, enum test_mode test_mode)
 	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);
 
-	data->fb_id[0] = 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(data->fb_id[0]);
-	data->fb_id[1] = 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(data->fb_id[1]);
-
-	data->handle[0] = data->fb[0].gem_handle;
-	data->handle[1] = data->fb[1].gem_handle;
+	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);
 
 	/* scanout = fb[1] */
 	igt_plane_set_fb(data->primary, &data->fb[1]);
@@ -372,10 +367,10 @@ static bool prepare_test(data_t *data, enum test_mode test_mode)
 		 * Disable FBC RT address for both contexts
 		 * (by "rendering" to a non-scanout buffer).
 		 */
-		exec_nop(data, data->handle[0], data->ctx[1]);
-		exec_nop(data, data->handle[0], data->ctx[0]);
-		exec_nop(data, data->handle[0], data->ctx[1]);
-		exec_nop(data, data->handle[0], data->ctx[0]);
+		exec_nop(data, data->fb[0].gem_handle, data->ctx[1]);
+		exec_nop(data, data->fb[0].gem_handle, data->ctx[0]);
+		exec_nop(data, data->fb[0].gem_handle, data->ctx[1]);
+		exec_nop(data, data->fb[0].gem_handle, data->ctx[0]);
 	}
 
 	/* scanout = fb[0] */
-- 
2.1.4



More information about the Intel-gfx mailing list