public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
To: Intel-gfx@lists.freedesktop.org
Subject: [PATCH i-g-t 04/13] lib/skl: Add gen9 specific igt_blitter_fast_copy()
Date: Tue,  3 Mar 2015 14:10:57 +0000	[thread overview]
Message-ID: <1425391866-15377-5-git-send-email-tvrtko.ursulin@linux.intel.com> (raw)
In-Reply-To: <1425391866-15377-1-git-send-email-tvrtko.ursulin@linux.intel.com>

From: Damien Lespiau <damien.lespiau@intel.com>

v2: Adjust for BB handling changes. (Tvrtko Ursulin)
    Correct XY_FAST_COPY_DST_TILING_Yf. (Tvrtko Ursulin)

v3: New tiling modes are not defined in the kernel any more. (Tvrtko Ursulin)

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 lib/intel_batchbuffer.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++++
 lib/intel_batchbuffer.h |  17 ++++++++
 lib/intel_reg.h         |  18 ++++++++
 3 files changed, 141 insertions(+)

diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
index d3efc1e..9b8ae0d 100644
--- a/lib/intel_batchbuffer.c
+++ b/lib/intel_batchbuffer.c
@@ -483,6 +483,112 @@ void igt_buf_write_to_png(struct igt_buf *buf, const char *filename)
 	drm_intel_bo_unmap(buf->bo);
 }
 
+/*
+ * pitches are in bytes if the surfaces are linear, number of dwords
+ * otherwise
+ */
+static uint32_t fast_copy_pitch(struct igt_buf *buf)
+{
+	if (buf->tiling != I915_TILING_NONE)
+		return buf->stride / 4;
+	else
+		return buf->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)
+{
+	uint32_t src_pitch, dst_pitch;
+	uint32_t dword0 = 0, dword1 = 0;
+
+	src_pitch = fast_copy_pitch(src);
+	dst_pitch = fast_copy_pitch(dst);
+
+#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
+
+	dword0 |= XY_FAST_COPY_BLT;
+
+	switch (src->tiling) {
+	case I915_TILING_X:
+		dword0 |= XY_FAST_COPY_SRC_TILING_X;
+		break;
+	case I915_TILING_Y:
+	case I915_TILING_Yf:
+		dword0 |= XY_FAST_COPY_SRC_TILING_Yb_Yf;
+		break;
+	case I915_TILING_Ys:
+		dword0 |= XY_FAST_COPY_SRC_TILING_Ys;
+		break;
+	case I915_TILING_NONE:
+	default:
+		break;
+	}
+
+	switch (dst->tiling) {
+	case I915_TILING_X:
+		dword0 |= XY_FAST_COPY_DST_TILING_X;
+		break;
+	case I915_TILING_Y:
+	case I915_TILING_Yf:
+		dword0 |= XY_FAST_COPY_DST_TILING_Yb_Yf;
+		break;
+	case I915_TILING_Ys:
+		dword0 |= XY_FAST_COPY_DST_TILING_Ys;
+		break;
+	case I915_TILING_NONE:
+	default:
+		break;
+	}
+
+	if (src->tiling == I915_TILING_Yf)
+		dword1 |= XY_FAST_COPY_SRC_TILING_Yf;
+	if (dst->tiling == I915_TILING_Yf)
+		dword1 |= XY_FAST_COPY_DST_TILING_Yf;
+
+	dword1 |= XY_FAST_COPY_COLOR_DEPTH_32;
+
+	BEGIN_BATCH(10, 2);
+	OUT_BATCH(dword0);
+	OUT_BATCH(dword1 | dst_pitch);
+	OUT_BATCH((dst_y << 16) | dst_x); /* dst x1,y1 */
+	OUT_BATCH(((dst_y + height) << 16) | (dst_x + width)); /* dst x2,y2 */
+	OUT_RELOC(dst->bo, I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER, 0);
+	OUT_BATCH(0);	/* dst address upper bits */
+	OUT_BATCH((src_y << 16) | src_x); /* src x1,y1 */
+	OUT_BATCH(src_pitch);
+	OUT_RELOC(src->bo, I915_GEM_DOMAIN_RENDER, 0, 0);
+	OUT_BATCH(0);	/* src address upper bits */
+	ADVANCE_BATCH();
+
+	intel_batchbuffer_flush(batch);
+}
+
 /**
  * igt_get_render_copyfunc:
  * @devid: pci device id
diff --git a/lib/intel_batchbuffer.h b/lib/intel_batchbuffer.h
index e2afc3b..0f22cd6 100644
--- a/lib/intel_batchbuffer.h
+++ b/lib/intel_batchbuffer.h
@@ -186,6 +186,18 @@ void intel_copy_bo(struct intel_batchbuffer *batch,
 		   long int size);
 
 /**
+ * Yf/Ys tiling
+ *
+ * Tiling mode in the I915_TILING_... namespace for new tiling modes which are
+ * defined in the kernel. (They are not fenceable so the kernel does not need
+ * to know about them.)
+ *
+ * They are to be used the the blitting routines below.
+ */
+#define I915_TILING_Yf	3
+#define I915_TILING_Ys	4
+
+/**
  * igt_buf:
  * @bo: underlying libdrm buffer object
  * @stride: stride of the buffer
@@ -212,6 +224,11 @@ unsigned igt_buf_height(struct igt_buf *buf);
 
 void igt_buf_write_to_png(struct igt_buf *buf, const char *filename);
 
+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);
+
 /**
  * igt_render_copyfunc_t:
  * @batch: batchbuffer object
diff --git a/lib/intel_reg.h b/lib/intel_reg.h
index ade1c0c..0ffa803 100644
--- a/lib/intel_reg.h
+++ b/lib/intel_reg.h
@@ -2514,6 +2514,24 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define XY_MONO_SRC_BLT_WRITE_ALPHA	(1<<21)
 #define XY_MONO_SRC_BLT_WRITE_RGB	(1<<20)
 
+#define XY_FAST_COPY_BLT				((2<<29)|(0x42<<22)|0x8)
+/* dword 0 */
+#define   XY_FAST_COPY_SRC_TILING_LINEAR		(0 << 20)
+#define   XY_FAST_COPY_SRC_TILING_X			(1 << 20)
+#define   XY_FAST_COPY_SRC_TILING_Yb_Yf			(2 << 20)
+#define   XY_FAST_COPY_SRC_TILING_Ys			(3 << 20)
+#define   XY_FAST_COPY_SRC_HORIZONTAL_ALIGNMENT(n)	(n << 17)
+#define   XY_FAST_COPY_SRC_VERTICAL_ALIGNMENT(n)	(n << 15)
+#define   XY_FAST_COPY_DST_TILING_X			(1 << 13)
+#define   XY_FAST_COPY_DST_TILING_Yb_Yf			(2 << 13)
+#define   XY_FAST_COPY_DST_TILING_Ys			(3 << 13)
+#define   XY_FAST_COPY_DST_HORIZONTAL_ALIGNMENT(n)	(n << 10)
+#define   XY_FAST_COPY_DST_VERTICAL_ALIGNMENT(n)	(n <<  8)
+/* dword 1 */
+#define   XY_FAST_COPY_SRC_TILING_Yf			(1 <<  31)
+#define   XY_FAST_COPY_DST_TILING_Yf			(1 <<  30)
+#define   XY_FAST_COPY_COLOR_DEPTH_32			(3  << 24)
+
 #define MI_STORE_DWORD_IMM		((0x20<<23)|2)
 #define   MI_MEM_VIRTUAL	(1 << 22) /* 965+ only */
 
