[Mesa-dev] [PATCH 1/2] i965: Don't include missing components in the fast clear color

Neil Roberts neil at linux.intel.com
Thu Nov 5 03:29:29 PST 2015


Ben Widawsky <ben at bwidawsk.net> writes:

> It seems reasonable to me, but since you touch the same code I touch
> in fast clears, and since I always screw up rebases, any chance I
> could persuade you to wait until I land fast clears?

Sure, I don't mind waiting. I did have a go at rebasing the patch on top
of your branch and I think the code should look something like this:

    if (brw->gen >= 9) {
       mt->gen9_fast_clear_color = *color;
+
+      /* Override components that aren't in the surface format */
+      for (int i = 0; i < 4; i++) {
+         if (!_mesa_format_has_color_component(mt->format, i)) {
+            if (_mesa_is_format_integer(mt->format))
+               mt->gen9_fast_clear_color.i[i] = (i == 3);
+            else
+               mt->gen9_fast_clear_color.f[i] = (i == 3);
+         }
+      }
    } else {
       mt->fast_clear_color_value = 0;
       for (int i = 0; i < 4; i++) {
-         /* Testing for non-0 works for integer and float colors */
-         if (color->f[i] != 0.0f) {
-             mt->fast_clear_color_value |=
-                1 << (GEN7_SURFACE_CLEAR_COLOR_SHIFT + (3 - i));
+         /* Testing for non-0 works for integer and float colors. If the
+          * component doesn't exist in the format then force the color to 0 for
+          * the RGB components and 1 for the alpha.
+          */
+         if (_mesa_format_has_color_component(mt->format, i) ?
+             (color->f[i] != 0.0f) :
+             (i == 3)) {
+            mt->fast_clear_color_value |=
+               1 << (GEN7_SURFACE_CLEAR_COLOR_SHIFT + (3 - i));
          }
       }
    }

However I haven't been able to get it to work. It looks like there is a
more general problem with fast clears on SKL where a bunch of formats
(such as GL_RGB) always return 0,0,0,0 for the pixels that are cleared
regardless of the clear color. I think we haven't noticed this in the
Piglit tests because most of them clear to black anyway. However if you
modify ColorGradientSunburst to clear to white instead then the
multisample formats tests starts failing for a lot more formats. I am
currently trying to look into this but maybe we should discuss this in a
different thread because I think it's not directly related to this
patch.

Regards,
- Neil


More information about the mesa-dev mailing list