Vulkan: Initial Implementation of PBO support (software only)
This contains support for both pixel unpack buffers (i.e. for glTex*Image*)
and pixel pack buffers (i.e. for glReadPixels).
Bug: angleproject:3209
Bug: angleproject:3210
Change-Id: I077cccbffb96fb5f0198922bc7c1850a7eb3f616
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1723096
Commit-Queue: Ian Elliott <ianelliott@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/renderer/vulkan/FramebufferVk.cpp b/src/libANGLE/renderer/vulkan/FramebufferVk.cpp
index 5a00888..eee1d58 100644
--- a/src/libANGLE/renderer/vulkan/FramebufferVk.cpp
+++ b/src/libANGLE/renderer/vulkan/FramebufferVk.cpp
@@ -1515,8 +1515,24 @@
// created with the host coherent bit.
ANGLE_TRY(mReadPixelBuffer.invalidate(contextVk));
- PackPixels(packPixelsParams, *readFormat, area.width * readFormat->pixelBytes, readPixelBuffer,
- static_cast<uint8_t *>(pixels));
+ const gl::State &glState = contextVk->getState();
+ gl::Buffer *packBuffer = glState.getTargetBuffer(gl::BufferBinding::PixelPack);
+ if (packBuffer != nullptr)
+ {
+ // Must map the PBO in order to read its contents (and then unmap it later)
+ BufferVk *packBufferVk = vk::GetImpl(packBuffer);
+ void *mapPtr = nullptr;
+ ANGLE_TRY(packBufferVk->mapImpl(contextVk, &mapPtr));
+ uint8_t *dest = static_cast<uint8_t *>(mapPtr) + reinterpret_cast<ptrdiff_t>(pixels);
+ PackPixels(packPixelsParams, *readFormat, area.width * readFormat->pixelBytes,
+ readPixelBuffer, static_cast<uint8_t *>(dest));
+ packBufferVk->unmapImpl(contextVk);
+ }
+ else
+ {
+ PackPixels(packPixelsParams, *readFormat, area.width * readFormat->pixelBytes,
+ readPixelBuffer, static_cast<uint8_t *>(pixels));
+ }
return angle::Result::Continue;
}