From: Paul Kocialkowski <paul.kocialkowski@linux.intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: Lyude <lyude@redhat.com>
Subject: [PATCH i-g-t v4 6/7] chamelium: Dump captured and reference frames to png on crc error
Date: Wed, 12 Jul 2017 17:50:30 +0300 [thread overview]
Message-ID: <20170712145031.3531-7-paul.kocialkowski@linux.intel.com> (raw)
In-Reply-To: <20170712145031.3531-1-paul.kocialkowski@linux.intel.com>
This adds support for dumping both the frame capture from the chamelium
and the reference frame generated by cairo when the captured crc does
not match the crc calculated from the reference, using common helpers.
Getting a dump of the frames is quite useful in order to compare them.
Signed-off-by: Paul Kocialkowski <paul.kocialkowski@linux.intel.com>
---
lib/igt_chamelium.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++
lib/igt_chamelium.h | 4 +++
tests/chamelium.c | 14 ++++++---
3 files changed, 95 insertions(+), 4 deletions(-)
diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
index baa6399c..df49936b 100644
--- a/lib/igt_chamelium.c
+++ b/lib/igt_chamelium.c
@@ -930,6 +930,32 @@ static pixman_image_t *convert_frame_format(pixman_image_t *src,
return converted;
}
+static cairo_surface_t *convert_frame_dump_argb32(const struct chamelium_frame_dump *dump)
+{
+ cairo_surface_t *dump_surface;
+ pixman_image_t *image_bgr;
+ pixman_image_t *image_argb;
+ int w = dump->width, h = dump->height;
+ uint32_t *bits_bgr = (uint32_t *) dump->bgr;
+ unsigned char *bits_argb;
+
+ image_bgr = pixman_image_create_bits(
+ PIXMAN_b8g8r8, w, h, bits_bgr,
+ PIXMAN_FORMAT_BPP(PIXMAN_b8g8r8) / 8 * w);
+ image_argb = convert_frame_format(image_bgr, PIXMAN_x8r8g8b8);
+ pixman_image_unref(image_bgr);
+
+ bits_argb = (unsigned char *) pixman_image_get_data(image_argb);
+
+ dump_surface = cairo_image_surface_create_for_data(
+ bits_argb, CAIRO_FORMAT_ARGB32, w, h,
+ PIXMAN_FORMAT_BPP(PIXMAN_x8r8g8b8) / 8 * w);
+
+ pixman_image_unref(image_argb);
+
+ return dump_surface;
+}
+
/**
* chamelium_assert_frame_eq:
* @chamelium: The chamelium instance the frame dump belongs to
@@ -974,6 +1000,61 @@ void chamelium_assert_frame_eq(const struct chamelium *chamelium,
}
/**
+ * chamelium_assert_crc_eq_or_dump:
+ * @chamelium: The chamelium instance the frame dump belongs to
+ * @reference_crc: The CRC for the reference frame
+ * @capture_crc: The CRC for the captured frame
+ * @fb: pointer to an #igt_fb structure
+ *
+ * Asserts that the CRC provided for both the reference and the captured frame
+ * are identical. If they are not, this grabs the captured frame and saves it
+ * along with the reference to a png file.
+ */
+void chamelium_assert_crc_eq_or_dump(struct chamelium *chamelium,
+ igt_crc_t *reference_crc,
+ igt_crc_t *capture_crc, struct igt_fb *fb,
+ int index)
+{
+ struct chamelium_frame_dump *frame;
+ cairo_surface_t *reference;
+ cairo_surface_t *capture;
+ char *reference_suffix;
+ char *capture_suffix;
+ bool eq;
+
+ eq = igt_check_crc_equal(reference_crc, capture_crc);
+ if (!eq && igt_frame_dump_is_enabled()) {
+ /* Grab the reference frame from framebuffer */
+ reference = igt_get_cairo_surface(chamelium->drm_fd, fb);
+
+ /* Grab the captured frame from chamelium */
+ frame = chamelium_read_captured_frame(chamelium, index);
+ igt_assert(frame);
+
+ capture = convert_frame_dump_argb32(frame);
+
+ reference_suffix = igt_crc_to_string_extended(reference_crc,
+ '-', 2);
+ capture_suffix = igt_crc_to_string_extended(capture_crc, '-',
+ 2);
+
+ /* Write reference and capture frames to png */
+ igt_write_compared_frames_to_png(reference, capture,
+ reference_suffix,
+ capture_suffix);
+
+ free(reference_suffix);
+ free(capture_suffix);
+
+ chamelium_destroy_frame_dump(frame);
+
+ cairo_surface_destroy(capture);
+ }
+
+ igt_assert(eq);
+}
+
+/**
* chamelium_get_frame_limit:
* @chamelium: The Chamelium instance to use
* @port: The port to check the frame limit on
diff --git a/lib/igt_chamelium.h b/lib/igt_chamelium.h
index 2bfbfdc7..80afcafa 100644
--- a/lib/igt_chamelium.h
+++ b/lib/igt_chamelium.h
@@ -105,6 +105,10 @@ int chamelium_get_frame_limit(struct chamelium *chamelium,
void chamelium_assert_frame_eq(const struct chamelium *chamelium,
const struct chamelium_frame_dump *dump,
struct igt_fb *fb);
+void chamelium_assert_crc_eq_or_dump(struct chamelium *chamelium,
+ igt_crc_t *reference_crc,
+ igt_crc_t *capture_crc, struct igt_fb *fb,
+ int index);
void chamelium_destroy_frame_dump(struct chamelium_frame_dump *dump);
#endif /* IGT_CHAMELIUM_H */
diff --git a/tests/chamelium.c b/tests/chamelium.c
index da98de47..f93ff7ee 100644
--- a/tests/chamelium.c
+++ b/tests/chamelium.c
@@ -390,7 +390,7 @@ test_display_crc_single(data_t *data, struct chamelium_port *port)
struct igt_fb fb;
drmModeModeInfo *mode;
drmModeConnector *connector;
- int fb_id, i;
+ int fb_id, i, captured_frame_count;
reset_state(data, port);
@@ -415,11 +415,15 @@ test_display_crc_single(data_t *data, struct chamelium_port *port)
igt_debug("Testing single CRC fetch\n");
- crc = chamelium_get_crc_for_area(data->chamelium, port,
- 0, 0, 0, 0);
+ chamelium_capture(data->chamelium, port, 0, 0, 0, 0, 1);
+ crc = chamelium_read_captured_crcs(data->chamelium,
+ &captured_frame_count);
expected_crc = chamelium_calculate_fb_crc_async_finish(fb_crc);
+ chamelium_assert_crc_eq_or_dump(data->chamelium, expected_crc,
+ crc, &fb, 0);
+
igt_assert_crc_equal(crc, expected_crc);
free(expected_crc);
free(crc);
@@ -481,7 +485,9 @@ test_display_crc_multiple(data_t *data, struct chamelium_port *port)
expected_crc = chamelium_calculate_fb_crc_async_finish(fb_crc);
for (j = 0; j < captured_frame_count; j++)
- igt_assert_crc_equal(&crc[j], expected_crc);
+ chamelium_assert_crc_eq_or_dump(data->chamelium,
+ expected_crc, &crc[j],
+ &fb, j);
free(expected_crc);
free(crc);
--
2.13.2
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2017-07-12 14:51 UTC|newest]
Thread overview: 57+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-05 8:04 [PATCH i-g-t v3 1/4] chamelium: Calculate CRC from framebuffer instead of hardcoding it Paul Kocialkowski
2017-07-05 8:04 ` [PATCH i-g-t v3 2/4] tests/ chamelium: Remove the frame dump tests Paul Kocialkowski
2017-07-05 20:53 ` Lyude Paul
2017-07-06 7:37 ` Martin Peres
2017-07-06 13:29 ` Paul Kocialkowski
2017-07-05 8:04 ` [PATCH i-g-t v3 3/4] lib/igt_chamelium: Add support for dumping chamelium frames to a png Paul Kocialkowski
2017-07-05 21:16 ` Lyude Paul
2017-07-05 8:04 ` [PATCH i-g-t v3 4/4] chamelium: Dump obtained and reference frames to png on crc error Paul Kocialkowski
2017-07-05 21:44 ` Lyude Paul
2017-07-06 7:41 ` Martin Peres
2017-07-06 11:35 ` Paul Kocialkowski
2017-07-06 22:23 ` Lyude Paul
2017-07-10 10:12 ` Paul Kocialkowski
2017-07-06 11:31 ` Paul Kocialkowski
2017-07-06 13:33 ` Paul Kocialkowski
2017-07-06 21:57 ` Lyude Paul
2017-07-10 10:27 ` Paul Kocialkowski
2017-07-11 17:27 ` Lyude Paul
2017-07-10 10:31 ` Paul Kocialkowski
2017-07-10 10:33 ` Martin Peres
2017-07-10 12:06 ` Paul Kocialkowski
2017-07-10 13:56 ` Martin Peres
2017-07-10 14:11 ` Paul Kocialkowski
2017-07-10 16:02 ` Martin Peres
2017-07-05 20:34 ` [PATCH i-g-t v3 1/4] chamelium: Calculate CRC from framebuffer instead of hardcoding it Lyude Paul
2017-07-05 20:49 ` Lyude Paul
2017-07-06 8:49 ` Paul Kocialkowski
2017-07-06 13:14 ` Paul Kocialkowski
2017-07-06 22:33 ` Lyude Paul
2017-07-12 14:50 ` [PATCH i-g-t v4 0/7] CRC testing with Chamelium improvements Paul Kocialkowski
2017-07-12 14:50 ` [PATCH i-g-t v4 1/7] lib/igt_fb: Export the cairo surface instead of writing to a png Paul Kocialkowski
2017-07-12 14:50 ` [PATCH i-g-t v4 2/7] chamelium: Calculate CRC from framebuffer instead of hardcoding it Paul Kocialkowski
2017-07-17 16:29 ` Lyude Paul
2017-07-19 11:11 ` Paul Kocialkowski
2017-07-12 14:50 ` [PATCH i-g-t v4 3/7] lib/igt_debugfs: Introduce CRC check function, with logic made common Paul Kocialkowski
2017-07-12 14:50 ` [PATCH i-g-t v4 4/7] Introduce common frame dumping configuration and helpers Paul Kocialkowski
2017-07-12 14:50 ` [PATCH i-g-t v4 5/7] lib/igt_debugfs: Add extended helper to format crc to string Paul Kocialkowski
2017-07-12 14:50 ` Paul Kocialkowski [this message]
2017-07-12 14:50 ` [PATCH i-g-t v4 7/7] tests/chamelium: Merge the crc testing functions into one Paul Kocialkowski
2017-07-12 14:53 ` [PATCH i-g-t v4 0/7] CRC testing with Chamelium improvements Paul Kocialkowski
2017-07-17 17:04 ` Lyude Paul
2017-07-19 13:46 ` [PATCH i-g-t v5 " Paul Kocialkowski
2017-07-19 13:46 ` [PATCH i-g-t v5 1/7] lib/igt_fb: Export the cairo surface instead of writing to a png Paul Kocialkowski
2017-07-19 13:46 ` [PATCH i-g-t v5 2/7] chamelium: Calculate CRC from framebuffer instead of hardcoding it Paul Kocialkowski
2017-07-19 13:46 ` [PATCH i-g-t v5 3/7] lib/igt_debugfs: Introduce CRC check function, with logic made common Paul Kocialkowski
2017-07-19 13:46 ` [PATCH i-g-t v5 4/7] Introduce common frame dumping configuration and helpers Paul Kocialkowski
2017-07-20 7:24 ` Daniel Vetter
2017-07-20 14:14 ` Paul Kocialkowski
2017-07-19 13:46 ` [PATCH i-g-t v5 5/7] lib/igt_debugfs: Add extended helper to format crc to string Paul Kocialkowski
2017-07-19 13:46 ` [PATCH i-g-t v5 6/7] chamelium: Dump captured and reference frames to png on crc error Paul Kocialkowski
2017-07-19 13:46 ` [PATCH i-g-t v5 7/7] tests/chamelium: Merge the crc testing functions into one Paul Kocialkowski
2017-07-19 16:09 ` [PATCH i-g-t v5 0/7] CRC testing with Chamelium improvements Lyude Paul
2017-07-20 9:39 ` Jani Nikula
2017-07-20 11:15 ` Martin Peres
2017-07-20 11:27 ` Paul Kocialkowski
2017-07-20 12:41 ` Daniel Vetter
2017-07-20 12:44 ` Paul Kocialkowski
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=20170712145031.3531-7-paul.kocialkowski@linux.intel.com \
--to=paul.kocialkowski@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=lyude@redhat.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;
as well as URLs for NNTP newsgroup(s).