[igt-dev] [PATCH i-g-t v30 24/33] tests/gem_render_copy_redux: remove libdrm dependency
Zbigniew Kempczyński
zbigniew.kempczynski at intel.com
Wed Aug 19 12:32:57 UTC 2020
Use intel_bb / intel_buf to remove libdrm dependency.
Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
Cc: Dominik Grzegorzek <dominik.grzegorzek at intel.com>
Cc: Chris Wilson <chris at chris-wilson.co.uk>
---
tests/i915/gem_render_copy_redux.c | 67 +++++++++++++-----------------
1 file changed, 29 insertions(+), 38 deletions(-)
diff --git a/tests/i915/gem_render_copy_redux.c b/tests/i915/gem_render_copy_redux.c
index a3f77e84..3f9f926c 100644
--- a/tests/i915/gem_render_copy_redux.c
+++ b/tests/i915/gem_render_copy_redux.c
@@ -48,7 +48,6 @@
#include "i915/gem.h"
#include "igt.h"
-#include "intel_bufmgr.h"
IGT_TEST_DESCRIPTION("Advanced test for the render_copy() function.");
@@ -63,8 +62,8 @@ IGT_TEST_DESCRIPTION("Advanced test for the render_copy() function.");
typedef struct {
int fd;
uint32_t devid;
- drm_intel_bufmgr *bufmgr;
- struct intel_batchbuffer *batch;
+ struct buf_ops *bops;
+ struct intel_bb *ibb;
igt_render_copyfunc_t render_copy;
uint32_t linear[WIDTH * HEIGHT];
} data_t;
@@ -74,58 +73,50 @@ static void data_init(data_t *data)
data->fd = drm_open_driver(DRIVER_INTEL);
data->devid = intel_get_drm_devid(data->fd);
- data->bufmgr = drm_intel_bufmgr_gem_init(data->fd, 4096);
- igt_assert(data->bufmgr);
-
+ data->bops = buf_ops_create(data->fd);
data->render_copy = igt_get_render_copyfunc(data->devid);
igt_require_f(data->render_copy,
"no render-copy function\n");
- data->batch = intel_batchbuffer_alloc(data->bufmgr, data->devid);
- igt_assert(data->batch);
+ data->ibb = intel_bb_create(data->fd, 4096);
}
static void data_fini(data_t *data)
{
- intel_batchbuffer_free(data->batch);
- drm_intel_bufmgr_destroy(data->bufmgr);
- close(data->fd);
+ intel_bb_destroy(data->ibb);
+ buf_ops_destroy(data->bops);
+ close(data->fd);
}
-static void scratch_buf_init(data_t *data, struct igt_buf *buf,
+static void scratch_buf_init(data_t *data, struct intel_buf *buf,
int width, int height, int stride, uint32_t color)
{
- drm_intel_bo *bo;
int i;
- bo = drm_intel_bo_alloc(data->bufmgr, "", SIZE, 4096);
+ intel_buf_init(data->bops, buf, width, height, 32, 0,
+ I915_TILING_NONE, I915_COMPRESSION_NONE);
+ igt_assert(buf->surface[0].size == SIZE);
+ igt_assert(buf->surface[0].stride == stride);
+
for (i = 0; i < width * height; i++)
data->linear[i] = color;
- gem_write(data->fd, bo->handle, 0, data->linear,
+ gem_write(data->fd, buf->handle, 0, data->linear,
sizeof(data->linear));
-
- memset(buf, 0, sizeof(*buf));
-
- buf->bo = bo;
- buf->surface[0].stride = stride;
- buf->tiling = I915_TILING_NONE;
- buf->surface[0].size = SIZE;
- buf->bpp = 32;
}
-static void scratch_buf_fini(data_t *data, struct igt_buf *buf)
+static void scratch_buf_fini(data_t *data, struct intel_buf *buf)
{
- dri_bo_unreference(buf->bo);
+ intel_buf_close(data->bops, buf);
memset(buf, 0, sizeof(*buf));
}
static void
-scratch_buf_check(data_t *data, struct igt_buf *buf, int x, int y,
+scratch_buf_check(data_t *data, struct intel_buf *buf, int x, int y,
uint32_t color)
{
uint32_t val;
- gem_read(data->fd, buf->bo->handle, 0,
+ gem_read(data->fd, buf->handle, 0,
data->linear, sizeof(data->linear));
val = data->linear[y * WIDTH + x];
igt_assert_f(val == color,
@@ -135,7 +126,7 @@ scratch_buf_check(data_t *data, struct igt_buf *buf, int x, int y,
static void copy(data_t *data)
{
- struct igt_buf src, dst;
+ struct intel_buf src, dst;
scratch_buf_init(data, &src, WIDTH, HEIGHT, STRIDE, SRC_COLOR);
scratch_buf_init(data, &dst, WIDTH, HEIGHT, STRIDE, DST_COLOR);
@@ -143,7 +134,7 @@ static void copy(data_t *data)
scratch_buf_check(data, &src, WIDTH / 2, HEIGHT / 2, SRC_COLOR);
scratch_buf_check(data, &dst, WIDTH / 2, HEIGHT / 2, DST_COLOR);
- data->render_copy(data->batch, NULL,
+ data->render_copy(data->ibb, 0,
&src, 0, 0, WIDTH, HEIGHT,
&dst, WIDTH / 2, HEIGHT / 2);
@@ -157,9 +148,9 @@ static void copy(data_t *data)
static void copy_flink(data_t *data)
{
data_t local;
- struct igt_buf src, dst;
- struct igt_buf local_src, local_dst;
- struct igt_buf flink;
+ struct intel_buf src, dst;
+ struct intel_buf local_src, local_dst;
+ struct intel_buf flink;
uint32_t name;
data_init(&local);
@@ -167,23 +158,22 @@ static void copy_flink(data_t *data)
scratch_buf_init(data, &src, WIDTH, HEIGHT, STRIDE, 0);
scratch_buf_init(data, &dst, WIDTH, HEIGHT, STRIDE, DST_COLOR);
- data->render_copy(data->batch, NULL,
+ data->render_copy(data->ibb, 0,
&src, 0, 0, WIDTH, HEIGHT,
&dst, WIDTH, HEIGHT);
scratch_buf_init(&local, &local_src, WIDTH, HEIGHT, STRIDE, 0);
scratch_buf_init(&local, &local_dst, WIDTH, HEIGHT, STRIDE, SRC_COLOR);
- local.render_copy(local.batch, NULL,
+ local.render_copy(local.ibb, 0,
&local_src, 0, 0, WIDTH, HEIGHT,
&local_dst, WIDTH, HEIGHT);
-
- drm_intel_bo_flink(local_dst.bo, &name);
+ name = gem_flink(local.fd, local_dst.handle);
flink = local_dst;
- flink.bo = drm_intel_bo_gem_create_from_name(data->bufmgr, "flink", name);
+ flink.handle = gem_open(data->fd, name);
- data->render_copy(data->batch, NULL,
+ data->render_copy(data->ibb, 0,
&flink, 0, 0, WIDTH, HEIGHT,
&dst, WIDTH / 2, HEIGHT / 2);
@@ -193,6 +183,7 @@ static void copy_flink(data_t *data)
scratch_buf_check(data, &dst, 10, 10, DST_COLOR);
scratch_buf_check(data, &dst, WIDTH - 10, HEIGHT - 10, SRC_COLOR);
+ intel_bb_reset(data->ibb, true);
scratch_buf_fini(data, &src);
scratch_buf_fini(data, &flink);
scratch_buf_fini(data, &dst);
--
2.26.0
More information about the igt-dev
mailing list