[igt-dev] [PATCH i-g-t 2/4] lib/igt_fb/tgl+: Prevent CCS FB UV surface offset overalignment

Ville Syrjälä ville.syrjala at linux.intel.com
Wed Oct 27 09:46:11 UTC 2021


On Wed, Oct 27, 2021 at 12:26:18AM +0300, Imre Deak wrote:
> The offset of semiplanar UV surfaces in CCS FBs must be 64 kbyte aligned
> as required by the Vebox engine which IGT uses to convert between tiling
> formats. At the same time the display engine requires the offset to be
> tile-row aligned. So far we ensured both of these alignment requirements
> by aligning all color surface widths/heights to 4x4 tiles. This however
> wastes memory in case the number of tiles in one tile-row modulo 16 is 0
> or 8 where 1 or 2 tile-row alignment correspondingly would be enough.
> 
> The next patch removes the 4x4 tile alignment, here prepare for that by
> aligning TGL+ UV surface offsets to LCM(tile-row size, 64 kbyte)
> ensuring the minimum tile-row size and 64 kbyte alignment.
> 
> Signed-off-by: Imre Deak <imre.deak at intel.com>
> ---
>  lib/igt_fb.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 51 insertions(+)
> 
> diff --git a/lib/igt_fb.c b/lib/igt_fb.c
> index b8b2396d3..86d0ae426 100644
> --- a/lib/igt_fb.c
> +++ b/lib/igt_fb.c
> @@ -392,6 +392,12 @@ bool igt_format_is_yuv_semiplanar(uint32_t format)
>  	return igt_format_is_yuv(format) && f->num_planes == 2;
>  }
>  
> +static bool is_yuv_semiplanar_plane(const struct igt_fb *fb, int color_plane)
> +{
> +	return igt_format_is_yuv_semiplanar(fb->drm_format) &&
> +	       color_plane == 1;
> +}
> +
>  /**
>   * igt_get_fb_tile_size:
>   * @fd: the DRM file descriptor
> @@ -843,16 +849,61 @@ static uint64_t calc_plane_size(struct igt_fb *fb, int plane)
>  	}
>  }
>  
> +static unsigned int gcd(unsigned int a, unsigned int b)
> +{
> +	if (b == 0)
> +		return a;
> +
> +	return gcd(b, a % b);

I would write that w/o the recursion. 

-- 
Ville Syrjälä
Intel


More information about the igt-dev mailing list