summaryrefslogtreecommitdiff
path: root/lib/intel_batchbuffer.c
diff options
context:
space:
mode:
authorDamien Lespiau <damien.lespiau@intel.com>2015-03-03 14:10:59 +0000
committerDamien Lespiau <damien.lespiau@intel.com>2015-03-12 14:20:08 +0000
commit6533d113a9710429115bee26d1f372e1a06701df (patch)
tree20d7541057492c2c614bbae6a92ff8e1f954e692 /lib/intel_batchbuffer.c
parent130221b3b5be3ad03bd0ac2b12d8b009eaf540d4 (diff)
lib: Split two helpers to build fast copy's dword0 and dword1
Again, these helpers will be useful for a raw version of the gen9 fast copy. Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
Diffstat (limited to 'lib/intel_batchbuffer.c')
-rw-r--r--lib/intel_batchbuffer.c96
1 files changed, 57 insertions, 39 deletions
diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
index 2d1a23fa..50421a51 100644
--- a/lib/intel_batchbuffer.c
+++ b/lib/intel_batchbuffer.c
@@ -469,46 +469,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;
@@ -524,7 +492,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;
@@ -540,13 +508,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);