Always defer memory free in swr_resource_destroy
authorGeorge Kyriazis <george.kyriazis@intel.com>
Tue, 10 Jan 2017 23:12:03 +0000 (17:12 -0600)
committerTim Rowley <timothy.o.rowley@intel.com>
Thu, 12 Jan 2017 15:10:15 +0000 (09:10 -0600)
Defer delete on regular resources.  This ensures that any work being done
on the resource is completed before freeing up the resource's memory.

Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
src/gallium/drivers/swr/swr_screen.cpp

index cc8030eaff68ae97c448dfab3cb40777586463fe..50123887b50b23bfb3c9d5830091b8e406875f03 100644 (file)
@@ -880,18 +880,11 @@ swr_resource_destroy(struct pipe_screen *p_screen, struct pipe_resource *pt)
       winsys->displaytarget_destroy(winsys, spr->display_target);
 
    } else {
-      /* For regular resources, if the resource is being used, defer deletion
-       * (use aligned-free) */
-      if (pipe && spr->status) {
-         swr_resource_unused(pt);
-         swr_fence_work_free(screen->flush_fence,
-                             spr->swr.pBaseAddress, true);
-         swr_fence_work_free(screen->flush_fence, 
-                             spr->secondary.pBaseAddress, true);
-      } else {
-         AlignedFree(spr->swr.pBaseAddress);
-         AlignedFree(spr->secondary.pBaseAddress);
-      }
+      /* For regular resources, defer deletion */
+      swr_resource_unused(pt);
+      swr_fence_work_free(screen->flush_fence, spr->swr.pBaseAddress, true);
+      swr_fence_work_free(screen->flush_fence,
+                          spr->secondary.pBaseAddress, true);
    }
 
    FREE(spr);