From: Paulo Zanoni <przanoni@gmail.com>
To: intel-gfx@lists.freedesktop.org
Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
Subject: [PATCH 6/7] tests/kms_fbc_crc: remove redundant information from data_t
Date: Wed, 25 Mar 2015 18:50:38 -0300 [thread overview]
Message-ID: <1427320239-25667-6-git-send-email-przanoni@gmail.com> (raw)
In-Reply-To: <1427320239-25667-1-git-send-email-przanoni@gmail.com>
From: Paulo Zanoni <paulo.r.zanoni@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@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
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2015-03-25 21:51 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-25 21:50 [PATCH 1/7] lib: add igt_wait() Paulo Zanoni
2015-03-25 21:50 ` [PATCH 2/7] tests/kms_fb_crc: call gem_sync() instead of gem_bo_busy() Paulo Zanoni
2015-03-26 10:06 ` Daniel Vetter
2015-03-25 21:50 ` [PATCH 3/7] tests/kms_fbc_crc: add wait_for_fbc_enabled() Paulo Zanoni
2015-03-26 10:07 ` Daniel Vetter
2015-03-25 21:50 ` [PATCH 4/7] tests/kms_fbc_crc: also gem_sync() on exec_nop() Paulo Zanoni
2015-03-25 21:50 ` [PATCH 5/7] tests/kms_fbc_crc: use igt_pipe_crc_collect_crc() Paulo Zanoni
2015-03-25 21:50 ` Paulo Zanoni [this message]
2015-03-25 21:50 ` [PATCH 7/7] lib: add igt_draw Paulo Zanoni
2015-03-26 10:19 ` Daniel Vetter
2015-03-30 19:45 ` Paulo Zanoni
2015-03-31 13:07 ` Daniel Vetter
2015-03-31 14:03 ` Paulo Zanoni
2015-03-31 21:52 ` Paulo Zanoni
2015-03-31 22:05 ` Chris Wilson
2015-04-01 22:08 ` Paulo Zanoni
2015-04-01 22:22 ` Chris Wilson
2015-04-01 22:33 ` Paulo Zanoni
2015-04-01 22:40 ` Paulo Zanoni
2015-04-01 23:15 ` Chris Wilson
2015-04-01 23:17 ` Chris Wilson
2015-04-07 8:10 ` Daniel Vetter
2015-04-07 8:36 ` Chris Wilson
2015-04-07 9:07 ` Daniel Vetter
2015-04-07 10:12 ` Chris Wilson
2015-04-07 13:44 ` Daniel Vetter
2015-05-05 21:30 ` Paulo Zanoni
2015-05-06 9:00 ` Daniel Vetter
2015-04-01 23:03 ` Chris Wilson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1427320239-25667-6-git-send-email-przanoni@gmail.com \
--to=przanoni@gmail.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=paulo.r.zanoni@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox