title: Transferring memory from GPU to CPU with Vulkan and vkInvalidateMappedMemoryRanges synchronization?
body: <p>In Vulkan, when I want to transfer some memory the GPU back to the CPU, I think the most efficient way to do this is to write the data into memory which has the flags <code>VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT</code>.</p>
  
  <p>Question #1: Is that assumption correct? </p>
  
  <p>(Full list of available memory property flags can be found in Vulkan's documentation of <a href="https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkMemoryPropertyFlagBits.html" rel="noreferrer">VkMemoryPropertyFlagBits</a>)</p>
  
  <p>In order to get the latest data, I have to invalidate the memory using <a href="https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/vkInvalidateMappedMemoryRanges.html" rel="noreferrer">vkInvalidateMappedMemoryRanges</a>, right? </p>
  
  <p>Question #2: What is happening under the hood during <code>vkInvalidateMappedMemoryRanges</code>? Is this just a <code>memcpy</code> from some internal cache or can this be a longer procedure? </p>
  
  <p>Question #3: If this could take longer (i.e. it is not a simple <code>memcpy</code>), then I probably should have some possibility to synchronize with the completion of it, right?  However, <code>vkInvalidateMappedMemoryRanges</code> does not offer any synchronization parameters. Actually, my question is: IF I have to synchronize it, HOW do I synchronize it? </p>