iris: Support clears in more GPU-based copies
authorNanley Chery <nanley.g.chery@intel.com>
Mon, 28 Dec 2020 17:31:33 +0000 (09:31 -0800)
committerMarge Bot <eric+marge@anholt.net>
Wed, 30 Dec 2020 23:50:22 +0000 (23:50 +0000)
Commit 7779b1d71bf053f0c73a1b717e6d2ed91f948378, disabled clear support
when copying to/from color buffers. According to the performance CI, it
falls within a range of commits that introduced a performance regression
on Bioshock Infinite with Tigerlake. Icelake isn't noticeably affected.

By analyzing a trace of the game, I found a couple cases where that
commit added new partial resolves. Update get_copy_region_aux_settings
to avoid them:

- The trace uploads to R8_UNORM textures. On TGL, these enter the
  COMPRESSED_CLEAR state on the upload and are partially resolved before
  every subsequent upload. Thankfully, they keep their initial clear
  color of all zeroes. Since zeros can survive format reinterpretation,
  allow clear support for it.

- The trace copies between RGBA16_FLOAT textures. The ones with zero
  clear color are helped by the optimization above. The ones with
  non-zero clear color are used as source textures. Thankfully on ICL+,
  the clear color used for sampling is in pixel form and can thus be
  sampled from with format reinterpretation. Allow clear support for
  this case.

I haven't tested the actual performance impact of this change, but it
should be beneficial regardless.

Reported-by: Clayton Craft <clayton.a.craft@intel.com>
Reported-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8262>

src/gallium/drivers/iris/iris_blit.c

index 0d6a358..a527d2d 100644 (file)
@@ -599,6 +599,9 @@ get_copy_region_aux_settings(struct iris_context *ice,
                              bool *out_clear_supported,
                              bool is_render_target)
 {
+   struct iris_screen *screen = (void *) ice->ctx.screen;
+   struct gen_device_info *devinfo = &screen->devinfo;
+
    switch (res->aux.usage) {
    case ISL_AUX_USAGE_HIZ:
    case ISL_AUX_USAGE_HIZ_CCS:
@@ -617,7 +620,27 @@ get_copy_region_aux_settings(struct iris_context *ice,
    case ISL_AUX_USAGE_CCS_E:
    case ISL_AUX_USAGE_GEN12_CCS_E:
       *out_aux_usage = res->aux.usage;
-      *out_clear_supported = false;
+
+      /* blorp_copy may reinterpret the surface format and has limited support
+       * for adjusting the clear color, so clear support may only be enabled
+       * in some cases:
+       *
+       * - On gen11+, the clear color is indirect and comes in two forms: a
+       *   32bpc representation used for rendering and a pixel representation
+       *   used for sampling. blorp_copy doesn't change indirect clear colors,
+       *   so clears are only supported in the sampling case.
+       *
+       * - A clear color of zeroes holds the same meaning regardless of the
+       *   format. Although it could avoid more resolves, we don't use
+       *   isl_color_value_is_zero because the surface format used by
+       *   blorp_copy isn't guaranteed to access the same components as the
+       *   original format (e.g. A8_UNORM/R8_UINT).
+       */
+      *out_clear_supported = (devinfo->gen >= 11 && !is_render_target) ||
+                             (res->aux.clear_color.u32[0] == 0 &&
+                              res->aux.clear_color.u32[1] == 0 &&
+                              res->aux.clear_color.u32[2] == 0 &&
+                              res->aux.clear_color.u32[3] == 0);
       break;
    default:
       *out_aux_usage = ISL_AUX_USAGE_NONE;