From 85a7fb1e197086bd0baf4a80558a4581da43b6d1 Mon Sep 17 00:00:00 2001 From: Nanley Chery Date: Mon, 27 Dec 2021 10:06:34 -0500 Subject: [PATCH] intel/isl: Add format assertions for surfaces using CCS This caught some invalid CCS surface states created by iris. Reviewed-by: Kenneth Graunke Part-of: --- src/intel/isl/isl_surface_state.c | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/intel/isl/isl_surface_state.c b/src/intel/isl/isl_surface_state.c index 98603d782c8..97f92d9d00f 100644 --- a/src/intel/isl/isl_surface_state.c +++ b/src/intel/isl/isl_surface_state.c @@ -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