-- 
2.3.0

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

  parent reply	other threads:[~2015-03-03 14:11 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-03 14:10 [PATCH i-g-t v3 00/13] Testing the Y tiled display Tvrtko Ursulin
2015-03-03 14:10 ` [PATCH i-g-t 01/13] tests/kms_addfb: Add support for fb modifiers Tvrtko Ursulin
2015-03-03 14:10 ` [PATCH i-g-t 02/13] lib: Extract igt_buf_write_to_png() from gem_render_copy Tvrtko Ursulin
2015-03-03 16:03   ` Tvrtko Ursulin
2015-03-03 16:12     ` Gore, Tim
2015-03-03 14:10 ` [PATCH i-g-t 03/13] tests/kms_addfb: Y tiled testcases Tvrtko Ursulin
2015-03-03 14:10 ` Tvrtko Ursulin [this message]
2015-03-03 14:10 ` [PATCH i-g-t 05/13] lib: Don't give a struct igt_buf * to fast_copy_pitch() Tvrtko Ursulin
2015-03-03 14:10 ` [PATCH i-g-t 06/13] lib: Split two helpers to build fast copy's dword0 and dword1 Tvrtko Ursulin
2015-03-03 14:11 ` [PATCH i-g-t 07/13] lib: Provide a raw version of the gen9 fast copy blits Tvrtko Ursulin
2015-03-03 14:11 ` [PATCH i-g-t 08/13] tiling: Convert framebuffer helpers to use fb modifiers Tvrtko Ursulin
2015-03-03 14:11 ` [PATCH i-g-t 09/13] lib: Add support for new extension to the ADDFB2 ioctl Tvrtko Ursulin
2015-03-03 14:11 ` [PATCH i-g-t 10/13] lib/igt_fb: Use new ADDFB2 extension for new tiling modes Tvrtko Ursulin
2015-03-03 14:11 ` [PATCH i-g-t 11/13] lib: Allow the creation of Ys/Yf tiled FBs Tvrtko Ursulin
2015-03-03 14:11 ` [PATCH i-g-t 12/13] testdisplay/skl: Add command line options for Yb/Yf tiled fbs Tvrtko Ursulin
2015-03-03 14:11 ` [PATCH i-g-t 13/13] tests/kms_flip_tiling: Exercise Y tiling modes on Gen9+ Tvrtko Ursulin
2015-03-12 14:36 ` [PATCH i-g-t v3 00/13] Testing the Y tiled display Damien Lespiau

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1425391866-15377-5-git-send-email-tvrtko.ursulin@linux.intel.com \
    --to=tvrtko.ursulin@linux.intel.com \
    --cc=Intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox