[igt-dev] [PATCH i-g-t 13/25] lib/igt_fb: Extract calc_plane_stride()

Paulo Zanoni paulo.r.zanoni at intel.com
Fri Sep 21 22:33:52 UTC 2018


Em Qui, 2018-07-19 às 18:04 +0300, Ville Syrjala escreveu:
> From: Ville Syrjälä <ville.syrjala at linux.intel.com>
> 
> Extract the stride calculation from calc_fb_size_packed() to its own
> thing so that we can use it to calculate just the stride.

I think it makes more sense to wait for the rebased versions before
giving r-b tags to patches 13 and 14. Patch 13 looks good, but 14 is
starting to get hard to review without applying it locally.


> 
> Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
> ---
>  lib/igt_fb.c | 53 ++++++++++++++++++++++++++++++++++++++++--------
> -----
>  1 file changed, 40 insertions(+), 13 deletions(-)
> 
> diff --git a/lib/igt_fb.c b/lib/igt_fb.c
> index 0319afa9749f..dd6cd1f6409c 100644
> --- a/lib/igt_fb.c
> +++ b/lib/igt_fb.c
> @@ -226,6 +226,38 @@ static int fb_num_planes(struct
> format_desc_struct *format)
>  	return format->num_planes;
>  }
>  
> +static unsigned calc_plane_stride(int fd,
> +				  struct format_desc_struct *format,
> +				  int width, uint64_t tiling, int
> plane)
> +{
> +	uint32_t min_stride = fb_plane_min_stride(format, width,
> plane);
> +
> +	if (tiling != LOCAL_DRM_FORMAT_MOD_NONE &&
> +	    intel_gen(intel_get_drm_devid(fd)) <= 3) {
> +		uint32_t stride;
> +
> +		/* Round the tiling up to the next power-of-two and
> the region
> +		 * up to the next pot fence size so that this works
> on all
> +		 * generations.
> +		 *
> +		 * This can still fail if the framebuffer is too
> large to be
> +		 * tiled. But then that failure is expected.
> +		 */
> +		for (stride = 512; stride < min_stride; stride *= 2)
> +			;
> +
> +		return stride;
> +	} else {
> +		unsigned int tile_width, tile_height;
> +
> +		igt_get_fb_tile_size(fd, tiling,
> +				     fb_plane_bpp(format, plane),
> +				     &tile_width, &tile_height);
> +
> +		return ALIGN(min_stride, tile_width);
> +	}
> +}
> +
>  static void calc_fb_size_planar(int fd, int width, int height,
>  				struct format_desc_struct *format,
>  				uint64_t tiling, unsigned stride,
> @@ -272,11 +304,10 @@ static void calc_fb_size_packed(int fd, int
> width, int height,
>  				struct format_desc_struct *format,
> uint64_t tiling,
>  				unsigned stride, unsigned *size_ret,
> unsigned *stride_ret)
>  {
> -	unsigned int tile_width, tile_height, size;
> -	int byte_width = fb_plane_min_stride(format, width, 0);
> +	unsigned int size;
>  
> -	igt_get_fb_tile_size(fd, tiling, fb_plane_bpp(format, 0),
> -			     &tile_width, &tile_height);
> +	if (!stride)
> +		stride = calc_plane_stride(fd, format, width,
> tiling, 0);
>  
>  	if (tiling != LOCAL_DRM_FORMAT_MOD_NONE &&
>  	    intel_gen(intel_get_drm_devid(fd)) <= 3) {
> @@ -289,19 +320,15 @@ static void calc_fb_size_packed(int fd, int
> width, int height,
>  		 * This can still fail if the framebuffer is too
> large to be
>  		 * tiled. But then that failure is expected.
>  		 */
> -
> -		if (!stride) {
> -			v = byte_width;
> -			for (stride = 512; stride < v; stride *= 2)
> -				;
> -		}
> -
>  		v = stride * height;
>  		for (size = 1024*1024; size < v; size *= 2)
>  			;
>  	} else {
> -		if (!stride)
> -			stride = ALIGN(byte_width, tile_width);
> +		unsigned int tile_width, tile_height;
> +
> +		igt_get_fb_tile_size(fd, tiling,
> fb_plane_bpp(format, 0),
> +				     &tile_width, &tile_height);
> +
>  		size = stride * ALIGN(height, tile_height);
>  	}
>  


More information about the igt-dev mailing list