i965/cnl: Avoid fast-clearing sRGB render buffers
authorNanley Chery <nanley.g.chery@intel.com>
Fri, 1 Dec 2017 22:18:21 +0000 (14:18 -0800)
committerNanley Chery <nanley.g.chery@intel.com>
Mon, 4 Dec 2017 22:21:47 +0000 (14:21 -0800)
Gen10 doesn't automatically decode the clear color of sRGB buffers. To
get correct rendering, avoid fast-clearing such buffers for now.

The driver now passes the following piglit tests:
* spec@arb_framebuffer_srgb@msaa-fast-clear
* spec@ext_texture_srgb@multisample-fast-clear gl_ext_texture_srgb

Suggested-by: Kenneth Graunke <kenneth@whitecape.org>
Suggested-by: Jason Ekstrand <jason@jlekstrand.net>
Signed-off-by: Nanley Chery <nanley.g.chery@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/mesa/drivers/dri/i965/brw_meta_util.c

index ba92168934e344a846fdc405ff856d0870edc572..54dc6a5ff9a20f72c409864b67b318a94d7a85df 100644 (file)
@@ -298,13 +298,23 @@ brw_is_color_fast_clear_compatible(struct brw_context *brw,
     * resolved in intel_update_state. In that case it's pointless to do a
     * fast clear because it's very likely to be immediately resolved.
     */
+   const bool srgb_rb = _mesa_get_srgb_format_linear(mt->format) != mt->format;
    if (devinfo->gen >= 9 &&
        mt->surf.samples == 1 &&
-       ctx->Color.sRGBEnabled &&
-       _mesa_get_srgb_format_linear(mt->format) != mt->format)
+       ctx->Color.sRGBEnabled && srgb_rb)
       return false;
 
+  /* Gen10 doesn't automatically decode the clear color of sRGB buffers. Since
+   * we currently don't perform this decode in software, avoid a fast-clear
+   * altogether. TODO: Do this in software.
+   */
    const mesa_format format = _mesa_get_render_format(ctx, mt->format);
+   if (devinfo->gen >= 10 && srgb_rb) {
+      perf_debug("sRGB fast clear not enabled for (%s)",
+                 _mesa_get_format_name(format));
+      return false;
+   }
+
    if (_mesa_is_format_integer_color(format)) {
       if (devinfo->gen >= 8) {
          perf_debug("Integer fast clear not enabled for (%s)",