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 <sagar.ghuge@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8755>
(cherry picked from commit eef4c708b3)
This commit is contained in:
Nanley Chery 2021-01-26 15:44:05 -08:00 committed by Eric Engestrom
parent e266136b38
commit 5df6ee6693
3 changed files with 39 additions and 3 deletions

View file

@ -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
},

View file

@ -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);

View file

@ -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,