[i-g-t,v3,05/21] lib/igt_fb: Allow interpreting the tile height as a stride equivalent

Submitted by Paul Kocialkowski on Jan. 11, 2019, 9:05 a.m.

Details

Message ID 20190111090532.19235-6-paul.kocialkowski@bootlin.com
State Accepted
Commit 3fa1953d28350929672cf90002fcfce34bc59f35
Headers show
Series "Chamelium VC4 plane fuzzy testing, with SAND and T-tiled mode" ( rev: 1 ) in IGT

Not browsing as part of any series.

Commit Message

Paul Kocialkowski Jan. 11, 2019, 9:05 a.m.
The VC4 SAND tiling modes are disposed in columns that follow each
other in memory. The column height defines the number of fixed-width
lines from the beginning of one column to the other, which may be
greater than the display height. In this case, the extra lines are
used as padding and the column height becomes a height-based stride
equivalent.

Support this when calculating the plane size by using the tile height
directly if it is greater than the plane height. This works better than
alignment for non-power-of-two cases (no space is wasted) and it is
equivalent to alignment for power-of-two tile heights.

Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
---
 lib/igt_fb.c | 7 +++++++
 1 file changed, 7 insertions(+)

Patch hide | download patch | download mbox

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 7fb8e7d44bd2..03a6b8be9618 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -450,6 +450,13 @@  static uint64_t calc_plane_size(struct igt_fb *fb, int plane)
 		igt_get_fb_tile_size(fb->fd, fb->tiling, fb->plane_bpp[plane],
 				     &tile_width, &tile_height);
 
+		/* Special case where the "tile height" represents a
+		 * height-based stride, such as with VC4 SAND tiling modes.
+		 */
+
+		if (tile_height > fb->plane_height[plane])
+			return fb->strides[plane] * tile_height;
+
 		return (uint64_t) fb->strides[plane] *
 			ALIGN(fb->plane_height[plane], tile_height);
 	}

Comments

On Fri, Jan 11, 2019 at 10:05:16AM +0100, Paul Kocialkowski wrote:
> The VC4 SAND tiling modes are disposed in columns that follow each
> other in memory. The column height defines the number of fixed-width
> lines from the beginning of one column to the other, which may be
> greater than the display height. In this case, the extra lines are
> used as padding and the column height becomes a height-based stride
> equivalent.
> 
> Support this when calculating the plane size by using the tile height
> directly if it is greater than the plane height. This works better than
> alignment for non-power-of-two cases (no space is wasted) and it is
> equivalent to alignment for power-of-two tile heights.
> 
> Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>

Reviewed-by: Maxime Ripard <maxime.ripard@bootlin.com>

Maxime
Reviewed-by: Lyude Paul <lyude@redhat.com>

On Fri, 2019-01-11 at 10:05 +0100, Paul Kocialkowski wrote:
> The VC4 SAND tiling modes are disposed in columns that follow each
> other in memory. The column height defines the number of fixed-width
> lines from the beginning of one column to the other, which may be
> greater than the display height. In this case, the extra lines are
> used as padding and the column height becomes a height-based stride
> equivalent.
> 
> Support this when calculating the plane size by using the tile height
> directly if it is greater than the plane height. This works better than
> alignment for non-power-of-two cases (no space is wasted) and it is
> equivalent to alignment for power-of-two tile heights.
> 
> Signed-off-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> ---
>  lib/igt_fb.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/lib/igt_fb.c b/lib/igt_fb.c
> index 7fb8e7d44bd2..03a6b8be9618 100644
> --- a/lib/igt_fb.c
> +++ b/lib/igt_fb.c
> @@ -450,6 +450,13 @@ static uint64_t calc_plane_size(struct igt_fb *fb, int
> plane)
>  		igt_get_fb_tile_size(fb->fd, fb->tiling, fb->plane_bpp[plane],
>  				     &tile_width, &tile_height);
>  
> +		/* Special case where the "tile height" represents a
> +		 * height-based stride, such as with VC4 SAND tiling modes.
> +		 */
> +
> +		if (tile_height > fb->plane_height[plane])
> +			return fb->strides[plane] * tile_height;
> +
>  		return (uint64_t) fb->strides[plane] *
>  			ALIGN(fb->plane_height[plane], tile_height);
>  	}