Module: Mesa
Branch: main
Commit: 11b1a37553a9339b358ddae99df38160c4cc2252
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=11b1a37553a9339b358ddae99df38160c4cc2252

Author: Matt Coster <[email protected]>
Date:   Fri Apr 28 15:00:21 2023 +0100

pvr: Unmap mapped memory on free

>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 <[email protected]>
Reviewed-by: Karmjit Mahil <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22762>

---

 src/imagination/vulkan/pvr_device.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/imagination/vulkan/pvr_device.c 
b/src/imagination/vulkan/pvr_device.c
index 7d652d61f2f..fefa2586e24 100644
--- a/src/imagination/vulkan/pvr_device.c
+++ b/src/imagination/vulkan/pvr_device.c
@@ -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);

Reply via email to