[Mesa-dev] [PATCH v2 17/35] isl: Add functions for computing surface offsets in samples

Pohjolainen, Topi topi.pohjolainen at intel.com
Wed Jul 27 18:32:09 UTC 2016


On Tue, Jul 26, 2016 at 03:02:08PM -0700, Jason Ekstrand wrote:
> ---
>  src/intel/isl/isl.c | 24 ++++++++++++------------
>  src/intel/isl/isl.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 60 insertions(+), 12 deletions(-)

This looks logical, I compared to isl_surf_get_image_offset_el/sa():

Reviewed-by: Topi Pohjolainen <topi.pohjolainen at intel.com>

> 
> diff --git a/src/intel/isl/isl.c b/src/intel/isl/isl.c
> index a713eeb..f65f9c8 100644
> --- a/src/intel/isl/isl.c
> +++ b/src/intel/isl/isl.c
> @@ -1475,13 +1475,13 @@ get_image_offset_sa_gen9_1d(const struct isl_surf *surf,
>   * @invariant logical_array_layer < logical array length of surface
>   * @invariant logical_z_offset_px < logical depth of surface at level
>   */
> -static void
> -get_image_offset_sa(const struct isl_surf *surf,
> -                    uint32_t level,
> -                    uint32_t logical_array_layer,
> -                    uint32_t logical_z_offset_px,
> -                    uint32_t *x_offset_sa,
> -                    uint32_t *y_offset_sa)
> +void
> +isl_surf_get_image_offset_sa(const struct isl_surf *surf,
> +                             uint32_t level,
> +                             uint32_t logical_array_layer,
> +                             uint32_t logical_z_offset_px,
> +                             uint32_t *x_offset_sa,
> +                             uint32_t *y_offset_sa)
>  {
>     assert(level < surf->levels);
>     assert(logical_array_layer < surf->logical_level0_px.array_len);
> @@ -1524,11 +1524,11 @@ isl_surf_get_image_offset_el(const struct isl_surf *surf,
>            < isl_minify(surf->logical_level0_px.depth, level));
>  
>     uint32_t x_offset_sa, y_offset_sa;
> -   get_image_offset_sa(surf, level,
> -                       logical_array_layer,
> -                       logical_z_offset_px,
> -                       &x_offset_sa,
> -                       &y_offset_sa);
> +   isl_surf_get_image_offset_sa(surf, level,
> +                                logical_array_layer,
> +                                logical_z_offset_px,
> +                                &x_offset_sa,
> +                                &y_offset_sa);
>  
>     *x_offset_el = x_offset_sa / fmtl->bw;
>     *y_offset_el = y_offset_sa / fmtl->bh;
> diff --git a/src/intel/isl/isl.h b/src/intel/isl/isl.h
> index d0bac5d..68ad8a4 100644
> --- a/src/intel/isl/isl.h
> +++ b/src/intel/isl/isl.h
> @@ -1323,6 +1323,22 @@ isl_surf_get_array_pitch(const struct isl_surf *surf)
>  }
>  
>  /**
> + * Calculate the offset, in units of surface samples, to a subimage in the
> + * surface.
> + *
> + * @invariant level < surface levels
> + * @invariant logical_array_layer < logical array length of surface
> + * @invariant logical_z_offset_px < logical depth of surface at level
> + */
> +void
> +isl_surf_get_image_offset_sa(const struct isl_surf *surf,
> +                             uint32_t level,
> +                             uint32_t logical_array_layer,
> +                             uint32_t logical_z_offset_px,
> +                             uint32_t *x_offset_sa,
> +                             uint32_t *y_offset_sa);
> +
> +/**
>   * Calculate the offset, in units of surface elements, to a subimage in the
>   * surface.
>   *
> @@ -1359,6 +1375,38 @@ isl_tiling_get_intratile_offset_el(const struct isl_device *dev,
>                                     uint32_t *x_offset_el,
>                                     uint32_t *y_offset_el);
>  
> +static inline void
> +isl_tiling_get_intratile_offset_sa(const struct isl_device *dev,
> +                                   enum isl_tiling tiling,
> +                                   enum isl_format format,
> +                                   uint32_t row_pitch,
> +                                   uint32_t total_x_offset_sa,
> +                                   uint32_t total_y_offset_sa,
> +                                   uint32_t *base_address_offset,
> +                                   uint32_t *x_offset_sa,
> +                                   uint32_t *y_offset_sa)
> +{
> +   const struct isl_format_layout *fmtl = isl_format_get_layout(format);
> +
> +   assert(fmtl->bpb % 8 == 0);
> +
> +   /* For computing the intratile offsets, we actually want a strange unit
> +    * which is samples for multisampled surfaces but elements for compressed
> +    * surfaces.
> +    */
> +   assert(total_x_offset_sa % fmtl->bw == 0);
> +   assert(total_y_offset_sa % fmtl->bw == 0);
> +   const uint32_t total_x_offset = total_x_offset_sa / fmtl->bw;
> +   const uint32_t total_y_offset = total_y_offset_sa / fmtl->bh;
> +
> +   isl_tiling_get_intratile_offset_el(dev, tiling, fmtl->bpb / 8, row_pitch,
> +                                      total_x_offset, total_y_offset,
> +                                      base_address_offset,
> +                                      x_offset_sa, y_offset_sa);
> +   *x_offset_sa *= fmtl->bw;
> +   *y_offset_sa *= fmtl->bh;
> +}
> +
>  /**
>   * @brief Get value of 3DSTATE_DEPTH_BUFFER.SurfaceFormat
>   *
> -- 
> 2.5.0.400.gff86faf
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list