pvr: Unmap mapped memory on free
authorMatt Coster <matt.coster@imgtec.com>
Fri, 28 Apr 2023 14:00:21 +0000 (15:00 +0100)
committerMarge Bot <emma+marge@anholt.net>
Tue, 2 May 2023 09:36:11 +0000 (09:36 +0000)
From the Vulkan spec (§11.2.13. Freeing Device Memory):
  If a memory object is mapped at the time it is freed, it is implicitly
  unmapped.

Signed-off-by: Matt Coster <matt.coster@imgtec.com>
Reviewed-by: Karmjit Mahil <Karmjit.Mahil@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22762>

src/imagination/vulkan/pvr_device.c

index 7d652d6..fefa258 100644 (file)
@@ -2112,6 +2112,13 @@ void pvr_FreeMemory(VkDevice _device,
    if (!mem)
       return;
 
+   /* From the Vulkan spec (§11.2.13. Freeing Device Memory):
+    *   If a memory object is mapped at the time it is freed, it is implicitly
+    *   unmapped.
+    */
+   if (mem->bo->map)
+      device->ws->ops->buffer_unmap(mem->bo);
+
    device->ws->ops->buffer_destroy(mem->bo);
 
    vk_object_free(&device->vk, pAllocator, mem);