From: Samuel Pitoiset Date: Wed, 21 Mar 2018 20:30:41 +0000 (+0100) Subject: radv: add radv_calc_decompress_on_z_planes() helper X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5ae97722450dd818fb019b1e4727b3e2a44e1ed1;p=mesa.git radv: add radv_calc_decompress_on_z_planes() helper Signed-off-by: Samuel Pitoiset Reviewed-by: Bas Nieuwenhuizen --- diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index 36ba0c3833d..22500bfc130 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -3597,6 +3597,35 @@ radv_initialise_color_surface(struct radv_device *device, } } +static unsigned +radv_calc_decompress_on_z_planes(struct radv_device *device, + struct radv_image_view *iview) +{ + unsigned max_zplanes = 0; + + assert(iview->image->tc_compatible_htile); + + if (device->physical_device->rad_info.chip_class >= GFX9) { + /* Default value for 32-bit depth surfaces. */ + max_zplanes = 4; + + if (iview->vk_format == VK_FORMAT_D16_UNORM && + iview->image->info.samples > 1) + max_zplanes = 2; + + max_zplanes = max_zplanes + 1; + } else { + if (iview->image->info.samples <= 1) + max_zplanes = 5; + else if (iview->image->info.samples <= 4) + max_zplanes = 3; + else + max_zplanes = 2; + } + + return max_zplanes; +} + static void radv_initialise_ds_surface(struct radv_device *device, struct radv_ds_buffer_info *ds, @@ -3667,14 +3696,11 @@ radv_initialise_ds_surface(struct radv_device *device, ds->db_z_info |= S_028038_TILE_SURFACE_ENABLE(1); if (iview->image->tc_compatible_htile) { - unsigned max_zplanes = 4; - - if (iview->vk_format == VK_FORMAT_D16_UNORM && - iview->image->info.samples > 1) - max_zplanes = 2; + unsigned max_zplanes = + radv_calc_decompress_on_z_planes(device, iview); - ds->db_z_info |= S_028038_DECOMPRESS_ON_N_ZPLANES(max_zplanes + 1) | - S_028038_ITERATE_FLUSH(1); + ds->db_z_info |= S_028038_DECOMPRESS_ON_N_ZPLANES(max_zplanes) | + S_028038_ITERATE_FLUSH(1); ds->db_stencil_info |= S_02803C_ITERATE_FLUSH(1); } @@ -3752,14 +3778,11 @@ radv_initialise_ds_surface(struct radv_device *device, ds->db_htile_surface = S_028ABC_FULL_CACHE(1); if (iview->image->tc_compatible_htile) { - ds->db_htile_surface |= S_028ABC_TC_COMPATIBLE(1); + unsigned max_zplanes = + radv_calc_decompress_on_z_planes(device, iview); - if (iview->image->info.samples <= 1) - ds->db_z_info |= S_028040_DECOMPRESS_ON_N_ZPLANES(5); - else if (iview->image->info.samples <= 4) - ds->db_z_info |= S_028040_DECOMPRESS_ON_N_ZPLANES(3); - else - ds->db_z_info|= S_028040_DECOMPRESS_ON_N_ZPLANES(2); + ds->db_htile_surface |= S_028ABC_TC_COMPATIBLE(1); + ds->db_z_info |= S_028040_DECOMPRESS_ON_N_ZPLANES(max_zplanes); } } }