<div dir="ltr">Better commit message:<br><br>    Re-enable regular fast-clears (CCS_D) on gen9+<br>    <br>    This reverts commit ee57b15ec764736e2d5360beaef9fb2045ed0f68, "i965:<br>    Disable regular fast-clears (CCS_D) on gen9+".  How taht we've fixed the<br>    issue with too many different aux usages in the render cache, it should<br>    be safe to re-enable CCS_D for sRGB.<br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 13, 2017 at 5:52 PM, Jason Ekstrand <span dir="ltr"><<a href="mailto:jason@jlekstrand.net" target="_blank">jason@jlekstrand.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This reverts commit ee57b15ec764736e2d5360beaef9fb<wbr>2045ed0f68.<br>
<br>
Cc: "17.3" <<a href="mailto:mesa-stable@lists.freedesktop.org">mesa-stable@lists.<wbr>freedesktop.org</a>><br>
---<br>
 src/mesa/drivers/dri/i965/brw_<wbr>meta_util.c     | 10 -----<br>
 src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c | 57 ++++++++++++---------------<br>
 2 files changed, 25 insertions(+), 42 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>brw_meta_util.c b/src/mesa/drivers/dri/i965/<wbr>brw_meta_util.c<br>
index 54dc6a5..b311815 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>brw_meta_util.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>brw_meta_util.c<br>
@@ -293,17 +293,7 @@ brw_is_color_fast_clear_<wbr>compatible(struct brw_context *brw,<br>
        brw->mesa_to_isl_render_<wbr>format[mt->format])<br>
       return false;<br>
<br>
-   /* Gen9 doesn't support fast clear on single-sampled SRGB buffers. When<br>
-    * GL_FRAMEBUFFER_SRGB is enabled any color renderbuffers will be<br>
-    * resolved in intel_update_state. In that case it's pointless to do a<br>
-    * fast clear because it's very likely to be immediately resolved.<br>
-    */<br>
    const bool srgb_rb = _mesa_get_srgb_format_linear(<wbr>mt->format) != mt->format;<br>
-   if (devinfo->gen >= 9 &&<br>
-       mt->surf.samples == 1 &&<br>
-       ctx->Color.sRGBEnabled && srgb_rb)<br>
-      return false;<br>
-<br>
   /* Gen10 doesn't automatically decode the clear color of sRGB buffers. Since<br>
    * we currently don't perform this decode in software, avoid a fast-clear<br>
    * altogether. TODO: Do this in software.<br>
diff --git a/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c b/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c<br>
index c1a4ce1..b87d356 100644<br>
--- a/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c<br>
+++ b/src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c<br>
@@ -207,13 +207,7 @@ intel_miptree_supports_ccs(<wbr>struct brw_context *brw,<br>
    if (!brw->mesa_format_supports_<wbr>render[mt->format])<br>
       return false;<br>
<br>
-   if (devinfo->gen >= 9) {<br>
-      mesa_format linear_format = _mesa_get_srgb_format_linear(<wbr>mt->format);<br>
-      const enum isl_format isl_format =<br>
-         brw_isl_format_for_mesa_<wbr>format(linear_format);<br>
-      return isl_format_supports_ccs_e(&<wbr>brw->screen->devinfo, isl_format);<br>
-   } else<br>
-      return true;<br>
+   return true;<br>
 }<br>
<br>
 static bool<br>
@@ -256,7 +250,7 @@ intel_miptree_supports_hiz(<wbr>const struct brw_context *brw,<br>
  * our HW tends to support more linear formats than sRGB ones, we use this<br>
  * format variant for check for CCS_E compatibility.<br>
  */<br>
-MAYBE_UNUSED static bool<br>
+static bool<br>
 format_ccs_e_compat_with_<wbr>miptree(const struct gen_device_info *devinfo,<br>
                                  const struct intel_mipmap_tree *mt,<br>
                                  enum isl_format access_format)<br>
@@ -290,12 +284,13 @@ intel_miptree_supports_ccs_e(<wbr>struct brw_context *brw,<br>
    if (!intel_miptree_supports_ccs(<wbr>brw, mt))<br>
       return false;<br>
<br>
-   /* Fast clear can be also used to clear srgb surfaces by using equivalent<br>
-    * linear format. This trick, however, can't be extended to be used with<br>
-    * lossless compression and therefore a check is needed to see if the format<br>
-    * really is linear.<br>
+   /* Many window system buffers are sRGB even if they are never rendered as<br>
+    * sRGB.  For those, we want CCS_E for when sRGBEncode is false.  When the<br>
+    * surface is used as sRGB, we fall back to CCS_D.<br>
     */<br>
-   return _mesa_get_srgb_format_linear(<wbr>mt->format) == mt->format;<br>
+   mesa_format linear_format = _mesa_get_srgb_format_linear(<wbr>mt->format);<br>
+   enum isl_format isl_format = brw_isl_format_for_mesa_<wbr>format(linear_format);<br>
+   return isl_format_supports_ccs_e(&<wbr>brw->screen->devinfo, isl_format);<br>
 }<br>
<br>
 /**<br>
@@ -2686,29 +2681,27 @@ intel_miptree_render_aux_<wbr>usage(struct brw_context *brw,<br>
       return ISL_AUX_USAGE_MCS;<br>
<br>
    case ISL_AUX_USAGE_CCS_D:<br>
-      /* If FRAMEBUFFER_SRGB is used on Gen9+ then we need to resolve any of<br>
-       * the single-sampled color renderbuffers because the CCS buffer isn't<br>
-       * supported for SRGB formats. This only matters if FRAMEBUFFER_SRGB is<br>
-       * enabled because otherwise the surface state will be programmed with<br>
-       * the linear equivalent format anyway.<br>
-       */<br>
-      if (isl_format_is_srgb(render_<wbr>format) &&<br>
-          _mesa_get_srgb_format_linear(<wbr>mt->format) != mt->format) {<br>
-         return ISL_AUX_USAGE_NONE;<br>
-      } else if (!mt->mcs_buf) {<br>
-         return ISL_AUX_USAGE_NONE;<br>
-      } else {<br>
-         return ISL_AUX_USAGE_CCS_D;<br>
-      }<br>
+      return mt->mcs_buf ? ISL_AUX_USAGE_CCS_D : ISL_AUX_USAGE_NONE;<br>
<br>
    case ISL_AUX_USAGE_CCS_E: {<br>
-      /* Lossless compression is not supported for SRGB formats, it<br>
-       * should be impossible to get here with such surfaces.<br>
+      /* If the format supports CCS_E and is compatible with the miptree,<br>
+       * then we can use it.<br>
        */<br>
-      assert(!isl_format_is_srgb(<wbr>render_format) ||<br>
-             _mesa_get_srgb_format_linear(<wbr>mt->format) == mt->format);<br>
+      if (format_ccs_e_compat_with_<wbr>miptree(&brw->screen->devinfo,<br>
+                                           mt, render_format))<br>
+         return ISL_AUX_USAGE_CCS_E;<br>
+<br>
+      /* Otherwise, we have to fall back to CCS_D */<br>
+<br>
+      /* gen9 hardware technically supports non-0/1 clear colors with sRGB<br>
+       * formats.  However, there are issues with blending where it doesn't<br>
+       * properly apply the sRGB curve to the clear color when blending.<br>
+       */<br>
+      if (blend_enabled && isl_format_is_srgb(render_<wbr>format) &&<br>
+          !isl_color_value_is_zero_one(<wbr>mt->fast_clear_color, render_format))<br>
+         return ISL_AUX_USAGE_NONE;<br>
<br>
-      return ISL_AUX_USAGE_CCS_E;<br>
+      return ISL_AUX_USAGE_CCS_D;<br>
    }<br>
<br>
    default:<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.5.0.400.gff86faf<br>
<br>
</font></span></blockquote></div><br></div>