tests/vkrenderframework.cpp
VkResult VkImageObj::CopyImageOut(VkImageObj &dst_image) {
    VkImageLayout src_image_layout, dest_image_layout;

    VkCommandPoolObj pool(m_device, m_device->graphics_queue_node_index_);
    VkCommandBufferObj cmd_buf(m_device, &pool);

    cmd_buf.begin();

    src_image_layout = this->Layout();
    this->SetLayout(&cmd_buf, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);

    dest_image_layout = (dst_image.Layout() == VK_IMAGE_LAYOUT_UNDEFINED) ? VK_IMAGE_LAYOUT_GENERAL : this->Layout();
    dst_image.SetLayout(&cmd_buf, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);

    VkImageCopy copy_region = {};
    copy_region.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
    copy_region.srcSubresource.baseArrayLayer = 0;
    copy_region.srcSubresource.mipLevel = 0;
    copy_region.srcSubresource.layerCount = 1;
    copy_region.srcOffset.x = 0;
    copy_region.srcOffset.y = 0;
    copy_region.srcOffset.z = 0;
    copy_region.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
    copy_region.dstSubresource.baseArrayLayer = 0;
    copy_region.dstSubresource.mipLevel = 0;
    copy_region.dstSubresource.layerCount = 1;
    copy_region.dstOffset.x = 0;
    copy_region.dstOffset.y = 0;
    copy_region.dstOffset.z = 0;
    copy_region.extent = dst_image.extent();

    vkCmdCopyImage(cmd_buf.handle(), handle(), Layout(), dst_image.handle(), dst_image.Layout(), 1, &copy_region);

    this->SetLayout(&cmd_buf, VK_IMAGE_ASPECT_COLOR_BIT, src_image_layout);

    dst_image.SetLayout(&cmd_buf, VK_IMAGE_ASPECT_COLOR_BIT, dest_image_layout);

    cmd_buf.end();

    cmd_buf.QueueCommandBuffer();

    return VK_SUCCESS;
}
// Same as CopyImage, but in the opposite direction
Same as CopyImage, but in the opposite direction
Same as CopyImage but in the opposite direction
VkResult VkImageObj::CopyImageOut(VkImageObj &dst_image) {
    VkImageLayout src_image_layout, dest_image_layout;
    VkCommandPoolObj pool(m_device, m_device->graphics_queue_node_index_);
    VkCommandBufferObj cmd_buf(m_device, &pool);
    cmd_buf.begin();
    src_image_layout = this->Layout();
    this->SetLayout(&cmd_buf, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
    dest_image_layout = (dst_image.Layout() == VK_IMAGE_LAYOUT_UNDEFINED) ? VK_IMAGE_LAYOUT_GENERAL : this->Layout();
    dst_image.SetLayout(&cmd_buf, VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
    VkImageCopy copy_region = {};
    copy_region.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
    copy_region.srcSubresource.baseArrayLayer = 0;
    copy_region.srcSubresource.mipLevel = 0;
    copy_region.srcSubresource.layerCount = 1;
    copy_region.srcOffset.x = 0;
    copy_region.srcOffset.y = 0;
    copy_region.srcOffset.z = 0;
    copy_region.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
    copy_region.dstSubresource.baseArrayLayer = 0;
    copy_region.dstSubresource.mipLevel = 0;
    copy_region.dstSubresource.layerCount = 1;
    copy_region.dstOffset.x = 0;
    copy_region.dstOffset.y = 0;
    copy_region.dstOffset.z = 0;
    copy_region.extent = dst_image.extent();
    vkCmdCopyImage(cmd_buf.handle(), handle(), Layout(), dst_image.handle(), dst_image.Layout(), 1, &copy_region);
    this->SetLayout(&cmd_buf, VK_IMAGE_ASPECT_COLOR_BIT, src_image_layout);
    dst_image.SetLayout(&cmd_buf, VK_IMAGE_ASPECT_COLOR_BIT, dest_image_layout);
    cmd_buf.end();
    cmd_buf.QueueCommandBuffer();
    return VK_SUCCESS;
}
VkResult VkImageObj :: CopyImageOut ( VkImageObj & dst_image ) { VkImageLayout src_image_layout , dest_image_layout ; VkCommandPoolObj pool ( m_device , m_device -> graphics_queue_node_index_ ) ; VkCommandBufferObj cmd_buf ( m_device , & pool ) ; cmd_buf . begin ( ) ; src_image_layout = this -> Layout ( ) ; this -> SetLayout ( & cmd_buf , VK_IMAGE_ASPECT_COLOR_BIT , VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL ) ; dest_image_layout = ( dst_image . Layout ( ) == VK_IMAGE_LAYOUT_UNDEFINED ) ? VK_IMAGE_LAYOUT_GENERAL : this -> Layout ( ) ; dst_image . SetLayout ( & cmd_buf , VK_IMAGE_ASPECT_COLOR_BIT , VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL ) ; VkImageCopy copy_region = { } ; copy_region . srcSubresource . aspectMask = VK_IMAGE_ASPECT_COLOR_BIT ; copy_region . srcSubresource . baseArrayLayer = 0 ; copy_region . srcSubresource . mipLevel = 0 ; copy_region . srcSubresource . layerCount = 1 ; copy_region . srcOffset . x = 0 ; copy_region . srcOffset . y = 0 ; copy_region . srcOffset . z = 0 ; copy_region . dstSubresource . aspectMask = VK_IMAGE_ASPECT_COLOR_BIT ; copy_region . dstSubresource . baseArrayLayer = 0 ; copy_region . dstSubresource . mipLevel = 0 ; copy_region . dstSubresource . layerCount = 1 ; copy_region . dstOffset . x = 0 ; copy_region . dstOffset . y = 0 ; copy_region . dstOffset . z = 0 ; copy_region . extent = dst_image . extent ( ) ; vkCmdCopyImage ( cmd_buf . handle ( ) , handle ( ) , Layout ( ) , dst_image . handle ( ) , dst_image . Layout ( ) , 1 , & copy_region ) ; this -> SetLayout ( & cmd_buf , VK_IMAGE_ASPECT_COLOR_BIT , src_image_layout ) ; dst_image . SetLayout ( & cmd_buf , VK_IMAGE_ASPECT_COLOR_BIT , dest_image_layout ) ; cmd_buf . end ( ) ; cmd_buf . QueueCommandBuffer ( ) ; return VK_SUCCESS ; }
Same as CopyImage, but in the opposite direction
Same as CopyImage but in the opposite direction