[PATCH i-g-t 2/4] test/prime_vgem: Make blitter access work on Gen < 9
Janusz Krzysztofik
janusz.krzysztofik at linux.intel.com
Tue Dec 31 13:28:58 UTC 2019
As fast copy is not supported on platforms older than Gen 9, use
XY_SRC_COPY instead.
Suggested-by: Chris Wilson <chris at chris-wilson.co.uk>
Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik at linux.intel.com>
Cc: Daniel Vetter <daniel.vetter at ffwll.ch>
---
tests/prime_vgem.c | 134 +++++++++++++++++++++++++++------------------
1 file changed, 80 insertions(+), 54 deletions(-)
diff --git a/tests/prime_vgem.c b/tests/prime_vgem.c
index cb6046b8..399cc758 100644
--- a/tests/prime_vgem.c
+++ b/tests/prime_vgem.c
@@ -172,6 +172,69 @@ 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;
@@ -208,13 +271,8 @@ static void test_fence_blt(int i915, int vgem)
write(master[1], &child, sizeof(child));
read(slave[0], &child, sizeof(child));
- igt_blitter_fast_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);
+ copy(i915, prime, native, 0, 0, scratch.width, scratch.height,
+ scratch.bpp);
gem_sync(i915, native);
for (i = 0; i < 1024; i++)
@@ -331,12 +389,8 @@ static void test_blt(int vgem, int i915)
ptr[1024 * i] = i;
munmap(ptr, scratch.size);
- igt_blitter_fast_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);
+ copy(i915, native, prime, 0, 0, scratch.width, scratch.height,
+ scratch.bpp);
gem_sync(i915, prime);
ptr = vgem_mmap(vgem, &scratch, PROT_READ | PROT_WRITE);
@@ -346,12 +400,8 @@ static void test_blt(int vgem, int i915)
}
munmap(ptr, scratch.size);
- igt_blitter_fast_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);
+ copy(i915, prime, native, 0, 0, scratch.width, scratch.height,
+ scratch.bpp);
gem_sync(i915, native);
ptr = gem_mmap__wc(i915, native, 0, scratch.size, PROT_READ);
@@ -470,24 +520,12 @@ static void test_blt_interleaved(int vgem, int i915)
for (i = 0; i < 1024; i++) {
local[1024 * i] = i;
- igt_blitter_fast_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);
+ copy(i915, native, prime, 0, i, scratch.width, 1, scratch.bpp);
gem_sync(i915, prime);
igt_assert_eq(foreign[1024 * i], i);
foreign[1024 * i] = ~i;
- igt_blitter_fast_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);
+ copy(i915, prime, native, 0, i, scratch.width, 1, scratch.bpp);
gem_sync(i915, native);
igt_assert_eq(local[1024 * i], ~i);
}
@@ -1015,13 +1053,9 @@ igt_main
igt_subtest("basic-gtt")
test_gtt(vgem, i915);
- igt_subtest_group {
- igt_fixture
- igt_require(intel_gen(intel_get_drm_devid(i915)) >= 9);
- igt_describe("Examine blitter access path");
- igt_subtest("basic-blt")
- test_blt(vgem, i915);
- }
+ igt_describe("Examine blitter access path");
+ igt_subtest("basic-blt")
+ test_blt(vgem, i915);
igt_subtest("shrink")
test_shrink(vgem, i915);
@@ -1029,13 +1063,9 @@ igt_main
igt_subtest("coherency-gtt")
test_gtt_interleaved(vgem, i915);
- igt_subtest_group {
- igt_fixture
- igt_require(intel_gen(intel_get_drm_devid(i915)) >= 9);
- igt_describe("Examine blitter access path WC coherency");
- igt_subtest("coherency-blt")
- test_blt_interleaved(vgem, i915);
- }
+ igt_describe("Examine blitter access path WC coherency");
+ igt_subtest("coherency-blt")
+ test_blt_interleaved(vgem, i915);
for (e = intel_execution_engines; e->name; e++) {
igt_subtest_f("%ssync-%s",
@@ -1083,13 +1113,9 @@ igt_main
test_fence_read(i915, vgem);
igt_subtest("basic-fence-mmap")
test_fence_mmap(i915, vgem);
- igt_subtest_group {
- igt_fixture
- igt_require(intel_gen(intel_get_drm_devid(i915)) >= 9);
- igt_describe("Examine blitter access path fencing");
- igt_subtest("basic-fence-blt")
- test_fence_blt(i915, vgem);
- }
+ igt_describe("Examine blitter access path fencing");
+ igt_subtest("basic-fence-blt")
+ test_fence_blt(i915, vgem);
for (e = intel_execution_engines; e->name; e++) {
igt_subtest_f("%sfence-wait-%s",
--
2.21.0
More information about the Intel-gfx-trybot
mailing list