Vulkan: Fix copyImage region parameters.
In cases where we were reading back more than one pixel in ReadPixels,
and in some cases for texture init, we weren't using the correct
parameters to vkCmdCopyImage. This CL fixes both of those by using
more correct copy regions, and fixing the row and depth pitch
computation using vkGetImageSubresourceLayout.
BUG=angleproject:2167
Change-Id: Ib70217ed4a17be6b4b1b8aeec9a8a6199d210d88
Reviewed-on: https://chromium-review.googlesource.com/732190
Reviewed-by: Frank Henigman <fjhenigman@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/renderer/vulkan/FramebufferVk.cpp b/src/libANGLE/renderer/vulkan/FramebufferVk.cpp
index 7b2883a..9c8d155 100644
--- a/src/libANGLE/renderer/vulkan/FramebufferVk.cpp
+++ b/src/libANGLE/renderer/vulkan/FramebufferVk.cpp
@@ -295,18 +295,29 @@
stagingImage.getImage().changeLayoutTop(VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_GENERAL,
commandBuffer);
- gl::Box copyRegion;
- copyRegion.x = area.x;
- copyRegion.y = area.y;
- copyRegion.z = 0;
- copyRegion.width = area.width;
- copyRegion.height = area.height;
- copyRegion.depth = 1;
-
readImage->changeLayoutTop(VK_IMAGE_ASPECT_COLOR_BIT, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
commandBuffer);
- commandBuffer->copySingleImage(*readImage, stagingImage.getImage(), copyRegion,
- VK_IMAGE_ASPECT_COLOR_BIT);
+
+ VkImageCopy region;
+ region.srcSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
+ region.srcSubresource.mipLevel = 0;
+ region.srcSubresource.baseArrayLayer = 0;
+ region.srcSubresource.layerCount = 1;
+ region.srcOffset.x = area.x;
+ region.srcOffset.y = area.y;
+ region.srcOffset.z = 0;
+ region.dstSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
+ region.dstSubresource.mipLevel = 0;
+ region.dstSubresource.baseArrayLayer = 0;
+ region.dstSubresource.layerCount = 1;
+ region.dstOffset.x = 0;
+ region.dstOffset.y = 0;
+ region.dstOffset.z = 0;
+ region.extent.width = area.width;
+ region.extent.height = area.height;
+ region.extent.depth = 1;
+
+ commandBuffer->copyImage(*readImage, stagingImage.getImage(), 1, ®ion);
ANGLE_TRY(renderer->submitAndFinishCommandBuffer(commandBuffer));