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 6/6] tests/gem_gpgpu_fill: Add gen7 version without libdrm dependency
Date: Tue, 12 May 2020 10:24:02 +0200 [thread overview]
Message-ID: <20200512082402.26792-7-zbigniew.kempczynski@intel.com> (raw)
In-Reply-To: <20200512082402.26792-1-zbigniew.kempczynski@intel.com>
Rewriting all gpgpu tests is time consuming, so provide single
gen7 version which can be litmus paper does change goes toward
appropriate direction or not. Gpgpu pipeline creation is a little
bit coupled (some functions are used in other gens) so providing
"v2" version of the same functions is necessary unless former
will have full replacement.
So gpgpu fill prefers now "newer" version of the same pipeline
creation which is libdrm-free.
Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
---
tests/i915/gem_gpgpu_fill.c | 125 ++++++++++++++++++++++++++++--------
1 file changed, 98 insertions(+), 27 deletions(-)
diff --git a/tests/i915/gem_gpgpu_fill.c b/tests/i915/gem_gpgpu_fill.c
index fb1758bd..e35d40a1 100644
--- a/tests/i915/gem_gpgpu_fill.c
+++ b/tests/i915/gem_gpgpu_fill.c
@@ -46,6 +46,7 @@
#include "i915/gem.h"
#include "igt.h"
#include "intel_bufmgr.h"
+#include "intel_bufops.h"
#define WIDTH 64
#define HEIGHT 64
@@ -60,6 +61,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,
@@ -83,6 +85,33 @@ 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, 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)
@@ -97,47 +126,89 @@ 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__cpu_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 gpgpu_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 gpgpu_fill = NULL;
+ igt_fillfunc_v2_t gpgpu_fill_v2 = NULL;
+
data.drm_fd = drm_open_driver_render(DRIVER_INTEL);
data.devid = intel_get_drm_devid(data.drm_fd);
igt_require_gem(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);
gpgpu_fill = igt_get_gpgpu_fillfunc(data.devid);
+ gpgpu_fill_v2 = igt_get_gpgpu_fillfunc_v2(data.devid);
- igt_require_f(gpgpu_fill,
+ igt_require_f(gpgpu_fill || gpgpu_fill_v2,
"no gpgpu-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);
- }
- }
-
- gpgpu_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 (gpgpu_fill_v2)
+ no_libdrm(&data, gpgpu_fill_v2);
+ else
+ with_libdrm(&data, gpgpu_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-12 8:24 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-12 8:23 [igt-dev] [PATCH i-g-t 0/6] Make gpgpu fill tests libdrm independent Zbigniew Kempczyński
2020-05-12 8:23 ` [igt-dev] [PATCH i-g-t 1/6] lib/intel_bufops: Add bufops reference and relaxate stride requirement Zbigniew Kempczyński
2020-05-12 9:29 ` Chris Wilson
2020-05-12 8:23 ` [igt-dev] [PATCH i-g-t 2/6] lib/intel_batchbuffer: Introduce intel_bb Zbigniew Kempczyński
2020-05-12 9:39 ` Chris Wilson
2020-05-12 8:23 ` [igt-dev] [PATCH i-g-t 3/6] lib/intel_batchbuffer: Introduce temporary igt_fillfunc_v2_t Zbigniew Kempczyński
2020-05-12 8:24 ` [igt-dev] [PATCH i-g-t 4/6] lib/gpu_cmds: Add gpgpu pipeline functions based on intel_bb Zbigniew Kempczyński
2020-05-12 8:24 ` [igt-dev] [PATCH i-g-t 5/6] lib/gpgpu_fill: libdrm-free gpgpu pipeline creation for gen7 Zbigniew Kempczyński
2020-05-12 8:24 ` Zbigniew Kempczyński [this message]
2020-05-12 8:59 ` [igt-dev] ✓ Fi.CI.BAT: success for Make gpgpu fill tests libdrm independent Patchwork
2020-05-12 10:43 ` [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=20200512082402.26792-7-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