summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Ekstrand <jason@jlekstrand.net>2021-05-04 13:30:35 -0500
committerMarge Bot <eric+marge@anholt.net>2021-05-05 12:20:09 +0000
commit9301b637cfe82e4ad671aac22102ad95e9fda0a2 (patch)
tree28b0bf86368e5edbbe451ca0aee92bd29f001e22
parenta2d091694f8cf30f7f8a15d9c26712d4e56eaa6c (diff)
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>
-rw-r--r--src/intel/vulkan/anv_image.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
index d041af77b23..e47e525affa 100644
--- a/src/intel/vulkan/anv_image.c
+++ b/src/intel/vulkan/anv_image.c
@@ -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);
}