Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] lib: Factor out a function to check if an environment variable is set
@ 2013-02-20 14:53 Damien Lespiau
  2013-02-20 14:53 ` [PATCH 2/4] lib: Allow to override the device id at run time Damien Lespiau
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Damien Lespiau @ 2013-02-20 14:53 UTC (permalink / raw)
  To: intel-gfx

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 lib/drmtest.c |   24 +++++++++++++-----------
 1 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/lib/drmtest.c b/lib/drmtest.c
index 117fb31..641028c 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -574,22 +574,24 @@ bool drmtest_only_list_subtests(void)
 	return list_subtests;
 }
 
+static bool env_set(const char *env_var)
+{
+	char *val;
+
+	val = getenv(env_var);
+	if (!val)
+		return false;
+
+	return atoi(val) != 0;
+}
+
 bool drmtest_run_quick(void)
 {
 	static int run_quick = -1;
 
-	if (run_quick == -1) {
-		char *igt_quick;
+	if (run_quick == -1)
+		run_quick = env_set("IGT_QUICK");
 
-		igt_quick = getenv("IGT_QUICK");
-		if (!igt_quick) {
-			run_quick = 0;
-			goto out;
-		}
-
-		run_quick = atoi(igt_quick);
-	}
-out:
 	return run_quick;
 }
 
-- 
1.7.7.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/4] lib: Allow to override the device id at run time
  2013-02-20 14:53 [PATCH 1/4] lib: Factor out a function to check if an environment variable is set Damien Lespiau
@ 2013-02-20 14:53 ` Damien Lespiau
  2013-02-20 14:53 ` [PATCH 3/4] rendercopy: Add a way to dump an .aub file with the rendercopy bos Damien Lespiau
  2013-02-20 14:53 ` [PATCH 4/4] build: Guard the inclusions of config.h with HAVE_CONFIG_H Damien Lespiau
  2 siblings, 0 replies; 4+ messages in thread
From: Damien Lespiau @ 2013-02-20 14:53 UTC (permalink / raw)
  To: intel-gfx

Using the same environment variable as libdrm so one doesn't have to
remember two different things. This is helpful to run a test under a
fake identity, to, say, dump an aub file.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 lib/intel_drm.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/lib/intel_drm.c b/lib/intel_drm.c
index 8d89d24..eaf9895 100644
--- a/lib/intel_drm.c
+++ b/lib/intel_drm.c
@@ -54,12 +54,18 @@ intel_get_drm_devid(int fd)
 	int ret;
 	struct drm_i915_getparam gp;
 	uint32_t devid;
+	char *override;
 
-	gp.param = I915_PARAM_CHIPSET_ID;
-	gp.value = (int *)&devid;
+	override = getenv("INTEL_DEVID_OVERRIDE");
+	if (override) {
+		devid = strtod(override, NULL);
+	} else {
+		gp.param = I915_PARAM_CHIPSET_ID;
+		gp.value = (int *)&devid;
 
-	ret = ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp));
-	assert(ret == 0);
+		ret = ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp, sizeof(gp));
+		assert(ret == 0);
+	}
 
 	return devid;
 }
-- 
1.7.7.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/4] rendercopy: Add a way to dump an .aub file with the rendercopy bos
  2013-02-20 14:53 [PATCH 1/4] lib: Factor out a function to check if an environment variable is set Damien Lespiau
  2013-02-20 14:53 ` [PATCH 2/4] lib: Allow to override the device id at run time Damien Lespiau
@ 2013-02-20 14:53 ` Damien Lespiau
  2013-02-20 14:53 ` [PATCH 4/4] build: Guard the inclusions of config.h with HAVE_CONFIG_H Damien Lespiau
  2 siblings, 0 replies; 4+ messages in thread
From: Damien Lespiau @ 2013-02-20 14:53 UTC (permalink / raw)
  To: intel-gfx

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 --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]);
-- 
1.7.7.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 4/4] build: Guard the inclusions of config.h with HAVE_CONFIG_H
  2013-02-20 14:53 [PATCH 1/4] lib: Factor out a function to check if an environment variable is set Damien Lespiau
  2013-02-20 14:53 ` [PATCH 2/4] lib: Allow to override the device id at run time Damien Lespiau
  2013-02-20 14:53 ` [PATCH 3/4] rendercopy: Add a way to dump an .aub file with the rendercopy bos Damien Lespiau
@ 2013-02-20 14:53 ` Damien Lespiau
  2 siblings, 0 replies; 4+ messages in thread
From: Damien Lespiau @ 2013-02-20 14:53 UTC (permalink / raw)
  To: intel-gfx

autoconf can be configured to not generate a config.h but to give the
defines with command line arguments instead. In this case, there's no
config.h to include.

To work in both cases autoconf adds a HAVE_CONFIG_H define on the command
line to signal there's a config.h to include.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 lib/intel_drm.c          |    2 ++
 tests/gem_fence_thrash.c |    2 ++
 tests/kms_flip.c         |    2 ++
 tests/testdisplay.c      |    2 ++
 tools/intel_gpu_top.c    |    2 ++
 5 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/lib/intel_drm.c b/lib/intel_drm.c
index eaf9895..4656b49 100644
--- a/lib/intel_drm.c
+++ b/lib/intel_drm.c
@@ -26,7 +26,9 @@
  *
  */
 
+#ifdef HAVE_CONFIG_H
 #include "config.h"
+#endif
 
 #include <unistd.h>
 #include <stdlib.h>
diff --git a/tests/gem_fence_thrash.c b/tests/gem_fence_thrash.c
index 3d50e33..c9e847b 100644
--- a/tests/gem_fence_thrash.c
+++ b/tests/gem_fence_thrash.c
@@ -26,7 +26,9 @@
  *
  */
 
+#ifdef HAVE_CONFIG_H
 #include "config.h"
+#endif
 
 #include <unistd.h>
 #include <stdlib.h>
diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index c2a29ae..1de6154 100644
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -21,7 +21,9 @@
  * IN THE SOFTWARE.
  */
 
+#ifdef HAVE_CONFIG_H
 #include "config.h"
+#endif
 
 #include <assert.h>
 #include <cairo.h>
diff --git a/tests/testdisplay.c b/tests/testdisplay.c
index 4d29ddb..251141f 100644
--- a/tests/testdisplay.c
+++ b/tests/testdisplay.c
@@ -45,7 +45,9 @@
  *  - DP commands (e.g. poweroff)
  * - verify outputs against VBT/physical connectors
  */
+#ifdef HAVE_CONFIG_H
 #include "config.h"
+#endif
 
 #include <assert.h>
 #include <cairo.h>
diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c
index 76a2b0b..c8b506a 100644
--- a/tools/intel_gpu_top.c
+++ b/tools/intel_gpu_top.c
@@ -27,7 +27,9 @@
  *
  */
 
+#ifdef HAVE_CONFIG_H
 #include "config.h"
+#endif
 
 #include <unistd.h>
 #include <stdlib.h>
-- 
1.7.7.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-02-20 14:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-20 14:53 [PATCH 1/4] lib: Factor out a function to check if an environment variable is set Damien Lespiau
2013-02-20 14:53 ` [PATCH 2/4] lib: Allow to override the device id at run time Damien Lespiau
2013-02-20 14:53 ` [PATCH 3/4] rendercopy: Add a way to dump an .aub file with the rendercopy bos Damien Lespiau
2013-02-20 14:53 ` [PATCH 4/4] build: Guard the inclusions of config.h with HAVE_CONFIG_H Damien Lespiau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox