<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Oct 27, 2017 at 12:24 PM, Nanley Chery <span dir="ltr"><<a href="mailto:nanleychery@gmail.com" target="_blank">nanleychery@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Only use CCS_E to render to a texture that is CCS_E-compatible with the<br>
original texture's miptree (linear) format. This prevents render<br>
operations from writing data that can't be decoded with the original<br>
miptree format.<br>
<br>
On Gen10, with the new CCS_E-enabled formats handled, this enables the<br>
driver to pass the arb_texture_view-rendering-<wbr>formats piglit test.<br>
<br>
Cc: <<a href="mailto:mesa-stable@lists.freedesktop.org">mesa-stable@lists.<wbr>freedesktop.org</a>><br>
Signed-off-by: Nanley Chery <<a href="mailto:nanley.g.chery@intel.com">nanley.g.chery@intel.com</a>><br>
---<br>
 src/mesa/drivers/dri/i965/<wbr>intel_mipmap_tree.c | 28 +++++++++++++++++++++++++--<br>
 1 file changed, 26 insertions(+), 2 deletions(-)<br>
<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 a850f4d17b..59c57c227b 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>
@@ -241,6 +241,27 @@ intel_miptree_supports_hiz(<wbr>const struct brw_context *brw,<br>
    }<br>
 }<br>
<br>
+/**<br>
+ * Return true if the format that will be used to access the miptree is<br>
+ * CCS_E-compatible with the miptree's linear/non-sRGB format.<br>
+ *<br>
+ * Why use the linear format? Well, although the miptree may be specified with<br>
+ * an sRGB format, the usage of that color space/format can be toggled. Since<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>
+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>
+{<br>
+   assert(mt->aux_usage == ISL_AUX_USAGE_CCS_E);<br>
+<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_formats_are_ccs_e_<wbr>compatible(devinfo, isl_format, access_format);<br>
+}<br>
+<br>
 static bool<br>
 intel_miptree_supports_ccs_e(<wbr>struct brw_context *brw,<br>
                              const struct intel_mipmap_tree *mt)<br>
@@ -2662,8 +2683,11 @@ intel_miptree_render_aux_<wbr>usage(struct brw_context *brw,<br>
       return mt->mcs_buf ? ISL_AUX_USAGE_CCS_D : ISL_AUX_USAGE_NONE;<br>
<br>
    case ISL_AUX_USAGE_CCS_E: {<br>
-      /* If the format supports CCS_E, then we can just use it */<br>
-      if (isl_format_supports_ccs_e(&<wbr>brw->screen->devinfo, render_format))<br>
+      /* If the format supports CCS_E and is compatible with the miptree,<br>
+       * then we can use it.<br>
+       */<br>
+      if (format_ccs_e_compat_with_<wbr>miptree(&brw->screen->devinfo,<br>
+                                           mt, render_format))<br></blockquote><div><br></div><div>You don't need the helper if you just use mt->surf.format.  That's what can_texture_with_ccs does.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
          return ISL_AUX_USAGE_CCS_E;<br>
<br>
       /* Otherwise, we have to fall back to CCS_D */<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.14.3<br>
<br>
______________________________<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>
</font></span></blockquote></div><br></div></div>