In Vulkan, we can not only transfer data from a buffer to an image, but also the other way--we can copy data from an image to the buffer. It doesn't matter what the properties of memory objects bound to them are. But, the data copy operation is the only way to update a device-local memory which cannot be mapped.
Copying data from an image to a buffer
How to do it...
- Take the handle of a command buffer and store it in a variable of type VkCommandBuffer named command_buffer. Make sure the command buffer is already in a recording state (refer to the Beginning a command buffer recording operation recipe from Chapter 3, Command Buffers and Synchronization).
- Take an image from which data will be copied. Store its handle in a variable of type VkImage named source_image...