<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Feb 27, 2018 at 4:33 AM, Pohjolainen, Topi <span dir="ltr"><<a href="mailto:topi.pohjolainen@gmail.com" target="_blank">topi.pohjolainen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Thu, Feb 22, 2018 at 11:06:45PM -0800, Jason Ekstrand wrote:<br>
> With Yf and Ys tiling, everything is actually four dimensional because<br>
> we can have multiple depth or multisampled array slices in the same<br>
> tile.  This commit just enhances the calculations so they can handle it.<br>
> ---<br>
>  src/intel/isl/isl.c | 71 ++++++++++++++++++++++++++++++<wbr>+++++++++--------------<br>
>  1 file changed, 53 insertions(+), 18 deletions(-)<br>
><br>
> diff --git a/src/intel/isl/isl.c b/src/intel/isl/isl.c<br>
> index 5bdc726..46aff46 100644<br>
> --- a/src/intel/isl/isl.c<br>
> +++ b/src/intel/isl/isl.c<br>
> @@ -988,7 +988,7 @@ isl_calc_phys_total_extent_el_<wbr>gen4_2d(<br>
>        const struct isl_extent4d *phys_level0_sa,<br>
>        enum isl_array_pitch_span array_pitch_span,<br>
>        uint32_t *array_pitch_el_rows,<br>
> -      struct isl_extent2d *total_extent_el)<br>
> +      struct isl_extent4d *phys_total_el)<br>
>  {<br>
>     const struct isl_format_layout *fmtl = isl_format_get_layout(info-><wbr>format);<br>
><br>
> @@ -1001,10 +1001,12 @@ isl_calc_phys_total_extent_el_<wbr>gen4_2d(<br>
>                                             image_align_sa, phys_level0_sa,<br>
>                                             array_pitch_span,<br>
>                                             &phys_slice0_sa);<br>
> -   *total_extent_el = (struct isl_extent2d) {<br>
> +   *phys_total_el = (struct isl_extent4d) {<br>
>        .w = isl_assert_div(phys_slice0_sa.<wbr>w, fmtl->bw),<br>
>        .h = *array_pitch_el_rows * (phys_level0_sa->array_len - 1) +<br>
>             isl_assert_div(phys_slice0_sa.<wbr>h, fmtl->bh),<br>
> +      .d = 1,<br>
> +      .a = 1,<br>
>     };<br>
>  }<br>
><br>
> @@ -1019,7 +1021,7 @@ isl_calc_phys_total_extent_el_<wbr>gen4_3d(<br>
>        const struct isl_extent3d *image_align_sa,<br>
>        const struct isl_extent4d *phys_level0_sa,<br>
>        uint32_t *array_pitch_el_rows,<br>
> -      struct isl_extent2d *phys_total_el)<br>
> +      struct isl_extent4d *phys_total_el)<br>
>  {<br>
>     const struct isl_format_layout *fmtl = isl_format_get_layout(info-><wbr>format);<br>
><br>
> @@ -1066,9 +1068,11 @@ isl_calc_phys_total_extent_el_<wbr>gen4_3d(<br>
>      */<br>
>     *array_pitch_el_rows =<br>
>        isl_align_npot(phys_level0_sa-<wbr>>h, image_align_sa->h) / fmtl->bw;<br>
> -   *phys_total_el = (struct isl_extent2d) {<br>
> +   *phys_total_el = (struct isl_extent4d) {<br>
>        .w = isl_assert_div(total_w, fmtl->bw),<br>
>        .h = isl_assert_div(total_h, fmtl->bh),<br>
> +      .d = 1,<br>
> +      .a = 1,<br>
>     };<br>
>  }<br>
><br>
> @@ -1084,7 +1088,7 @@ isl_calc_phys_total_extent_el_<wbr>gen6_stencil_hiz(<br>
>        const struct isl_extent3d *image_align_sa,<br>
>        const struct isl_extent4d *phys_level0_sa,<br>
>        uint32_t *array_pitch_el_rows,<br>
> -      struct isl_extent2d *phys_total_el)<br>
> +      struct isl_extent4d *phys_total_el)<br>
>  {<br>
>     const struct isl_format_layout *fmtl = isl_format_get_layout(info-><wbr>format);<br>
><br>
> @@ -1127,9 +1131,11 @@ isl_calc_phys_total_extent_el_<wbr>gen6_stencil_hiz(<br>
><br>
>     *array_pitch_el_rows =<br>
>        isl_assert_div(isl_align(H0, image_align_sa->h), fmtl->bh);<br>
> -   *phys_total_el = (struct isl_extent2d) {<br>
> +   *phys_total_el = (struct isl_extent4d) {<br>
>        .w = isl_assert_div(MAX(total_top_<wbr>w, total_bottom_w), fmtl->bw),<br>
>        .h = isl_assert_div(total_h, fmtl->bh),<br>
> +      .d = 1,<br>
> +      .a = 1,<br>
>     };<br>
>  }<br>
><br>
> @@ -1144,7 +1150,7 @@ isl_calc_phys_total_extent_el_<wbr>gen9_1d(<br>
>        const struct isl_extent3d *image_align_sa,<br>
>        const struct isl_extent4d *phys_level0_sa,<br>
>        uint32_t *array_pitch_el_rows,<br>
> -      struct isl_extent2d *phys_total_el)<br>
> +      struct isl_extent4d *phys_total_el)<br>
>  {<br>
>     MAYBE_UNUSED const struct isl_format_layout *fmtl = isl_format_get_layout(info-><wbr>format);<br>
><br>
> @@ -1164,9 +1170,11 @@ isl_calc_phys_total_extent_el_<wbr>gen9_1d(<br>
>     }<br>
><br>
>     *array_pitch_el_rows = 1;<br>
> -   *phys_total_el = (struct isl_extent2d) {<br>
> +   *phys_total_el = (struct isl_extent4d) {<br>
>        .w = isl_assert_div(slice_w, fmtl->bw),<br>
>        .h = phys_level0_sa->array_len,<br>
> +      .d = 1,<br>
> +      .a = 1,<br>
>     };<br>
>  }<br>
><br>
> @@ -1184,7 +1192,7 @@ isl_calc_phys_total_extent_el(<wbr>const struct isl_device *dev,<br>
>                                const struct isl_extent4d *phys_level0_sa,<br>
>                                enum isl_array_pitch_span array_pitch_span,<br>
>                                uint32_t *array_pitch_el_rows,<br>
> -                              struct isl_extent2d *total_extent_el)<br>
> +                              struct isl_extent4d *phys_total_el)<br>
>  {<br>
>     switch (dim_layout) {<br>
>     case ISL_DIM_LAYOUT_GEN9_1D:<br>
> @@ -1192,14 +1200,14 @@ isl_calc_phys_total_extent_el(<wbr>const struct isl_device *dev,<br>
>        isl_calc_phys_total_extent_el_<wbr>gen9_1d(dev, info,<br>
>                                              image_align_sa, phys_level0_sa,<br>
>                                              array_pitch_el_rows,<br>
> -                                            total_extent_el);<br>
> +                                            phys_total_el);<br>
>        return;<br>
>     case ISL_DIM_LAYOUT_GEN4_2D:<br>
>        isl_calc_phys_total_extent_el_<wbr>gen4_2d(dev, info, tile_info, msaa_layout,<br>
>                                              image_align_sa, phys_level0_sa,<br>
>                                              array_pitch_span,<br>
>                                              array_pitch_el_rows,<br>
> -                                            total_extent_el);<br>
> +                                            phys_total_el);<br>
>        return;<br>
>     case ISL_DIM_LAYOUT_GEN6_STENCIL_<wbr>HIZ:<br>
>        assert(array_pitch_span == ISL_ARRAY_PITCH_SPAN_COMPACT);<br>
> @@ -1207,14 +1215,14 @@ isl_calc_phys_total_extent_el(<wbr>const struct isl_device *dev,<br>
>                                                       image_align_sa,<br>
>                                                       phys_level0_sa,<br>
>                                                       array_pitch_el_rows,<br>
> -                                                     total_extent_el);<br>
> +                                                     phys_total_el);<br>
>        return;<br>
>     case ISL_DIM_LAYOUT_GEN4_3D:<br>
>        assert(array_pitch_span == ISL_ARRAY_PITCH_SPAN_COMPACT);<br>
>        isl_calc_phys_total_extent_el_<wbr>gen4_3d(dev, info,<br>
>                                              image_align_sa, phys_level0_sa,<br>
>                                              array_pitch_el_rows,<br>
> -                                            total_extent_el);<br>
> +                                            phys_total_el);<br>
>        return;<br>
>     }<br>
>  }<br>
> @@ -1257,7 +1265,7 @@ isl_calc_row_pitch_alignment(<wbr>const struct isl_surf_init_info *surf_info,<br>
>  static uint32_t<br>
>  isl_calc_linear_min_row_pitch(<wbr>const struct isl_device *dev,<br>
>                                const struct isl_surf_init_info *info,<br>
> -                              const struct isl_extent2d *phys_total_el,<br>
> +                              const struct isl_extent4d *phys_total_el,<br>
>                                uint32_t alignment)<br>
>  {<br>
>     const struct isl_format_layout *fmtl = isl_format_get_layout(info-><wbr>format);<br>
> @@ -1270,7 +1278,7 @@ static uint32_t<br>
>  isl_calc_tiled_min_row_pitch(<wbr>const struct isl_device *dev,<br>
>                               const struct isl_surf_init_info *surf_info,<br>
>                               const struct isl_tile_info *tile_info,<br>
> -                             const struct isl_extent2d *phys_total_el,<br>
> +                             const struct isl_extent4d *phys_total_el,<br>
>                               uint32_t alignment)<br>
>  {<br>
>     const struct isl_format_layout *fmtl = isl_format_get_layout(surf_<wbr>info->format);<br>
> @@ -1290,7 +1298,7 @@ static uint32_t<br>
>  isl_calc_min_row_pitch(const struct isl_device *dev,<br>
>                         const struct isl_surf_init_info *surf_info,<br>
>                         const struct isl_tile_info *tile_info,<br>
> -                       const struct isl_extent2d *phys_total_el,<br>
> +                       const struct isl_extent4d *phys_total_el,<br>
>                         uint32_t alignment)<br>
>  {<br>
>     if (tile_info->tiling == ISL_TILING_LINEAR) {<br>
> @@ -1323,7 +1331,7 @@ isl_calc_row_pitch(const struct isl_device *dev,<br>
>                     const struct isl_surf_init_info *surf_info,<br>
>                     const struct isl_tile_info *tile_info,<br>
>                     enum isl_dim_layout dim_layout,<br>
> -                   const struct isl_extent2d *phys_total_el,<br>
> +                   const struct isl_extent4d *phys_total_el,<br>
>                     uint32_t *out_row_pitch)<br>
>  {<br>
>     uint32_t alignment =<br>
> @@ -1446,7 +1454,7 @@ isl_surf_init_s(const struct isl_device *dev,<br>
>        isl_choose_array_pitch_span(<wbr>dev, info, dim_layout, &phys_level0_sa);<br>
><br>
>     uint32_t array_pitch_el_rows;<br>
> -   struct isl_extent2d phys_total_el;<br>
> +   struct isl_extent4d phys_total_el;<br>
>     isl_calc_phys_total_extent_el(<wbr>dev, info, &tile_info,<br>
>                                   dim_layout, msaa_layout,<br>
>                                   &image_align_sa, &phys_level0_sa,<br>
> @@ -1461,6 +1469,9 @@ isl_surf_init_s(const struct isl_device *dev,<br>
>     uint32_t base_alignment;<br>
>     uint64_t size;<br>
>     if (tiling == ISL_TILING_LINEAR) {<br>
> +      /* LINEAR tiling has no concept of intra-tile arrays */<br>
> +      assert(phys_total_el.d == 1 && phys_total_el.a == 1);<br>
> +<br>
>        size = (uint64_t) row_pitch * phys_total_el.h;<br>
><br>
>        /* From the Broadwell PRM Vol 2d, RENDER_SURFACE_STATE::<wbr>SurfaceBaseAddress:<br>
> @@ -1482,7 +1493,31 @@ isl_surf_init_s(const struct isl_device *dev,<br>
>        }<br>
>        base_alignment = isl_round_up_to_power_of_two(<wbr>base_alignment);<br>
>     } else {<br>
> +      /* Pitches must make sense with the tiling */<br>
> +      assert(row_pitch % tile_info.phys_extent_B.width == 0);<br>
> +      assert(array_pitch_el_rows % tile_info.logical_extent_el.d == 0);<br>
> +      assert(array_pitch_el_rows % tile_info.logical_extent_el.a == 0);<br>
> +<br>
> +      uint32_t array_slices;<br>
> +      if (phys_total_el.d > 1) {<br>
> +         assert(phys_total_el.a == 1);<br>
> +         array_slices = isl_align_div(phys_total_el.d,<br>
> +                                      tile_info.logical_extent_el.d)<wbr>;<br>
> +      } else if (phys_total_el.a > 1) {<br>
> +         assert(phys_total_el.d == 1);<br>
> +         array_slices = isl_align_div(phys_total_el.a,<br>
> +                                      tile_info.logical_extent_el.a)<wbr>;<br>
> +      } else {<br>
> +         assert(phys_total_el.d == 1 && phys_total_el.a == 1);<br>
> +         array_slices = 1;<br>
> +      }<br>
> +<br>
> +      uint32_t array_pitch_tl_rows =<br>
> +         array_pitch_el_rows / MAX2(tile_info.logical_extent_<wbr>el.d,<br>
> +                                    tile_info.logical_extent_el.a)<wbr>;<br>
> +<br>
>        const uint32_t total_h_tl =<br>
> +         (array_slices - 1) * array_pitch_tl_rows +<br>
<br>
</div></div>I probably need to read further to understand the subtraction of one, and why<br>
we use "array_slices == 1" for the case where "phys_total_el.d == 1 &&<br>
phys_total_el.a == 1".</blockquote><div><br></div><div>It's because the array stride is used to get us to the last slice and the bit below with phys_total_el.h is used to get us to the toal height.  This lets us avoid aligning the total height to the array stride in the case where it's overly large.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Patches 1-4 are:<br>
<br>
Reviewed-by: Topi Pohjolainen <<a href="mailto:topi.pohjolainen@intel.com">topi.pohjolainen@intel.com</a>><span class=""><br></span></blockquote><div><br></div><div>Thanks!<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
>           isl_align_div(phys_total_el.h, tile_info.logical_extent_el.<wbr>height);<br>
><br>
>        size = (uint64_t) total_h_tl * tile_info.phys_extent_B.height * row_pitch;<br>
> --<br>
> 2.5.0.400.gff86faf<br>
><br>
</span>> ______________________________<wbr>_________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</blockquote></div><br></div></div>