intel/isl: Add format assertions for surfaces using CCS

This caught some invalid CCS surface states created by iris.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14806>
This commit is contained in:
Nanley Chery 2021-12-27 10:06:34 -05:00 committed by Marge Bot
parent 05b8b08ef4
commit 85a7fb1e19
1 changed files with 36 additions and 0 deletions

View File

@ -597,6 +597,42 @@ isl_genX(surf_fill_state_s)(const struct isl_device *dev, void *state,
#if GFX_VER >= 12
s.MemoryCompressionEnable = info->aux_usage == ISL_AUX_USAGE_MC;
#endif
#if GFX_VER >= 9
/* Some CCS aux usages have format restrictions. The Skylake PRM doc for
* RENDER_SURFACE_STATE::AuxiliarySurfaceMode says:
*
* If Number of Multisamples is MULTISAMPLECOUNT_1, AUX_CCS_E setting
* is only allowed if Surface Format is supported for Render Target
* Compression. This setting enables render target compression.
*
* If CCS_E is in use, the format must support it.
*/
if (info->aux_usage == ISL_AUX_USAGE_CCS_E ||
info->aux_usage == ISL_AUX_USAGE_GFX12_CCS_E)
assert(isl_format_supports_ccs_e(dev->info, info->view->format));
/* It also says:
*
* If Number of Multisamples is MULTISAMPLECOUNT_1, AUX_CCS_D setting
* is only allowed if Surface Format supported for Fast Clear. In
* addition, if the surface is bound to the sampling engine, Surface
* Format must be supported for Render Target Compression for
* surfaces bound to the sampling engine. For render target surfaces,
* this setting disables render target compression. For sampling
* engine surfaces, this mode behaves the same as AUX_CCS_E.
*
* If CCS_D is in use while rendering, the format must support it. If
* it's in use while sampling, the format must support CCS_E.
*/
if (info->aux_usage == ISL_AUX_USAGE_CCS_D) {
if (info->view->usage & ISL_SURF_USAGE_RENDER_TARGET_BIT) {
assert(isl_format_supports_ccs_d(dev->info, info->view->format));
} else {
assert(info->view->usage & ISL_SURF_USAGE_TEXTURE_BIT);
assert(isl_format_supports_ccs_e(dev->info, info->view->format));
}
}
#endif
#if GFX_VER >= 8
s.AuxiliarySurfaceMode = isl_encode_aux_mode[info->aux_usage];
#else