iris: Resolve stencil resource prior to copy or used by CPU
authorSagar Ghuge <sagar.ghuge@intel.com>
Tue, 17 Sep 2019 20:20:16 +0000 (13:20 -0700)
committerSagar Ghuge <sagar.ghuge@intel.com>
Tue, 29 Oct 2019 21:46:15 +0000 (14:46 -0700)
v2: Decide aux usage in get_copy_region_aux_settings (Nanley Chery)

v3: Use isl_surf_usage_is_stencil function (Nanley Chery)

Signed-off-by: Sagar Ghuge <sagar.ghuge@intel.com>
Reviewed-by: Nanley Chery <nanley.g.chery@intel.com>
src/gallium/drivers/iris/iris_blit.c

index e10e54667f43100fb6c3583b93d4ebcb7073ea1d..62179edd9bb648edc820fbd3b253fe0acaa28a70 100644 (file)
@@ -566,19 +566,29 @@ static void
 get_copy_region_aux_settings(const struct gen_device_info *devinfo,
                              struct iris_resource *res,
                              enum isl_aux_usage *out_aux_usage,
-                             bool *out_clear_supported)
+                             bool *out_clear_supported,
+                             bool is_render_target)
 {
    switch (res->aux.usage) {
    case ISL_AUX_USAGE_MCS:
    case ISL_AUX_USAGE_MCS_CCS:
    case ISL_AUX_USAGE_CCS_E:
-      *out_aux_usage = res->aux.usage;
-      /* Prior to Gen9, fast-clear only supported 0/1 clear colors.  Since
-       * we're going to re-interpret the format as an integer format possibly
-       * with a different number of components, we can't handle clear colors
-       * until Gen9.
+      /* A stencil resolve operation must be performed prior to doing resource
+       * copies or used by CPU.
+       * (see HSD 1209978162)
        */
-      *out_clear_supported = devinfo->gen >= 9;
+      if (is_render_target && isl_surf_usage_is_stencil(res->surf.usage)) {
+         *out_aux_usage = ISL_AUX_USAGE_NONE;
+         *out_clear_supported = false;
+      } else {
+         *out_aux_usage = res->aux.usage;
+         /* Prior to Gen9, fast-clear only supported 0/1 clear colors.  Since
+          * we're going to re-interpret the format as an integer format possibly
+          * with a different number of components, we can't handle clear colors
+          * until Gen9.
+          */
+         *out_clear_supported = devinfo->gen >= 9;
+      }
       break;
    default:
       *out_aux_usage = ISL_AUX_USAGE_NONE;
@@ -615,9 +625,9 @@ iris_copy_region(struct blorp_context *blorp,
    enum isl_aux_usage src_aux_usage, dst_aux_usage;
    bool src_clear_supported, dst_clear_supported;
    get_copy_region_aux_settings(devinfo, src_res, &src_aux_usage,
-                                &src_clear_supported);
+                                &src_clear_supported, false);
    get_copy_region_aux_settings(devinfo, dst_res, &dst_aux_usage,
-                                &dst_clear_supported);
+                                &dst_clear_supported, true);
 
    if (iris_batch_references(batch, src_res->bo))
       tex_cache_flush_hack(batch, ISL_FORMAT_UNSUPPORTED, src_res->surf.format);