From: "Zbigniew Kempczyński" <zbigniew.kempczynski@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Subject: [igt-dev] [PATCH i-g-t v2 4/5] i915/gem_media_fill: Remove libdrm dependency
Date: Thu, 21 May 2020 10:39:25 +0200 [thread overview]
Message-ID: <20200521083926.20428-5-zbigniew.kempczynski@intel.com> (raw)
In-Reply-To: <20200521083926.20428-1-zbigniew.kempczynski@intel.com>
We still have some dependencies to libdrm code in other tests so
"divide and conquer" strategy is required to migrate and remove
old code. Add no-libdrm version to continue migration process.
Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
---
tests/i915/gem_media_fill.c | 127 ++++++++++++++++++++++++++++--------
1 file changed, 99 insertions(+), 28 deletions(-)
diff --git a/tests/i915/gem_media_fill.c b/tests/i915/gem_media_fill.c
index 3f0fec57..7c975577 100644
--- a/tests/i915/gem_media_fill.c
+++ b/tests/i915/gem_media_fill.c
@@ -63,6 +63,7 @@ typedef struct {
uint32_t devid;
drm_intel_bufmgr *bufmgr;
uint8_t linear[WIDTH * HEIGHT];
+ struct buf_ops *bops;
} data_t;
static void scratch_buf_init(data_t *data, struct igt_buf *buf,
@@ -86,6 +87,34 @@ static void scratch_buf_init(data_t *data, struct igt_buf *buf,
buf->bpp = 32;
}
+static struct intel_buf *
+create_buf(data_t *data, int width, int height, uint8_t color)
+{
+ struct intel_buf *buf;
+ uint8_t *ptr;
+ int i;
+
+ buf = calloc(1, sizeof(*buf));
+ igt_assert(buf);
+
+ /*
+ * Legacy code uses 32 bpp after buffer creation.
+ * Let's do the same due to keep shader intact.
+ */
+ intel_buf_init(data->bops, buf, width/4, height, 32, 0,
+ I915_TILING_NONE, 0);
+
+ ptr = gem_mmap__cpu_coherent(data->drm_fd,
+ buf->handle, 0, buf->size, PROT_WRITE);
+
+ for (i = 0; i < buf->size; i++)
+ ptr[i] = color;
+
+ munmap(ptr, buf->size);
+
+ return buf;
+}
+
static void
scratch_buf_check(data_t *data, struct igt_buf *buf, int x, int y,
uint8_t color)
@@ -100,48 +129,90 @@ scratch_buf_check(data_t *data, struct igt_buf *buf, int x, int y,
color, val, x, y);
}
-igt_simple_main
+static void buf_check(uint8_t *ptr, int x, int y, uint8_t color)
+{
+ uint8_t val;
+
+ val = ptr[y * WIDTH + x];
+ igt_assert_f(val == color,
+ "Expected 0x%02x, found 0x%02x at (%d,%d)\n",
+ color, val, x, y);
+}
+
+static void no_libdrm(data_t *data, igt_fillfunc_v2_t fill)
+{
+ struct intel_buf *buf;
+ uint8_t *ptr;
+ int i, j;
+
+ buf = create_buf(data, WIDTH, HEIGHT, COLOR_C4);
+ ptr = gem_mmap__device_coherent(data->drm_fd, buf->handle,
+ 0, buf->size, PROT_READ);
+ for (i = 0; i < WIDTH; i++)
+ for (j = 0; j < HEIGHT; j++)
+ buf_check(ptr, i, j, COLOR_C4);
+
+ fill(data->drm_fd, buf, 0, 0, WIDTH / 2, HEIGHT / 2, COLOR_4C);
+
+ for (i = 0; i < WIDTH; i++)
+ for (j = 0; j < HEIGHT; j++)
+ if (i < WIDTH / 2 && j < HEIGHT / 2)
+ buf_check(ptr, i, j, COLOR_4C);
+ else
+ buf_check(ptr, i, j, COLOR_C4);
+
+ munmap(ptr, buf->size);
+}
+
+static void with_libdrm(data_t *data, igt_fillfunc_t fill)
{
- data_t data = {0, };
struct intel_batchbuffer *batch = NULL;
struct igt_buf dst;
- igt_fillfunc_t media_fill = NULL;
int i, j;
+ batch = intel_batchbuffer_alloc(data->bufmgr, data->devid);
+ igt_assert(batch);
+
+ scratch_buf_init(data, &dst, WIDTH, HEIGHT, STRIDE, COLOR_C4);
+
+ for (i = 0; i < WIDTH; i++)
+ for (j = 0; j < HEIGHT; j++)
+ scratch_buf_check(data, &dst, i, j, COLOR_C4);
+
+ fill(batch, &dst, 0, 0, WIDTH / 2, HEIGHT / 2, COLOR_4C);
+
+ for (i = 0; i < WIDTH; i++)
+ for (j = 0; j < HEIGHT; j++)
+ if (i < WIDTH / 2 && j < HEIGHT / 2)
+ scratch_buf_check(data, &dst, i, j, COLOR_4C);
+ else
+ scratch_buf_check(data, &dst, i, j, COLOR_C4);
+
+}
+
+igt_simple_main
+{
+ data_t data = {0, };
+ igt_fillfunc_t media_fill = NULL;
+ igt_fillfunc_v2_t media_fill_v2 = NULL;
+
data.drm_fd = drm_open_driver_render(DRIVER_INTEL);
igt_require_gem(data.drm_fd);
data.devid = intel_get_drm_devid(data.drm_fd);
+ data.bops = buf_ops_create(data.drm_fd);
data.bufmgr = drm_intel_bufmgr_gem_init(data.drm_fd, 4096);
igt_assert(data.bufmgr);
media_fill = igt_get_media_fillfunc(data.devid);
+ media_fill_v2 = igt_get_media_fillfunc_v2(data.devid);
- igt_require_f(media_fill,
- "no media-fill function\n");
+ igt_require_f(media_fill || media_fill_v2,
+ "no media-fill function\n");
- batch = intel_batchbuffer_alloc(data.bufmgr, data.devid);
- igt_assert(batch);
-
- scratch_buf_init(&data, &dst, WIDTH, HEIGHT, STRIDE, COLOR_C4);
-
- for (i = 0; i < WIDTH; i++) {
- for (j = 0; j < HEIGHT; j++) {
- scratch_buf_check(&data, &dst, i, j, COLOR_C4);
- }
- }
-
- media_fill(batch,
- &dst, 0, 0, WIDTH / 2, HEIGHT / 2,
- COLOR_4C);
-
- for (i = 0; i < WIDTH; i++) {
- for (j = 0; j < HEIGHT; j++) {
- if (i < WIDTH / 2 && j < HEIGHT / 2)
- scratch_buf_check(&data, &dst, i, j, COLOR_4C);
- else
- scratch_buf_check(&data, &dst, i, j, COLOR_C4);
- }
- }
+ if (media_fill_v2)
+ no_libdrm(&data, media_fill_v2);
+ else
+ with_libdrm(&data, media_fill);
}
--
2.26.0
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2020-05-21 8:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-21 8:39 [igt-dev] [PATCH i-g-t v2 0/5] Change media fill to be libdrm-free Zbigniew Kempczyński
2020-05-21 8:39 ` [igt-dev] [PATCH i-g-t v2 1/5] lib/gpu_cmds: Add media pipeline functions based on intel_bb Zbigniew Kempczyński
2020-05-21 8:39 ` [igt-dev] [PATCH i-g-t v2 2/5] lib/media_fill: libdrm-free media pipeline creation Zbigniew Kempczyński
2020-05-21 8:39 ` [igt-dev] [PATCH i-g-t v2 3/5] lib/intel_batchbuffer: Add new media fillfunc v2 Zbigniew Kempczyński
2020-05-21 8:39 ` Zbigniew Kempczyński [this message]
2020-05-21 8:39 ` [igt-dev] [PATCH i-g-t v2 5/5] HAX: run media_fill in BAT only Zbigniew Kempczyński
2020-05-21 9:32 ` [igt-dev] ✓ Fi.CI.BAT: success for Change media fill to be libdrm-free (rev2) Patchwork
2020-05-22 1:44 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
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=20200521083926.20428-5-zbigniew.kempczynski@intel.com \
--to=zbigniew.kempczynski@intel.com \
--cc=chris@chris-wilson.co.uk \
--cc=igt-dev@lists.freedesktop.org \
/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