[Mesa-dev] [PATCH 4/7] isl: Validate the calculated row pitch

Jason Ekstrand jason at jlekstrand.net
Wed Mar 15 16:48:51 UTC 2017


Fun story: This will implicitly handle the (invalid) case of trying to
create a MCS for a 16xMSAA surface that's more than 8k wide. :-)  We may
want to keep the check in init_mcs for clarity and because it's in the docs
but the extra validation is nice.

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

> Validate that it fits in RENDER_SURFACE_STATE::SurfacePitch or, if it's
> an aux surface, AuxiliarySurfacePitch.
> ---
>  src/intel/isl/isl.c | 35 +++++++++++++++++++++++++++++------
>  1 file changed, 29 insertions(+), 6 deletions(-)
>
> diff --git a/src/intel/isl/isl.c b/src/intel/isl/isl.c
> index 784566749b4..405f5b917fe 100644
> --- a/src/intel/isl/isl.c
> +++ b/src/intel/isl/isl.c
> @@ -1089,18 +1089,39 @@ isl_calc_min_row_pitch(const struct isl_device
> *dev,
>     }
>  }
>
> -static uint32_t
> +static bool
>  isl_calc_row_pitch(const struct isl_device *dev,
>                     const struct isl_surf_init_info *surf_info,
>                     const struct isl_tile_info *tile_info,
>                     enum isl_dim_layout dim_layout,
> -                   const struct isl_extent2d *phys_slice0_sa)
> +                   const struct isl_extent2d *phys_slice0_sa,
> +                   uint32_t *out_row_pitch)
>  {
>     const uint32_t alignment =
>        isl_calc_row_pitch_alignment(surf_info, tile_info);
>
> -   return isl_calc_min_row_pitch(dev, surf_info, tile_info,
> phys_slice0_sa,
> -                                 alignment);
> +   const uint32_t row_pitch =
> +      isl_calc_min_row_pitch(dev, surf_info, tile_info, phys_slice0_sa,
> +                             alignment);
> +
> +   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
> +    * AuxiliarySurfacePitch.
> +    */
> +   if (dim_layout == ISL_DIM_LAYOUT_GEN9_1D) {
> +      /* SurfacePitch is ignored for this layout.
> +       * FINISHME: How to validate row pitch for ISL_DIM_LAYOUT_GEN9_1D?
> +       */
> +   } else if (isl_tiling_is_aux(tile_info->tiling)) {
> +      if (row_pitch_tiles > (1 << 9))
> +         return false;
> +   } else if (row_pitch > (1 << 17)) {
> +      return false;
> +   }
> +
> +   *out_row_pitch = row_pitch;
> +   return true;
>  }
>
>  /**
> @@ -1275,8 +1296,10 @@ isl_surf_init_s(const struct isl_device *dev,
>     uint32_t pad_bytes;
>     isl_apply_surface_padding(dev, info, &tile_info, &total_h_el,
> &pad_bytes);
>
> -   const uint32_t row_pitch = isl_calc_row_pitch(dev, info, &tile_info,
> -                                                 dim_layout,
> &phys_slice0_sa);
> +   uint32_t row_pitch;
> +   if (!isl_calc_row_pitch(dev, info, &tile_info, dim_layout,
> +                           &phys_slice0_sa, &row_pitch))
> +      return false;
>
>     uint32_t size, base_alignment;
>     if (tiling == ISL_TILING_LINEAR) {
> --
> 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/a88f7c19/attachment.html>


More information about the mesa-dev mailing list