[PATCH i-g-t 4/4] tests/prime_vgem: Use library helper for XY_SRC_COPY_BLT
Janusz Krzysztofik
janusz.krzysztofik at linux.intel.com
Thu Dec 19 11:14:59 UTC 2019
Commit xx introduced a local helper implementing XY_SRC_COPY_BLT. Now
as a similar library helper has been introduced by commit yy, use it
and drop the local version.
Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik at linux.intel.com>
---
tests/prime_vgem.c | 104 ++++++++++++++-------------------------------
1 file changed, 33 insertions(+), 71 deletions(-)
diff --git a/tests/prime_vgem.c b/tests/prime_vgem.c
index 399cc758..9ceee47a 100644
--- a/tests/prime_vgem.c
+++ b/tests/prime_vgem.c
@@ -172,69 +172,6 @@ static void test_fence_mmap(int i915, int vgem)
close(slave[1]);
}
-static void copy(int i915, uint32_t src, uint32_t dst,
- int x, int y, int width, int height, int bpp)
-{
- uint32_t batch[12];
- struct drm_i915_gem_relocation_entry reloc[2];
- struct drm_i915_gem_exec_object2 obj[3];
- struct drm_i915_gem_execbuffer2 exec;
- uint32_t devid = intel_get_drm_devid(i915);
- unsigned int gen = intel_gen(devid);
- int i = 0;
-
- batch[i++] = XY_SRC_COPY_BLT_CMD | XY_SRC_COPY_BLT_WRITE_ALPHA |
- XY_SRC_COPY_BLT_WRITE_RGB | (gen >= 8 ? 8 : 6);
- batch[i++] = (((bpp / 8) - 1) << 24) | (0xcc << 16) |
- (width * (bpp / 8));
- batch[i++] = (y << 16) | x;
- batch[i++] = ((y + height) << 16) | (x + width);
-
- reloc[0].target_handle = dst;
- reloc[0].delta = 0;
- reloc[0].offset = i * sizeof(batch[0]);
- reloc[0].presumed_offset = 0;
- reloc[0].read_domains = I915_GEM_DOMAIN_RENDER;
- reloc[0].write_domain = I915_GEM_DOMAIN_RENDER;
-
- batch[i++] = 0;
- if (gen >= 8)
- batch[i++] = 0;
- batch[i++] = (y << 16) | x;
- batch[i++] = width * (bpp / 8);
-
- reloc[1].target_handle = src;
- reloc[1].delta = 0;
- reloc[1].offset = i * sizeof(batch[0]);
- reloc[1].presumed_offset = 0;
- reloc[1].read_domains = I915_GEM_DOMAIN_RENDER;
- reloc[1].write_domain = 0;
-
- batch[i++] = 0;
- if (gen >= 8)
- batch[i++] = 0;
- batch[i++] = MI_BATCH_BUFFER_END;
- batch[i++] = MI_NOOP;
-
- memset(obj, 0, sizeof(obj));
- obj[0].handle = dst;
- obj[1].handle = src;
- obj[2].handle = gem_create(i915, 4096);
- obj[2].relocation_count = 2;
- obj[2].relocs_ptr = to_user_pointer(reloc);
-
- gem_write(i915, obj[2].handle, 0, batch, i * sizeof(batch[0]));
-
- memset(&exec, 0, sizeof(exec));
- exec.buffers_ptr = to_user_pointer(obj);
- exec.buffer_count = 3;
- exec.batch_len = i * sizeof(batch[0]);
- exec.flags = HAS_BLT_RING(devid) ? I915_EXEC_BLT : 0;
-
- gem_execbuf(i915, &exec);
- gem_close(i915, obj[2].handle);
-}
-
static void test_fence_blt(int i915, int vgem)
{
struct vgem_bo scratch;
@@ -271,8 +208,13 @@ static void test_fence_blt(int i915, int vgem)
write(master[1], &child, sizeof(child));
read(slave[0], &child, sizeof(child));
- copy(i915, prime, native, 0, 0, scratch.width, scratch.height,
- scratch.bpp);
+ igt_blitter_src_copy__raw(i915, prime, 0,
+ scratch.width * scratch.bpp / 8,
+ I915_TILING_NONE, 0, 0,
+ scratch.width, scratch.height,
+ scratch.bpp, native, 0,
+ scratch.width * scratch.bpp / 8,
+ I915_TILING_NONE, 0, 0);
gem_sync(i915, native);
for (i = 0; i < 1024; i++)
@@ -389,8 +331,12 @@ static void test_blt(int vgem, int i915)
ptr[1024 * i] = i;
munmap(ptr, scratch.size);
- copy(i915, native, prime, 0, 0, scratch.width, scratch.height,
- scratch.bpp);
+ igt_blitter_src_copy__raw(i915,
+ native, 0, scratch.width * scratch.bpp / 8,
+ I915_TILING_NONE, 0, 0,
+ scratch.width, scratch.height, scratch.bpp,
+ prime, 0, scratch.width * scratch.bpp / 8,
+ I915_TILING_NONE, 0, 0);
gem_sync(i915, prime);
ptr = vgem_mmap(vgem, &scratch, PROT_READ | PROT_WRITE);
@@ -400,8 +346,12 @@ static void test_blt(int vgem, int i915)
}
munmap(ptr, scratch.size);
- copy(i915, prime, native, 0, 0, scratch.width, scratch.height,
- scratch.bpp);
+ igt_blitter_src_copy__raw(i915,
+ prime, 0, scratch.width * scratch.bpp / 8,
+ I915_TILING_NONE, 0, 0,
+ scratch.width, scratch.height, scratch.bpp,
+ native, 0, scratch.width * scratch.bpp / 8,
+ I915_TILING_NONE, 0, 0);
gem_sync(i915, native);
ptr = gem_mmap__wc(i915, native, 0, scratch.size, PROT_READ);
@@ -520,12 +470,24 @@ static void test_blt_interleaved(int vgem, int i915)
for (i = 0; i < 1024; i++) {
local[1024 * i] = i;
- copy(i915, native, prime, 0, i, scratch.width, 1, scratch.bpp);
+ igt_blitter_src_copy__raw(i915, native, 0,
+ scratch.width * scratch.bpp / 8,
+ I915_TILING_NONE, 0, i,
+ scratch.width, 1, scratch.bpp,
+ prime, 0,
+ scratch.width * scratch.bpp / 8,
+ I915_TILING_NONE, 0, i);
gem_sync(i915, prime);
igt_assert_eq(foreign[1024 * i], i);
foreign[1024 * i] = ~i;
- copy(i915, prime, native, 0, i, scratch.width, 1, scratch.bpp);
+ igt_blitter_src_copy__raw(i915, prime, 0,
+ scratch.width * scratch.bpp / 8,
+ I915_TILING_NONE, 0, i,
+ scratch.width, 1, scratch.bpp,
+ native, 0,
+ scratch.width * scratch.bpp / 8,
+ I915_TILING_NONE, 0, i);
gem_sync(i915, native);
igt_assert_eq(local[1024 * i], ~i);
}
--
2.21.0
More information about the Intel-gfx-trybot
mailing list