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>
This commit is contained in:
Nanley Chery 2021-01-26 15:44:05 -08:00 committed by Marge Bot
parent 608c131638
commit eef4c708b3
2 changed files with 38 additions and 2 deletions

View file

@ -2214,8 +2214,12 @@ anv_layout_to_aux_state(const struct intel_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;
@ -2248,7 +2252,6 @@ anv_layout_to_aux_state(const struct intel_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;
@ -2256,6 +2259,14 @@ anv_layout_to_aux_state(const struct intel_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

@ -3954,6 +3954,31 @@ anv_can_sample_with_hiz(const struct intel_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 intel_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,