[Mesa-dev] [PATCH 5/7] isl: Let isl_surf_init's caller set the exact row pitch (v2)

Jason Ekstrand jason at jlekstrand.net
Wed Mar 15 16:54:27 UTC 2017


On Mon, Mar 13, 2017 at 3:28 PM, Chad Versace <chadversary at chromium.org>
wrote:

> The caller does so by setting the new field
> isl_surf_init_info::row_pitch.
>
> v2:
>   - Validate the requested row_pitch.
> ---
>  src/intel/isl/isl.c | 14 +++++++++++++-
>  src/intel/isl/isl.h |  6 ++++++
>  2 files changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/src/intel/isl/isl.c b/src/intel/isl/isl.c
> index 405f5b917fe..0e0eb35ef52 100644
> --- a/src/intel/isl/isl.c
> +++ b/src/intel/isl/isl.c
> @@ -1100,10 +1100,22 @@ isl_calc_row_pitch(const struct isl_device *dev,
>     const uint32_t alignment =
>        isl_calc_row_pitch_alignment(surf_info, tile_info);
>
> -   const uint32_t row_pitch =
> +   const uint32_t min_row_pitch =
>        isl_calc_min_row_pitch(dev, surf_info, tile_info, phys_slice0_sa,
>                               alignment);
>
> +   uint32_t row_pitch = min_row_pitch;
> +
> +   if (surf_info->row_pitch != 0) {
> +      row_pitch = surf_info->row_pitch;
> +
> +      if (row_pitch < min_row_pitch)
> +         return false;
> +
> +      if (row_pitch % alignment != 0)
> +         return false;
> +   }
>

Looking at this a bit more, I think I do have a mild preference for
calc_row_pitch to handle alignment.  If we did that, this would become:

if (surf_info->row_pitch) {
   /* The stuff you have */
} else {
   row_pitch = isl_align_u32(min_row_pitch, alignment);
}

which is a nice if/else.

The counter-argument, of course, is that if min_row_pitch hasn't been
aligned then it isn't really the minimum because it isn't a valid row
pitch.  Never mind my mild preferences, let's tell the truth.  You're doing
it just fine and I'm arguing with myself on the mailing list. :-)


> +
>     const uint32_t row_pitch_tiles = row_pitch / tile_info->phys_extent_B.
> width;
>
>     /* Check that the pitch fits in RENDER_SURFACE_STATE::SurfacePitch or
> diff --git a/src/intel/isl/isl.h b/src/intel/isl/isl.h
> index b79793b0c93..fb2bcfaec10 100644
> --- a/src/intel/isl/isl.h
> +++ b/src/intel/isl/isl.h
> @@ -816,6 +816,12 @@ struct isl_surf_init_info {
>     /** Lower bound for isl_surf::pitch, in bytes. */
>     uint32_t min_pitch;
>
> +   /**
> +    * Exact value for isl_surf::row_pitch. Ignored if zero.
> isl_surf_init()
> +    * will fail if this is misaligned or out of bounds.
> +    */
> +   uint32_t row_pitch;
> +
>     isl_surf_usage_flags_t usage;
>
>     /** Flags that alter how ISL selects isl_surf::tiling.  */
> --
> 2.12.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170315/af641e61/attachment-0001.html>


More information about the mesa-dev mailing list