[Mesa-dev] [PATCH 3/3] anv/device: Implicitly unmap memory objects in FreeMemory

Jason Ekstrand jason at jlekstrand.net
Tue Nov 8 01:28:14 UTC 2016


>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 at jlekstrand.net>
Cc: "12.0 13.0" <mesa-dev at lists.freedesktop.org>
---
 src/intel/vulkan/anv_device.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index 54efb47..bc8397e 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -1210,6 +1210,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;
@@ -1231,6 +1234,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);
 
@@ -1305,6 +1311,9 @@ void anv_UnmapMemory(
       return;
 
    anv_gem_munmap(mem->map, mem->map_size);
+
+   mem->map = NULL;
+   mem->map_size = 0;
 }
 
 static void
-- 
2.5.0.400.gff86faf



More information about the mesa-dev mailing list