aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2018-05-31 07:21:45 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2018-05-31 07:21:45 +0000
commitbf6d51a4ef57b08ff26533ccc127068adad9bd3b (patch)
tree7702658bc251d61c377ca798ced6cb3125044b8f
parent92744064860c30211426812f984ea370ddd71470 (diff)
parent22dc42d6cf91ef90ae3fb6342d8e716666a87df8 (diff)
downloaddevice_generic_goldfish-opengl-pie-cts-release.tar.gz
device_generic_goldfish-opengl-pie-cts-release.tar.bz2
device_generic_goldfish-opengl-pie-cts-release.zip
Snap for 4813226 from 22dc42d6cf91ef90ae3fb6342d8e716666a87df8 to pi-releaseandroid-wear-9.0.0_r9android-wear-9.0.0_r8android-wear-9.0.0_r7android-wear-9.0.0_r6android-wear-9.0.0_r5android-wear-9.0.0_r4android-wear-9.0.0_r3android-wear-9.0.0_r23android-wear-9.0.0_r22android-wear-9.0.0_r21android-wear-9.0.0_r20android-wear-9.0.0_r2android-wear-9.0.0_r19android-wear-9.0.0_r18android-wear-9.0.0_r17android-wear-9.0.0_r16android-wear-9.0.0_r15android-wear-9.0.0_r14android-wear-9.0.0_r13android-wear-9.0.0_r12android-wear-9.0.0_r11android-wear-9.0.0_r10android-wear-9.0.0_r1android-vts-9.0_r9android-vts-9.0_r8android-vts-9.0_r7android-vts-9.0_r6android-vts-9.0_r5android-vts-9.0_r4android-vts-9.0_r14android-vts-9.0_r13android-vts-9.0_r12android-vts-9.0_r11android-vts-9.0_r10android-cts-9.0_r9android-cts-9.0_r8android-cts-9.0_r7android-cts-9.0_r6android-cts-9.0_r5android-cts-9.0_r4android-cts-9.0_r3android-cts-9.0_r2android-cts-9.0_r13android-cts-9.0_r12android-cts-9.0_r11android-cts-9.0_r10android-cts-9.0_r1android-9.0.0_r9android-9.0.0_r8android-9.0.0_r7android-9.0.0_r60android-9.0.0_r6android-9.0.0_r59android-9.0.0_r58android-9.0.0_r57android-9.0.0_r56android-9.0.0_r55android-9.0.0_r54android-9.0.0_r53android-9.0.0_r52android-9.0.0_r51android-9.0.0_r50android-9.0.0_r5android-9.0.0_r49android-9.0.0_r48android-9.0.0_r3android-9.0.0_r2android-9.0.0_r18android-9.0.0_r17android-9.0.0_r10android-9.0.0_r1security-pi-releasepie-vts-releasepie-security-releasepie-s2-releasepie-release-2pie-releasepie-r2-s2-releasepie-r2-s1-releasepie-r2-releasepie-cts-releasemaster-cuttlefish-testing-release
Change-Id: I21f5684debac5913e77f16ec7d59801f50b98dd1
-rw-r--r--host/include/libOpenglRender/IOStream.h2
-rw-r--r--shared/OpenglCodecCommon/GLClientState.cpp23
-rw-r--r--shared/OpenglCodecCommon/GLClientState.h1
-rw-r--r--shared/OpenglCodecCommon/GLESTextureUtils.cpp25
-rw-r--r--shared/OpenglCodecCommon/GLESTextureUtils.h15
-rw-r--r--system/GLESv2_enc/Android.mk1
-rw-r--r--system/GLESv2_enc/gl2_enc.cpp5
-rw-r--r--system/enc_common/IOStream_common.cpp59
8 files changed, 130 insertions, 1 deletions
diff --git a/host/include/libOpenglRender/IOStream.h b/host/include/libOpenglRender/IOStream.h
index 445ec17d..1d32ea15 100644
--- a/host/include/libOpenglRender/IOStream.h
+++ b/host/include/libOpenglRender/IOStream.h
@@ -83,6 +83,8 @@ public:
return readFully(buf, len);
}
+ void readbackPixels(void* context, int width, int height, unsigned int format, unsigned int type, void* pixels);
+
private:
unsigned char *m_buf;
diff --git a/shared/OpenglCodecCommon/GLClientState.cpp b/shared/OpenglCodecCommon/GLClientState.cpp
index 6e9c8f67..7d403894 100644
--- a/shared/OpenglCodecCommon/GLClientState.cpp
+++ b/shared/OpenglCodecCommon/GLClientState.cpp
@@ -664,6 +664,29 @@ size_t GLClientState::clearBufferNumElts(GLenum buffer) const
return 1;
}
+void GLClientState::getPackingOffsets2D(GLsizei width, GLsizei height, GLenum format, GLenum type, int* startOffset, int* pixelRowSize, int* totalRowSize, int* skipRows) const
+{
+ if (width <= 0 || height <= 0) {
+ *startOffset = 0;
+ *pixelRowSize = 0;
+ *totalRowSize = 0;
+ return;
+ }
+
+ GLESTextureUtils::computePackingOffsets2D(
+ width, height,
+ format, type,
+ m_pixelStore.pack_alignment,
+ m_pixelStore.pack_row_length,
+ m_pixelStore.pack_skip_pixels,
+ m_pixelStore.pack_skip_rows,
+ startOffset,
+ pixelRowSize,
+ totalRowSize);
+
+ *skipRows = m_pixelStore.pack_skip_rows;
+}
+
void GLClientState::setNumActiveUniformsInUniformBlock(GLuint program, GLuint uniformBlockIndex, GLint numActiveUniforms) {
UniformBlockInfoKey key;
key.program = program;
diff --git a/shared/OpenglCodecCommon/GLClientState.h b/shared/OpenglCodecCommon/GLClientState.h
index e41cf440..675cea40 100644
--- a/shared/OpenglCodecCommon/GLClientState.h
+++ b/shared/OpenglCodecCommon/GLClientState.h
@@ -239,6 +239,7 @@ public:
size_t pixelDataSize(GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, int pack) const;
size_t pboNeededDataSize(GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, int pack) const;
size_t clearBufferNumElts(GLenum buffer) const;
+ void getPackingOffsets2D(GLsizei width, GLsizei height, GLenum format, GLenum type, int* startOffset, int* pixelRowSize, int* totalRowSize, int* skipRows) const;
void setCurrentProgram(GLint program) { m_currentProgram = program; }
void setCurrentShaderProgram(GLint program) { m_currentShaderProgram = program; }
diff --git a/shared/OpenglCodecCommon/GLESTextureUtils.cpp b/shared/OpenglCodecCommon/GLESTextureUtils.cpp
index 1aef8cb4..45729053 100644
--- a/shared/OpenglCodecCommon/GLESTextureUtils.cpp
+++ b/shared/OpenglCodecCommon/GLESTextureUtils.cpp
@@ -284,4 +284,29 @@ int computeNeededBufferSize(
return end - start;
}
+void computePackingOffsets2D(
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ int packAlignment,
+ int packRowLength,
+ int packSkipPixels,
+ int packSkipRows,
+ int* startOffset,
+ int* packingPixelRowSize,
+ int* packingTotalRowSize) {
+
+ int widthTotal = (packRowLength == 0) ? width : packRowLength;
+ int totalRowSize = computePitch(widthTotal, format, type, packAlignment);
+ int pixelsOnlyRowSize = computePitch(width, format, type, packAlignment);
+
+ int packingOffsetStart =
+ computePackingOffset(
+ format, type, widthTotal, height, packAlignment, packSkipPixels, packSkipRows, 0 /* skip images = 0 */);
+
+ if (startOffset) *startOffset = packingOffsetStart;
+ if (packingPixelRowSize) *packingPixelRowSize = pixelsOnlyRowSize;
+ if (packingTotalRowSize) *packingTotalRowSize = totalRowSize;
+}
+
+
} // namespace GLESTextureUtils
diff --git a/shared/OpenglCodecCommon/GLESTextureUtils.h b/shared/OpenglCodecCommon/GLESTextureUtils.h
index 906e5904..f623d23b 100644
--- a/shared/OpenglCodecCommon/GLESTextureUtils.h
+++ b/shared/OpenglCodecCommon/GLESTextureUtils.h
@@ -37,6 +37,21 @@ int computeNeededBufferSize(
int unpackSkipRows,
int unpackSkipImages);
+// Writes out |height| offsets for glReadPixels to read back
+// data in separate rows of pixels. Returns:
+// 1. |startOffset|: offset in bytes to apply at the beginning
+// 2. |packingPixelRowSize|: the buffer size in bytes that has the actual pixels per row.
+// 2. |packingTotalRowSize|: the length in bytes of each row including the padding from row length.
+void computePackingOffsets2D(
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ int packAlignment,
+ int packRowLength,
+ int packSkipPixels,
+ int packSkipRows,
+ int* startOffset,
+ int* packingPixelRowSize,
+ int* packingTotalRowSize);
} // namespace GLESTextureUtils
#endif
diff --git a/system/GLESv2_enc/Android.mk b/system/GLESv2_enc/Android.mk
index c5081d33..f61c9f70 100644
--- a/system/GLESv2_enc/Android.mk
+++ b/system/GLESv2_enc/Android.mk
@@ -10,6 +10,7 @@ LOCAL_SRC_FILES := \
gl2_client_context.cpp \
gl2_enc.cpp \
gl2_entry.cpp \
+ ../enc_common/IOStream_common.cpp \
LOCAL_CFLAGS += -DLOG_TAG=\"emuglGLESv2_enc\"
diff --git a/system/GLESv2_enc/gl2_enc.cpp b/system/GLESv2_enc/gl2_enc.cpp
index 8357c686..f42e7ba3 100644
--- a/system/GLESv2_enc/gl2_enc.cpp
+++ b/system/GLESv2_enc/gl2_enc.cpp
@@ -3028,7 +3028,10 @@ void glReadPixels_enc(void *self , GLint x, GLint y, GLsizei width, GLsizei heig
if (useChecksum) checksumCalculator->addBuffer(buf, ptr-buf);
if (useChecksum) checksumCalculator->writeChecksum(ptr, checksumSize); ptr += checksumSize;
- stream->readback(pixels, __size_pixels);
+ // TODO: make this part of autogenerated pipe code.
+ // b/79208762
+ stream->readbackPixels(self, width, height, format, type, pixels);
+
if (useChecksum) checksumCalculator->addBuffer(pixels, __size_pixels);
if (useChecksum) {
unsigned char *checksumBufPtr = NULL;
diff --git a/system/enc_common/IOStream_common.cpp b/system/enc_common/IOStream_common.cpp
new file mode 100644
index 00000000..43f03af2
--- /dev/null
+++ b/system/enc_common/IOStream_common.cpp
@@ -0,0 +1,59 @@
+#include "IOStream.h"
+
+#include "GL2Encoder.h"
+
+#include <GLES3/gl31.h>
+
+#include <vector>
+
+void IOStream::readbackPixels(void* context, int width, int height, unsigned int format, unsigned int type, void* pixels) {
+ GL2Encoder *ctx = (GL2Encoder *)context;
+ assert (ctx->state() != NULL);
+
+ int startOffset = 0;
+ int pixelRowSize = 0;
+ int totalRowSize = 0;
+ int skipRows = 0;
+
+ ctx->state()->getPackingOffsets2D(width, height, format, type,
+ &startOffset,
+ &pixelRowSize,
+ &totalRowSize,
+ &skipRows);
+
+ size_t pixelDataSize =
+ ctx->state()->pixelDataSize(
+ width, height, 1, format, type, 1 /* is pack */);
+
+ if (startOffset == 0 &&
+ pixelRowSize == totalRowSize) {
+ // fast path
+ readback(pixels, pixelDataSize);
+ } else if (pixelRowSize == totalRowSize) {
+ // fast path but with skip in the beginning
+ std::vector<char> paddingToDiscard(startOffset, 0);
+ readback(&paddingToDiscard[0], startOffset);
+ readback((char*)pixels + startOffset, pixelDataSize - startOffset);
+ } else {
+ int totalReadback = 0;
+
+ if (startOffset > 0) {
+ std::vector<char> paddingToDiscard(startOffset, 0);
+ readback(&paddingToDiscard[0], startOffset);
+ totalReadback += startOffset;
+ }
+ // need to read back row by row
+ size_t paddingSize = totalRowSize - pixelRowSize;
+ std::vector<char> paddingToDiscard(paddingSize, 0);
+
+ char* start = (char*)pixels + startOffset;
+
+ for (int i = 0; i < height; i++) {
+ readback(start, pixelRowSize);
+ totalReadback += pixelRowSize;
+ readback(&paddingToDiscard[0], paddingSize);
+ totalReadback += paddingSize;
+ start += totalRowSize;
+ }
+ }
+}