<div dir="ltr"><div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 13, 2016 at 10:16 AM, Chad Versace <span dir="ltr"><<a href="mailto:chad.versace@intel.com" target="_blank">chad.versace@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="">On Sat 09 Jul 2016, Jason Ekstrand wrote:<br>
> ---<br>
>  src/intel/isl/isl.c                 | 32 ++++++++++++++++++++++++++++++++<br>
>  src/intel/isl/isl.h                 | 14 ++++++++++++++<br>
>  src/intel/isl/isl_format_layout.csv |  9 +++++++++<br>
>  src/intel/isl/isl_gen7.c            |  7 +++++++<br>
>  src/intel/isl/isl_gen8.c            | 13 +++++++++++++<br>
>  src/intel/isl/isl_gen9.c            | 12 ++++++++++++<br>
>  6 files changed, 87 insertions(+)<br>
><br>
> diff --git a/src/intel/isl/isl.c b/src/intel/isl/isl.c<br>
> index 9ccdea2..da9d3d4 100644<br>
> --- a/src/intel/isl/isl.c<br>
> +++ b/src/intel/isl/isl.c<br>
> @@ -177,6 +177,15 @@ isl_tiling_get_info(const struct isl_device *dev,<br>
>        phys_B = isl_extent2d(128, 32);<br>
>        break;<br>
><br>
> +   case ISL_TILING_CCS:<br>
> +      /* CCS surfaces are required to have one of the GENX_CCS_* formats which<br>
> +       * have a block size of 1 or 2 bits per block.<br>
<br>
</span>I'd like to see a comment here, similar to case ISL_TILING_HIZ, that<br>
states ISL_TILING_CCS is related to Y-tiling. Such a comment would<br>
immediately explain the magic numbers below.<br></blockquote><div><br></div><div>How about this:<br><br>      /* CCS surfaces are required to have one of the GENX_CCS_* formats which<br>       * have a block size of 1 or 2 bits per block and each CCS element<br>       * corresponds to one cache-line pair in the main surface.  From the Sky<br>       * Lake PRM Vol. 12 in the section on planes:<br>       *<br>       *    "The Color Control Surface (CCS) contains the compression status<br>       *    of the cache-line pairs. The compression state of the cache-line<br>       *    pair is specified by 2 bits in the CCS.  Each CCS cache-line<br>       *    represents an area on the main surface of 16x16 sets of 128 byte<br>       *    Y-tiled cache-line-pairs. CCS is always Y tiled."<br>       *<br>       * The CCS being Y-tiled implies that it's an 8x8 grid of cache-lines.<br>       * Since each cache line corresponds to a 16x16 set of cache-line pairs,<br>       * that yields total tile area of 128x128 cache-line pairs or CCS<br>       * elements.  On older hardware, each CCS element is 1 bit and the tile<br>       * is 128x256 elements.<br>       */<br><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<span class=""><br>
> +       */<br>
> +      assert(format_bpb == 1 || format_bpb == 2);<br>
> +      logical_el = isl_extent2d(128, 256 / format_bpb);<br>
> +      phys_B = isl_extent2d(128, 32);<br>
> +      break;<br>
> +<br>
>     default:<br>
>        unreachable("not reached");<br>
>     } /* end switch */<br>
<br>
<br>
<br>
</span><span class="">> @@ -844,6 +854,28 @@ isl_calc_array_pitch_el_rows(const struct isl_device *dev,<br>
>     assert(pitch_sa_rows % fmtl->bh == 0);<br>
>     uint32_t pitch_el_rows = pitch_sa_rows / fmtl->bh;<br>
><br>
> +   if (ISL_DEV_GEN(dev) >= 9 && fmtl->txc == ISL_TXC_CCS) {<br>
> +      /*<br>
> +       * From the Sky Lake PRM Vol 7, "MCS Buffer for Render Target(s)" (p. 632):<br>
> +       *<br>
> +       *    "Mip-mapped and arrayed surfaces are supported with MCS buffer<br>
> +       *    layout with these alignments in the RT space: Horizontal<br>
> +       *    Alignment = 128 and Vertical Alignment = 64."<br>
> +       *<br>
> +       * From the Sky Lake PRM Vol. 2d, "RENDER_SURFACE_STATE" (p. 435):<br>
> +       *<br>
> +       *    "For non-multisampled render target's CCS auxiliary surface,<br>
> +       *    QPitch must be computed with Horizontal Alignment = 128 and<br>
> +       *    Surface Vertical Alignment = 256. These alignments are only for<br>
> +       *    CCS buffer and not for associated render target."<br>
> +       *<br>
> +       * The alignment in the second PRM quotation only applies to the qpitch<br>
> +       * so it needs to be applied here.<br>
> +       */<br>
<br>
</span>I have a comment about the first restriction (HorizontalAlignment=64 and<br>
VerticalAlignment=64). The code snippet below implicitly satisfies the<br>
first restriction, and it would be good to explicitly call that out.<br></blockquote><div><br></div><div>I'm not sure what you mean.  Maybe something like this?<br><br></div><div>The first restriction is already handled by isl_choose_image_alignment_el but the second restriction, which is an extension of the first, only applies to qpitch and must be applied here.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<span class=""><br>
> +      assert(fmtl->bh == 4);<br>
> +      pitch_el_rows = isl_align(pitch_el_rows, 256 / 4);<br>
> +   }<br>
> +<br>
>     if (ISL_DEV_GEN(dev) >= 9 &&<br>
>         info->dim == ISL_SURF_DIM_3D &&<br>
>         tile_info->tiling != ISL_TILING_LINEAR) {<br>
> diff --git a/src/intel/isl/isl.h b/src/intel/isl/isl.h<br>
> index 598ed2c..0ea19d1 100644<br>
> --- a/src/intel/isl/isl.h<br>
> +++ b/src/intel/isl/isl.h<br>
> @@ -356,6 +356,15 @@ enum isl_format {<br>
>     ISL_FORMAT_MCS_4X,<br>
>     ISL_FORMAT_MCS_8X,<br>
>     ISL_FORMAT_MCS_16X,<br>
> +   ISL_FORMAT_GEN7_CCS_32BPP_X,<br>
> +   ISL_FORMAT_GEN7_CCS_64BPP_X,<br>
> +   ISL_FORMAT_GEN7_CCS_128BPP_X,<br>
> +   ISL_FORMAT_GEN7_CCS_32BPP_Y,<br>
> +   ISL_FORMAT_GEN7_CCS_64BPP_Y,<br>
> +   ISL_FORMAT_GEN7_CCS_128BPP_Y,<br>
> +   ISL_FORMAT_GEN9_CCS_32BPP,<br>
> +   ISL_FORMAT_GEN9_CCS_64BPP,<br>
> +   ISL_FORMAT_GEN9_CCS_128BPP,<br>
<br>
</span>The format names look good.<br>
<span class=""><br>
> @@ -989,6 +1002,7 @@ isl_format_has_bc_compression(enum isl_format fmt)<br>
><br>
>     case ISL_TXC_HIZ:<br>
>     case ISL_TXC_MCS:<br>
> +   case ISL_TXC_CCS:<br>
>        unreachable("Should not be called on an aux surface");<br>
>     }<br>
><br>
> diff --git a/src/intel/isl/isl_format_layout.csv b/src/intel/isl/isl_format_layout.csv<br>
> index 972d50f..f0f31c7 100644<br>
> --- a/src/intel/isl/isl_format_layout.csv<br>
> +++ b/src/intel/isl/isl_format_layout.csv<br>
> @@ -319,3 +319,12 @@ MCS_2X                      ,   8,  1,  1,  1,     ,     ,     ,     ,     ,<br>
>  MCS_4X                      ,   8,  1,  1,  1,     ,     ,     ,     ,     ,     ,    ,       ,   mcs<br>
>  MCS_8X                      ,  32,  1,  1,  1,     ,     ,     ,     ,     ,     ,    ,       ,   mcs<br>
>  MCS_16X                     ,  64,  1,  1,  1,     ,     ,     ,     ,     ,     ,    ,       ,   mcs<br>
> +GEN7_CCS_32BPP_X            ,   1, 16,  2,  1,     ,     ,     ,     ,     ,     ,    ,       ,   ccs<br>
> +GEN7_CCS_64BPP_X            ,   1,  8,  2,  1,     ,     ,     ,     ,     ,     ,    ,       ,   ccs<br>
> +GEN7_CCS_128BPP_X           ,   1,  4,  2,  1,     ,     ,     ,     ,     ,     ,    ,       ,   ccs<br>
> +GEN7_CCS_32BPP_Y            ,   1,  8,  4,  1,     ,     ,     ,     ,     ,     ,    ,       ,   ccs<br>
> +GEN7_CCS_64BPP_Y            ,   1,  4,  4,  1,     ,     ,     ,     ,     ,     ,    ,       ,   ccs<br>
> +GEN7_CCS_128BPP_Y           ,   1,  2,  4,  1,     ,     ,     ,     ,     ,     ,    ,       ,   ccs<br>
> +GEN9_CCS_32BPP              ,   2,  8,  4,  1,     ,     ,     ,     ,     ,     ,    ,       ,   ccs<br>
> +GEN9_CCS_64BPP              ,   2,  4,  4,  1,     ,     ,     ,     ,     ,     ,    ,       ,   ccs<br>
> +GEN9_CCS_128BPP             ,   2,  2,  4,  1,     ,     ,     ,     ,     ,     ,    ,       ,   ccs<br>
<br>
</span>The block dimensions look right to me.<br>
<span class=""><br>
> diff --git a/src/intel/isl/isl_gen7.c b/src/intel/isl/isl_gen7.c<br>
> index 4b511c8..1c31d98 100644<br>
> --- a/src/intel/isl/isl_gen7.c<br>
> +++ b/src/intel/isl/isl_gen7.c<br>
> @@ -242,6 +242,13 @@ gen7_filter_tiling(const struct isl_device *dev,<br>
>     if (isl_format_get_layout(info->format)->txc == ISL_TXC_MCS)<br>
>        *flags &= ISL_TILING_Y0_BIT;<br>
><br>
> +   /* The CCS formats and tiling always go together */<br>
> +   if (isl_format_get_layout(info->format)->txc == ISL_TXC_CCS) {<br>
> +      *flags &= ISL_TILING_CCS_BIT;<br>
> +   } else {<br>
> +      *flags &= ~ISL_TILING_CCS_BIT;<br>
> +   }<br>
> +<br>
>     if (info->usage & (ISL_SURF_USAGE_DISPLAY_ROTATE_90_BIT |<br>
>                        ISL_SURF_USAGE_DISPLAY_ROTATE_180_BIT |<br>
>                        ISL_SURF_USAGE_DISPLAY_ROTATE_270_BIT)) {<br>
<br>
</span>I expected to this patch to make changes to<br>
gen7_choose_image_alignment_el(). Why is that missing? Does gen7 not<br>
impose special alignment restrictions on the CCS?<br></blockquote><div><br></div><div>gen7 doesn't allow CCS for multi-LOD or multi-slice images so it doesn't matter.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div><div class="h5"><br>
> diff --git a/src/intel/isl/isl_gen8.c b/src/intel/isl/isl_gen8.c<br>
> index 62c331c..ec40d6d 100644<br>
> --- a/src/intel/isl/isl_gen8.c<br>
> +++ b/src/intel/isl/isl_gen8.c<br>
> @@ -201,6 +201,19 @@ gen8_choose_image_alignment_el(const struct isl_device *dev,<br>
>  {<br>
>     assert(!isl_tiling_is_std_y(tiling));<br>
><br>
> +   const struct isl_format_layout *fmtl = isl_format_get_layout(info->format);<br>
> +   if (fmtl->txc == ISL_TXC_CCS) {<br>
> +      /*<br>
> +       * Broadwell PRM Vol 7, "MCS Buffer for Render Target(s)" (p. 676):<br>
> +       *<br>
> +       *    "Mip-mapped and arrayed surfaces are supported with MCS buffer<br>
> +       *    layout with these alignments in the RT space: Horizontal<br>
> +       *    Alignment = 256 and Vertical Alignment = 128.<br>
> +       */<br>
> +      *image_align_el = isl_extent3d(256 / fmtl->bw, 128 / fmtl->bh, 1);<br>
> +      return;<br>
> +   }<br>
> +<br>
>     /* The below text from the Broadwell PRM provides some insight into the<br>
>      * hardware's requirements for LOD alignment.  From the Broadwell PRM >><br>
>      * Volume 5: Memory Views >> Surface Layout >> 2D Surfaces:<br>
> diff --git a/src/intel/isl/isl_gen9.c b/src/intel/isl/isl_gen9.c<br>
> index 39f4092..bb7f298 100644<br>
> --- a/src/intel/isl/isl_gen9.c<br>
> +++ b/src/intel/isl/isl_gen9.c<br>
> @@ -103,6 +103,18 @@ gen9_choose_image_alignment_el(const struct isl_device *dev,<br>
>                                 enum isl_msaa_layout msaa_layout,<br>
>                                 struct isl_extent3d *image_align_el)<br>
>  {<br>
> +   const struct isl_format_layout *fmtl = isl_format_get_layout(info->format);<br>
> +   if (fmtl->txc == ISL_TXC_CCS) {<br>
> +      /* Sky Lake PRM Vol. 7, "MCS Buffer for Render Target(s)" (p. 632):<br>
> +       *<br>
> +       *    "Mip-mapped and arrayed surfaces are supported with MCS buffer<br>
> +       *    layout with these alignments in the RT space: Horizontal<br>
> +       *    Alignment = 128 and Vertical Alignment = 64."<br>
> +       */<br>
> +      *image_align_el = isl_extent3d(128 / fmtl->bw, 64 / fmtl->bh, 1);<br>
> +      return;<br>
> +   }<br>
> +<br>
>     /* This BSpec text provides some insight into the hardware's alignment<br>
>      * requirements [Skylake BSpec > Memory Views > Common Surface Formats ><br>
>      * Surface Layout and Tiling > 2D Surfaces]:<br>
> --<br>
> 2.5.0.400.gff86faf<br>
><br>
</div></div>> _______________________________________________<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/mailman/listinfo/mesa-dev</a><br>
</blockquote></div><br></div></div></div>