diff mbox

[3/4] rendercopy: Add a way to dump an .aub file with the rendercopy bos

Message ID 1361371996-28166-3-git-send-email-damien.lespiau@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Lespiau, Damien Feb. 20, 2013, 2:53 p.m. UTC
To not bump the dependency on libdrm for a debug feature, the use of new
libdrm symbols are gated by ENABLE_AUB_DUMP and depends on having the
next (2.4.43) libdrm release.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 configure.ac                    |    6 ++++++
 lib/drmtest.c                   |   10 ++++++++++
 lib/drmtest.h                   |    2 ++
 tests/gem_render_linear_blits.c |   24 ++++++++++++++++++++++++
 4 files changed, 42 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/configure.ac b/configure.ac
index 5e2dbed..1ba1584 100644
--- a/configure.ac
+++ b/configure.ac
@@ -59,6 +59,12 @@  XORG_DEFAULT_OPTIONS
 PKG_CHECK_MODULES(DRM, [libdrm_intel >= 2.4.38 libdrm])
 PKG_CHECK_MODULES(PCIACCESS, [pciaccess >= 0.10])
 
+# check if we libdrm is recent enough for our aub dump code
+PKG_CHECK_EXISTS(AUB, [libdrm_intel >= 2.4.43],
+		 [enable_aub_dump=yes], [enable_aub_dump=no])
+AS_IF([test x"$enable_aub_dump" = xyes],
+      [AC_DEFINE(ENABLE_AUB_DUMP,1,[Enable AUB dumps])])
+
 # for testdisplay
 PKG_CHECK_MODULES(CAIRO, cairo)
 PKG_CHECK_MODULES(LIBUDEV, [libudev], [udev=yes], [udev=no])
diff --git a/lib/drmtest.c b/lib/drmtest.c
index 641028c..1146715 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -595,6 +595,16 @@  bool drmtest_run_quick(void)
 	return run_quick;
 }
 
+bool drmtest_dump_aub(void)
+{
+	static int dump_aub = -1;
+
+	if (dump_aub == -1)
+		dump_aub = env_set("IGT_DUMP_AUB");
+
+	return dump_aub;
+}
+
 /* other helpers */
 void drmtest_exchange_int(void *array, unsigned i, unsigned j)
 {
diff --git a/lib/drmtest.h b/lib/drmtest.h
index 78732a0..1358491 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -91,6 +91,8 @@  bool drmtest_only_list_subtests(void);
 bool drmtest_run_quick(void);
 #define SLOW_QUICK(slow,quick) (drmtest_run_quick() ? (quick) : (slow))
 
+bool drmtest_dump_aub(void);
+
 /* helpers based upon the libdrm buffer manager */
 void drmtest_init_aperture_trashers(drm_intel_bufmgr *bufmgr);
 void drmtest_trash_aperture(void);
diff --git a/tests/gem_render_linear_blits.c b/tests/gem_render_linear_blits.c
index a7e0189..4c1c6ad 100644
--- a/tests/gem_render_linear_blits.c
+++ b/tests/gem_render_linear_blits.c
@@ -33,6 +33,10 @@ 
  * The goal is to simply ensure the basics work.
  */
 
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include "rendercopy.h"
 
 #define WIDTH 512
@@ -83,6 +87,13 @@  int main(int argc, char **argv)
 	count = 0;
 	if (argc > 1)
 		count = atoi(argv[1]);
+#ifdef ENABLE_AUB_DUMP
+	if (drmtest_dump_aub()) {
+		count = 2;
+		drm_intel_bufmgr_gem_set_aub_filename(bufmgr, "rendercopy.aub");
+		drm_intel_bufmgr_gem_set_aub_dump(bufmgr, true);
+	}
+#endif
 	if (count == 0)
 		count = 3 * gem_aperture_size(fd) / SIZE / 2;
 	else if (count < 2) {
@@ -123,6 +134,19 @@  int main(int argc, char **argv)
 
 		render_copy(batch, &src, 0, 0, WIDTH, HEIGHT, &dst, 0, 0);
 		start_val[(i + 1) % count] = start_val[i % count];
+
+#ifdef ENABLE_AUB_DUMP
+		/* We're not really here for the test, we just want to dump a
+		 * trace of a call to render_copy() */
+		if (drmtest_dump_aub()) {
+			drm_intel_gem_bo_aub_dump_bmp(dst.bo,
+				0, 0, WIDTH, HEIGHT,
+				AUB_DUMP_BMP_FORMAT_ARGB_8888,
+				STRIDE, 0);
+			drm_intel_bufmgr_gem_set_aub_dump(bufmgr, false);
+			return 0;
+		}
+#endif
 	}
 	for (i = 0; i < count; i++)
 		check_bo(fd, bo[i]->handle, start_val[i]);