[PATCH i-g-t 06/13] lib: Split two helpers to build fast copy's dword0 and dword1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Damien Lespiau <damien.lespiau@xxxxxxxxx>

Again, these helpers will be useful for a raw version of the gen9 fast
copy.

Signed-off-by: Damien Lespiau <damien.lespiau@xxxxxxxxx>
---
 lib/intel_batchbuffer.c | 96 +++++++++++++++++++++++++++++--------------------
 1 file changed, 57 insertions(+), 39 deletions(-)

diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
index f964d12..1eeabe4 100644
--- a/lib/intel_batchbuffer.c
+++ b/lib/intel_batchbuffer.c
@@ -495,46 +495,14 @@ static uint32_t fast_copy_pitch(unsigned int stride, enum i915_tiling tiling)
 		return stride;
 }
 
-/**
- * igt_blitter_fast_copy:
- * @batch: batchbuffer object
- * @context: libdrm hardware context to use
- * @src: source i-g-t buffer object
- * @src_x: source pixel x-coordination
- * @src_y: source pixel y-coordination
- * @width: width of the copied rectangle
- * @height: height of the copied rectangle
- * @dst: destination i-g-t buffer object
- * @dst_x: destination pixel x-coordination
- * @dst_y: destination pixel y-coordination
- *
- * Copy @src into @dst using the gen9 fast copy blitter comamnd.
- *
- * The source and destination surfaces cannot overlap.
- */
-void igt_blitter_fast_copy(struct intel_batchbuffer *batch,
-			   struct igt_buf *src, unsigned src_x, unsigned src_y,
-			   unsigned width, unsigned height,
-			   struct igt_buf *dst, unsigned dst_x, unsigned dst_y)
+static uint32_t fast_copy_dword0(unsigned int src_tiling,
+				 unsigned int dst_tiling)
 {
-	uint32_t src_pitch, dst_pitch;
-	uint32_t dword0 = 0, dword1 = 0;
-
-	src_pitch = fast_copy_pitch(src->stride, src->tiling);
-	dst_pitch = fast_copy_pitch(dst->stride, src->tiling);
-
-#define CHECK_RANGE(x)	((x) >= 0 && (x) < (1 << 15))
-	assert(CHECK_RANGE(src_x) && CHECK_RANGE(src_y) &&
-	       CHECK_RANGE(dst_x) && CHECK_RANGE(dst_y) &&
-	       CHECK_RANGE(width) && CHECK_RANGE(height) &&
-	       CHECK_RANGE(src_x + width) && CHECK_RANGE(src_y + height) &&
-	       CHECK_RANGE(dst_x + width) && CHECK_RANGE(dst_y + height) &&
-	       CHECK_RANGE(src_pitch) && CHECK_RANGE(dst_pitch));
-#undef CHECK_RANGE
+	uint32_t dword0 = 0;
 
 	dword0 |= XY_FAST_COPY_BLT;
 
-	switch (src->tiling) {
+	switch (src_tiling) {
 	case I915_TILING_X:
 		dword0 |= XY_FAST_COPY_SRC_TILING_X;
 		break;
@@ -550,7 +518,7 @@ void igt_blitter_fast_copy(struct intel_batchbuffer *batch,
 		break;
 	}
 
-	switch (dst->tiling) {
+	switch (dst_tiling) {
 	case I915_TILING_X:
 		dword0 |= XY_FAST_COPY_DST_TILING_X;
 		break;
@@ -566,13 +534,63 @@ void igt_blitter_fast_copy(struct intel_batchbuffer *batch,
 		break;
 	}
 
-	if (src->tiling == I915_TILING_Yf)
+	return dword0;
+}
+
+static uint32_t fast_copy_dword1(unsigned int src_tiling,
+				 unsigned int dst_tiling)
+{
+	uint32_t dword1 = 0;
+
+	if (src_tiling == I915_TILING_Yf)
 		dword1 |= XY_FAST_COPY_SRC_TILING_Yf;
-	if (dst->tiling == I915_TILING_Yf)
+	if (dst_tiling == I915_TILING_Yf)
 		dword1 |= XY_FAST_COPY_DST_TILING_Yf;
 
 	dword1 |= XY_FAST_COPY_COLOR_DEPTH_32;
 
+	return dword1;
+}
+
+/**
+ * igt_blitter_fast_copy:
+ * @batch: batchbuffer object
+ * @context: libdrm hardware context to use
+ * @src: source i-g-t buffer object
+ * @src_x: source pixel x-coordination
+ * @src_y: source pixel y-coordination
+ * @width: width of the copied rectangle
+ * @height: height of the copied rectangle
+ * @dst: destination i-g-t buffer object
+ * @dst_x: destination pixel x-coordination
+ * @dst_y: destination pixel y-coordination
+ *
+ * Copy @src into @dst using the gen9 fast copy blitter comamnd.
+ *
+ * The source and destination surfaces cannot overlap.
+ */
+void igt_blitter_fast_copy(struct intel_batchbuffer *batch,
+			   struct igt_buf *src, unsigned src_x, unsigned src_y,
+			   unsigned width, unsigned height,
+			   struct igt_buf *dst, unsigned dst_x, unsigned dst_y)
+{
+	uint32_t src_pitch, dst_pitch;
+	uint32_t dword0, dword1;
+
+	src_pitch = fast_copy_pitch(src->stride, src->tiling);
+	dst_pitch = fast_copy_pitch(dst->stride, src->tiling);
+	dword0 = fast_copy_dword0(src->tiling, dst->tiling);
+	dword1 = fast_copy_dword1(src->tiling, dst->tiling);
+
+#define CHECK_RANGE(x)	((x) >= 0 && (x) < (1 << 15))
+	assert(CHECK_RANGE(src_x) && CHECK_RANGE(src_y) &&
+	       CHECK_RANGE(dst_x) && CHECK_RANGE(dst_y) &&
+	       CHECK_RANGE(width) && CHECK_RANGE(height) &&
+	       CHECK_RANGE(src_x + width) && CHECK_RANGE(src_y + height) &&
+	       CHECK_RANGE(dst_x + width) && CHECK_RANGE(dst_y + height) &&
+	       CHECK_RANGE(src_pitch) && CHECK_RANGE(dst_pitch));
+#undef CHECK_RANGE
+
 	BEGIN_BATCH(10, 2);
 	OUT_BATCH(dword0);
 	OUT_BATCH(dword1 | dst_pitch);
-- 
2.3.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx





[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux