Mesa (master): anv: Check offset instead of alloc_size for freeing surface states

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed May 5 12:26:14 UTC 2021


Module: Mesa
Branch: master
Commit: 9301b637cfe82e4ad671aac22102ad95e9fda0a2
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9301b637cfe82e4ad671aac22102ad95e9fda0a2

Author: Jason Ekstrand <jason at jlekstrand.net>
Date:   Tue May  4 13:30:35 2021 -0500

anv: Check offset instead of alloc_size for freeing surface states

Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10624>

---

 src/intel/vulkan/anv_image.c | 12 ++++++++----
 1 file 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);
       }



More information about the mesa-commit mailing list