vulkan: Destroy image before releasing associate memory
authorGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Thu, 14 Dec 2017 00:43:50 +0000 (22:43 -0200)
committerGeorges Basile Stavracas Neto <georges.stavracas@gmail.com>
Thu, 14 Dec 2017 00:49:16 +0000 (22:49 -0200)
VkImage contains a reference to the VkDeviceMemory and, because
the current code frees the VkDeviceMemory before destroying the
VkImage that references it, a warning is triggered by the validation
layers.

This is not critical, since we release both resources at the same
place. But the warning triggered by the validation layers sums up
adding 1 MB per second of extra debug logging, making the debugging
process much more painful.

This commit simply swaps the destruction order, and destroys the
VkImage first, then the now unused VkDeviceMemory.

gsk/gskvulkanimage.c

index 8ebcd9e358fd359c4d409623451aa85258640b30..8d3bdb42e0198eaaea44eb81044b20e1043d11a9 100644 (file)
@@ -772,11 +772,11 @@ gsk_vulkan_image_finalize (GObject *object)
    * the VkImage */
   if (self->memory)
     {
-      gsk_vulkan_memory_free (self->memory);
-
       vkDestroyImage (gdk_vulkan_context_get_device (self->vulkan),
                       self->vk_image,
                       NULL);
+
+      gsk_vulkan_memory_free (self->memory);
     }
 
   g_object_unref (self->vulkan);