anv: Check offset instead of alloc_size for freeing surface states

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10624>
This commit is contained in:
Jason Ekstrand 2021-05-04 13:30:35 -05:00 committed by Marge Bot
parent a2d091694f
commit 9301b637cf
1 changed files with 8 additions and 4 deletions

View File

@ -2911,22 +2911,26 @@ anv_DestroyImageView(VkDevice _device, VkImageView _iview,
return;
for (uint32_t plane = 0; plane < iview->n_planes; plane++) {
if (iview->planes[plane].optimal_sampler_surface_state.state.alloc_size > 0) {
/* Check offset instead of alloc_size because this they might be
* device->null_surface_state which always has offset == 0. We don't
* own that one so we don't want to accidentally free it.
*/
if (iview->planes[plane].optimal_sampler_surface_state.state.offset) {
anv_state_pool_free(&device->surface_state_pool,
iview->planes[plane].optimal_sampler_surface_state.state);
}
if (iview->planes[plane].general_sampler_surface_state.state.alloc_size > 0) {
if (iview->planes[plane].general_sampler_surface_state.state.offset) {
anv_state_pool_free(&device->surface_state_pool,
iview->planes[plane].general_sampler_surface_state.state);
}
if (iview->planes[plane].storage_surface_state.state.alloc_size > 0) {
if (iview->planes[plane].storage_surface_state.state.offset) {
anv_state_pool_free(&device->surface_state_pool,
iview->planes[plane].storage_surface_state.state);
}
if (iview->planes[plane].writeonly_storage_surface_state.state.alloc_size > 0) {
if (iview->planes[plane].writeonly_storage_surface_state.state.offset) {
anv_state_pool_free(&device->surface_state_pool,
iview->planes[plane].writeonly_storage_surface_state.state);
}