<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sat, Dec 16, 2017 at 3:07 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"><div class="HOEnZb"><div class="h5">On December 16, 2017 14:35:29 Nanley Chery <<a href="mailto:nanleychery@gmail.com" target="_blank">nanleychery@gmail.com</a>> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Wed, Dec 13, 2017 at 05:52:03PM -0800, Jason Ekstrand 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" target="_blank">mesa-stable@lists.freedesktop<wbr>.org</a>><br>
---<br>
src/mesa/drivers/dri/i965/<wbr>brw_meta_util.c | 10 -----<br>
src/mesa/drivers/dri/i965/int<wbr>el_mipmap_tree.c | 57 ++++++++++++---------------<br>
2 files changed, 25 insertions(+), 42 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/i965/br<wbr>w_meta_util.c b/src/mesa/drivers/dri/i965/br<wbr>w_meta_util.c<br>
index 54dc6a5..b311815 100644<br>
--- a/src/mesa/drivers/dri/i965/br<wbr>w_meta_util.c<br>
+++ b/src/mesa/drivers/dri/i965/br<wbr>w_meta_util.c<br>
@@ -293,17 +293,7 @@ brw_is_color_fast_clear_compat<wbr>ible(struct brw_context *brw,<br>
brw->mesa_to_isl_render_format<wbr>[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(m<wbr>t->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/in<wbr>tel_mipmap_tree.c b/src/mesa/drivers/dri/i965/in<wbr>tel_mipmap_tree.c<br>
index c1a4ce1..b87d356 100644<br>
--- a/src/mesa/drivers/dri/i965/in<wbr>tel_mipmap_tree.c<br>
+++ b/src/mesa/drivers/dri/i965/in<wbr>tel_mipmap_tree.c<br>
@@ -207,13 +207,7 @@ intel_miptree_supports_ccs(str<wbr>uct brw_context *brw,<br>
if (!brw->mesa_format_supports_re<wbr>nder[mt->format])<br>
return false;<br>
<br>
- if (devinfo->gen >= 9) {<br>
- mesa_format linear_format = _mesa_get_srgb_format_linear(m<wbr>t->format);<br>
- const enum isl_format isl_format =<br>
- brw_isl_format_for_mesa_forma<wbr>t(linear_format);<br>
- return isl_format_supports_ccs_e(&brw<wbr>->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(con<wbr>st 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_mipt<wbr>ree(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(s<wbr>truct brw_context *brw,<br>
if (!intel_miptree_supports_ccs(b<wbr>rw, 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(m<wbr>t->format) == mt->format;<br>
+ mesa_format linear_format = _mesa_get_srgb_format_linear(m<wbr>t->format);<br>
+ enum isl_format isl_format = brw_isl_format_for_mesa_format<wbr>(linear_format);<br>
+ return isl_format_supports_ccs_e(&brw<wbr>->screen->devinfo, isl_format);<br>
}<br>
<br>
/**<br>
@@ -2686,29 +2681,27 @@ intel_miptree_render_aux_usage<wbr>(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_for<wbr>mat) &&<br>
- _mesa_get_srgb_format_linear(m<wbr>t->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(ren<wbr>der_format) ||<br>
- _mesa_get_srgb_format_linear(<wbr>mt->format) == mt->format);<br>
+ if (format_ccs_e_compat_with_mipt<wbr>ree(&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_form<wbr>at) &&<br>
+ !isl_color_value_is_zero_one(m<wbr>t->fast_clear_color, render_format))<br>
+ return ISL_AUX_USAGE_NONE;<br>
<br>
</blockquote>
<br>
We also need the blend workaround for the CCS_D case. Otherwise, we'll<br>
start failing piglit's arb_framebuffer_srgb-fast-clea<wbr>r-blend when<br>
DEBUG_NO_RBC is set (MD5-287).<br>
</blockquote>
<br></div></div>
Initially, I waz very confused as to why that's in the CCS_E case at all. However, as of this patch, mt->aux_usage is always set to CCS_D for any 8888 surfaces. That said, it would probably be better to have it in both cases.</blockquote><div><br></div><div>Sorry, I misread and didn't see the bit about DEBUG_NO_RGC. Given that it requires a debug flag, do you mind if I do that as a follow-on?</div><div><br></div><div>--Jason<br></div></div></div></div>