zink: refactor fence destruction
authorErik Faye-Lund <erik.faye-lund@collabora.com>
Wed, 10 Jul 2019 12:11:56 +0000 (14:11 +0200)
committerErik Faye-Lund <erik.faye-lund@collabora.com>
Mon, 28 Oct 2019 08:51:45 +0000 (08:51 +0000)
Acked-by: Jordan Justen <jordan.l.justen@intel.com>
src/gallium/drivers/zink/zink_fence.c

index 6df13b9eca88e2b1c16d9f76cd55d72205295cd9..ac761e667a3a365f4410be6bc8899387d44e9ec2 100644 (file)
 
 #include "util/u_memory.h"
 
+static void
+destroy_fence(struct zink_screen *screen, struct zink_fence *fence)
+{
+   if (fence->fence)
+      vkDestroyFence(screen->dev, fence->fence, NULL);
+   FREE(fence);
+}
+
 struct zink_fence *
 zink_create_fence(struct pipe_screen *pscreen)
 {
@@ -50,7 +58,7 @@ zink_create_fence(struct pipe_screen *pscreen)
    return ret;
 
 fail:
-   FREE(ret);
+   destroy_fence(screen, ret);
    return NULL;
 }
 
@@ -59,10 +67,8 @@ zink_fence_reference(struct zink_screen *screen,
                      struct zink_fence **ptr,
                      struct zink_fence *fence)
 {
-   if (pipe_reference(&(*ptr)->reference, &fence->reference)) {
-      vkDestroyFence(screen->dev, (*ptr)->fence, NULL);
-      free(*ptr);
-   }
+   if (pipe_reference(&(*ptr)->reference, &fence->reference))
+      destroy_fence(screen, *ptr);
 
    *ptr = fence;
 }