[igt-dev] [PATCH i-g-t v3 06/15] i915/gem_tiled_blits: Remove libdrm dependency
Zbigniew Kempczyński
zbigniew.kempczynski at intel.com
Fri Oct 23 08:19:03 UTC 2020
On Fri, Oct 02, 2020 at 08:54:33AM +0200, Dominik Grzegorzek wrote:
> Use intel_bb / intel_buf to remove libdrm dependency.
>
> Signed-off-by: Dominik Grzegorzek <dominik.grzegorzek at intel.com>
> Cc: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
> Cc: Chris Wilson <chris at chris-wilson.co.uk>
> ---
> tests/i915/gem_tiled_blits.c | 75 ++++++++++++++++++------------------
> 1 file changed, 38 insertions(+), 37 deletions(-)
Remove this test from series and try to adopt it on top of:
https://patchwork.freedesktop.org/series/82954/
--
Zbigniew
>
> diff --git a/tests/i915/gem_tiled_blits.c b/tests/i915/gem_tiled_blits.c
> index 36e96785..2149f27f 100644
> --- a/tests/i915/gem_tiled_blits.c
> +++ b/tests/i915/gem_tiled_blits.c
> @@ -60,49 +60,51 @@ IGT_TEST_DESCRIPTION("Test doing many tiled blits, with a working set larger"
>
> static int width = 512, height = 512;
>
> -static drm_intel_bo *
> -create_bo(drm_intel_bufmgr *bufmgr, struct intel_batchbuffer *batch, uint32_t x)
> +static struct intel_buf *
> +create_bo(struct buf_ops *bops, struct intel_bb *ibb, uint32_t x)
> {
> - drm_intel_bo *bo, *linear_bo;
> + struct intel_buf *buf, *linear_buf;
> uint32_t *linear;
> uint32_t tiling = I915_TILING_X;
> int i;
>
> - bo = drm_intel_bo_alloc(bufmgr, "tiled bo", 1024 * 1024, 4096);
> - do_or_die(drm_intel_bo_set_tiling(bo, &tiling, width * 4));
> - igt_assert(tiling == I915_TILING_X);
> + buf = intel_buf_create(bops, width, height, 32, 0, tiling,
> + I915_COMPRESSION_NONE);
>
> - linear_bo = drm_intel_bo_alloc(bufmgr, "linear src", 1024 * 1024, 4096);
> + linear_buf = intel_buf_create(bops, width, height, 32, 0,
> + I915_TILING_NONE, I915_COMPRESSION_NONE);
>
> /* Fill the BO with dwords starting at start_val */
> - do_or_die(drm_intel_bo_map(linear_bo, 1));
> - linear = linear_bo->virtual;
> + intel_buf_cpu_map(linear_buf, 1);
> + linear = linear_buf->ptr;
> for (i = 0; i < 1024 * 1024 / 4; i++)
> linear[i] = x++;
> - drm_intel_bo_unmap(linear_bo);
> + intel_buf_unmap(linear_buf);
>
> - intel_copy_bo (batch, bo, linear_bo, width*height*4);
> + intel_bb_copy_intel_buf(ibb, linear_buf, buf, width*height*4);
> + intel_bb_reset(ibb, true);
>
> - drm_intel_bo_unreference(linear_bo);
> + intel_buf_destroy(linear_buf);
>
> - return bo;
> + return buf;
> }
>
> static void
> -check_bo(drm_intel_bo *bo, uint32_t val, struct intel_batchbuffer *batch)
> +check_bo(struct intel_buf *buf, uint32_t val, struct intel_bb *ibb)
> {
> - drm_intel_bo *linear_bo;
> + struct intel_buf *linear_buf;
> uint32_t *linear;
> int num_errors;
> int i;
>
> - linear_bo = drm_intel_bo_alloc(bo->bufmgr, "linear dst",
> - 1024 * 1024, 4096);
> + linear_buf = intel_buf_create(buf->bops, width, height, 32, 0,
> + I915_TILING_NONE, I915_COMPRESSION_NONE);
>
> - intel_copy_bo(batch, linear_bo, bo, width*height*4);
> + intel_bb_copy_intel_buf(ibb, buf, linear_buf, width*height*4);
> + intel_bb_reset(ibb, true);
>
> - do_or_die(drm_intel_bo_map(linear_bo, 0));
> - linear = linear_bo->virtual;
> + intel_buf_cpu_map(linear_buf, 0);
> + linear = linear_buf->ptr;
>
> num_errors = 0;
> for (i = 0; i < 1024 * 1024 / 4; i++) {
> @@ -112,31 +114,28 @@ check_bo(drm_intel_bo *bo, uint32_t val, struct intel_batchbuffer *batch)
> val++;
> }
> igt_assert_eq(num_errors, 0);
> - drm_intel_bo_unmap(linear_bo);
> + intel_buf_unmap(linear_buf);
>
> - drm_intel_bo_unreference(linear_bo);
> + intel_buf_destroy(linear_buf);
> }
>
> static void run_test(int fd, int count)
> {
> - struct intel_batchbuffer *batch;
> - drm_intel_bufmgr *bufmgr;
> - drm_intel_bo **bo;
> + struct intel_bb *ibb;
> + struct buf_ops *bops;
> + struct intel_buf **bo;
> uint32_t *bo_start_val;
> uint32_t start = 0;
> int i;
>
> - bufmgr = drm_intel_bufmgr_gem_init(fd, 4096);
> - drm_intel_bufmgr_gem_set_vma_cache_size(bufmgr, 32);
> - drm_intel_bufmgr_gem_enable_reuse(bufmgr);
> - batch = intel_batchbuffer_alloc(bufmgr, intel_get_drm_devid(fd));
> + bops = buf_ops_create(fd);
> + ibb = intel_bb_create(fd, 4096);
>
> -
> - bo = malloc(sizeof(drm_intel_bo *)*count);
> + bo = malloc(sizeof(struct intel_buf *)*count);
> bo_start_val = malloc(sizeof(uint32_t)*count);
>
> for (i = 0; i < count; i++) {
> - bo[i] = create_bo(bufmgr, batch, start);
> + bo[i] = create_bo(bops, ibb, start);
> bo_start_val[i] = start;
> start += 1024 * 1024 / 4;
> }
> @@ -148,20 +147,22 @@ static void run_test(int fd, int count)
> if (src == dst)
> continue;
>
> - intel_copy_bo(batch, bo[dst], bo[src], width*height*4);
> + intel_bb_copy_intel_buf(ibb, bo[src], bo[dst], width*height*4);
> + intel_bb_reset(ibb, true);
> +
> bo_start_val[dst] = bo_start_val[src];
> }
>
> for (i = 0; i < count; i++) {
> - check_bo(bo[i], bo_start_val[i], batch);
> - drm_intel_bo_unreference(bo[i]);
> + check_bo(bo[i], bo_start_val[i], ibb);
> + intel_buf_destroy(bo[i]);
> }
>
> free(bo_start_val);
> free(bo);
>
> - intel_batchbuffer_free(batch);
> - drm_intel_bufmgr_destroy(bufmgr);
> + intel_bb_destroy(ibb);
> + buf_ops_destroy(bops);
> }
>
> #define MAX_32b ((1ull << 32) - 4096)
> --
> 2.20.1
>
More information about the igt-dev
mailing list