[PATCH i-g-t] igt_fb: Add support for drawing to non-32bit Y/Yf tiled FBs

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

 



When drawing with cairo to Y/Yf tiled FBs we use a temporary linear
buffer which is mapped to the CPU, but the fast blit needed for this
only expects 32 bpp FBs. Add support for other bpps too.

This is needed for upcoming patches testing non-32bit bpp formats with
Y/Yf tiling.

Thanks to Ville for explaining why we need the temporary buffer. (Looks
like for Y tiling we could do without, but that's a separate topic.)

Cc: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx>
Cc: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
Signed-off-by: Imre Deak <imre.deak@xxxxxxxxx>
---
 lib/igt_fb.c            |  2 ++
 lib/intel_batchbuffer.c | 33 +++++++++++++++++++++++++++++----
 lib/intel_batchbuffer.h |  4 ++++
 lib/intel_reg.h         |  4 ++++
 4 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index d4eaed71..dcae07df 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -1043,6 +1043,7 @@ static void destroy_cairo_surface__blit(void *arg)
 				   I915_TILING_NONE,
 				   0, 0, /* src_x, src_y */
 				   fb->width, fb->height,
+				   igt_drm_format_to_bpp(fb->drm_format),
 				   fb->gem_handle,
 				   fb->stride,
 				   obj_tiling,
@@ -1090,6 +1091,7 @@ static void create_cairo_surface__blit(int fd, struct igt_fb *fb)
 				   obj_tiling,
 				   0, 0, /* src_x, src_y */
 				   fb->width, fb->height,
+				   igt_drm_format_to_bpp(fb->drm_format),
 				   blit->linear.handle,
 				   blit->linear.stride,
 				   I915_TILING_NONE,
diff --git a/lib/intel_batchbuffer.c b/lib/intel_batchbuffer.c
index 53449894..9a53b6f8 100644
--- a/lib/intel_batchbuffer.c
+++ b/lib/intel_batchbuffer.c
@@ -519,7 +519,8 @@ static uint32_t fast_copy_dword0(unsigned int src_tiling,
 }
 
 static uint32_t fast_copy_dword1(unsigned int src_tiling,
-				 unsigned int dst_tiling)
+				 unsigned int dst_tiling,
+				 int bpp)
 {
 	uint32_t dword1 = 0;
 
@@ -528,7 +529,25 @@ static uint32_t fast_copy_dword1(unsigned int src_tiling,
 	if (dst_tiling == I915_TILING_Yf)
 		dword1 |= XY_FAST_COPY_DST_TILING_Yf;
 
-	dword1 |= XY_FAST_COPY_COLOR_DEPTH_32;
+	switch (bpp) {
+	case 8:
+		dword1 |= XY_FAST_COPY_COLOR_DEPTH_8;
+		break;
+	case 16:
+		dword1 |= XY_FAST_COPY_COLOR_DEPTH_16;
+		break;
+	case 32:
+		dword1 |= XY_FAST_COPY_COLOR_DEPTH_32;
+		break;
+	case 64:
+		dword1 |= XY_FAST_COPY_COLOR_DEPTH_64;
+		break;
+	case 128:
+		dword1 |= XY_FAST_COPY_COLOR_DEPTH_128;
+		break;
+	default:
+		igt_assert(0);
+	}
 
 	return dword1;
 }
@@ -586,6 +605,7 @@ static void exec_blit(int fd,
  * @src_y: Y coordinate of the source region to copy
  * @width: Width of the region to copy
  * @height: Height of the region to copy
+ * @bpp: source and destination bits per pixel
  * @dst_handle: GEM handle of the source buffer
  * @dst_stride: Stride (in bytes) of the destination buffer
  * @dst_tiling: Tiling mode of the destination buffer
@@ -604,6 +624,9 @@ void igt_blitter_fast_copy__raw(int fd,
 				/* size */
 				unsigned int width, unsigned int height,
 
+				/* bpp */
+				int bpp,
+
 				/* dst */
 				uint32_t dst_handle,
 				unsigned int dst_stride,
@@ -621,7 +644,7 @@ void igt_blitter_fast_copy__raw(int fd,
 	src_pitch = fast_copy_pitch(src_stride, src_tiling);
 	dst_pitch = fast_copy_pitch(dst_stride, dst_tiling);
 	dword0 = fast_copy_dword0(src_tiling, dst_tiling);
-	dword1 = fast_copy_dword1(src_tiling, dst_tiling);
+	dword1 = fast_copy_dword1(src_tiling, dst_tiling, bpp);
 
 #define CHECK_RANGE(x)	((x) >= 0 && (x) < (1 << 15))
 	assert(CHECK_RANGE(src_x) && CHECK_RANGE(src_y) &&
@@ -671,6 +694,7 @@ void igt_blitter_fast_copy__raw(int fd,
  * @src_y: source pixel y-coordination
  * @width: width of the copied rectangle
  * @height: height of the copied rectangle
+ * @bpp: source and destination bits per pixel
  * @dst: destination i-g-t buffer object
  * @dst_x: destination pixel x-coordination
  * @dst_y: destination pixel y-coordination
@@ -682,6 +706,7 @@ void igt_blitter_fast_copy__raw(int fd,
 void igt_blitter_fast_copy(struct intel_batchbuffer *batch,
 			   struct igt_buf *src, unsigned src_x, unsigned src_y,
 			   unsigned width, unsigned height,
+			   int bpp,
 			   struct igt_buf *dst, unsigned dst_x, unsigned dst_y)
 {
 	uint32_t src_pitch, dst_pitch;
@@ -690,7 +715,7 @@ void igt_blitter_fast_copy(struct intel_batchbuffer *batch,
 	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);
+	dword1 = fast_copy_dword1(src->tiling, dst->tiling, bpp);
 
 #define CHECK_RANGE(x)	((x) >= 0 && (x) < (1 << 15))
 	assert(CHECK_RANGE(src_x) && CHECK_RANGE(src_y) &&
diff --git a/lib/intel_batchbuffer.h b/lib/intel_batchbuffer.h
index 869747db..6bee4167 100644
--- a/lib/intel_batchbuffer.h
+++ b/lib/intel_batchbuffer.h
@@ -228,6 +228,7 @@ unsigned igt_buf_height(struct igt_buf *buf);
 void igt_blitter_fast_copy(struct intel_batchbuffer *batch,
 			  struct igt_buf *src, unsigned src_x, unsigned src_y,
 			  unsigned width, unsigned height,
+			  int bpp,
 			  struct igt_buf *dst, unsigned dst_x, unsigned dst_y);
 
 void igt_blitter_fast_copy__raw(int fd,
@@ -240,6 +241,9 @@ void igt_blitter_fast_copy__raw(int fd,
 				/* size */
 				unsigned int width, unsigned int height,
 
+				/* bpp */
+				int bpp,
+
 				/* dst */
 				uint32_t dst_handle,
 				unsigned int dst_stride,
diff --git a/lib/intel_reg.h b/lib/intel_reg.h
index 3a28c08c..f85fb742 100644
--- a/lib/intel_reg.h
+++ b/lib/intel_reg.h
@@ -2530,7 +2530,11 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 /* 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_8			(0  << 24)
+#define   XY_FAST_COPY_COLOR_DEPTH_16			(1  << 24)
 #define   XY_FAST_COPY_COLOR_DEPTH_32			(3  << 24)
+#define   XY_FAST_COPY_COLOR_DEPTH_64			(4  << 24)
+#define   XY_FAST_COPY_COLOR_DEPTH_128			(5  << 24)
 
 #define MI_STORE_DWORD_IMM		((0x20<<23)|2)
 #define   MI_MEM_VIRTUAL	(1 << 22) /* 965+ only */
-- 
2.11.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://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