Vulkan: Support of npot textures
The bug was with the readPixels not using the rowPitch, and not really
with the support of npot.
Bug:angleproject:2413
Change-Id: I09c0d87768bc29d3beb452ae83996cd4d2b4a600
Reviewed-on: https://chromium-review.googlesource.com/971830
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Luc Ferron <lucferron@chromium.org>
diff --git a/src/libANGLE/renderer/vulkan/FramebufferVk.cpp b/src/libANGLE/renderer/vulkan/FramebufferVk.cpp
index 529f3b2..69f0e77 100644
--- a/src/libANGLE/renderer/vulkan/FramebufferVk.cpp
+++ b/src/libANGLE/renderer/vulkan/FramebufferVk.cpp
@@ -308,17 +308,23 @@
// TODO(jmadill): Use pixel bytes from the ANGLE format directly.
const auto &glFormat = gl::GetSizedInternalFormatInfo(angleFormat.glInternalFormat);
- int inputPitch = glFormat.pixelBytes * area.width;
+ int outputPitch = glFormat.pixelBytes * area.width;
+
+ // Get the staging image pitch and use it to pack the pixels later.
+ VkSubresourceLayout subresourceLayout;
+ stagingImage.getImage().getSubresourceLayout(device, VK_IMAGE_ASPECT_COLOR_BIT, 0, 0,
+ &subresourceLayout);
PackPixelsParams params;
params.area = area;
params.format = format;
params.type = type;
- params.outputPitch = inputPitch;
+ params.outputPitch = outputPitch;
params.packBuffer = glState.getTargetBuffer(gl::BufferBinding::PixelPack);
params.pack = glState.getPackState();
- PackPixels(params, angleFormat, inputPitch, mapPointer, reinterpret_cast<uint8_t *>(pixels));
+ PackPixels(params, angleFormat, static_cast<int>(subresourceLayout.rowPitch), mapPointer,
+ reinterpret_cast<uint8_t *>(pixels));
stagingImage.getDeviceMemory().unmap(device);
renderer->releaseObject(renderer->getCurrentQueueSerial(), &stagingImage);