Skip to contentSkip to conversation

Fill block-copy test gap for unaligned sizes

PATCH Superseded Zbigniew Kempczyński 3 participants 20 messages Feb 1, 2024 Library code

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover Fill block-copy test gap for unaligned sizes

Using 512x512 resolution for testing is too optimistic and hides intel_blt limitation for using different (smaller) resolutions which also might not be aligned to expected stride and height.

Address this by adding few helpers, change blt buffer creation size calculation and add "increment" version of the test in xe_ccs.

v2: fix handling Tile64 what also requires bpp in dumping to
png as helper for aligned height depend on it
v3: fix xmajor stride + make helpers public
v4: use original width/height on filename write to png,
extend fast-copy with different sizes test

Zbigniew Kempczyński (4):
lib/intel_blt: Add helpers for calculating stride and aligned height lib/intel_blt: Change surface size calculation lib/intel_blt: Use object pitch and aligned height on png write tests/xe-ccs: Add tests which exercise small to large blit sizes tests/xe_exercise_blt: Exercise small to large fast-copy blits

 lib/intel_blt.c                |  89 +++++++++++++++++-
 lib/intel_blt.h                |   6 +-
 tests/intel/gem_ccs.c          |  23 ++---
 tests/intel/gem_exercise_blt.c |  16 ++--
 tests/intel/xe_ccs.c           | 167 ++++++++++++++++++++++++---------
 tests/intel/xe_exercise_blt.c  |  79 ++++++++++++----
 6 files changed, 293 insertions(+), 87 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH v4 1/5 lib/intel_blt: Add helpers for calculating stride and aligned height

Tiled surfaces have stride / aligned height constraints. Currently blt library has limitation and doesn't work properly when surface stride is not valid for specific tiling.

As an example lets say we want to copy from linear to xmajor 33 x 33 x 32bpp surface. Xmajor surface expects stride aligned to 512 bytes and height to 8 rows so this surface will occupy 512B x 40 (128 x 40 x 32 bpp).

---
v2: Fix stride/aligned height calculation for Tile64
v3: Fix stride calculation for xmajor
Make helpers public (fixes compilation warning due to lack or static function users)

---
 lib/intel_blt.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++
 lib/intel_blt.h |  4 ++++
 2 files changed, 68 insertions(+)
lib/intel_blt.c +64 -0
index 25d251c4f8..13b1dbba4f 100644
@@ -521,6 +521,70 @@ static int __block_tiling(enum blt_tiling_type tiling)
 	return 0;
 }
 
