title: How to Copy Swap Chain Image to a VkBuffer in Vulkan?
body: <p>I am currently modifying the Adreno SDK Vulkan example of Triangle. I want read the color values of the rendered Swap Chain image. The process I followed is as follows:</p>
  
  <ol>
  <li><p>I create VkBuffer with width and height of Swap Chain image.
  Its details:</p>
  
  <pre><code>VkBufferCreateInfo outputinfo = {};
  outputinfo.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO;
  outputinfo.size = m_width * m_height * 3 * sizeof(int8_t);
  outputinfo.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT;
  outputinfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;`
  </code></pre>
  
  <p>Int because the Image format is <code>VK_FORMAT_R8G8B8_SINT</code>
  Then allocate memory and bind it to the buffer with type <code>VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT</code></p></li>
  <li><p>Call <code>vkCmdCopyImageToBuffer</code> in Command Buffer after the <code>vkCmdDraw</code>, <code>vkCmdEndRenderPass</code>.</p></li>
  <li><p>Then do <code>vkQueueSubmit</code> and <code>vkQueueWaitIdle</code>.
  Call <code>vkMapMemory</code> for the Buffer memory and read the data, but they are garbage values. For <code>malloc</code> I am keeping the data format as int.</p></li>
  </ol>