[igt-dev] [PATCH 2/2] lib/intel_batchbuffer: Add blitter copy method with tiling arguments
Vanshidhar Konda
vanshidhar.r.konda at intel.com
Thu Nov 14 01:10:15 UTC 2019
Add a method that uses the blitter to copy data between BOs and takes
tiling for buffer objects as arguments. The intel_copy_bo method
is also modified to copy only linear (non-tiled) buffers. These changes
avoid having to call GET_TILING IOCTL inside the blitter copy methods
and require the IGT test calling it to specify the tiling.
Signed-off-by: Vanshidhar Konda <vanshidhar.r.konda at intel.com>
---
lib/intel_batchbuffer.c | 28 +++++++++++++++++++++++++---
lib/intel_batchbuffer.h | 4 ++++
tests/i915/gem_tiled_blits.c | 17 +++++++++++------
3 files changed, 40 insertions(+), 9 deletions(-)
diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
index f60bd5bd..27d3deb8 100644
--- a/lib/intel_batchbuffer.c
+++ b/lib/intel_batchbuffer.c
@@ -492,11 +492,33 @@ intel_copy_bo(struct intel_batchbuffer *batch,
drm_intel_bo *dst_bo, drm_intel_bo *src_bo,
long int size)
{
- uint32_t src_tiling, dst_tiling, swizzle;
igt_assert(size % 4096 == 0);
- drm_intel_bo_get_tiling(src_bo, &src_tiling, &swizzle);
- drm_intel_bo_get_tiling(dst_bo, &dst_tiling, &swizzle);
+ intel_blt_copy(batch,
+ src_bo, 0, 0, 4096, I915_TILING_NONE,
+ dst_bo, 0, 0, 4096, I915_TILING_NONE,
+ 4096/4, size/4096, 32);
+}
+/**
+ * intel_copy_tiled_bo:
+ * @batch: batchbuffer object
+ * @src_bo: source libdrm buffer object
+ * @src_tiling: @src_bo's tiling
+ * @dst_bo: destination libdrm buffer object
+ * @dst_tiling: @dst_bo's tiling
+ * @size: size of the copy range in bytes
+ *
+ * This emits a copy operation using blitter commands into the supplied batch
+ * buffer object. A total of @size bytes from the start of @src_bo is copied
+ * over to @dst_bo. Note that @size must be page-aligned.
+ */
+void
+intel_copy_tiled_bo(struct intel_batchbuffer *batch,
+ drm_intel_bo *dst_bo, uint32_t dst_tiling,
+ drm_intel_bo *src_bo, uint32_t src_tiling,
+ long int size)
+{
+ igt_assert(size % 4096 == 0);
intel_blt_copy(batch,
src_bo, 0, 0, 4096, src_tiling,
diff --git a/lib/intel_batchbuffer.h b/lib/intel_batchbuffer.h
index 1e9558fb..1af7b71a 100644
--- a/lib/intel_batchbuffer.h
+++ b/lib/intel_batchbuffer.h
@@ -199,6 +199,10 @@ intel_blt_copy(struct intel_batchbuffer *batch,
void intel_copy_bo(struct intel_batchbuffer *batch,
drm_intel_bo *dst_bo, drm_intel_bo *src_bo,
long int size);
+void intel_copy_tiled_bo(struct intel_batchbuffer *batch,
+ drm_intel_bo *dst_bo, uint32_t dst_tilig,
+ drm_intel_bo *src_bo, uint32_t src_tilig,
+ long int size);
/*
* Yf/Ys tiling
diff --git a/tests/i915/gem_tiled_blits.c b/tests/i915/gem_tiled_blits.c
index df0699f3..6c27678f 100644
--- a/tests/i915/gem_tiled_blits.c
+++ b/tests/i915/gem_tiled_blits.c
@@ -60,13 +60,13 @@ IGT_TEST_DESCRIPTION("Test doing many tiled blits, with a working set larger"
static drm_intel_bufmgr *bufmgr;
struct intel_batchbuffer *batch;
static int width = 512, height = 512;
+uint32_t tiling = I915_TILING_X;
static drm_intel_bo *
create_bo(uint32_t start_val)
{
drm_intel_bo *bo, *linear_bo;
uint32_t *linear;
- uint32_t tiling = I915_TILING_X;
int i;
bo = drm_intel_bo_alloc(bufmgr, "tiled bo", 1024 * 1024, 4096);
@@ -82,7 +82,8 @@ create_bo(uint32_t start_val)
linear[i] = start_val++;
drm_intel_bo_unmap(linear_bo);
- intel_copy_bo (batch, bo, linear_bo, width*height*4);
+ intel_copy_tiled_bo(batch, bo, tiling, linear_bo, I915_TILING_NONE,
+ width*height*4);
drm_intel_bo_unreference(linear_bo);
@@ -99,7 +100,8 @@ check_bo(drm_intel_bo *bo, uint32_t val)
linear_bo = drm_intel_bo_alloc(bufmgr, "linear dst", 1024 * 1024, 4096);
- intel_copy_bo(batch, linear_bo, bo, width*height*4);
+ intel_copy_tiled_bo(batch, linear_bo, I915_TILING_NONE,
+ bo, tiling, width*height*4);
do_or_die(drm_intel_bo_map(linear_bo, 0));
linear = linear_bo->virtual;
@@ -146,7 +148,8 @@ static void run_test(int count)
if (src == dst)
continue;
- intel_copy_bo(batch, bo[dst], bo[src], width*height*4);
+ intel_copy_tiled_bo(batch, bo[dst], tiling,
+ bo[src], tiling, width*height*4);
bo_start_val[dst] = bo_start_val[src];
}
for (i = 0; i < count; i++)
@@ -168,7 +171,8 @@ static void run_test(int count)
if (src == dst)
continue;
- intel_copy_bo(batch, bo[dst], bo[src], width*height*4);
+ intel_copy_tiled_bo(batch, bo[dst], tiling,
+ bo[src], tiling, width*height*4);
bo_start_val[dst] = bo_start_val[src];
}
for (i = 0; i < count; i++)
@@ -182,7 +186,8 @@ static void run_test(int count)
if (src == dst)
continue;
- intel_copy_bo(batch, bo[dst], bo[src], width*height*4);
+ intel_copy_tiled_bo(batch, bo[dst], tiling,
+ bo[src], tiling, width*height*4);
bo_start_val[dst] = bo_start_val[src];
}
for (i = 0; i < count; i++) {
--
2.24.0
More information about the igt-dev
mailing list