OSDN Git Service

anv/device: Implicitly unmap memory objects in FreeMemory
authorJason Ekstrand <jason.ekstrand@intel.com>
Tue, 8 Nov 2016 01:25:07 +0000 (17:25 -0800)
committerEmil Velikov <emil.l.velikov@gmail.com>
Thu, 15 Dec 2016 16:14:55 +0000 (16:14 +0000)
From the Vulkan spec version 1.0.32 docs for vkFreeMemory:

   "If a memory object is mapped at the time it is freed, it is implicitly
   unmapped."

Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Nanley Chery <nanley.g.chery@intel.com>
Cc: "12.0 13.0" <mesa-dev@lists.freedesktop.org>
(cherry picked from commit b1217eada9e32bf387d4d14615340aa5b5fd1f5c)

src/intel/vulkan/anv_device.c

index 9595fe3..5333856 100644 (file)
@@ -1243,6 +1243,9 @@ VkResult anv_AllocateMemory(
 
    mem->type_index = pAllocateInfo->memoryTypeIndex;
 
+   mem->map = NULL;
+   mem->map_size = 0;
+
    *pMem = anv_device_memory_to_handle(mem);
 
    return VK_SUCCESS;
@@ -1264,6 +1267,9 @@ void anv_FreeMemory(
    if (mem == NULL)
       return;
 
+   if (mem->map)
+      anv_UnmapMemory(_device, _mem);
+
    if (mem->bo.map)
       anv_gem_munmap(mem->bo.map, mem->bo.size);
 
@@ -1333,6 +1339,9 @@ void anv_UnmapMemory(
       return;
 
    anv_gem_munmap(mem->map, mem->map_size);
+
+   mem->map = NULL;
+   mem->map_size = 0;
 }
 
 static void