+/**
+ * blt_get_min_stride
+ * @width: width in pixels
+ * @bpp: bits per pixel
+ * @tiling: tiling
+ *
+ * Function returns minimum posibble stride in bytes for width, bpp and tiling.
+ *
+ * Returns:
+ * minimum possible stride in bytes.
+ */
+uint32_t blt_get_min_stride(uint32_t width, uint32_t bpp,
+			    enum blt_tiling_type tiling)
+{
+	switch (tiling) {
+	case T_LINEAR:
+		return width * bpp / 8;
+	case T_XMAJOR:
+		return ALIGN(width * bpp / 8, 512);
+	case T_TILE64:
+		if (bpp == 8)
+			return ALIGN(width, 256);
+		else if (bpp == 16 || bpp == 32)
+			return ALIGN(width * bpp / 8, 512);
+		return ALIGN(width * bpp / 8, 1024);
+
+	default:
+		return ALIGN(width * bpp / 8, 128);
+	}
+}
+
+/**
+ * blt_get_aligned_height
+ * @height: height in pixels
+ * @bpp: bits per pixel (used for Tile64 due to different tile organization
+ * in pixels)
+ * @tiling: tiling
+ *
+ * Function returns aligned height for specific tiling. Height returned is
+ * important from memory allocation perspective, because each tiling has
+ * specific memory constraints.
+ *
+ * Returns:
+ * height (rows) expected for specific tiling
+ */
+uint32_t blt_get_aligned_height(uint32_t height, uint32_t bpp,
+				enum blt_tiling_type tiling)
+{
+	switch (tiling) {
+	case T_LINEAR:
+		return height;
+	case T_XMAJOR:
+		return ALIGN(height, 8);
+	case T_TILE64:
+		if (bpp == 8)
+			return ALIGN(height, 256);
+		else if (bpp == 16 || bpp == 32)
+			return ALIGN(height, 128);
+		return ALIGN(height, 64);
+	default:
+		return ALIGN(height, 32);
+	}
+}
+
 static int __special_mode(const struct blt_copy_data *blt)
 {
 	if (blt->src.handle == blt->dst.handle &&
lib/intel_blt.h +4 -0
index d9be22fdf4..e3084dc0cd 100644
@@ -212,6 +212,10 @@ bool blt_block_copy_supports_compression(int fd);
 bool blt_uses_extended_block_copy(int fd);
 
 const char *blt_tiling_name(enum blt_tiling_type tiling);
+uint32_t blt_get_min_stride(uint32_t width, uint32_t bpp,
+			    enum blt_tiling_type tiling);
+uint32_t blt_get_aligned_height(uint32_t height, uint32_t bpp,
+				enum blt_tiling_type tiling);
 
 void blt_copy_init(int fd, struct blt_copy_data *blt);
 
Signature · 1 line
2.34.1
Reviewed-by on v4 1/5
#2 lore raw

Re: [PATCH i-g-t v4 1/5] lib/intel_blt: Add helpers for calculating stride and aligned height

Quoted 11 lines · Zbigniew Kempczyński

Tiled surfaces have stride / aligned height constraints. Currently blt library has limitation and doesn't work properly when surface stride is not valid for specific tiling.

As an example lets say we want to copy from linear to xmajor 33 x 33 x 32bpp surface. Xmajor surface expects stride aligned to 512 bytes and height to 8 rows so this surface will occupy 512B x 40 (128 x 40 x 32 bpp).

Just a bunch of nits, nothing major.

Quoted 15 lines

---
v2: Fix stride/aligned height calculation for Tile64
v3: Fix stride calculation for xmajor
Make helpers public (fixes compilation warning due to lack or static function users)

---
  lib/intel_blt.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++
  lib/intel_blt.h |  4 ++++
  2 files changed, 68 insertions(+)
lib/intel_blt.c +0 -0
index 25d251c4f8..13b1dbba4f 100644

lib/intel_blt.c static int __block_tiling(enum blt_tiling_type tiling) · line 530

Quoted 10 lines
lib/intel_blt.c +7 -0
@@ -521,6 +521,70 @@ static int __block_tiling(enum blt_tiling_type tiling)
  	return 0;
  }
 
+/**
+ * blt_get_min_stride
+ * @width: width in pixels
+ * @bpp: bits per pixel
+ * @tiling: tiling
+ *
+ * Function returns minimum posibble stride in bytes for width, bpp and tiling.

"return" is already described, we could say "calculates minimum possible stride..."

Quoted 24 lines
lib/intel_blt.c +24 -0
+ *
+ * Returns:
+ * minimum possible stride in bytes.
+ */
+uint32_t blt_get_min_stride(uint32_t width, uint32_t bpp,
+			    enum blt_tiling_type tiling)
+{
+	switch (tiling) {
+	case T_LINEAR:
+		return width * bpp / 8;
+	case T_XMAJOR:
+		return ALIGN(width * bpp / 8, 512);
+	case T_TILE64:
+		if (bpp == 8)
+			return ALIGN(width, 256);
+		else if (bpp == 16 || bpp == 32)
+			return ALIGN(width * bpp / 8, 512);
+		return ALIGN(width * bpp / 8, 1024);
+
+	default:
+		return ALIGN(width * bpp / 8, 128);
+	}
+}
+

lib/intel_blt.c static int __block_tiling(enum blt_tiling_type tiling) · line 564

Quoted 10 lines
lib/intel_blt.c +10 -0
+/**
+ * blt_get_aligned_height
+ * @height: height in pixels
+ * @bpp: bits per pixel (used for Tile64 due to different tile organization
+ * in pixels)
+ * @tiling: tiling
+ *
+ * Function returns aligned height for specific tiling. Height returned is
+ * important from memory allocation perspective, because each tiling has
+ * specific memory constraints.

I'd move the comment on Tile64 to the description body and integrate it with the last sentence. You could say that each tiling has constrains dependent on bpp and mention a different pixel order for Tile64 as an example.

Apart from that, it's looking good to me:

Quoted 41 lines
lib/intel_blt.c +23 -0
+ *
+ * Returns:
+ * height (rows) expected for specific tiling
+ */
+uint32_t blt_get_aligned_height(uint32_t height, uint32_t bpp,
+				enum blt_tiling_type tiling)
+{
+	switch (tiling) {
+	case T_LINEAR:
+		return height;
+	case T_XMAJOR:
+		return ALIGN(height, 8);
+	case T_TILE64:
+		if (bpp == 8)
+			return ALIGN(height, 256);
+		else if (bpp == 16 || bpp == 32)
+			return ALIGN(height, 128);
+		return ALIGN(height, 64);
+	default:
+		return ALIGN(height, 32);
+	}
+}
+
  static int __special_mode(const struct blt_copy_data *blt)
  {
  	if (blt->src.handle == blt->dst.handle &&
lib/intel_blt.h +4 -0
index d9be22fdf4..e3084dc0cd 100644
@@ -212,6 +212,10 @@ bool blt_block_copy_supports_compression(int fd);
  bool blt_uses_extended_block_copy(int fd);
 
  const char *blt_tiling_name(enum blt_tiling_type tiling);
+uint32_t blt_get_min_stride(uint32_t width, uint32_t bpp,
+			    enum blt_tiling_type tiling);
+uint32_t blt_get_aligned_height(uint32_t height, uint32_t bpp,
+				enum blt_tiling_type tiling);
 
  void blt_copy_init(int fd, struct blt_copy_data *blt);
 
#3 lore raw

Re: [PATCH i-g-t v4 1/5] lib/intel_blt: Add helpers for calculating stride and aligned height

Quoted 34 lines · Karolina Stolarek
Quoted 11 lines · Zbigniew Kempczyński

Tiled surfaces have stride / aligned height constraints. Currently blt library has limitation and doesn't work properly when surface stride is not valid for specific tiling.

As an example lets say we want to copy from linear to xmajor 33 x 33 x 32bpp surface. Xmajor surface expects stride aligned to 512 bytes and height to 8 rows so this surface will occupy 512B x 40 (128 x 40 x 32 bpp).

Just a bunch of nits, nothing major.

Quoted 19 lines

---
v2: Fix stride/aligned height calculation for Tile64
v3: Fix stride calculation for xmajor
Make helpers public (fixes compilation warning due to lack or static function users)

---
  lib/intel_blt.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++
  lib/intel_blt.h |  4 ++++
  2 files changed, 68 insertions(+)
lib/intel_blt.c +2 -0
index 25d251c4f8..13b1dbba4f 100644
@@ -521,6 +521,70 @@ static int __block_tiling(enum blt_tiling_type tiling)
  	return 0;
  }
+/**
+ * blt_get_min_stride
Quoted 8 lines

lib/intel_blt.c static int __block_tiling(enum blt_tiling_type tiling) · line 530

Quoted 5 lines
lib/intel_blt.c +5 -0
+ * @width: width in pixels
+ * @bpp: bits per pixel
+ * @tiling: tiling
+ *
+ * Function returns minimum posibble stride in bytes for width, bpp and tiling.

"return" is already described, we could say "calculates minimum possible stride..."

Agree, repeating same looks odd.

Quoted 32 lines
Quoted 32 lines
lib/intel_blt.c +31 -0
+ *
+ * Returns:
+ * minimum possible stride in bytes.
+ */
+uint32_t blt_get_min_stride(uint32_t width, uint32_t bpp,
+			    enum blt_tiling_type tiling)
+{
+	switch (tiling) {
+	case T_LINEAR:
+		return width * bpp / 8;
+	case T_XMAJOR:
+		return ALIGN(width * bpp / 8, 512);
+	case T_TILE64:
+		if (bpp == 8)
+			return ALIGN(width, 256);
+		else if (bpp == 16 || bpp == 32)
+			return ALIGN(width * bpp / 8, 512);
+		return ALIGN(width * bpp / 8, 1024);
+
+	default:
+		return ALIGN(width * bpp / 8, 128);
+	}
+}
+
+/**
+ * blt_get_aligned_height
+ * @height: height in pixels
+ * @bpp: bits per pixel (used for Tile64 due to different tile organization
+ * in pixels)
+ * @tiling: tiling
+ *
Quoted 8 lines

lib/intel_blt.c static int __block_tiling(enum blt_tiling_type tiling) · line 564

Quoted 3 lines
lib/intel_blt.c +3 -0
+ * Function returns aligned height for specific tiling. Height returned is
+ * important from memory allocation perspective, because each tiling has
+ * specific memory constraints.

I'd move the comment on Tile64 to the description body and integrate it with the last sentence. You could say that each tiling has constrains dependent on bpp and mention a different pixel order for Tile64 as an example.

I've added some note about Tile64 to commit message to explain why we need to pass bpp either.

Thanks for the review.

Quoted 4 lines

Apart from that, it's looking good to me:

R-b taken.

--
Zbigniew

Quoted 39 lines
Quoted 39 lines
lib/intel_blt.c +23 -0
+ *
+ * Returns:
+ * height (rows) expected for specific tiling
+ */
+uint32_t blt_get_aligned_height(uint32_t height, uint32_t bpp,
+				enum blt_tiling_type tiling)
+{
+	switch (tiling) {
+	case T_LINEAR:
+		return height;
+	case T_XMAJOR:
+		return ALIGN(height, 8);
+	case T_TILE64:
+		if (bpp == 8)
+			return ALIGN(height, 256);
+		else if (bpp == 16 || bpp == 32)
+			return ALIGN(height, 128);
+		return ALIGN(height, 64);
+	default:
+		return ALIGN(height, 32);
+	}
+}
+
  static int __special_mode(const struct blt_copy_data *blt)
  {
  	if (blt->src.handle == blt->dst.handle &&
lib/intel_blt.h +4 -0
index d9be22fdf4..e3084dc0cd 100644
@@ -212,6 +212,10 @@ bool blt_block_copy_supports_compression(int fd);
  bool blt_uses_extended_block_copy(int fd);
  const char *blt_tiling_name(enum blt_tiling_type tiling);
+uint32_t blt_get_min_stride(uint32_t width, uint32_t bpp,
+			    enum blt_tiling_type tiling);
+uint32_t blt_get_aligned_height(uint32_t height, uint32_t bpp,
+				enum blt_tiling_type tiling);
  void blt_copy_init(int fd, struct blt_copy_data *blt);
#4 lore raw

PATCH v4 2/5 lib/intel_blt: Change surface size calculation

In reply to Zbigniew Kempczyński

For tiled surfaces we need to ensure stride and height are valid from the blit operation perspective. Calculate required surface size according to tiling constraints.

---
 lib/intel_blt.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
lib/intel_blt.c +10 -2
index 13b1dbba4f..00208fc243 100644
@@ -1858,13 +1858,21 @@ blt_create_object(const struct blt_copy_data *blt, uint32_t region,
 		  bool create_mapping)
 {
 	struct blt_copy_object *obj;
-	uint64_t size = width * height * bpp / 8;
-	uint32_t stride = tiling == T_LINEAR ? width * 4 : width;
+	uint32_t stride, aligned_height;
+	uint64_t size;
 	uint32_t handle;
 	uint8_t pat_index = DEFAULT_PAT_INDEX;
 
 	igt_assert_f(blt->driver, "Driver isn't set, have you called blt_copy_init()?\n");
 
+	stride = blt_get_min_stride(width, bpp, tiling);
+	aligned_height = blt_get_aligned_height(height, bpp, tiling);
+	size = stride * aligned_height;
+
+	/* blitter command expects stride in dwords on tiled surfaces */
+	if (tiling)
+		stride /= 4;
+
 	obj = calloc(1, sizeof(*obj));
 
 	obj->size = size;
Signature · 1 line
2.34.1
Reviewed-by on v4 2/5
#5 lore raw

Re: [PATCH i-g-t v4 2/5] lib/intel_blt: Change surface size calculation

Quoted 6 lines · Zbigniew Kempczyński

For tiled surfaces we need to ensure stride and height are valid from the blit operation perspective. Calculate required surface size according to tiling constraints.

I'm looking at blt_set_geom() function. We still pass normal height and width to it. Is this correct? Or should we change height to aligned_height? Because if we should, this patch should be updated to reflect that.

If that's not a problem, then:

Quoted 32 lines
---
  lib/intel_blt.c | 12 ++++++++++--
  1 file changed, 10 insertions(+), 2 deletions(-)
lib/intel_blt.c +10 -2
index 13b1dbba4f..00208fc243 100644
@@ -1858,13 +1858,21 @@ blt_create_object(const struct blt_copy_data *blt, uint32_t region,
  		  bool create_mapping)
  {
  	struct blt_copy_object *obj;
-	uint64_t size = width * height * bpp / 8;
-	uint32_t stride = tiling == T_LINEAR ? width * 4 : width;
+	uint32_t stride, aligned_height;
+	uint64_t size;
  	uint32_t handle;
  	uint8_t pat_index = DEFAULT_PAT_INDEX;
 
  	igt_assert_f(blt->driver, "Driver isn't set, have you called blt_copy_init()?\n");
 
+	stride = blt_get_min_stride(width, bpp, tiling);
+	aligned_height = blt_get_aligned_height(height, bpp, tiling);
+	size = stride * aligned_height;
+
+	/* blitter command expects stride in dwords on tiled surfaces */
+	if (tiling)
+		stride /= 4;
+
  	obj = calloc(1, sizeof(*obj));
 
  	obj->size = size;
#6 lore raw

Re: [PATCH i-g-t v4 2/5] lib/intel_blt: Change surface size calculation

Quoted 6 lines · Karolina Stolarek
Quoted 4 lines · Zbigniew Kempczyński

For tiled surfaces we need to ensure stride and height are valid from the blit operation perspective. Calculate required surface size according to tiling constraints.

Quoted 7 lines
Quoted 2 lines

I'm looking at blt_set_geom() function. We still pass normal height and width to it. Is this correct? Or should we change height to aligned_height? Because if we should, this patch should be updated to reflect that.

Function creates an object, which should be correct from stride/aligned height perspective. I mean you need to allocate enough memory to handle all pixels which will be touched during blit. So the best is to allocate whole tile (x/y/4/64). Then you'll be sure hw won't touch addresses outside your object and you don't hang the engine.

For example you want to blit 1x128x32bpp between two surfaces for Tile64. Even you're using single pixel in x (one dword) you need to provide stride 128 (in dwords). That's hardware requirement and even if this looks like waste of memory (127 pixels in x won't be used at all) hardware expects that. I learned this hard way during extending block-copy from small to large buffers.

I wondered to refactor blt_copy_object to contain bpp (this way we may warn if user passes invalid stride during object setup) but at the moment I resisted as my primary goal is to fill the test gap in blit/render-copy from small to large buffers.

Quoted 4 lines

If that's not a problem, then:

Thanks for the review.

--
Zbigniew

Quoted 30 lines
Quoted 30 lines
---
  lib/intel_blt.c | 12 ++++++++++--
  1 file changed, 10 insertions(+), 2 deletions(-)
lib/intel_blt.c +10 -2
index 13b1dbba4f..00208fc243 100644
@@ -1858,13 +1858,21 @@ blt_create_object(const struct blt_copy_data *blt, uint32_t region,
  		  bool create_mapping)
  {
  	struct blt_copy_object *obj;
-	uint64_t size = width * height * bpp / 8;
-	uint32_t stride = tiling == T_LINEAR ? width * 4 : width;
+	uint32_t stride, aligned_height;
+	uint64_t size;
  	uint32_t handle;
  	uint8_t pat_index = DEFAULT_PAT_INDEX;
  	igt_assert_f(blt->driver, "Driver isn't set, have you called blt_copy_init()?\n");
+	stride = blt_get_min_stride(width, bpp, tiling);
+	aligned_height = blt_get_aligned_height(height, bpp, tiling);
+	size = stride * aligned_height;
+
+	/* blitter command expects stride in dwords on tiled surfaces */
+	if (tiling)
+		stride /= 4;
+
  	obj = calloc(1, sizeof(*obj));
  	obj->size = size;
#7 lore raw

PATCH v4 3/5 lib/intel_blt: Use object pitch and aligned height on png write

In reply to Zbigniew Kempczyński

Pitch and buffer height on tiled surfaces might be bigger than image width and height so dump memory to png using pitch size instead width and aligned height instead height.

---
v4: Use original width/height in filename instead stride/aligned
height to avoid png overwriting (Zbigniew)

---
 lib/intel_blt.c                | 13 ++++++++++---
 lib/intel_blt.h                |  2 +-
 tests/intel/gem_ccs.c          | 23 ++++++++++++-----------
 tests/intel/gem_exercise_blt.c | 16 ++++++++--------
 tests/intel/xe_ccs.c           | 23 ++++++++++++-----------
 tests/intel/xe_exercise_blt.c  | 16 ++++++++--------
 6 files changed, 51 insertions(+), 42 deletions(-)
lib/intel_blt.c +10 -3
index 00208fc243..1cb5e68763 100644
@@ -2076,21 +2076,28 @@ void blt_surface_info(const char *info, const struct blt_copy_object *obj)
  * @obj: blitter copy object (@blt_copy_object) to save to png
  * @width: width
  * @height: height
+ * @bpp: bits per pixel
  *
  * Function save surface to png file. Assumes ARGB format where A == 0xff.
  */
 void blt_surface_to_png(int fd, uint32_t run_id, const char *fileid,
 			const struct blt_copy_object *obj,
-			uint32_t width, uint32_t height)
+			uint32_t width, uint32_t height, uint32_t bpp)
 {
 	cairo_surface_t *surface;
 	cairo_status_t ret;
+	uint32_t dump_width = width, dump_height = height;
 	uint8_t *map = (uint8_t *) obj->ptr;
 	int format;
 	int stride = obj->tiling ? obj->pitch * 4 : obj->pitch;
 	char filename[FILENAME_MAX];
 	bool is_xe = is_xe_device(fd);
 
+	if (obj->tiling) {
+		dump_width = obj->pitch;
+		dump_height = blt_get_aligned_height(height, bpp, obj->tiling);
+	}
+
 	snprintf(filename, FILENAME_MAX-1, "%d-%s-%s-%ux%u-%s.png",
 		 run_id, fileid, blt_tiling_name(obj->tiling), width, height,
 		 obj->compression ? "compressed" : "uncompressed");
@@ -2103,8 +2110,8 @@ void blt_surface_to_png(int fd, uint32_t run_id, const char *fileid,
 							obj->size, PROT_READ);
 	}
 	format = CAIRO_FORMAT_RGB24;
-	surface = cairo_image_surface_create_for_data(map,
-						      format, width, height,
+	surface = cairo_image_surface_create_for_data(map, format,
+						      dump_width, dump_height,
 						      stride);
 	ret = cairo_surface_write_to_png(surface, filename);
 	if (ret)
lib/intel_blt.h +1 -1
index e3084dc0cd..077283a088 100644
@@ -315,7 +315,7 @@ void blt_surface_fill_rect(int fd, const struct blt_copy_object *obj,
 			   uint32_t width, uint32_t height);
 void blt_surface_to_png(int fd, uint32_t run_id, const char *fileid,
 			const struct blt_copy_object *obj,
-			uint32_t width, uint32_t height);
+			uint32_t width, uint32_t height, uint32_t bpp);
 void blt_dump_corruption_info_32b(const struct blt_copy_object *surf1,
 				  const struct blt_copy_object *surf2);
 
tests/intel/gem_ccs.c +12 -11
index 80a29ecab7..e8f16d7d88 100644
@@ -82,9 +82,9 @@ struct test_config {
 	if (param.print_surface_info) \
 		blt_surface_info((name), (obj)); } while (0)
 
-#define WRITE_PNG(fd, id, name, obj, w, h) do { \
+#define WRITE_PNG(fd, id, name, obj, w, h, bpp) do { \
 	if (param.write_png) \
-		blt_surface_to_png((fd), (id), (name), (obj), (w), (h)); } while (0)
+		blt_surface_to_png((fd), (id), (name), (obj), (w), (h), (bpp)); } while (0)
 
 static void surf_copy(int i915,
 		      const intel_ctx_t *ctx,
@@ -98,6 +98,7 @@ static void surf_copy(int i915,
 	struct blt_copy_data blt = {};
 	struct blt_block_copy_data_ext ext = {};
 	struct blt_ctrl_surf_copy_data surf = {};
+	const uint32_t bpp = 32;
 	uint32_t bb1, bb2, ccs, ccs2, *ccsmap, *ccsmap2;
 	uint64_t bb_size, ccssize = mid->size / CCS_RATIO(i915);
 	uint32_t *ccscopy;
@@ -172,7 +173,7 @@ static void surf_copy(int i915,
 	blt_set_batch(&blt.bb, bb2, bb_size, REGION_SMEM);
 	blt_block_copy(i915, ctx, e, ahnd, &blt, &ext);
 	gem_sync(i915, blt.dst.handle);
-	WRITE_PNG(i915, run_id, "corrupted", &blt.dst, dst->x2, dst->y2);
+	WRITE_PNG(i915, run_id, "corrupted", &blt.dst, dst->x2, dst->y2, bpp);
 	result = memcmp(src->ptr, dst->ptr, src->size);
 	igt_assert(result != 0);
 
@@ -182,7 +183,7 @@ static void surf_copy(int i915,
 
 	blt_block_copy(i915, ctx, e, ahnd, &blt, &ext);
 	gem_sync(i915, blt.dst.handle);
-	WRITE_PNG(i915, run_id, "corrected", &blt.dst, dst->x2, dst->y2);
+	WRITE_PNG(i915, run_id, "corrected", &blt.dst, dst->x2, dst->y2, bpp);
 	result = memcmp(src->ptr, dst->ptr, src->size);
 	if (result)
 		blt_dump_corruption_info_32b(src, dst);
@@ -346,7 +347,7 @@ static void block_copy(int i915,
 	PRINT_SURFACE_INFO("dst", dst);
 
 	blt_surface_fill_rect(i915, src, width, height);
-	WRITE_PNG(i915, run_id, "src", src, width, height);
+	WRITE_PNG(i915, run_id, "src", src, width, height, bpp);
 
 	blt.color_depth = CD_32bit;
 	blt.print_bb = param.print_bb;
@@ -363,7 +364,7 @@ static void block_copy(int i915,
 	if (mid->compression)
 		igt_assert(memcmp(src->ptr, mid->ptr, src->size) != 0);
 
-	WRITE_PNG(i915, run_id, "mid", &blt.dst, width, height);
+	WRITE_PNG(i915, run_id, "mid", &blt.dst, width, height, bpp);
 
 	if (config->surfcopy && pext) {
 		const intel_ctx_t *surf_ctx = ctx;
@@ -408,7 +409,7 @@ static void block_copy(int i915,
 	blt_set_batch(&blt.bb, bb, bb_size, region1);
 	blt_block_copy(i915, ctx, e, ahnd, &blt, pext);
 	gem_sync(i915, blt.dst.handle);
-	WRITE_PNG(i915, run_id, "dst", &blt.dst, width, height);
+	WRITE_PNG(i915, run_id, "dst", &blt.dst, width, height, bpp);
 
 	result = memcmp(src->ptr, blt.dst.ptr, src->size);
 
@@ -491,11 +492,11 @@ static void block_multicopy(int i915,
 	blt_block_copy3(i915, ctx, e, ahnd, &blt3, pext3);
 	gem_sync(i915, blt3.final.handle);
 
-	WRITE_PNG(i915, run_id, "src", &blt3.src, width, height);
+	WRITE_PNG(i915, run_id, "src", &blt3.src, width, height, bpp);
 	if (!config->inplace)
-		WRITE_PNG(i915, run_id, "mid", &blt3.mid, width, height);
-	WRITE_PNG(i915, run_id, "dst", &blt3.dst, width, height);
-	WRITE_PNG(i915, run_id, "final", &blt3.final, width, height);
+		WRITE_PNG(i915, run_id, "mid", &blt3.mid, width, height, bpp);
+	WRITE_PNG(i915, run_id, "dst", &blt3.dst, width, height, bpp);
+	WRITE_PNG(i915, run_id, "final", &blt3.final, width, height, bpp);
 
 	result = memcmp(src->ptr, blt3.final.ptr, src->size);
 
tests/intel/gem_exercise_blt.c +8 -8
index 7355eabbe9..4a9bc37298 100644
@@ -50,9 +50,9 @@ static struct param {
 	if (param.print_surface_info) \
 		blt_surface_info((name), (obj)); } while (0)
 
-#define WRITE_PNG(fd, id, name, obj, w, h) do { \
+#define WRITE_PNG(fd, id, name, obj, w, h, bpp) do { \
 	if (param.write_png) \
-		blt_surface_to_png((fd), (id), (name), (obj), (w), (h)); } while (0)
+		blt_surface_to_png((fd), (id), (name), (obj), (w), (h), (bpp)); } while (0)
 
 struct blt_fast_copy_data {
 	int i915;
@@ -167,7 +167,7 @@ static void fast_copy_emit(int i915, const intel_ctx_t *ctx,
 	PRINT_SURFACE_INFO("dst", dst);
 
 	blt_surface_fill_rect(i915, src, width, height);
-	WRITE_PNG(i915, mid_tiling, "src", src, width, height);
+	WRITE_PNG(i915, mid_tiling, "src", src, width, height, bpp);
 
 	memset(&blt, 0, sizeof(blt));
 	blt.color_depth = CD_32bit;
@@ -180,8 +180,8 @@ static void fast_copy_emit(int i915, const intel_ctx_t *ctx,
 	fast_copy_one_bb(i915, ctx, e, ahnd, &blt);
 	gem_sync(i915, blt.dst.handle);
 
-	WRITE_PNG(i915, mid_tiling, "mid", &blt.mid, width, height);
-	WRITE_PNG(i915, mid_tiling, "dst", &blt.dst, width, height);
+	WRITE_PNG(i915, mid_tiling, "mid", &blt.mid, width, height, bpp);
+	WRITE_PNG(i915, mid_tiling, "dst", &blt.dst, width, height, bpp);
 
 	result = memcmp(src->ptr, blt.dst.ptr, src->size);
 
@@ -234,8 +234,8 @@ static void fast_copy(int i915, const intel_ctx_t *ctx,
 	blt_fast_copy(i915, ctx, e, ahnd, &blt);
 	gem_sync(i915, mid->handle);
 
-	WRITE_PNG(i915, mid_tiling, "src", &blt.src, width, height);
-	WRITE_PNG(i915, mid_tiling, "mid", &blt.dst, width, height);
+	WRITE_PNG(i915, mid_tiling, "src", &blt.src, width, height, bpp);
+	WRITE_PNG(i915, mid_tiling, "mid", &blt.dst, width, height, bpp);
 
 	blt_copy_init(i915, &blt);
 	blt.color_depth = CD_32bit;
@@ -247,7 +247,7 @@ static void fast_copy(int i915, const intel_ctx_t *ctx,
 	blt_fast_copy(i915, ctx, e, ahnd, &blt);
 	gem_sync(i915, blt.dst.handle);
 
-	WRITE_PNG(i915, mid_tiling, "dst", &blt.dst, width, height);
+	WRITE_PNG(i915, mid_tiling, "dst", &blt.dst, width, height, bpp);
 
 	result = memcmp(src->ptr, blt.dst.ptr, src->size);
 
tests/intel/xe_ccs.c +12 -11
index 7d0e8ed7a5..a7785edcb1 100644
@@ -79,9 +79,9 @@ struct test_config {
 	if (param.print_surface_info) \
 		blt_surface_info((name), (obj)); } while (0)
 
-#define WRITE_PNG(fd, id, name, obj, w, h) do { \
+#define WRITE_PNG(fd, id, name, obj, w, h, bpp) do { \
 	if (param.write_png) \
-		blt_surface_to_png((fd), (id), (name), (obj), (w), (h)); } while (0)
+		blt_surface_to_png((fd), (id), (name), (obj), (w), (h), (bpp)); } while (0)
 
 static void surf_copy(int xe,
 		      intel_ctx_t *ctx,
@@ -94,6 +94,7 @@ static void surf_copy(int xe,
 	struct blt_copy_data blt = {};
 	struct blt_block_copy_data_ext ext = {};
 	struct blt_ctrl_surf_copy_data surf = {};
+	const uint32_t bpp = 32;
 	uint32_t bb1, bb2, ccs, ccs2, *ccsmap, *ccsmap2;
 	uint64_t bb_size, ccssize = mid->size / CCS_RATIO(xe);
 	uint64_t ccs_bo_size = xe_get_default_alignment(xe);
@@ -179,7 +180,7 @@ static void surf_copy(int xe,
 	blt_set_batch(&blt.bb, bb2, bb_size, sysmem);
 	blt_block_copy(xe, ctx, NULL, ahnd, &blt, &ext);
 	intel_ctx_xe_sync(ctx, true);
-	WRITE_PNG(xe, run_id, "corrupted", &blt.dst, dst->x2, dst->y2);
+	WRITE_PNG(xe, run_id, "corrupted", &blt.dst, dst->x2, dst->y2, bpp);
 	result = memcmp(src->ptr, dst->ptr, src->size);
 	igt_assert(result != 0);
 
@@ -189,7 +190,7 @@ static void surf_copy(int xe,
 
 	blt_block_copy(xe, ctx, NULL, ahnd, &blt, &ext);
 	intel_ctx_xe_sync(ctx, true);
-	WRITE_PNG(xe, run_id, "corrected", &blt.dst, dst->x2, dst->y2);
+	WRITE_PNG(xe, run_id, "corrected", &blt.dst, dst->x2, dst->y2, bpp);
 	result = memcmp(src->ptr, dst->ptr, src->size);
 	if (result)
 		blt_dump_corruption_info_32b(src, dst);
@@ -326,7 +327,7 @@ static void block_copy(int xe,
 	PRINT_SURFACE_INFO("dst", dst);
 
 	blt_surface_fill_rect(xe, src, width, height);
-	WRITE_PNG(xe, run_id, "src", src, width, height);
+	WRITE_PNG(xe, run_id, "src", src, width, height, bpp);
 
 	blt.color_depth = CD_32bit;
 	blt.print_bb = param.print_bb;
@@ -342,7 +343,7 @@ static void block_copy(int xe,
 	if (mid->compression)
 		igt_assert(memcmp(src->ptr, mid->ptr, src->size) != 0);
 
-	WRITE_PNG(xe, run_id, "mid", &blt.dst, width, height);
+	WRITE_PNG(xe, run_id, "mid", &blt.dst, width, height, bpp);
 
 	if (config->surfcopy && pext) {
 		struct drm_xe_engine_class_instance inst = {
@@ -393,7 +394,7 @@ static void block_copy(int xe,
 	blt_block_copy(xe, ctx, NULL, ahnd, &blt, pext);
 	intel_ctx_xe_sync(ctx, true);
 
-	WRITE_PNG(xe, run_id, "dst", &blt.dst, width, height);
+	WRITE_PNG(xe, run_id, "dst", &blt.dst, width, height, bpp);
 
 	result = memcmp(src->ptr, blt.dst.ptr, src->size);
 
@@ -486,11 +487,11 @@ static void block_multicopy(int xe,
 	blt_block_copy3(xe, ctx, ahnd, &blt3, pext3);
 	intel_ctx_xe_sync(ctx, true);
 
-	WRITE_PNG(xe, run_id, "src", &blt3.src, width, height);
+	WRITE_PNG(xe, run_id, "src", &blt3.src, width, height, bpp);
 	if (!config->inplace)
-		WRITE_PNG(xe, run_id, "mid", &blt3.mid, width, height);
-	WRITE_PNG(xe, run_id, "dst", &blt3.dst, width, height);
-	WRITE_PNG(xe, run_id, "final", &blt3.final, width, height);
+		WRITE_PNG(xe, run_id, "mid", &blt3.mid, width, height, bpp);
+	WRITE_PNG(xe, run_id, "dst", &blt3.dst, width, height, bpp);
+	WRITE_PNG(xe, run_id, "final", &blt3.final, width, height, bpp);
 
 	result = memcmp(src->ptr, blt3.final.ptr, src->size);
 
tests/intel/xe_exercise_blt.c +8 -8
index c908800cf4..ddf9d188a7 100644
@@ -53,9 +53,9 @@ static struct param {
 	if (param.print_surface_info) \
 		blt_surface_info((name), (obj)); } while (0)
 
-#define WRITE_PNG(fd, id, name, obj, w, h) do { \
+#define WRITE_PNG(fd, id, name, obj, w, h, bpp) do { \
 	if (param.write_png) \
-		blt_surface_to_png((fd), (id), (name), (obj), (w), (h)); } while (0)
+		blt_surface_to_png((fd), (id), (name), (obj), (w), (h), (bpp)); } while (0)
 
 struct blt_fast_copy_data {
 	int xe;
@@ -141,7 +141,7 @@ static void fast_copy_emit(int xe, const intel_ctx_t *ctx,
 	PRINT_SURFACE_INFO("dst", dst);
 
 	blt_surface_fill_rect(xe, src, width, height);
-	WRITE_PNG(xe, mid_tiling, "src", src, width, height);
+	WRITE_PNG(xe, mid_tiling, "src", src, width, height, bpp);
 
 	memset(&blt, 0, sizeof(blt));
 	blt.color_depth = CD_32bit;
@@ -153,8 +153,8 @@ static void fast_copy_emit(int xe, const intel_ctx_t *ctx,
 
 	fast_copy_one_bb(xe, ctx, ahnd, &blt);
 
-	WRITE_PNG(xe, mid_tiling, "mid", &blt.mid, width, height);
-	WRITE_PNG(xe, mid_tiling, "dst", &blt.dst, width, height);
+	WRITE_PNG(xe, mid_tiling, "mid", &blt.mid, width, height, bpp);
+	WRITE_PNG(xe, mid_tiling, "dst", &blt.dst, width, height, bpp);
 
 	result = memcmp(src->ptr, blt.dst.ptr, src->size);
 
@@ -205,8 +205,8 @@ static void fast_copy(int xe, const intel_ctx_t *ctx,
 
 	blt_fast_copy(xe, ctx, NULL, ahnd, &blt);
 
-	WRITE_PNG(xe, mid_tiling, "src", &blt.src, width, height);
-	WRITE_PNG(xe, mid_tiling, "mid", &blt.dst, width, height);
+	WRITE_PNG(xe, mid_tiling, "src", &blt.src, width, height, bpp);
+	WRITE_PNG(xe, mid_tiling, "mid", &blt.dst, width, height, bpp);
 
 	blt_copy_init(xe, &blt);
 	blt.color_depth = CD_32bit;
@@ -217,7 +217,7 @@ static void fast_copy(int xe, const intel_ctx_t *ctx,
 
 	blt_fast_copy(xe, ctx, NULL, ahnd, &blt);
 
-	WRITE_PNG(xe, mid_tiling, "dst", &blt.dst, width, height);
+	WRITE_PNG(xe, mid_tiling, "dst", &blt.dst, width, height, bpp);
 
 	result = memcmp(src->ptr, blt.dst.ptr, src->size);
 
Signature · 1 line
2.34.1
Reviewed-by on v4 3/5
#8 lore raw

Re: [PATCH i-g-t v4 3/5] lib/intel_blt: Use object pitch and aligned height on png write

Quoted 9 lines · Zbigniew Kempczyński

Pitch and buffer height on tiled surfaces might be bigger than image width and height so dump memory to png using pitch size instead width and aligned height instead height.

---
v4: Use original width/height in filename instead stride/aligned
height to avoid png overwriting (Zbigniew)

Quoted 349 lines
---
  lib/intel_blt.c                | 13 ++++++++++---
  lib/intel_blt.h                |  2 +-
  tests/intel/gem_ccs.c          | 23 ++++++++++++-----------
  tests/intel/gem_exercise_blt.c | 16 ++++++++--------
  tests/intel/xe_ccs.c           | 23 ++++++++++++-----------
  tests/intel/xe_exercise_blt.c  | 16 ++++++++--------
  6 files changed, 51 insertions(+), 42 deletions(-)
lib/intel_blt.c +10 -3
index 00208fc243..1cb5e68763 100644
@@ -2076,21 +2076,28 @@ void blt_surface_info(const char *info, const struct blt_copy_object *obj)
   * @obj: blitter copy object (@blt_copy_object) to save to png
   * @width: width
   * @height: height
+ * @bpp: bits per pixel
   *
   * Function save surface to png file. Assumes ARGB format where A == 0xff.
   */
  void blt_surface_to_png(int fd, uint32_t run_id, const char *fileid,
  			const struct blt_copy_object *obj,
-			uint32_t width, uint32_t height)
+			uint32_t width, uint32_t height, uint32_t bpp)
  {
  	cairo_surface_t *surface;
  	cairo_status_t ret;
+	uint32_t dump_width = width, dump_height = height;
  	uint8_t *map = (uint8_t *) obj->ptr;
  	int format;
  	int stride = obj->tiling ? obj->pitch * 4 : obj->pitch;
  	char filename[FILENAME_MAX];
  	bool is_xe = is_xe_device(fd);
 
+	if (obj->tiling) {
+		dump_width = obj->pitch;
+		dump_height = blt_get_aligned_height(height, bpp, obj->tiling);
+	}
+
  	snprintf(filename, FILENAME_MAX-1, "%d-%s-%s-%ux%u-%s.png",
  		 run_id, fileid, blt_tiling_name(obj->tiling), width, height,
  		 obj->compression ? "compressed" : "uncompressed");
@@ -2103,8 +2110,8 @@ void blt_surface_to_png(int fd, uint32_t run_id, const char *fileid,
  							obj->size, PROT_READ);
  	}
  	format = CAIRO_FORMAT_RGB24;
-	surface = cairo_image_surface_create_for_data(map,
-						      format, width, height,
+	surface = cairo_image_surface_create_for_data(map, format,
+						      dump_width, dump_height,
  						      stride);
  	ret = cairo_surface_write_to_png(surface, filename);
  	if (ret)
lib/intel_blt.h +1 -1
index e3084dc0cd..077283a088 100644
@@ -315,7 +315,7 @@ void blt_surface_fill_rect(int fd, const struct blt_copy_object *obj,
  			   uint32_t width, uint32_t height);
  void blt_surface_to_png(int fd, uint32_t run_id, const char *fileid,
  			const struct blt_copy_object *obj,
-			uint32_t width, uint32_t height);
+			uint32_t width, uint32_t height, uint32_t bpp);
  void blt_dump_corruption_info_32b(const struct blt_copy_object *surf1,
  				  const struct blt_copy_object *surf2);
 
tests/intel/gem_ccs.c +12 -11
index 80a29ecab7..e8f16d7d88 100644
@@ -82,9 +82,9 @@ struct test_config {
  	if (param.print_surface_info) \
  		blt_surface_info((name), (obj)); } while (0)
 
-#define WRITE_PNG(fd, id, name, obj, w, h) do { \
+#define WRITE_PNG(fd, id, name, obj, w, h, bpp) do { \
  	if (param.write_png) \
-		blt_surface_to_png((fd), (id), (name), (obj), (w), (h)); } while (0)
+		blt_surface_to_png((fd), (id), (name), (obj), (w), (h), (bpp)); } while (0)
 
  static void surf_copy(int i915,
  		      const intel_ctx_t *ctx,
@@ -98,6 +98,7 @@ static void surf_copy(int i915,
  	struct blt_copy_data blt = {};
  	struct blt_block_copy_data_ext ext = {};
  	struct blt_ctrl_surf_copy_data surf = {};
+	const uint32_t bpp = 32;
  	uint32_t bb1, bb2, ccs, ccs2, *ccsmap, *ccsmap2;
  	uint64_t bb_size, ccssize = mid->size / CCS_RATIO(i915);
  	uint32_t *ccscopy;
@@ -172,7 +173,7 @@ static void surf_copy(int i915,
  	blt_set_batch(&blt.bb, bb2, bb_size, REGION_SMEM);
  	blt_block_copy(i915, ctx, e, ahnd, &blt, &ext);
  	gem_sync(i915, blt.dst.handle);
-	WRITE_PNG(i915, run_id, "corrupted", &blt.dst, dst->x2, dst->y2);
+	WRITE_PNG(i915, run_id, "corrupted", &blt.dst, dst->x2, dst->y2, bpp);
  	result = memcmp(src->ptr, dst->ptr, src->size);
  	igt_assert(result != 0);
 
@@ -182,7 +183,7 @@ static void surf_copy(int i915,
 
  	blt_block_copy(i915, ctx, e, ahnd, &blt, &ext);
  	gem_sync(i915, blt.dst.handle);
-	WRITE_PNG(i915, run_id, "corrected", &blt.dst, dst->x2, dst->y2);
+	WRITE_PNG(i915, run_id, "corrected", &blt.dst, dst->x2, dst->y2, bpp);
  	result = memcmp(src->ptr, dst->ptr, src->size);
  	if (result)
  		blt_dump_corruption_info_32b(src, dst);
@@ -346,7 +347,7 @@ static void block_copy(int i915,
  	PRINT_SURFACE_INFO("dst", dst);
 
  	blt_surface_fill_rect(i915, src, width, height);
-	WRITE_PNG(i915, run_id, "src", src, width, height);
+	WRITE_PNG(i915, run_id, "src", src, width, height, bpp);
 
  	blt.color_depth = CD_32bit;
  	blt.print_bb = param.print_bb;
@@ -363,7 +364,7 @@ static void block_copy(int i915,
  	if (mid->compression)
  		igt_assert(memcmp(src->ptr, mid->ptr, src->size) != 0);
 
-	WRITE_PNG(i915, run_id, "mid", &blt.dst, width, height);
+	WRITE_PNG(i915, run_id, "mid", &blt.dst, width, height, bpp);
 
  	if (config->surfcopy && pext) {
  		const intel_ctx_t *surf_ctx = ctx;
@@ -408,7 +409,7 @@ static void block_copy(int i915,
  	blt_set_batch(&blt.bb, bb, bb_size, region1);
  	blt_block_copy(i915, ctx, e, ahnd, &blt, pext);
  	gem_sync(i915, blt.dst.handle);
-	WRITE_PNG(i915, run_id, "dst", &blt.dst, width, height);
+	WRITE_PNG(i915, run_id, "dst", &blt.dst, width, height, bpp);
 
  	result = memcmp(src->ptr, blt.dst.ptr, src->size);
 
@@ -491,11 +492,11 @@ static void block_multicopy(int i915,
  	blt_block_copy3(i915, ctx, e, ahnd, &blt3, pext3);
  	gem_sync(i915, blt3.final.handle);
 
-	WRITE_PNG(i915, run_id, "src", &blt3.src, width, height);
+	WRITE_PNG(i915, run_id, "src", &blt3.src, width, height, bpp);
  	if (!config->inplace)
-		WRITE_PNG(i915, run_id, "mid", &blt3.mid, width, height);
-	WRITE_PNG(i915, run_id, "dst", &blt3.dst, width, height);
-	WRITE_PNG(i915, run_id, "final", &blt3.final, width, height);
+		WRITE_PNG(i915, run_id, "mid", &blt3.mid, width, height, bpp);
+	WRITE_PNG(i915, run_id, "dst", &blt3.dst, width, height, bpp);
+	WRITE_PNG(i915, run_id, "final", &blt3.final, width, height, bpp);
 
  	result = memcmp(src->ptr, blt3.final.ptr, src->size);
 
tests/intel/gem_exercise_blt.c +8 -8
index 7355eabbe9..4a9bc37298 100644
@@ -50,9 +50,9 @@ static struct param {
  	if (param.print_surface_info) \
  		blt_surface_info((name), (obj)); } while (0)
 
-#define WRITE_PNG(fd, id, name, obj, w, h) do { \
+#define WRITE_PNG(fd, id, name, obj, w, h, bpp) do { \
  	if (param.write_png) \
-		blt_surface_to_png((fd), (id), (name), (obj), (w), (h)); } while (0)
+		blt_surface_to_png((fd), (id), (name), (obj), (w), (h), (bpp)); } while (0)
 
  struct blt_fast_copy_data {
  	int i915;
@@ -167,7 +167,7 @@ static void fast_copy_emit(int i915, const intel_ctx_t *ctx,
  	PRINT_SURFACE_INFO("dst", dst);
 
  	blt_surface_fill_rect(i915, src, width, height);
-	WRITE_PNG(i915, mid_tiling, "src", src, width, height);
+	WRITE_PNG(i915, mid_tiling, "src", src, width, height, bpp);
 
  	memset(&blt, 0, sizeof(blt));
  	blt.color_depth = CD_32bit;
@@ -180,8 +180,8 @@ static void fast_copy_emit(int i915, const intel_ctx_t *ctx,
  	fast_copy_one_bb(i915, ctx, e, ahnd, &blt);
  	gem_sync(i915, blt.dst.handle);
 
-	WRITE_PNG(i915, mid_tiling, "mid", &blt.mid, width, height);
-	WRITE_PNG(i915, mid_tiling, "dst", &blt.dst, width, height);
+	WRITE_PNG(i915, mid_tiling, "mid", &blt.mid, width, height, bpp);
+	WRITE_PNG(i915, mid_tiling, "dst", &blt.dst, width, height, bpp);
 
  	result = memcmp(src->ptr, blt.dst.ptr, src->size);
 
@@ -234,8 +234,8 @@ static void fast_copy(int i915, const intel_ctx_t *ctx,
  	blt_fast_copy(i915, ctx, e, ahnd, &blt);
  	gem_sync(i915, mid->handle);
 
-	WRITE_PNG(i915, mid_tiling, "src", &blt.src, width, height);
-	WRITE_PNG(i915, mid_tiling, "mid", &blt.dst, width, height);
+	WRITE_PNG(i915, mid_tiling, "src", &blt.src, width, height, bpp);
+	WRITE_PNG(i915, mid_tiling, "mid", &blt.dst, width, height, bpp);
 
  	blt_copy_init(i915, &blt);
  	blt.color_depth = CD_32bit;
@@ -247,7 +247,7 @@ static void fast_copy(int i915, const intel_ctx_t *ctx,
  	blt_fast_copy(i915, ctx, e, ahnd, &blt);
  	gem_sync(i915, blt.dst.handle);
 
-	WRITE_PNG(i915, mid_tiling, "dst", &blt.dst, width, height);
+	WRITE_PNG(i915, mid_tiling, "dst", &blt.dst, width, height, bpp);
 
  	result = memcmp(src->ptr, blt.dst.ptr, src->size);
 
tests/intel/xe_ccs.c +12 -11
index 7d0e8ed7a5..a7785edcb1 100644
@@ -79,9 +79,9 @@ struct test_config {
  	if (param.print_surface_info) \
  		blt_surface_info((name), (obj)); } while (0)
 
-#define WRITE_PNG(fd, id, name, obj, w, h) do { \
+#define WRITE_PNG(fd, id, name, obj, w, h, bpp) do { \
  	if (param.write_png) \
-		blt_surface_to_png((fd), (id), (name), (obj), (w), (h)); } while (0)
+		blt_surface_to_png((fd), (id), (name), (obj), (w), (h), (bpp)); } while (0)
 
  static void surf_copy(int xe,
  		      intel_ctx_t *ctx,
@@ -94,6 +94,7 @@ static void surf_copy(int xe,
  	struct blt_copy_data blt = {};
  	struct blt_block_copy_data_ext ext = {};
  	struct blt_ctrl_surf_copy_data surf = {};
+	const uint32_t bpp = 32;
  	uint32_t bb1, bb2, ccs, ccs2, *ccsmap, *ccsmap2;
  	uint64_t bb_size, ccssize = mid->size / CCS_RATIO(xe);
  	uint64_t ccs_bo_size = xe_get_default_alignment(xe);
@@ -179,7 +180,7 @@ static void surf_copy(int xe,
  	blt_set_batch(&blt.bb, bb2, bb_size, sysmem);
  	blt_block_copy(xe, ctx, NULL, ahnd, &blt, &ext);
  	intel_ctx_xe_sync(ctx, true);
-	WRITE_PNG(xe, run_id, "corrupted", &blt.dst, dst->x2, dst->y2);
+	WRITE_PNG(xe, run_id, "corrupted", &blt.dst, dst->x2, dst->y2, bpp);
  	result = memcmp(src->ptr, dst->ptr, src->size);
  	igt_assert(result != 0);
 
@@ -189,7 +190,7 @@ static void surf_copy(int xe,
 
  	blt_block_copy(xe, ctx, NULL, ahnd, &blt, &ext);
  	intel_ctx_xe_sync(ctx, true);
-	WRITE_PNG(xe, run_id, "corrected", &blt.dst, dst->x2, dst->y2);
+	WRITE_PNG(xe, run_id, "corrected", &blt.dst, dst->x2, dst->y2, bpp);
  	result = memcmp(src->ptr, dst->ptr, src->size);
  	if (result)
  		blt_dump_corruption_info_32b(src, dst);
@@ -326,7 +327,7 @@ static void block_copy(int xe,
  	PRINT_SURFACE_INFO("dst", dst);
 
  	blt_surface_fill_rect(xe, src, width, height);
-	WRITE_PNG(xe, run_id, "src", src, width, height);
+	WRITE_PNG(xe, run_id, "src", src, width, height, bpp);
 
  	blt.color_depth = CD_32bit;
  	blt.print_bb = param.print_bb;
@@ -342,7 +343,7 @@ static void block_copy(int xe,
  	if (mid->compression)
  		igt_assert(memcmp(src->ptr, mid->ptr, src->size) != 0);
 
-	WRITE_PNG(xe, run_id, "mid", &blt.dst, width, height);
+	WRITE_PNG(xe, run_id, "mid", &blt.dst, width, height, bpp);
 
  	if (config->surfcopy && pext) {
  		struct drm_xe_engine_class_instance inst = {
@@ -393,7 +394,7 @@ static void block_copy(int xe,
  	blt_block_copy(xe, ctx, NULL, ahnd, &blt, pext);
  	intel_ctx_xe_sync(ctx, true);
 
-	WRITE_PNG(xe, run_id, "dst", &blt.dst, width, height);
+	WRITE_PNG(xe, run_id, "dst", &blt.dst, width, height, bpp);
 
  	result = memcmp(src->ptr, blt.dst.ptr, src->size);
 
@@ -486,11 +487,11 @@ static void block_multicopy(int xe,
  	blt_block_copy3(xe, ctx, ahnd, &blt3, pext3);
  	intel_ctx_xe_sync(ctx, true);
 
-	WRITE_PNG(xe, run_id, "src", &blt3.src, width, height);
+	WRITE_PNG(xe, run_id, "src", &blt3.src, width, height, bpp);
  	if (!config->inplace)
-		WRITE_PNG(xe, run_id, "mid", &blt3.mid, width, height);
-	WRITE_PNG(xe, run_id, "dst", &blt3.dst, width, height);
-	WRITE_PNG(xe, run_id, "final", &blt3.final, width, height);
+		WRITE_PNG(xe, run_id, "mid", &blt3.mid, width, height, bpp);
+	WRITE_PNG(xe, run_id, "dst", &blt3.dst, width, height, bpp);
+	WRITE_PNG(xe, run_id, "final", &blt3.final, width, height, bpp);
 
  	result = memcmp(src->ptr, blt3.final.ptr, src->size);
 
tests/intel/xe_exercise_blt.c +8 -8
index c908800cf4..ddf9d188a7 100644
@@ -53,9 +53,9 @@ static struct param {
  	if (param.print_surface_info) \
  		blt_surface_info((name), (obj)); } while (0)
 
-#define WRITE_PNG(fd, id, name, obj, w, h) do { \
+#define WRITE_PNG(fd, id, name, obj, w, h, bpp) do { \
  	if (param.write_png) \
-		blt_surface_to_png((fd), (id), (name), (obj), (w), (h)); } while (0)
+		blt_surface_to_png((fd), (id), (name), (obj), (w), (h), (bpp)); } while (0)
 
  struct blt_fast_copy_data {
  	int xe;
@@ -141,7 +141,7 @@ static void fast_copy_emit(int xe, const intel_ctx_t *ctx,
  	PRINT_SURFACE_INFO("dst", dst);
 
  	blt_surface_fill_rect(xe, src, width, height);
-	WRITE_PNG(xe, mid_tiling, "src", src, width, height);
+	WRITE_PNG(xe, mid_tiling, "src", src, width, height, bpp);
 
  	memset(&blt, 0, sizeof(blt));
  	blt.color_depth = CD_32bit;
@@ -153,8 +153,8 @@ static void fast_copy_emit(int xe, const intel_ctx_t *ctx,
 
  	fast_copy_one_bb(xe, ctx, ahnd, &blt);
 
-	WRITE_PNG(xe, mid_tiling, "mid", &blt.mid, width, height);
-	WRITE_PNG(xe, mid_tiling, "dst", &blt.dst, width, height);
+	WRITE_PNG(xe, mid_tiling, "mid", &blt.mid, width, height, bpp);
+	WRITE_PNG(xe, mid_tiling, "dst", &blt.dst, width, height, bpp);
 
  	result = memcmp(src->ptr, blt.dst.ptr, src->size);
 
@@ -205,8 +205,8 @@ static void fast_copy(int xe, const intel_ctx_t *ctx,
 
  	blt_fast_copy(xe, ctx, NULL, ahnd, &blt);
 
-	WRITE_PNG(xe, mid_tiling, "src", &blt.src, width, height);
-	WRITE_PNG(xe, mid_tiling, "mid", &blt.dst, width, height);
+	WRITE_PNG(xe, mid_tiling, "src", &blt.src, width, height, bpp);
+	WRITE_PNG(xe, mid_tiling, "mid", &blt.dst, width, height, bpp);
 
  	blt_copy_init(xe, &blt);
  	blt.color_depth = CD_32bit;
@@ -217,7 +217,7 @@ static void fast_copy(int xe, const intel_ctx_t *ctx,
 
  	blt_fast_copy(xe, ctx, NULL, ahnd, &blt);
 
-	WRITE_PNG(xe, mid_tiling, "dst", &blt.dst, width, height);
+	WRITE_PNG(xe, mid_tiling, "dst", &blt.dst, width, height, bpp);
 
  	result = memcmp(src->ptr, blt.dst.ptr, src->size);
 
#9 lore raw

PATCH v4 4/5 tests/xe-ccs: Add tests which exercise small to large blit sizes

In reply to Zbigniew Kempczyński

Testing block-copy for 512 x 512 x 32bpp is not enough to verify blit is working for different (small) and not always aligned resolutions. Add 'increment' subtests which checks blits from small (1x1) to large (512x512) resolutions.

To avoid too long execution resolution increment equals 15x15 pixels.

---
 tests/intel/xe_ccs.c | 144 +++++++++++++++++++++++++++++++++----------
 1 file changed, 112 insertions(+), 32 deletions(-)
tests/intel/xe_ccs.c +112 -32
index a7785edcb1..627976049c 100644
@@ -28,9 +28,15 @@
  * SUBTEST: block-copy-compressed
  * Description: Check block-copy flatccs compressed blit
  *
+ * SUBTEST: block-copy-compressed-inc-dimension
+ * Description: Check block-copy compressed blit for different sizes
+ *
  * SUBTEST: block-copy-uncompressed
  * Description: Check block-copy uncompressed blit
  *
+ * SUBTEST: block-copy-uncompressed-inc-dimension
+ * Description: Check block-copy uncompressed blit for different sizes
+ *
  * SUBTEST: block-multicopy-compressed
  * Description: Check block-multicopy flatccs compressed blit
  *
@@ -73,6 +79,8 @@ struct test_config {
 	bool surfcopy;
 	bool new_ctx;
 	bool suspend_resume;
+	int width_increment;
+	int width_steps;
 };
 
 #define PRINT_SURFACE_INFO(name, obj) do { \
@@ -286,9 +294,17 @@ static int blt_block_copy3(int xe,
 	return ret;
 }
 
+#define CHECK_MIN_WIDTH 2
+#define CHECK_MIN_HEIGHT 2
+#define MIN_EXP_WH(w, h) ((w) >= CHECK_MIN_WIDTH && (h) >= CHECK_MIN_HEIGHT)
+#define CHECK_FROM_WIDTH 256
+#define CHECK_FROM_HEIGHT 256
+#define FROM_EXP_WH(w, h) ((w) >= CHECK_FROM_WIDTH && (h) >= CHECK_FROM_HEIGHT)
+
 static void block_copy(int xe,
 		       intel_ctx_t *ctx,
 		       uint32_t region1, uint32_t region2,
+		       uint32_t width, uint32_t height,
 		       enum blt_tiling_type mid_tiling,
 		       const struct test_config *config)
 {
@@ -301,7 +317,7 @@ static void block_copy(int xe,
 	uint32_t run_id = mid_tiling;
 	uint32_t mid_region = (AT_LEAST_GEN(intel_get_drm_devid(xe), 20) &
 							!xe_has_vram(xe)) ? region1 : region2;
-	uint32_t width = param.width, height = param.height, bb;
+	uint32_t bb;
 	enum blt_compression mid_compression = config->compression;
 	int mid_compression_format = param.compression_format;
 	enum blt_compression_type comp_type = COMPRESSION_TYPE_3D;
@@ -339,9 +355,16 @@ static void block_copy(int xe,
 	blt_block_copy(xe, ctx, NULL, ahnd, &blt, pext);
 	intel_ctx_xe_sync(ctx, true);
 
-	/* We expect mid != src if there's compression */
-	if (mid->compression)
-		igt_assert(memcmp(src->ptr, mid->ptr, src->size) != 0);
+	/*
+	 * We expect mid != src if there's compression. Ignore this for small
+	 * width x height for linear as compression for gradient occurs in the
+	 * middle for bigger sizes. We also ignore 1x1 as this looks same for
+	 * xmajor.
+	 */
+	if (mid->compression && MIN_EXP_WH(width, height)) {
+		if (mid_tiling != T_LINEAR || FROM_EXP_WH(width, height))
+			igt_assert(memcmp(src->ptr, mid->ptr, src->size) != 0);
+	}
 
 	WRITE_PNG(xe, run_id, "mid", &blt.dst, width, height, bpp);
 
@@ -416,6 +439,7 @@ static void block_copy(int xe,
 static void block_multicopy(int xe,
 			    intel_ctx_t *ctx,
 			    uint32_t region1, uint32_t region2,
+			    uint32_t width, uint32_t height,
 			    enum blt_tiling_type mid_tiling,
 			    const struct test_config *config)
 {
@@ -429,7 +453,7 @@ static void block_multicopy(int xe,
 	uint32_t run_id = mid_tiling;
 	uint32_t mid_region = (AT_LEAST_GEN(intel_get_drm_devid(xe), 20) &
 							!xe_has_vram(xe)) ? region1 : region2;
-	uint32_t width = param.width, height = param.height, bb;
+	uint32_t bb;
 	enum blt_compression mid_compression = config->compression;
 	int mid_compression_format = param.compression_format;
 	enum blt_compression_type comp_type = COMPRESSION_TYPE_3D;
@@ -521,6 +545,7 @@ static const struct {
 	void (*copyfn)(int fd,
 		       intel_ctx_t *ctx,
 		       uint32_t region1, uint32_t region2,
+		       uint32_t width, uint32_t height,
 		       enum blt_tiling_type btype,
 		       const struct test_config *config);
 } copyfns[] = {
@@ -528,17 +553,44 @@ static const struct {
 	[BLOCK_MULTICOPY] = { "-multicopy", block_multicopy },
 };
 
-static void block_copy_test(int xe,
-			    const struct test_config *config,
-			    struct igt_collection *set,
-			    enum copy_func copy_function)
+static void single_copy(int xe, const struct test_config *config,
+			int32_t region1, uint32_t region2,
+			uint32_t width, uint32_t height,
+			int tiling, enum copy_func copy_function)
 {
 	struct drm_xe_engine_class_instance inst = {
 		.engine_class = DRM_XE_ENGINE_CLASS_COPY,
 	};
+	uint32_t vm, exec_queue;
+	uint32_t sync_bind, sync_out;
 	intel_ctx_t *ctx;
+
+	vm = xe_vm_create(xe, 0, 0);
+	exec_queue = xe_exec_queue_create(xe, vm, &inst, 0);
+	sync_bind = syncobj_create(xe, 0);
+	sync_out = syncobj_create(xe, 0);
+	ctx = intel_ctx_xe(xe, vm, exec_queue,
+			   0, sync_bind, sync_out);
+
+	copyfns[copy_function].copyfn(xe, ctx,
+				      region1, region2,
+				      width, height,
+				      tiling, config);
+
+	xe_exec_queue_destroy(xe, exec_queue);
+	xe_vm_destroy(xe, vm);
+	syncobj_destroy(xe, sync_bind);
+	syncobj_destroy(xe, sync_out);
+	free(ctx);
+}
+
+static void block_copy_test(int xe,
+			    const struct test_config *config,
+			    struct igt_collection *set,
+			    enum copy_func copy_function)
+{
+
 	struct igt_collection *regions;
-	uint32_t vm, exec_queue;
 	int tiling;
 
 	if (config->compression && !blt_block_copy_supports_compression(xe))
@@ -555,6 +607,7 @@ static void block_copy_test(int xe,
 		for_each_variation_r(regions, 2, set) {
 			uint32_t region1, region2;
 			char *regtxt;
+			char testname[256];
 
 			region1 = igt_collection_get_value(regions, 0);
 			region2 = igt_collection_get_value(regions, 1);
@@ -566,30 +619,36 @@ static void block_copy_test(int xe,
 
 			regtxt = xe_memregion_dynamic_subtest_name(xe, regions);
 
-			igt_dynamic_f("%s-%s-compfmt%d-%s%s",
-				      blt_tiling_name(tiling),
-				      config->compression ?
-					      "compressed" : "uncompressed",
-				      param.compression_format, regtxt,
-				      copyfns[copy_function].suffix) {
-				uint32_t sync_bind, sync_out;
+			snprintf(testname, sizeof(testname),
+				 "%s-%s-compfmt%d-%s%s",
+				 blt_tiling_name(tiling),
+				 config->compression ?
+					 "compressed" : "uncompressed",
+				 param.compression_format, regtxt,
+				 copyfns[copy_function].suffix);
 
-				vm = xe_vm_create(xe, 0, 0);
-				exec_queue = xe_exec_queue_create(xe, vm, &inst, 0);
-				sync_bind = syncobj_create(xe, 0);
-				sync_out = syncobj_create(xe, 0);
-				ctx = intel_ctx_xe(xe, vm, exec_queue,
-						   0, sync_bind, sync_out);
+			if (!config->width_increment) {
+				igt_dynamic(testname)
+					single_copy(xe, config, region1, region2,
+						    param.width, param.height,
+						    tiling, copy_function);
+			} else {
+				for (int w = param.width;
+				     w < param.width + config->width_steps;
+				     w += config->width_increment) {
+					snprintf(testname, sizeof(testname),
+						 "%s-%s-compfmt%d-%s%s-%dx%d",
+						 blt_tiling_name(tiling),
+						 config->compression ?
+							 "compressed" : "uncompressed",
+						 param.compression_format, regtxt,
+						 copyfns[copy_function].suffix,
+						 w, w);
+					igt_dynamic(testname)
+						single_copy(xe, config, region1, region2,
+							    w, w, tiling, copy_function);
+				}
 
-				copyfns[copy_function].copyfn(xe, ctx,
-							      region1, region2,
-							      tiling, config);
-
-				xe_exec_queue_destroy(xe, exec_queue);
-				xe_vm_destroy(xe, vm);
-				syncobj_destroy(xe, sync_bind);
-				syncobj_destroy(xe, sync_out);
-				free(ctx);
 			}
 
 			free(regtxt);
@@ -669,6 +728,16 @@ igt_main_args("bf:pst:W:H:", NULL, help_str, opt_handler, NULL)
 		block_copy_test(xe, &config, set, BLOCK_COPY);
 	}
 
+	igt_describe("Check block-copy uncompressed blit with increment width/height");
+	igt_subtest_with_dynamic("block-copy-uncompressed-inc-dimension") {
+		struct test_config config = { .width_increment = 15,
+					      .width_steps = 512 };
+		param.width = 1;
+		param.height = 1;
+
+		block_copy_test(xe, &config, set, BLOCK_COPY);
+	}
+
 	igt_describe("Check block-copy flatccs compressed blit");
 	igt_subtest_with_dynamic("block-copy-compressed") {
 		struct test_config config = { .compression = true };
@@ -676,6 +745,17 @@ igt_main_args("bf:pst:W:H:", NULL, help_str, opt_handler, NULL)
 		block_copy_test(xe, &config, set, BLOCK_COPY);
 	}
 
+	igt_describe("Check block-copy compressed blit with increment width/height");
+	igt_subtest_with_dynamic("block-copy-compressed-inc-dimension") {
+		struct test_config config = { .compression = true,
+					      .width_increment = 15,
+					      .width_steps = 512 };
+		param.width = 1;
+		param.height = 1;
+
+		block_copy_test(xe, &config, set, BLOCK_COPY);
+	}
+
 	igt_describe("Check block-multicopy flatccs compressed blit");
 	igt_subtest_with_dynamic("block-multicopy-compressed") {
 		struct test_config config = { .compression = true };
Signature · 1 line
2.34.1
Reviewed-by on v4 4/5
#10 lore raw

Re: [PATCH i-g-t v4 4/5] tests/xe-ccs: Add tests which exercise small to large blit sizes

Quoted 10 lines · Zbigniew Kempczyński

Testing block-copy for 512 x 512 x 32bpp is not enough to verify blit is working for different (small) and not always aligned resolutions. Add 'increment' subtests which checks blits from small (1x1) to large (512x512) resolutions.

To avoid too long execution resolution increment equals 15x15 pixels.

---

Thanks for the comment on why the step is 15 px wide.

I wonder if we could just start testing the compressed case from bigger widths and heights, instead of adding that if on the mid surface. But probably we'd limit the coverage, so let's leave it as it is.

A small nit below.

Quoted 139 lines
  tests/intel/xe_ccs.c | 144 +++++++++++++++++++++++++++++++++----------
  1 file changed, 112 insertions(+), 32 deletions(-)
tests/intel/xe_ccs.c +52 -9
index a7785edcb1..627976049c 100644
@@ -28,9 +28,15 @@
   * SUBTEST: block-copy-compressed
   * Description: Check block-copy flatccs compressed blit
   *
+ * SUBTEST: block-copy-compressed-inc-dimension
+ * Description: Check block-copy compressed blit for different sizes
+ *
   * SUBTEST: block-copy-uncompressed
   * Description: Check block-copy uncompressed blit
   *
+ * SUBTEST: block-copy-uncompressed-inc-dimension
+ * Description: Check block-copy uncompressed blit for different sizes
+ *
   * SUBTEST: block-multicopy-compressed
   * Description: Check block-multicopy flatccs compressed blit
   *
@@ -73,6 +79,8 @@ struct test_config {
  	bool surfcopy;
  	bool new_ctx;
  	bool suspend_resume;
+	int width_increment;
+	int width_steps;
  };
 
  #define PRINT_SURFACE_INFO(name, obj) do { \
@@ -286,9 +294,17 @@ static int blt_block_copy3(int xe,
  	return ret;
  }
 
+#define CHECK_MIN_WIDTH 2
+#define CHECK_MIN_HEIGHT 2
+#define MIN_EXP_WH(w, h) ((w) >= CHECK_MIN_WIDTH && (h) >= CHECK_MIN_HEIGHT)
+#define CHECK_FROM_WIDTH 256
+#define CHECK_FROM_HEIGHT 256
+#define FROM_EXP_WH(w, h) ((w) >= CHECK_FROM_WIDTH && (h) >= CHECK_FROM_HEIGHT)
+
  static void block_copy(int xe,
  		       intel_ctx_t *ctx,
  		       uint32_t region1, uint32_t region2,
+		       uint32_t width, uint32_t height,
  		       enum blt_tiling_type mid_tiling,
  		       const struct test_config *config)
  {
@@ -301,7 +317,7 @@ static void block_copy(int xe,
  	uint32_t run_id = mid_tiling;
  	uint32_t mid_region = (AT_LEAST_GEN(intel_get_drm_devid(xe), 20) &
  							!xe_has_vram(xe)) ? region1 : region2;
-	uint32_t width = param.width, height = param.height, bb;
+	uint32_t bb;
  	enum blt_compression mid_compression = config->compression;
  	int mid_compression_format = param.compression_format;
  	enum blt_compression_type comp_type = COMPRESSION_TYPE_3D;
@@ -339,9 +355,16 @@ static void block_copy(int xe,
  	blt_block_copy(xe, ctx, NULL, ahnd, &blt, pext);
  	intel_ctx_xe_sync(ctx, true);
 
-	/* We expect mid != src if there's compression */
-	if (mid->compression)
-		igt_assert(memcmp(src->ptr, mid->ptr, src->size) != 0);
+	/*
+	 * We expect mid != src if there's compression. Ignore this for small
+	 * width x height for linear as compression for gradient occurs in the
+	 * middle for bigger sizes. We also ignore 1x1 as this looks same for
+	 * xmajor.
+	 */
+	if (mid->compression && MIN_EXP_WH(width, height)) {
+		if (mid_tiling != T_LINEAR || FROM_EXP_WH(width, height))
+			igt_assert(memcmp(src->ptr, mid->ptr, src->size) != 0);
+	}
 
  	WRITE_PNG(xe, run_id, "mid", &blt.dst, width, height, bpp);
 
@@ -416,6 +439,7 @@ static void block_copy(int xe,
  static void block_multicopy(int xe,
  			    intel_ctx_t *ctx,
  			    uint32_t region1, uint32_t region2,
+			    uint32_t width, uint32_t height,
  			    enum blt_tiling_type mid_tiling,
  			    const struct test_config *config)
  {
@@ -429,7 +453,7 @@ static void block_multicopy(int xe,
  	uint32_t run_id = mid_tiling;
  	uint32_t mid_region = (AT_LEAST_GEN(intel_get_drm_devid(xe), 20) &
  							!xe_has_vram(xe)) ? region1 : region2;
-	uint32_t width = param.width, height = param.height, bb;
+	uint32_t bb;
  	enum blt_compression mid_compression = config->compression;
  	int mid_compression_format = param.compression_format;
  	enum blt_compression_type comp_type = COMPRESSION_TYPE_3D;
@@ -521,6 +545,7 @@ static const struct {
  	void (*copyfn)(int fd,
  		       intel_ctx_t *ctx,
  		       uint32_t region1, uint32_t region2,
+		       uint32_t width, uint32_t height,
  		       enum blt_tiling_type btype,
  		       const struct test_config *config);
  } copyfns[] = {
@@ -528,17 +553,44 @@ static const struct {
  	[BLOCK_MULTICOPY] = { "-multicopy", block_multicopy },
  };
 
-static void block_copy_test(int xe,
-			    const struct test_config *config,
-			    struct igt_collection *set,
-			    enum copy_func copy_function)
+static void single_copy(int xe, const struct test_config *config,
+			int32_t region1, uint32_t region2,
+			uint32_t width, uint32_t height,
+			int tiling, enum copy_func copy_function)
  {
  	struct drm_xe_engine_class_instance inst = {
  		.engine_class = DRM_XE_ENGINE_CLASS_COPY,
  	};
+	uint32_t vm, exec_queue;
+	uint32_t sync_bind, sync_out;
  	intel_ctx_t *ctx;
+
+	vm = xe_vm_create(xe, 0, 0);
+	exec_queue = xe_exec_queue_create(xe, vm, &inst, 0);
+	sync_bind = syncobj_create(xe, 0);
+	sync_out = syncobj_create(xe, 0);
+	ctx = intel_ctx_xe(xe, vm, exec_queue,
+			   0, sync_bind, sync_out);
+
+	copyfns[copy_function].copyfn(xe, ctx,
+				      region1, region2,
+				      width, height,
+				      tiling, config);
+
+	xe_exec_queue_destroy(xe, exec_queue);
+	xe_vm_destroy(xe, vm);
+	syncobj_destroy(xe, sync_bind);

tests/intel/xe_ccs.c static const struct { · line 592

Quoted 10 lines
tests/intel/xe_ccs.c +10 -0
+	syncobj_destroy(xe, sync_out);
+	free(ctx);
+}
+
+static void block_copy_test(int xe,
+			    const struct test_config *config,
+			    struct igt_collection *set,
+			    enum copy_func copy_function)
+{
+

^-- there's an empty line (I almost missed that!)

But apart from that, the patch is looking good, I think. Just fix that line, and:

Quoted 107 lines
tests/intel/xe_ccs.c +50 -23
  	struct igt_collection *regions;
-	uint32_t vm, exec_queue;
  	int tiling;
 
  	if (config->compression && !blt_block_copy_supports_compression(xe))
@@ -555,6 +607,7 @@ static void block_copy_test(int xe,
  		for_each_variation_r(regions, 2, set) {
  			uint32_t region1, region2;
  			char *regtxt;
+			char testname[256];
 
  			region1 = igt_collection_get_value(regions, 0);
  			region2 = igt_collection_get_value(regions, 1);
@@ -566,30 +619,36 @@ static void block_copy_test(int xe,
 
  			regtxt = xe_memregion_dynamic_subtest_name(xe, regions);
 
-			igt_dynamic_f("%s-%s-compfmt%d-%s%s",
-				      blt_tiling_name(tiling),
-				      config->compression ?
-					      "compressed" : "uncompressed",
-				      param.compression_format, regtxt,
-				      copyfns[copy_function].suffix) {
-				uint32_t sync_bind, sync_out;
+			snprintf(testname, sizeof(testname),
+				 "%s-%s-compfmt%d-%s%s",
+				 blt_tiling_name(tiling),
+				 config->compression ?
+					 "compressed" : "uncompressed",
+				 param.compression_format, regtxt,
+				 copyfns[copy_function].suffix);
 
-				vm = xe_vm_create(xe, 0, 0);
-				exec_queue = xe_exec_queue_create(xe, vm, &inst, 0);
-				sync_bind = syncobj_create(xe, 0);
-				sync_out = syncobj_create(xe, 0);
-				ctx = intel_ctx_xe(xe, vm, exec_queue,
-						   0, sync_bind, sync_out);
+			if (!config->width_increment) {
+				igt_dynamic(testname)
+					single_copy(xe, config, region1, region2,
+						    param.width, param.height,
+						    tiling, copy_function);
+			} else {
+				for (int w = param.width;
+				     w < param.width + config->width_steps;
+				     w += config->width_increment) {
+					snprintf(testname, sizeof(testname),
+						 "%s-%s-compfmt%d-%s%s-%dx%d",
+						 blt_tiling_name(tiling),
+						 config->compression ?
+							 "compressed" : "uncompressed",
+						 param.compression_format, regtxt,
+						 copyfns[copy_function].suffix,
+						 w, w);
+					igt_dynamic(testname)
+						single_copy(xe, config, region1, region2,
+							    w, w, tiling, copy_function);
+				}
 
-				copyfns[copy_function].copyfn(xe, ctx,
-							      region1, region2,
-							      tiling, config);
-
-				xe_exec_queue_destroy(xe, exec_queue);
-				xe_vm_destroy(xe, vm);
-				syncobj_destroy(xe, sync_bind);
-				syncobj_destroy(xe, sync_out);
-				free(ctx);
  			}
 
  			free(regtxt);
@@ -669,6 +728,16 @@ igt_main_args("bf:pst:W:H:", NULL, help_str, opt_handler, NULL)
  		block_copy_test(xe, &config, set, BLOCK_COPY);
  	}
 
+	igt_describe("Check block-copy uncompressed blit with increment width/height");
+	igt_subtest_with_dynamic("block-copy-uncompressed-inc-dimension") {
+		struct test_config config = { .width_increment = 15,
+					      .width_steps = 512 };
+		param.width = 1;
+		param.height = 1;
+
+		block_copy_test(xe, &config, set, BLOCK_COPY);
+	}
+
  	igt_describe("Check block-copy flatccs compressed blit");
  	igt_subtest_with_dynamic("block-copy-compressed") {
  		struct test_config config = { .compression = true };
@@ -676,6 +745,17 @@ igt_main_args("bf:pst:W:H:", NULL, help_str, opt_handler, NULL)
  		block_copy_test(xe, &config, set, BLOCK_COPY);
  	}
 
+	igt_describe("Check block-copy compressed blit with increment width/height");
+	igt_subtest_with_dynamic("block-copy-compressed-inc-dimension") {
+		struct test_config config = { .compression = true,
+					      .width_increment = 15,
+					      .width_steps = 512 };
+		param.width = 1;
+		param.height = 1;
+
+		block_copy_test(xe, &config, set, BLOCK_COPY);
+	}
+
  	igt_describe("Check block-multicopy flatccs compressed blit");
  	igt_subtest_with_dynamic("block-multicopy-compressed") {
  		struct test_config config = { .compression = true };
#11 lore raw

Re: [PATCH i-g-t v4 4/5] tests/xe-ccs: Add tests which exercise small to large blit sizes

Quoted 12 lines · Karolina Stolarek
Quoted 10 lines · Zbigniew Kempczyński

Testing block-copy for 512 x 512 x 32bpp is not enough to verify blit is working for different (small) and not always aligned resolutions. Add 'increment' subtests which checks blits from small (1x1) to large (512x512) resolutions.

To avoid too long execution resolution increment equals 15x15 pixels.

---

Quoted 5 lines

Thanks for the comment on why the step is 15 px wide.

I wonder if we could just start testing the compressed case from bigger widths and heights, instead of adding that if on the mid surface. But probably we'd limit the coverage, so let's leave it as it is.

Both - small and large may lead to fail, depending on situation. Especially in Tile64. 15x15 is picked intentionally to step by step increase size which at some point will be modulo 16.

Quoted 140 lines

A small nit below.

Quoted 137 lines
  tests/intel/xe_ccs.c | 144 +++++++++++++++++++++++++++++++++----------
  1 file changed, 112 insertions(+), 32 deletions(-)
tests/intel/xe_ccs.c +56 -9
index a7785edcb1..627976049c 100644
@@ -28,9 +28,15 @@
   * SUBTEST: block-copy-compressed
   * Description: Check block-copy flatccs compressed blit
   *
+ * SUBTEST: block-copy-compressed-inc-dimension
+ * Description: Check block-copy compressed blit for different sizes
+ *
   * SUBTEST: block-copy-uncompressed
   * Description: Check block-copy uncompressed blit
   *
+ * SUBTEST: block-copy-uncompressed-inc-dimension
+ * Description: Check block-copy uncompressed blit for different sizes
+ *
   * SUBTEST: block-multicopy-compressed
   * Description: Check block-multicopy flatccs compressed blit
   *
@@ -73,6 +79,8 @@ struct test_config {
  	bool surfcopy;
  	bool new_ctx;
  	bool suspend_resume;
+	int width_increment;
+	int width_steps;
  };
  #define PRINT_SURFACE_INFO(name, obj) do { \
@@ -286,9 +294,17 @@ static int blt_block_copy3(int xe,
  	return ret;
  }
+#define CHECK_MIN_WIDTH 2
+#define CHECK_MIN_HEIGHT 2
+#define MIN_EXP_WH(w, h) ((w) >= CHECK_MIN_WIDTH && (h) >= CHECK_MIN_HEIGHT)
+#define CHECK_FROM_WIDTH 256
+#define CHECK_FROM_HEIGHT 256
+#define FROM_EXP_WH(w, h) ((w) >= CHECK_FROM_WIDTH && (h) >= CHECK_FROM_HEIGHT)
+
  static void block_copy(int xe,
  		       intel_ctx_t *ctx,
  		       uint32_t region1, uint32_t region2,
+		       uint32_t width, uint32_t height,
  		       enum blt_tiling_type mid_tiling,
  		       const struct test_config *config)
  {
@@ -301,7 +317,7 @@ static void block_copy(int xe,
  	uint32_t run_id = mid_tiling;
  	uint32_t mid_region = (AT_LEAST_GEN(intel_get_drm_devid(xe), 20) &
  							!xe_has_vram(xe)) ? region1 : region2;
-	uint32_t width = param.width, height = param.height, bb;
+	uint32_t bb;
  	enum blt_compression mid_compression = config->compression;
  	int mid_compression_format = param.compression_format;
  	enum blt_compression_type comp_type = COMPRESSION_TYPE_3D;
@@ -339,9 +355,16 @@ static void block_copy(int xe,
  	blt_block_copy(xe, ctx, NULL, ahnd, &blt, pext);
  	intel_ctx_xe_sync(ctx, true);
-	/* We expect mid != src if there's compression */
-	if (mid->compression)
-		igt_assert(memcmp(src->ptr, mid->ptr, src->size) != 0);
+	/*
+	 * We expect mid != src if there's compression. Ignore this for small
+	 * width x height for linear as compression for gradient occurs in the
+	 * middle for bigger sizes. We also ignore 1x1 as this looks same for
+	 * xmajor.
+	 */
+	if (mid->compression && MIN_EXP_WH(width, height)) {
+		if (mid_tiling != T_LINEAR || FROM_EXP_WH(width, height))
+			igt_assert(memcmp(src->ptr, mid->ptr, src->size) != 0);
+	}
  	WRITE_PNG(xe, run_id, "mid", &blt.dst, width, height, bpp);
@@ -416,6 +439,7 @@ static void block_copy(int xe,
  static void block_multicopy(int xe,
  			    intel_ctx_t *ctx,
  			    uint32_t region1, uint32_t region2,
+			    uint32_t width, uint32_t height,
  			    enum blt_tiling_type mid_tiling,
  			    const struct test_config *config)
  {
@@ -429,7 +453,7 @@ static void block_multicopy(int xe,
  	uint32_t run_id = mid_tiling;
  	uint32_t mid_region = (AT_LEAST_GEN(intel_get_drm_devid(xe), 20) &
  							!xe_has_vram(xe)) ? region1 : region2;
-	uint32_t width = param.width, height = param.height, bb;
+	uint32_t bb;
  	enum blt_compression mid_compression = config->compression;
  	int mid_compression_format = param.compression_format;
  	enum blt_compression_type comp_type = COMPRESSION_TYPE_3D;
@@ -521,6 +545,7 @@ static const struct {
  	void (*copyfn)(int fd,
  		       intel_ctx_t *ctx,
  		       uint32_t region1, uint32_t region2,
+		       uint32_t width, uint32_t height,
  		       enum blt_tiling_type btype,
  		       const struct test_config *config);
  } copyfns[] = {
@@ -528,17 +553,44 @@ static const struct {
  	[BLOCK_MULTICOPY] = { "-multicopy", block_multicopy },
  };
-static void block_copy_test(int xe,
-			    const struct test_config *config,
-			    struct igt_collection *set,
-			    enum copy_func copy_function)
+static void single_copy(int xe, const struct test_config *config,
+			int32_t region1, uint32_t region2,
+			uint32_t width, uint32_t height,
+			int tiling, enum copy_func copy_function)
  {
  	struct drm_xe_engine_class_instance inst = {
  		.engine_class = DRM_XE_ENGINE_CLASS_COPY,
  	};
+	uint32_t vm, exec_queue;
+	uint32_t sync_bind, sync_out;
  	intel_ctx_t *ctx;
+
+	vm = xe_vm_create(xe, 0, 0);
+	exec_queue = xe_exec_queue_create(xe, vm, &inst, 0);
+	sync_bind = syncobj_create(xe, 0);
+	sync_out = syncobj_create(xe, 0);
+	ctx = intel_ctx_xe(xe, vm, exec_queue,
+			   0, sync_bind, sync_out);
+
+	copyfns[copy_function].copyfn(xe, ctx,
+				      region1, region2,
+				      width, height,
+				      tiling, config);
+
+	xe_exec_queue_destroy(xe, exec_queue);
+	xe_vm_destroy(xe, vm);
+	syncobj_destroy(xe, sync_bind);
+	syncobj_destroy(xe, sync_out);
+	free(ctx);
+}
+
Quoted 8 lines

tests/intel/xe_ccs.c static const struct { · line 592

Quoted 6 lines
tests/intel/xe_ccs.c +6 -0
+static void block_copy_test(int xe,
+			    const struct test_config *config,
+			    struct igt_collection *set,
+			    enum copy_func copy_function)
+{
+

^-- there's an empty line (I almost missed that!)

Thanks for spotting this.

Quoted 5 lines

But apart from that, the patch is looking good, I think. Just fix that line, and:

Ok, thanks for the review.

--
Zbigniew

Quoted 99 lines
Quoted 99 lines
tests/intel/xe_ccs.c +50 -23
  	struct igt_collection *regions;
-	uint32_t vm, exec_queue;
  	int tiling;
  	if (config->compression && !blt_block_copy_supports_compression(xe))
@@ -555,6 +607,7 @@ static void block_copy_test(int xe,
  		for_each_variation_r(regions, 2, set) {
  			uint32_t region1, region2;
  			char *regtxt;
+			char testname[256];
  			region1 = igt_collection_get_value(regions, 0);
  			region2 = igt_collection_get_value(regions, 1);
@@ -566,30 +619,36 @@ static void block_copy_test(int xe,
  			regtxt = xe_memregion_dynamic_subtest_name(xe, regions);
-			igt_dynamic_f("%s-%s-compfmt%d-%s%s",
-				      blt_tiling_name(tiling),
-				      config->compression ?
-					      "compressed" : "uncompressed",
-				      param.compression_format, regtxt,
-				      copyfns[copy_function].suffix) {
-				uint32_t sync_bind, sync_out;
+			snprintf(testname, sizeof(testname),
+				 "%s-%s-compfmt%d-%s%s",
+				 blt_tiling_name(tiling),
+				 config->compression ?
+					 "compressed" : "uncompressed",
+				 param.compression_format, regtxt,
+				 copyfns[copy_function].suffix);
-				vm = xe_vm_create(xe, 0, 0);
-				exec_queue = xe_exec_queue_create(xe, vm, &inst, 0);
-				sync_bind = syncobj_create(xe, 0);
-				sync_out = syncobj_create(xe, 0);
-				ctx = intel_ctx_xe(xe, vm, exec_queue,
-						   0, sync_bind, sync_out);
+			if (!config->width_increment) {
+				igt_dynamic(testname)
+					single_copy(xe, config, region1, region2,
+						    param.width, param.height,
+						    tiling, copy_function);
+			} else {
+				for (int w = param.width;
+				     w < param.width + config->width_steps;
+				     w += config->width_increment) {
+					snprintf(testname, sizeof(testname),
+						 "%s-%s-compfmt%d-%s%s-%dx%d",
+						 blt_tiling_name(tiling),
+						 config->compression ?
+							 "compressed" : "uncompressed",
+						 param.compression_format, regtxt,
+						 copyfns[copy_function].suffix,
+						 w, w);
+					igt_dynamic(testname)
+						single_copy(xe, config, region1, region2,
+							    w, w, tiling, copy_function);
+				}
-				copyfns[copy_function].copyfn(xe, ctx,
-							      region1, region2,
-							      tiling, config);
-
-				xe_exec_queue_destroy(xe, exec_queue);
-				xe_vm_destroy(xe, vm);
-				syncobj_destroy(xe, sync_bind);
-				syncobj_destroy(xe, sync_out);
-				free(ctx);
  			}
  			free(regtxt);
@@ -669,6 +728,16 @@ igt_main_args("bf:pst:W:H:", NULL, help_str, opt_handler, NULL)
  		block_copy_test(xe, &config, set, BLOCK_COPY);
  	}
+	igt_describe("Check block-copy uncompressed blit with increment width/height");
+	igt_subtest_with_dynamic("block-copy-uncompressed-inc-dimension") {
+		struct test_config config = { .width_increment = 15,
+					      .width_steps = 512 };
+		param.width = 1;
+		param.height = 1;
+
+		block_copy_test(xe, &config, set, BLOCK_COPY);
+	}
+
  	igt_describe("Check block-copy flatccs compressed blit");
  	igt_subtest_with_dynamic("block-copy-compressed") {
  		struct test_config config = { .compression = true };
@@ -676,6 +745,17 @@ igt_main_args("bf:pst:W:H:", NULL, help_str, opt_handler, NULL)
  		block_copy_test(xe, &config, set, BLOCK_COPY);
  	}
+	igt_describe("Check block-copy compressed blit with increment width/height");
+	igt_subtest_with_dynamic("block-copy-compressed-inc-dimension") {
+		struct test_config config = { .compression = true,
+					      .width_increment = 15,
+					      .width_steps = 512 };
+		param.width = 1;
+		param.height = 1;
+
+		block_copy_test(xe, &config, set, BLOCK_COPY);
+	}
+
  	igt_describe("Check block-multicopy flatccs compressed blit");
  	igt_subtest_with_dynamic("block-multicopy-compressed") {
  		struct test_config config = { .compression = true };
#12 lore raw

Re: [PATCH i-g-t v4 4/5] tests/xe-ccs: Add tests which exercise small to large blit sizes

In reply to Zbigniew Kempczyński
Quoted 5 lines · Zbigniew Kempczyński

Testing block-copy for 512 x 512 x 32bpp is not enough to verify blit is working for different (small) and not always aligned resolutions. Add 'increment' subtests which checks blits from small (1x1) to large (512x512) resolutions.

Quoted 7 lines

To avoid too long execution resolution increment equals 15x15 pixels.

---
  tests/intel/xe_ccs.c | 144 +++++++++++++++++++++++++++++++++----------
  1 file changed, 112 insertions(+), 32 deletions(-)

Ah, one question actually. We use width == height, and I wonder if we want to test rectangular surfaces. I think that caused problems in the past, but maybe I'm misremembering something.

All the best,
Karolina

Quoted 254 lines
tests/intel/xe_ccs.c +112 -32
index a7785edcb1..627976049c 100644
@@ -28,9 +28,15 @@
   * SUBTEST: block-copy-compressed
   * Description: Check block-copy flatccs compressed blit
   *
+ * SUBTEST: block-copy-compressed-inc-dimension
+ * Description: Check block-copy compressed blit for different sizes
+ *
   * SUBTEST: block-copy-uncompressed
   * Description: Check block-copy uncompressed blit
   *
+ * SUBTEST: block-copy-uncompressed-inc-dimension
+ * Description: Check block-copy uncompressed blit for different sizes
+ *
   * SUBTEST: block-multicopy-compressed
   * Description: Check block-multicopy flatccs compressed blit
   *
@@ -73,6 +79,8 @@ struct test_config {
  	bool surfcopy;
  	bool new_ctx;
  	bool suspend_resume;
+	int width_increment;
+	int width_steps;
  };
 
  #define PRINT_SURFACE_INFO(name, obj) do { \
@@ -286,9 +294,17 @@ static int blt_block_copy3(int xe,
  	return ret;
  }
 
+#define CHECK_MIN_WIDTH 2
+#define CHECK_MIN_HEIGHT 2
+#define MIN_EXP_WH(w, h) ((w) >= CHECK_MIN_WIDTH && (h) >= CHECK_MIN_HEIGHT)
+#define CHECK_FROM_WIDTH 256
+#define CHECK_FROM_HEIGHT 256
+#define FROM_EXP_WH(w, h) ((w) >= CHECK_FROM_WIDTH && (h) >= CHECK_FROM_HEIGHT)
+
  static void block_copy(int xe,
  		       intel_ctx_t *ctx,
  		       uint32_t region1, uint32_t region2,
+		       uint32_t width, uint32_t height,
  		       enum blt_tiling_type mid_tiling,
  		       const struct test_config *config)
  {
@@ -301,7 +317,7 @@ static void block_copy(int xe,
  	uint32_t run_id = mid_tiling;
  	uint32_t mid_region = (AT_LEAST_GEN(intel_get_drm_devid(xe), 20) &
  							!xe_has_vram(xe)) ? region1 : region2;
-	uint32_t width = param.width, height = param.height, bb;
+	uint32_t bb;
  	enum blt_compression mid_compression = config->compression;
  	int mid_compression_format = param.compression_format;
  	enum blt_compression_type comp_type = COMPRESSION_TYPE_3D;
@@ -339,9 +355,16 @@ static void block_copy(int xe,
  	blt_block_copy(xe, ctx, NULL, ahnd, &blt, pext);
  	intel_ctx_xe_sync(ctx, true);
 
-	/* We expect mid != src if there's compression */
-	if (mid->compression)
-		igt_assert(memcmp(src->ptr, mid->ptr, src->size) != 0);
+	/*
+	 * We expect mid != src if there's compression. Ignore this for small
+	 * width x height for linear as compression for gradient occurs in the
+	 * middle for bigger sizes. We also ignore 1x1 as this looks same for
+	 * xmajor.
+	 */
+	if (mid->compression && MIN_EXP_WH(width, height)) {
+		if (mid_tiling != T_LINEAR || FROM_EXP_WH(width, height))
+			igt_assert(memcmp(src->ptr, mid->ptr, src->size) != 0);
+	}
 
  	WRITE_PNG(xe, run_id, "mid", &blt.dst, width, height, bpp);
 
@@ -416,6 +439,7 @@ static void block_copy(int xe,
  static void block_multicopy(int xe,
  			    intel_ctx_t *ctx,
  			    uint32_t region1, uint32_t region2,
+			    uint32_t width, uint32_t height,
  			    enum blt_tiling_type mid_tiling,
  			    const struct test_config *config)
  {
@@ -429,7 +453,7 @@ static void block_multicopy(int xe,
  	uint32_t run_id = mid_tiling;
  	uint32_t mid_region = (AT_LEAST_GEN(intel_get_drm_devid(xe), 20) &
  							!xe_has_vram(xe)) ? region1 : region2;
-	uint32_t width = param.width, height = param.height, bb;
+	uint32_t bb;
  	enum blt_compression mid_compression = config->compression;
  	int mid_compression_format = param.compression_format;
  	enum blt_compression_type comp_type = COMPRESSION_TYPE_3D;
@@ -521,6 +545,7 @@ static const struct {
  	void (*copyfn)(int fd,
  		       intel_ctx_t *ctx,
  		       uint32_t region1, uint32_t region2,
+		       uint32_t width, uint32_t height,
  		       enum blt_tiling_type btype,
  		       const struct test_config *config);
  } copyfns[] = {
@@ -528,17 +553,44 @@ static const struct {
  	[BLOCK_MULTICOPY] = { "-multicopy", block_multicopy },
  };
 
-static void block_copy_test(int xe,
-			    const struct test_config *config,
-			    struct igt_collection *set,
-			    enum copy_func copy_function)
+static void single_copy(int xe, const struct test_config *config,
+			int32_t region1, uint32_t region2,
+			uint32_t width, uint32_t height,
+			int tiling, enum copy_func copy_function)
  {
  	struct drm_xe_engine_class_instance inst = {
  		.engine_class = DRM_XE_ENGINE_CLASS_COPY,
  	};
+	uint32_t vm, exec_queue;
+	uint32_t sync_bind, sync_out;
  	intel_ctx_t *ctx;
+
+	vm = xe_vm_create(xe, 0, 0);
+	exec_queue = xe_exec_queue_create(xe, vm, &inst, 0);
+	sync_bind = syncobj_create(xe, 0);
+	sync_out = syncobj_create(xe, 0);
+	ctx = intel_ctx_xe(xe, vm, exec_queue,
+			   0, sync_bind, sync_out);
+
+	copyfns[copy_function].copyfn(xe, ctx,
+				      region1, region2,
+				      width, height,
+				      tiling, config);
+
+	xe_exec_queue_destroy(xe, exec_queue);
+	xe_vm_destroy(xe, vm);
+	syncobj_destroy(xe, sync_bind);
+	syncobj_destroy(xe, sync_out);
+	free(ctx);
+}
+
+static void block_copy_test(int xe,
+			    const struct test_config *config,
+			    struct igt_collection *set,
+			    enum copy_func copy_function)
+{
+
  	struct igt_collection *regions;
-	uint32_t vm, exec_queue;
  	int tiling;
 
  	if (config->compression && !blt_block_copy_supports_compression(xe))
@@ -555,6 +607,7 @@ static void block_copy_test(int xe,
  		for_each_variation_r(regions, 2, set) {
  			uint32_t region1, region2;
  			char *regtxt;
+			char testname[256];
 
  			region1 = igt_collection_get_value(regions, 0);
  			region2 = igt_collection_get_value(regions, 1);
@@ -566,30 +619,36 @@ static void block_copy_test(int xe,
 
  			regtxt = xe_memregion_dynamic_subtest_name(xe, regions);
 
-			igt_dynamic_f("%s-%s-compfmt%d-%s%s",
-				      blt_tiling_name(tiling),
-				      config->compression ?
-					      "compressed" : "uncompressed",
-				      param.compression_format, regtxt,
-				      copyfns[copy_function].suffix) {
-				uint32_t sync_bind, sync_out;
+			snprintf(testname, sizeof(testname),
+				 "%s-%s-compfmt%d-%s%s",
+				 blt_tiling_name(tiling),
+				 config->compression ?
+					 "compressed" : "uncompressed",
+				 param.compression_format, regtxt,
+				 copyfns[copy_function].suffix);
 
-				vm = xe_vm_create(xe, 0, 0);
-				exec_queue = xe_exec_queue_create(xe, vm, &inst, 0);
-				sync_bind = syncobj_create(xe, 0);
-				sync_out = syncobj_create(xe, 0);
-				ctx = intel_ctx_xe(xe, vm, exec_queue,
-						   0, sync_bind, sync_out);
+			if (!config->width_increment) {
+				igt_dynamic(testname)
+					single_copy(xe, config, region1, region2,
+						    param.width, param.height,
+						    tiling, copy_function);
+			} else {
+				for (int w = param.width;
+				     w < param.width + config->width_steps;
+				     w += config->width_increment) {
+					snprintf(testname, sizeof(testname),
+						 "%s-%s-compfmt%d-%s%s-%dx%d",
+						 blt_tiling_name(tiling),
+						 config->compression ?
+							 "compressed" : "uncompressed",
+						 param.compression_format, regtxt,
+						 copyfns[copy_function].suffix,
+						 w, w);
+					igt_dynamic(testname)
+						single_copy(xe, config, region1, region2,
+							    w, w, tiling, copy_function);
+				}
 
-				copyfns[copy_function].copyfn(xe, ctx,
-							      region1, region2,
-							      tiling, config);
-
-				xe_exec_queue_destroy(xe, exec_queue);
-				xe_vm_destroy(xe, vm);
-				syncobj_destroy(xe, sync_bind);
-				syncobj_destroy(xe, sync_out);
-				free(ctx);
  			}
 
  			free(regtxt);
@@ -669,6 +728,16 @@ igt_main_args("bf:pst:W:H:", NULL, help_str, opt_handler, NULL)
  		block_copy_test(xe, &config, set, BLOCK_COPY);
  	}
 
+	igt_describe("Check block-copy uncompressed blit with increment width/height");
+	igt_subtest_with_dynamic("block-copy-uncompressed-inc-dimension") {
+		struct test_config config = { .width_increment = 15,
+					      .width_steps = 512 };
+		param.width = 1;
+		param.height = 1;
+
+		block_copy_test(xe, &config, set, BLOCK_COPY);
+	}
+
  	igt_describe("Check block-copy flatccs compressed blit");
  	igt_subtest_with_dynamic("block-copy-compressed") {
  		struct test_config config = { .compression = true };
@@ -676,6 +745,17 @@ igt_main_args("bf:pst:W:H:", NULL, help_str, opt_handler, NULL)
  		block_copy_test(xe, &config, set, BLOCK_COPY);
  	}
 
+	igt_describe("Check block-copy compressed blit with increment width/height");
+	igt_subtest_with_dynamic("block-copy-compressed-inc-dimension") {
+		struct test_config config = { .compression = true,
+					      .width_increment = 15,
+					      .width_steps = 512 };
+		param.width = 1;
+		param.height = 1;
+
+		block_copy_test(xe, &config, set, BLOCK_COPY);
+	}
+
  	igt_describe("Check block-multicopy flatccs compressed blit");
  	igt_subtest_with_dynamic("block-multicopy-compressed") {
  		struct test_config config = { .compression = true };
#13 lore raw

Re: [PATCH i-g-t v4 4/5] tests/xe-ccs: Add tests which exercise small to large blit sizes

Quoted 14 lines · Karolina Stolarek
Quoted 5 lines · Zbigniew Kempczyński

Testing block-copy for 512 x 512 x 32bpp is not enough to verify blit is working for different (small) and not always aligned resolutions. Add 'increment' subtests which checks blits from small (1x1) to large (512x512) resolutions.

Quoted 7 lines

To avoid too long execution resolution increment equals 15x15 pixels.

---
  tests/intel/xe_ccs.c | 144 +++++++++++++++++++++++++++++++++----------
  1 file changed, 112 insertions(+), 32 deletions(-)
Quoted 3 lines

Ah, one question actually. We use width == height, and I wonder if we want to test rectangular surfaces. I think that caused problems in the past, but maybe I'm misremembering something.

Good question. I also thought to increment w/h depending on tile size but due to unnecessary code complication I dropped this idea. Going toward 512x512 in square shape imo is good enough to catch out of boundary accesses (try decreasing stride/aligned height by half in helpers and see how tests are failing).

--
Zbigniew

Quoted 243 lines

All the best,
Karolina

Quoted 239 lines
tests/intel/xe_ccs.c +112 -32
index a7785edcb1..627976049c 100644
@@ -28,9 +28,15 @@
   * SUBTEST: block-copy-compressed
   * Description: Check block-copy flatccs compressed blit
   *
+ * SUBTEST: block-copy-compressed-inc-dimension
+ * Description: Check block-copy compressed blit for different sizes
+ *
   * SUBTEST: block-copy-uncompressed
   * Description: Check block-copy uncompressed blit
   *
+ * SUBTEST: block-copy-uncompressed-inc-dimension
+ * Description: Check block-copy uncompressed blit for different sizes
+ *
   * SUBTEST: block-multicopy-compressed
   * Description: Check block-multicopy flatccs compressed blit
   *
@@ -73,6 +79,8 @@ struct test_config {
  	bool surfcopy;
  	bool new_ctx;
  	bool suspend_resume;
+	int width_increment;
+	int width_steps;
  };
  #define PRINT_SURFACE_INFO(name, obj) do { \
@@ -286,9 +294,17 @@ static int blt_block_copy3(int xe,
  	return ret;
  }
+#define CHECK_MIN_WIDTH 2
+#define CHECK_MIN_HEIGHT 2
+#define MIN_EXP_WH(w, h) ((w) >= CHECK_MIN_WIDTH && (h) >= CHECK_MIN_HEIGHT)
+#define CHECK_FROM_WIDTH 256
+#define CHECK_FROM_HEIGHT 256
+#define FROM_EXP_WH(w, h) ((w) >= CHECK_FROM_WIDTH && (h) >= CHECK_FROM_HEIGHT)
+
  static void block_copy(int xe,
  		       intel_ctx_t *ctx,
  		       uint32_t region1, uint32_t region2,
+		       uint32_t width, uint32_t height,
  		       enum blt_tiling_type mid_tiling,
  		       const struct test_config *config)
  {
@@ -301,7 +317,7 @@ static void block_copy(int xe,
  	uint32_t run_id = mid_tiling;
  	uint32_t mid_region = (AT_LEAST_GEN(intel_get_drm_devid(xe), 20) &
  							!xe_has_vram(xe)) ? region1 : region2;
-	uint32_t width = param.width, height = param.height, bb;
+	uint32_t bb;
  	enum blt_compression mid_compression = config->compression;
  	int mid_compression_format = param.compression_format;
  	enum blt_compression_type comp_type = COMPRESSION_TYPE_3D;
@@ -339,9 +355,16 @@ static void block_copy(int xe,
  	blt_block_copy(xe, ctx, NULL, ahnd, &blt, pext);
  	intel_ctx_xe_sync(ctx, true);
-	/* We expect mid != src if there's compression */
-	if (mid->compression)
-		igt_assert(memcmp(src->ptr, mid->ptr, src->size) != 0);
+	/*
+	 * We expect mid != src if there's compression. Ignore this for small
+	 * width x height for linear as compression for gradient occurs in the
+	 * middle for bigger sizes. We also ignore 1x1 as this looks same for
+	 * xmajor.
+	 */
+	if (mid->compression && MIN_EXP_WH(width, height)) {
+		if (mid_tiling != T_LINEAR || FROM_EXP_WH(width, height))
+			igt_assert(memcmp(src->ptr, mid->ptr, src->size) != 0);
+	}
  	WRITE_PNG(xe, run_id, "mid", &blt.dst, width, height, bpp);
@@ -416,6 +439,7 @@ static void block_copy(int xe,
  static void block_multicopy(int xe,
  			    intel_ctx_t *ctx,
  			    uint32_t region1, uint32_t region2,
+			    uint32_t width, uint32_t height,
  			    enum blt_tiling_type mid_tiling,
  			    const struct test_config *config)
  {
@@ -429,7 +453,7 @@ static void block_multicopy(int xe,
  	uint32_t run_id = mid_tiling;
  	uint32_t mid_region = (AT_LEAST_GEN(intel_get_drm_devid(xe), 20) &
  							!xe_has_vram(xe)) ? region1 : region2;
-	uint32_t width = param.width, height = param.height, bb;
+	uint32_t bb;
  	enum blt_compression mid_compression = config->compression;
  	int mid_compression_format = param.compression_format;
  	enum blt_compression_type comp_type = COMPRESSION_TYPE_3D;
@@ -521,6 +545,7 @@ static const struct {
  	void (*copyfn)(int fd,
  		       intel_ctx_t *ctx,
  		       uint32_t region1, uint32_t region2,
+		       uint32_t width, uint32_t height,
  		       enum blt_tiling_type btype,
  		       const struct test_config *config);
  } copyfns[] = {
@@ -528,17 +553,44 @@ static const struct {
  	[BLOCK_MULTICOPY] = { "-multicopy", block_multicopy },
  };
-static void block_copy_test(int xe,
-			    const struct test_config *config,
-			    struct igt_collection *set,
-			    enum copy_func copy_function)
+static void single_copy(int xe, const struct test_config *config,
+			int32_t region1, uint32_t region2,
+			uint32_t width, uint32_t height,
+			int tiling, enum copy_func copy_function)
  {
  	struct drm_xe_engine_class_instance inst = {
  		.engine_class = DRM_XE_ENGINE_CLASS_COPY,
  	};
+	uint32_t vm, exec_queue;
+	uint32_t sync_bind, sync_out;
  	intel_ctx_t *ctx;
+
+	vm = xe_vm_create(xe, 0, 0);
+	exec_queue = xe_exec_queue_create(xe, vm, &inst, 0);
+	sync_bind = syncobj_create(xe, 0);
+	sync_out = syncobj_create(xe, 0);
+	ctx = intel_ctx_xe(xe, vm, exec_queue,
+			   0, sync_bind, sync_out);
+
+	copyfns[copy_function].copyfn(xe, ctx,
+				      region1, region2,
+				      width, height,
+				      tiling, config);
+
+	xe_exec_queue_destroy(xe, exec_queue);
+	xe_vm_destroy(xe, vm);
+	syncobj_destroy(xe, sync_bind);
+	syncobj_destroy(xe, sync_out);
+	free(ctx);
+}
+
+static void block_copy_test(int xe,
+			    const struct test_config *config,
+			    struct igt_collection *set,
+			    enum copy_func copy_function)
+{
+
  	struct igt_collection *regions;
-	uint32_t vm, exec_queue;
  	int tiling;
  	if (config->compression && !blt_block_copy_supports_compression(xe))
@@ -555,6 +607,7 @@ static void block_copy_test(int xe,
  		for_each_variation_r(regions, 2, set) {
  			uint32_t region1, region2;
  			char *regtxt;
+			char testname[256];
  			region1 = igt_collection_get_value(regions, 0);
  			region2 = igt_collection_get_value(regions, 1);
@@ -566,30 +619,36 @@ static void block_copy_test(int xe,
  			regtxt = xe_memregion_dynamic_subtest_name(xe, regions);
-			igt_dynamic_f("%s-%s-compfmt%d-%s%s",
-				      blt_tiling_name(tiling),
-				      config->compression ?
-					      "compressed" : "uncompressed",
-				      param.compression_format, regtxt,
-				      copyfns[copy_function].suffix) {
-				uint32_t sync_bind, sync_out;
+			snprintf(testname, sizeof(testname),
+				 "%s-%s-compfmt%d-%s%s",
+				 blt_tiling_name(tiling),
+				 config->compression ?
+					 "compressed" : "uncompressed",
+				 param.compression_format, regtxt,
+				 copyfns[copy_function].suffix);
-				vm = xe_vm_create(xe, 0, 0);
-				exec_queue = xe_exec_queue_create(xe, vm, &inst, 0);
-				sync_bind = syncobj_create(xe, 0);
-				sync_out = syncobj_create(xe, 0);
-				ctx = intel_ctx_xe(xe, vm, exec_queue,
-						   0, sync_bind, sync_out);
+			if (!config->width_increment) {
+				igt_dynamic(testname)
+					single_copy(xe, config, region1, region2,
+						    param.width, param.height,
+						    tiling, copy_function);
+			} else {
+				for (int w = param.width;
+				     w < param.width + config->width_steps;
+				     w += config->width_increment) {
+					snprintf(testname, sizeof(testname),
+						 "%s-%s-compfmt%d-%s%s-%dx%d",
+						 blt_tiling_name(tiling),
+						 config->compression ?
+							 "compressed" : "uncompressed",
+						 param.compression_format, regtxt,
+						 copyfns[copy_function].suffix,
+						 w, w);
+					igt_dynamic(testname)
+						single_copy(xe, config, region1, region2,
+							    w, w, tiling, copy_function);
+				}
-				copyfns[copy_function].copyfn(xe, ctx,
-							      region1, region2,
-							      tiling, config);
-
-				xe_exec_queue_destroy(xe, exec_queue);
-				xe_vm_destroy(xe, vm);
-				syncobj_destroy(xe, sync_bind);
-				syncobj_destroy(xe, sync_out);
-				free(ctx);
  			}
  			free(regtxt);
@@ -669,6 +728,16 @@ igt_main_args("bf:pst:W:H:", NULL, help_str, opt_handler, NULL)
  		block_copy_test(xe, &config, set, BLOCK_COPY);
  	}
+	igt_describe("Check block-copy uncompressed blit with increment width/height");
+	igt_subtest_with_dynamic("block-copy-uncompressed-inc-dimension") {
+		struct test_config config = { .width_increment = 15,
+					      .width_steps = 512 };
+		param.width = 1;
+		param.height = 1;
+
+		block_copy_test(xe, &config, set, BLOCK_COPY);
+	}
+
  	igt_describe("Check block-copy flatccs compressed blit");
  	igt_subtest_with_dynamic("block-copy-compressed") {
  		struct test_config config = { .compression = true };
@@ -676,6 +745,17 @@ igt_main_args("bf:pst:W:H:", NULL, help_str, opt_handler, NULL)
  		block_copy_test(xe, &config, set, BLOCK_COPY);
  	}
+	igt_describe("Check block-copy compressed blit with increment width/height");
+	igt_subtest_with_dynamic("block-copy-compressed-inc-dimension") {
+		struct test_config config = { .compression = true,
+					      .width_increment = 15,
+					      .width_steps = 512 };
+		param.width = 1;
+		param.height = 1;
+
+		block_copy_test(xe, &config, set, BLOCK_COPY);
+	}
+
  	igt_describe("Check block-multicopy flatccs compressed blit");
  	igt_subtest_with_dynamic("block-multicopy-compressed") {
  		struct test_config config = { .compression = true };
#14 lore raw

PATCH v4 5/5 tests/xe_exercise_blt: Exercise small to large fast-copy blits

In reply to Zbigniew Kempczyński

Testing blitter with large size like 512x512 may be not enough to verify small or unaligned blits works properly. Add subtest which spread fast-copy blits from small to large.

---
 tests/intel/xe_exercise_blt.c | 63 +++++++++++++++++++++++++++++------
 1 file changed, 52 insertions(+), 11 deletions(-)
tests/intel/xe_exercise_blt.c +52 -11
index ddf9d188a7..8b4bae282b 100644
@@ -25,6 +25,10 @@
  *   Check fast-copy blit
  *   blitter
  *
+ * SUBTEST: fast-copy-inc-dimension
+ * Description:
+ *   Check fast-copy blit with sizes from small to large
+ *
  * SUBTEST: fast-copy-emit
  * Description:
  *   Check multiple fast-copy in one batch
@@ -40,6 +44,8 @@ static struct param {
 	bool print_surface_info;
 	int width;
 	int height;
+	int width_increment;
+	int width_steps;
 } param = {
 	.tiling = -1,
 	.write_png = false,
@@ -111,6 +117,7 @@ static int fast_copy_one_bb(int xe,
 }
 
 static void fast_copy_emit(int xe, const intel_ctx_t *ctx,
+			   uint32_t width, uint32_t height,
 			   uint32_t region1, uint32_t region2,
 			   enum blt_tiling_type mid_tiling)
 {
@@ -122,7 +129,7 @@ static void fast_copy_emit(int xe, const intel_ctx_t *ctx,
 	uint64_t ahnd = intel_allocator_open_full(xe, ctx->vm, 0, 0,
 						  INTEL_ALLOCATOR_SIMPLE,
 						  ALLOC_STRATEGY_LOW_TO_HIGH, 0);
-	uint32_t bb, width = param.width, height = param.height;
+	uint32_t bb;
 	int result;
 
 	bb = xe_bo_create(xe, 0, bb_size, region1, 0);
@@ -170,6 +177,7 @@ static void fast_copy_emit(int xe, const intel_ctx_t *ctx,
 }
 
 static void fast_copy(int xe, const intel_ctx_t *ctx,
+		      uint32_t width, uint32_t height,
 		      uint32_t region1, uint32_t region2,
 		      enum blt_tiling_type mid_tiling)
 {
@@ -181,7 +189,6 @@ static void fast_copy(int xe, const intel_ctx_t *ctx,
 						  INTEL_ALLOCATOR_SIMPLE,
 						  ALLOC_STRATEGY_LOW_TO_HIGH, 0);
 	uint32_t bb;
-	uint32_t width = param.width, height = param.height;
 	int result;
 
 	bb = xe_bo_create(xe, 0, bb_size, region1, 0);
@@ -241,14 +248,20 @@ enum fast_copy_func {
 };
 
 static char
-	*full_subtest_str(char *regtxt, enum blt_tiling_type tiling,
+	*full_subtest_str(char *regtxt, uint32_t width, uint32_t height,
+			  enum blt_tiling_type tiling,
 			  enum fast_copy_func func)
 {
 	char *name;
 	uint32_t len;
 
-	len = asprintf(&name, "%s-%s%s", blt_tiling_name(tiling), regtxt,
-		       func == FAST_COPY_EMIT ? "-emit" : "");
+	if (!width || !height)
+		len = asprintf(&name, "%s-%s%s", blt_tiling_name(tiling), regtxt,
+			       func == FAST_COPY_EMIT ? "-emit" : "");
+	else
+		len = asprintf(&name, "%s-%s%s-%ux%u", blt_tiling_name(tiling), regtxt,
+			       func == FAST_COPY_EMIT ? "-emit" : "",
+			       width, height);
 
 	igt_assert_f(len >= 0, "asprintf failed!\n");
 
@@ -264,6 +277,7 @@ static void fast_copy_test(int xe,
 	};
 	struct igt_collection *regions;
 	void (*copy_func)(int xe, const intel_ctx_t *ctx,
+			  uint32_t width, uint32_t height,
 			  uint32_t r1, uint32_t r2, enum blt_tiling_type tiling);
 	intel_ctx_t *ctx;
 	int tiling;
@@ -286,16 +300,32 @@ static void fast_copy_test(int xe,
 
 			copy_func = (func == FAST_COPY) ? fast_copy : fast_copy_emit;
 			regtxt = xe_memregion_dynamic_subtest_name(xe, regions);
-			test_name = full_subtest_str(regtxt, tiling, func);
 
-			igt_dynamic_f("%s", test_name) {
-				copy_func(xe, ctx,
-					  region1, region2,
-					  tiling);
+			if (!param.width_increment) {
+				test_name = full_subtest_str(regtxt, 0, 0, tiling, func);
+				igt_dynamic_f("%s", test_name) {
+					copy_func(xe, ctx,
+						  param.width, param.height,
+						  region1, region2,
+						  tiling);
+				}
+				free(test_name);
+			} else {
+				for (int w = param.width;
+				     w < param.width + param.width_steps;
+				     w += param.width_increment) {
+					test_name = full_subtest_str(regtxt, w, w, tiling, func);
+					igt_dynamic_f("%s", test_name) {
+						copy_func(xe, ctx,
+							  w, w,
+							  region1, region2,
+							  tiling);
+					}
+					free(test_name);
+				}
 			}
 
 			free(regtxt);
-			free(test_name);
 			xe_exec_queue_destroy(xe, exec_queue);
 			xe_vm_destroy(xe, vm);
 			free(ctx);
@@ -367,6 +397,17 @@ igt_main_args("b:pst:W:H:", NULL, help_str, opt_handler, NULL)
 		fast_copy_test(xe, set, FAST_COPY);
 	}
 
+	igt_describe("Check fast-copy with increment width/height");
+	igt_subtest_with_dynamic("fast-copy-inc-dimension") {
+		param.width = 1;
+		param.height = 1;
+		param.width_increment = 15;
+		param.width_steps = 512;
+
+		fast_copy_test(xe, set, FAST_COPY);
+	}
+
+
 	igt_describe("Check multiple fast-copy in one batch");
 	igt_subtest_with_dynamic("fast-copy-emit") {
 		fast_copy_test(xe, set, FAST_COPY_EMIT);
Signature · 1 line
2.34.1
#15 lore raw

Re: [PATCH i-g-t v4 5/5] tests/xe_exercise_blt: Exercise small to large fast-copy blits

Quoted 101 lines · Zbigniew Kempczyński

Testing blitter with large size like 512x512 may be not enough to verify small or unaligned blits works properly. Add subtest which spread fast-copy blits from small to large.

---
  tests/intel/xe_exercise_blt.c | 63 +++++++++++++++++++++++++++++------
  1 file changed, 52 insertions(+), 11 deletions(-)
tests/intel/xe_exercise_blt.c +19 -5
index ddf9d188a7..8b4bae282b 100644
@@ -25,6 +25,10 @@
   *   Check fast-copy blit
   *   blitter
   *
+ * SUBTEST: fast-copy-inc-dimension
+ * Description:
+ *   Check fast-copy blit with sizes from small to large
+ *
   * SUBTEST: fast-copy-emit
   * Description:
   *   Check multiple fast-copy in one batch
@@ -40,6 +44,8 @@ static struct param {
  	bool print_surface_info;
  	int width;
  	int height;
+	int width_increment;
+	int width_steps;
  } param = {
  	.tiling = -1,
  	.write_png = false,
@@ -111,6 +117,7 @@ static int fast_copy_one_bb(int xe,
  }
 
  static void fast_copy_emit(int xe, const intel_ctx_t *ctx,
+			   uint32_t width, uint32_t height,
  			   uint32_t region1, uint32_t region2,
  			   enum blt_tiling_type mid_tiling)
  {
@@ -122,7 +129,7 @@ static void fast_copy_emit(int xe, const intel_ctx_t *ctx,
  	uint64_t ahnd = intel_allocator_open_full(xe, ctx->vm, 0, 0,
  						  INTEL_ALLOCATOR_SIMPLE,
  						  ALLOC_STRATEGY_LOW_TO_HIGH, 0);
-	uint32_t bb, width = param.width, height = param.height;
+	uint32_t bb;
  	int result;
 
  	bb = xe_bo_create(xe, 0, bb_size, region1, 0);
@@ -170,6 +177,7 @@ static void fast_copy_emit(int xe, const intel_ctx_t *ctx,
  }
 
  static void fast_copy(int xe, const intel_ctx_t *ctx,
+		      uint32_t width, uint32_t height,
  		      uint32_t region1, uint32_t region2,
  		      enum blt_tiling_type mid_tiling)
  {
@@ -181,7 +189,6 @@ static void fast_copy(int xe, const intel_ctx_t *ctx,
  						  INTEL_ALLOCATOR_SIMPLE,
  						  ALLOC_STRATEGY_LOW_TO_HIGH, 0);
  	uint32_t bb;
-	uint32_t width = param.width, height = param.height;
  	int result;
 
  	bb = xe_bo_create(xe, 0, bb_size, region1, 0);
@@ -241,14 +248,20 @@ enum fast_copy_func {
  };
 
  static char
-	*full_subtest_str(char *regtxt, enum blt_tiling_type tiling,
+	*full_subtest_str(char *regtxt, uint32_t width, uint32_t height,
+			  enum blt_tiling_type tiling,
  			  enum fast_copy_func func)
  {
  	char *name;
  	uint32_t len;
 
-	len = asprintf(&name, "%s-%s%s", blt_tiling_name(tiling), regtxt,
-		       func == FAST_COPY_EMIT ? "-emit" : "");
+	if (!width || !height)
+		len = asprintf(&name, "%s-%s%s", blt_tiling_name(tiling), regtxt,
+			       func == FAST_COPY_EMIT ? "-emit" : "");
+	else
+		len = asprintf(&name, "%s-%s%s-%ux%u", blt_tiling_name(tiling), regtxt,
+			       func == FAST_COPY_EMIT ? "-emit" : "",
+			       width, height);
 
  	igt_assert_f(len >= 0, "asprintf failed!\n");
 
@@ -264,6 +277,7 @@ static void fast_copy_test(int xe,
  	};
  	struct igt_collection *regions;
  	void (*copy_func)(int xe, const intel_ctx_t *ctx,
+			  uint32_t width, uint32_t height,
  			  uint32_t r1, uint32_t r2, enum blt_tiling_type tiling);
  	intel_ctx_t *ctx;
  	int tiling;
@@ -286,16 +300,32 @@ static void fast_copy_test(int xe,
 

tests/intel/xe_exercise_blt.c static void fast_copy_test(int xe, · line 305

Quoted 10 lines
tests/intel/xe_exercise_blt.c +2 -5
  			copy_func = (func == FAST_COPY) ? fast_copy : fast_copy_emit;
  			regtxt = xe_memregion_dynamic_subtest_name(xe, regions);
-			test_name = full_subtest_str(regtxt, tiling, func);
 
-			igt_dynamic_f("%s", test_name) {
-				copy_func(xe, ctx,
-					  region1, region2,
-					  tiling);
+			if (!param.width_increment) {
+				test_name = full_subtest_str(regtxt, 0, 0, tiling, func);

I'd simply pass param.width and param.height here and use the common name for both width_increment and fixed size test cases. We don't have to keep the same "%s-%s%s" format, extending it would be fine (and helpful, I think).

All the best,
Karolina

Quoted 45 lines
tests/intel/xe_exercise_blt.c +31 -1
+				igt_dynamic_f("%s", test_name) {
+					copy_func(xe, ctx,
+						  param.width, param.height,
+						  region1, region2,
+						  tiling);
+				}
+				free(test_name);
+			} else {
+				for (int w = param.width;
+				     w < param.width + param.width_steps;
+				     w += param.width_increment) {
+					test_name = full_subtest_str(regtxt, w, w, tiling, func);
+					igt_dynamic_f("%s", test_name) {
+						copy_func(xe, ctx,
+							  w, w,
+							  region1, region2,
+							  tiling);
+					}
+					free(test_name);
+				}
  			}
 
  			free(regtxt);
-			free(test_name);
  			xe_exec_queue_destroy(xe, exec_queue);
  			xe_vm_destroy(xe, vm);
  			free(ctx);
@@ -367,6 +397,17 @@ igt_main_args("b:pst:W:H:", NULL, help_str, opt_handler, NULL)
  		fast_copy_test(xe, set, FAST_COPY);
  	}
 
+	igt_describe("Check fast-copy with increment width/height");
+	igt_subtest_with_dynamic("fast-copy-inc-dimension") {
+		param.width = 1;
+		param.height = 1;
+		param.width_increment = 15;
+		param.width_steps = 512;
+
+		fast_copy_test(xe, set, FAST_COPY);
+	}
+
+
  	igt_describe("Check multiple fast-copy in one batch");
  	igt_subtest_with_dynamic("fast-copy-emit") {
  		fast_copy_test(xe, set, FAST_COPY_EMIT);
#16 lore raw

Re: [PATCH i-g-t v4 5/5] tests/xe_exercise_blt: Exercise small to large fast-copy blits

Quoted 100 lines · Karolina Stolarek
Quoted 98 lines · Zbigniew Kempczyński

Testing blitter with large size like 512x512 may be not enough to verify small or unaligned blits works properly. Add subtest which spread fast-copy blits from small to large.

---
  tests/intel/xe_exercise_blt.c | 63 +++++++++++++++++++++++++++++------
  1 file changed, 52 insertions(+), 11 deletions(-)
tests/intel/xe_exercise_blt.c +19 -9
index ddf9d188a7..8b4bae282b 100644
@@ -25,6 +25,10 @@
   *   Check fast-copy blit
   *   blitter
   *
+ * SUBTEST: fast-copy-inc-dimension
+ * Description:
+ *   Check fast-copy blit with sizes from small to large
+ *
   * SUBTEST: fast-copy-emit
   * Description:
   *   Check multiple fast-copy in one batch
@@ -40,6 +44,8 @@ static struct param {
  	bool print_surface_info;
  	int width;
  	int height;
+	int width_increment;
+	int width_steps;
  } param = {
  	.tiling = -1,
  	.write_png = false,
@@ -111,6 +117,7 @@ static int fast_copy_one_bb(int xe,
  }
  static void fast_copy_emit(int xe, const intel_ctx_t *ctx,
+			   uint32_t width, uint32_t height,
  			   uint32_t region1, uint32_t region2,
  			   enum blt_tiling_type mid_tiling)
  {
@@ -122,7 +129,7 @@ static void fast_copy_emit(int xe, const intel_ctx_t *ctx,
  	uint64_t ahnd = intel_allocator_open_full(xe, ctx->vm, 0, 0,
  						  INTEL_ALLOCATOR_SIMPLE,
  						  ALLOC_STRATEGY_LOW_TO_HIGH, 0);
-	uint32_t bb, width = param.width, height = param.height;
+	uint32_t bb;
  	int result;
  	bb = xe_bo_create(xe, 0, bb_size, region1, 0);
@@ -170,6 +177,7 @@ static void fast_copy_emit(int xe, const intel_ctx_t *ctx,
  }
  static void fast_copy(int xe, const intel_ctx_t *ctx,
+		      uint32_t width, uint32_t height,
  		      uint32_t region1, uint32_t region2,
  		      enum blt_tiling_type mid_tiling)
  {
@@ -181,7 +189,6 @@ static void fast_copy(int xe, const intel_ctx_t *ctx,
  						  INTEL_ALLOCATOR_SIMPLE,
  						  ALLOC_STRATEGY_LOW_TO_HIGH, 0);
  	uint32_t bb;
-	uint32_t width = param.width, height = param.height;
  	int result;
  	bb = xe_bo_create(xe, 0, bb_size, region1, 0);
@@ -241,14 +248,20 @@ enum fast_copy_func {
  };
  static char
-	*full_subtest_str(char *regtxt, enum blt_tiling_type tiling,
+	*full_subtest_str(char *regtxt, uint32_t width, uint32_t height,
+			  enum blt_tiling_type tiling,
  			  enum fast_copy_func func)
  {
  	char *name;
  	uint32_t len;
-	len = asprintf(&name, "%s-%s%s", blt_tiling_name(tiling), regtxt,
-		       func == FAST_COPY_EMIT ? "-emit" : "");
+	if (!width || !height)
+		len = asprintf(&name, "%s-%s%s", blt_tiling_name(tiling), regtxt,
+			       func == FAST_COPY_EMIT ? "-emit" : "");
+	else
+		len = asprintf(&name, "%s-%s%s-%ux%u", blt_tiling_name(tiling), regtxt,
+			       func == FAST_COPY_EMIT ? "-emit" : "",
+			       width, height);
  	igt_assert_f(len >= 0, "asprintf failed!\n");
@@ -264,6 +277,7 @@ static void fast_copy_test(int xe,
  	};
  	struct igt_collection *regions;
  	void (*copy_func)(int xe, const intel_ctx_t *ctx,
+			  uint32_t width, uint32_t height,
  			  uint32_t r1, uint32_t r2, enum blt_tiling_type tiling);
  	intel_ctx_t *ctx;
  	int tiling;
@@ -286,16 +300,32 @@ static void fast_copy_test(int xe,
  			copy_func = (func == FAST_COPY) ? fast_copy : fast_copy_emit;
  			regtxt = xe_memregion_dynamic_subtest_name(xe, regions);
-			test_name = full_subtest_str(regtxt, tiling, func);
-			igt_dynamic_f("%s", test_name) {
-				copy_func(xe, ctx,
-					  region1, region2,
Quoted 8 lines

tests/intel/xe_exercise_blt.c static void fast_copy_test(int xe, · line 305

Quoted 3 lines
tests/intel/xe_exercise_blt.c +2 -1
-					  tiling);
+			if (!param.width_increment) {
+				test_name = full_subtest_str(regtxt, 0, 0, tiling, func);

I'd simply pass param.width and param.height here and use the common name for both width_increment and fixed size test cases. We don't have to keep the same "%s-%s%s" format, extending it would be fine (and helpful, I think).

I wanted to keep subtest name for previous test to avoid changes on patchwork. That's why I passed 0 here.

--
Zbigniew

Quoted 47 lines

All the best,
Karolina

Quoted 43 lines
tests/intel/xe_exercise_blt.c +31 -1
+				igt_dynamic_f("%s", test_name) {
+					copy_func(xe, ctx,
+						  param.width, param.height,
+						  region1, region2,
+						  tiling);
+				}
+				free(test_name);
+			} else {
+				for (int w = param.width;
+				     w < param.width + param.width_steps;
+				     w += param.width_increment) {
+					test_name = full_subtest_str(regtxt, w, w, tiling, func);
+					igt_dynamic_f("%s", test_name) {
+						copy_func(xe, ctx,
+							  w, w,
+							  region1, region2,
+							  tiling);
+					}
+					free(test_name);
+				}
  			}
  			free(regtxt);
-			free(test_name);
  			xe_exec_queue_destroy(xe, exec_queue);
  			xe_vm_destroy(xe, vm);
  			free(ctx);
@@ -367,6 +397,17 @@ igt_main_args("b:pst:W:H:", NULL, help_str, opt_handler, NULL)
  		fast_copy_test(xe, set, FAST_COPY);
  	}
+	igt_describe("Check fast-copy with increment width/height");
+	igt_subtest_with_dynamic("fast-copy-inc-dimension") {
+		param.width = 1;
+		param.height = 1;
+		param.width_increment = 15;
+		param.width_steps = 512;
+
+		fast_copy_test(xe, set, FAST_COPY);
+	}
+
+
  	igt_describe("Check multiple fast-copy in one batch");
  	igt_subtest_with_dynamic("fast-copy-emit") {
  		fast_copy_test(xe, set, FAST_COPY_EMIT);
#17 lore raw

Re: [PATCH i-g-t v4 5/5] tests/xe_exercise_blt: Exercise small to large fast-copy blits

In reply to Zbigniew Kempczyński

Ah, forgot to tell you that checkpatch was slightly uhappy with two blank lines after inc-dimension subtest...

On 1.02.2024 11:07, Zbigniew Kempczyński wrote:
(...)

tests/intel/xe_exercise_blt.c igt_main_args("b:pst:W:H:", NULL, help_str, opt_handler, NULL) · line 410

Quoted 12 lines
tests/intel/xe_exercise_blt.c +11 -0
+	igt_describe("Check fast-copy with increment width/height");
+	igt_subtest_with_dynamic("fast-copy-inc-dimension") {
+		param.width = 1;
+		param.height = 1;
+		param.width_increment = 15;
+		param.width_steps = 512;
+
+		fast_copy_test(xe, set, FAST_COPY);
+	}
+
+

^-- here!

Sorry for the email noise.

All the best,
Karolina

Quoted 3 lines
  	igt_describe("Check multiple fast-copy in one batch");
  	igt_subtest_with_dynamic("fast-copy-emit") {
  		fast_copy_test(xe, set, FAST_COPY_EMIT);
#18 lore raw

Re: [PATCH i-g-t v4 5/5] tests/xe_exercise_blt: Exercise small to large fast-copy blits

Quoted 18 lines · Karolina Stolarek

Ah, forgot to tell you that checkpatch was slightly uhappy with two blank lines after inc-dimension subtest...

On 1.02.2024 11:07, Zbigniew Kempczyński wrote:
(...)

tests/intel/xe_exercise_blt.c igt_main_args("b:pst:W:H:", NULL, help_str, opt_handler, NULL) · line 410

Quoted 11 lines
tests/intel/xe_exercise_blt.c +11 -0
+	igt_describe("Check fast-copy with increment width/height");
+	igt_subtest_with_dynamic("fast-copy-inc-dimension") {
+		param.width = 1;
+		param.height = 1;
+		param.width_increment = 15;
+		param.width_steps = 512;
+
+		fast_copy_test(xe, set, FAST_COPY);
+	}
+
+

^-- here!

Quoted 1 line

Sorry for the email noise.

No problem at all, thanks for spotting this. I'll resubmit on v5.

--
Zbigniew

Quoted 7 lines

All the best,
Karolina

Quoted 3 lines
  	igt_describe("Check multiple fast-copy in one batch");
  	igt_subtest_with_dynamic("fast-copy-emit") {
  		fast_copy_test(xe, set, FAST_COPY_EMIT);
#19 lore raw

✓ CI.xeBAT: success for Fill block-copy test gap for unaligned sizes (rev4)

In reply to Zbigniew Kempczyński
== Series Details ==

== Series Details ==

Series: Fill block-copy test gap for unaligned sizes (rev4)
URL : https://patchwork.freedesktop.org/series/129362/
State : success

== Summary ==

CI Bug Log - changes from XEIGT_7700_BAT -> XEIGTPW_10621_BAT
====================================================

Summary
-------

**SUCCESS**

No regressions found.

Participating hosts (4 -> 4)
------------------------------

No changes in participating hosts

Known issues
------------

Here are the changes found in XEIGTPW_10621_BAT that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@kms_pipe_crc_basic@nonblocking-crc-frame-sequence@pipe-d-dp-3:
- bat-dg2-oem2: [PASS][1] -> [FAIL][2] ([Intel XE#400] / [Intel XE#616]) +1 other test fail
[1]: https://intel-gfx-ci.01.org/tree/intel-xe/IGT_7700/bat-dg2-oem2/igt@kms_pipe_crc_basic@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10621/bat-dg2-oem2/igt@kms_pipe_crc_basic@[email protected]

[Intel XE#400]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/400
[Intel XE#616]: https://gitlab.freedesktop.org/drm/xe/kernel/issues/616

Build changes
-------------

* IGT: IGT_7700 -> IGTPW_10621
* Linux: xe-712-cba66c6a2af4df1b9b420fbad0a9ac1e68f14030 -> xe-714-bc72404452d402682457b998a9884af537adddd2

IGTPW_10621: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_10621/index.html
IGT_7700: 7700
xe-712-cba66c6a2af4df1b9b420fbad0a9ac1e68f14030: cba66c6a2af4df1b9b420fbad0a9ac1e68f14030 xe-714-bc72404452d402682457b998a9884af537adddd2: bc72404452d402682457b998a9884af537adddd2

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/intel-xe/IGTPW_10621/index.html