Module: Mesa
Branch: staging/21.1
Commit: be005c3d4df94e9b1b50e44341fc3db9327b6c14
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=be005c3d4df94e9b1b50e44341fc3db9327b6c14

Author: Nanley Chery <[email protected]>
Date:   Tue Jan 26 15:44:05 2021 -0800

anv: Avoid sampling some MCS surfaces with clear

Supposedly avoids GPU hangs in BF4. See HSD 1707282275 and 14013111325.

v2. Fix bug in WA implementation. (Sagar)

Cc: mesa-stable
Reviewed-by: Sagar Ghuge <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8755>
(cherry picked from commit eef4c708b3fd0af3c641b3d349588e2cfcfcb485)

---

 .pick_status.json              |  2 +-
 src/intel/vulkan/anv_image.c   | 15 +++++++++++++--
 src/intel/vulkan/anv_private.h | 25 +++++++++++++++++++++++++
 3 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 979d75203aa..9415e1cc679 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -94,7 +94,7 @@
         "description": "anv: Avoid sampling some MCS surfaces with clear",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": null
     },
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index 7de148b43de..b99891a4fcd 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -2208,8 +2208,12 @@ anv_layout_to_aux_state(const struct gen_device_info * 
const devinfo,
          clear_supported = false;
          break;
 
-      case ISL_AUX_USAGE_CCS_E:
       case ISL_AUX_USAGE_MCS:
+         if (!anv_can_sample_mcs_with_clear(devinfo, image))
+            clear_supported = false;
+         break;
+
+      case ISL_AUX_USAGE_CCS_E:
       case ISL_AUX_USAGE_STC_CCS:
          break;
 
@@ -2242,7 +2246,6 @@ anv_layout_to_aux_state(const struct gen_device_info * 
const devinfo,
       }
 
    case ISL_AUX_USAGE_CCS_E:
-   case ISL_AUX_USAGE_MCS:
       if (aux_supported) {
          assert(clear_supported);
          return ISL_AUX_STATE_COMPRESSED_CLEAR;
@@ -2250,6 +2253,14 @@ anv_layout_to_aux_state(const struct gen_device_info * 
const devinfo,
          return ISL_AUX_STATE_PASS_THROUGH;
       }
 
+   case ISL_AUX_USAGE_MCS:
+      assert(aux_supported);
+      if (clear_supported) {
+         return ISL_AUX_STATE_COMPRESSED_CLEAR;
+      } else {
+         return ISL_AUX_STATE_COMPRESSED_NO_CLEAR;
+      }
+
    case ISL_AUX_USAGE_STC_CCS:
       assert(aux_supported);
       assert(!clear_supported);
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 86a31bd552c..f1a636bc608 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -3939,6 +3939,31 @@ anv_can_sample_with_hiz(const struct gen_device_info * 
const devinfo,
    return image->samples == 1;
 }
 
+/* Returns true if an MCS-enabled buffer can be sampled from. */
+static inline bool
+anv_can_sample_mcs_with_clear(const struct gen_device_info * const devinfo,
+                              const struct anv_image *image)
+{
+   assert(image->aspects == VK_IMAGE_ASPECT_COLOR_BIT);
+   const uint32_t plane =
+      anv_image_aspect_to_plane(image->aspects, VK_IMAGE_ASPECT_COLOR_BIT);
+
+   assert(isl_aux_usage_has_mcs(image->planes[plane].aux_usage));
+
+   const struct anv_surface *anv_surf = &image->planes[plane].primary_surface;
+
+   /* On TGL, the sampler has an issue with some 8 and 16bpp MSAA fast clears.
+    * See HSD 1707282275, wa_14013111325. Due to the use of
+    * format-reinterpretation, a simplified workaround is implemented.
+    */
+   if (devinfo->ver >= 12 &&
+       isl_format_get_layout(anv_surf->isl.format)->bpb <= 16) {
+      return false;
+   }
+
+   return true;
+}
+
 static inline bool
 anv_image_plane_uses_aux_map(const struct anv_device *device,
                              const struct anv_image *image,

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to